Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

[Discussion] Else / And / If

18 years ago

Hey guys, ive been working on a script for random encounters.. basically if the chapter Id is the one that i want to have the random encounter s wwith, it rolls a die, if the die is 2, then it says "You have encoutnered somehting, and it rolls it again to see what exactly you have encountered.... for some reason, the code only evaluates until %Encounter := 1D2, it does not continue to reevaluate it to 1D100 if the roll is 2... do any of u have any idea what is wrong?

 

IF $CHAPTERID = 4 THEN

%ENCOUNTER := 1D2

IF %ENCOUNTER = 2 AND %SCORE <= 500 THEN

%ENCOUNTER := 1D100

IF %ENCOUNTER <= 19 AND %ENCOUNTER >= 60 AND %ENCOUNTER <= 69 AND %ENCOUNTER >= 35 AND %ENCOUNTER <= 44 AND %ENCOUNTER >= 90 AND %ENCOUNTER <= 100 THEN
$DEST := @C5

ELSE IF %ENCOUNTER >= 20 AND %ENCOUNTER <= 34 AND %ENCOUNTER >= 70 AND %ENCOUNTER <= 89 THEN
$DEST := @C6

ELSE IF %ENCOUNTER >= 50 AND %ENCOUNTER <= 59 THEN
$DEST := @C7

ELSE IF %ENCOUNTER >= 45 AND %ENCOUNTER <= 49 THEN 
$DEST := @C8


#################END LEVEL  1##########################
########################################################
###############BEGIN LEVEL 2############################

IF $CHAPTERID = 4 THEN

%ENCOUNTER := 1D2

IF %ENCOUNTER = 2 AND %SCORE > 500 AND %SCORE <= 2500 THEN

%ENCOUNTER := 1D100

IF %ENCOUNTER <= 9 AND %ENCOUNTER >= 80 AND %ENCOUNTER <= 89 AND %ENCOUNTER >= 60 AND %ENCOUNTER <= 64 THEN
$DEST := @C5

ELSE IF %ENCOUNTER >= 10 AND %ENCOUNTER <= 19 AND %ENCOUNTER >= 40 AND %ENCOUNTER <= 49 AND %ENCOUNTER >= 65 AND %ENCOUNTER <= 69 THEN
$DEST := @C6

ELSE IF %ENCOUNTER >= 20 AND %ENCOUNTER <= 29 AND %ENCOUNTER >= 70 AND %ENCOUNTER <= 79 THEN
$DEST := @C7

ELSE IF %ENCOUNTER >= 30 AND %ENCOUNTER <= 39 AND %ENCOUNTER >= 90 AND %ENCOUNTER <= 94 THEN
$DEST := @C8

ELSE IF %ENCOUNTER >= 50 AND %ENCOUNTER <= 59 THEN
$DEST := @C9

ELSE IF %ENCOUNTER >= 95 AND %ENCOUNTER <= 100 THEN
$DEST := @C10

#######################END LEVEL 2###############################
#################################################################
###################BEGIN LEVEL 3#################################

IF $CHAPTERID = 4 THEN

%ENCOUNTER := 1D2

IF %ENCOUNTER = 2 AND %SCORE > 2500 AND %SCORE <= 6500 THEN
%ENCOUNTER := 1D100

IF %ENCOUNTER >= 10 AND %ENCOUNTER <= 14 AND %ENCOUNTER >= 65 AND %ENCOUNTER <= 69 THEN
$DEST := @C5

ELSE IF %ENCOUNTER >= 15 AND %ENCOUNTER <= 19 AND %ENCOUNTER >= 40 AND %ENCOUNTER <= 49 AND %ENCOUNTER >= 90 AND %ENCOUNTER <= 100 THEN
$DEST := @C6

ELSE IF %ENCOUNTER <= 9 AND %ENCOUNTER >= 30 AND %ENCOUNTER <= 39 THEN    
$DEST := @C7 

ELSE IF %ENCOUNTER >= 50 AND %ENCOUNTER <= 59 AND %ENCOUNTER >= 80 AND %ENCOUNTER <= 86 THEN  
$DEST := @C8  

ELSE IF %ENCOUNTER >= 60 AND %ENCOUNTER <= 64 AND %ENCOUNTER >= 70 AND %ENCOUNTER <= 74 AND %ENCOUNTER >= 87 AND %ENCOUNTER <= 89 THEN 
$DEST := @C9

ELSE IF %ENCOUNTER >= 20 AND %ENCOUNTER <= 26 THEN 
$DEST := @C10

ELSE IF %ENCOUNTER >= 75 AND %ENCOUNTER <= 79 THEN
$DEST := @C11

ELSE IF %ENCOUNTER >= 27 AND %ENCOUNTER <= 29 THEN
$DEST := @C12

################END LEVEL 3#######################################
##################################################################
################BEGIN LEVEL 4##################################

IF $CHAPTERID = 4 THEN
%ENCOUNTER := 1D2

IF %ENCOUNTER = 2 AND %SCORE > 6500 THEN
%ENCOUNTER := 1D100

IF %ENCOUNTER >= 10 AND %ENCOUNTER <= 14 THEN
$DEST := @C5

ELSE IF %ENCOUNTER <= 9 AND %ENCOUNTER >= 30 AND %ENCOUNTER <= 39 AND %ENCOUNTER >= 70 AND %ENCOUNTER <= 79 THEN
$DEST := @C6

ELSE IF %ENCOUNTER >= 55 AND %ENCOUNTER <= 59 THEN
%DEST := @C7

ELSE IF %ENCOUNTER >= 40 AND %ENCOUNTER <= 49 THEN
$DEST := @C8

ELSE IF %ENCOUNTER >= 80 AND %ENCOUNTER <= 89 THEN
$DEST := @C9

ELSE IF %ENCOUNTER >= 25 AND %ENCOUNTER <= 29 AND %ENCOUNTER >= 50 AND %ENCOUNTER <= 54 THEN
$DEST := @C10

ELSE IF %ENCOUNTER >= 15 AND %ENCOUNTER <= 19 AND %ENCOUNTER >= 60 AND %ENCOUNTER <= 69 AND %ENCOUNTER >= 90 AND %ENCOUNTER <= 94 THEN 
$DEST := @C11

ELSE IF %ENCOUNTER >= 20 AND %ENCOUNTER <= 24 THEN
$DEST := @C12

ELSE IF %ENCOUNTER >= 97 AND %ENCOUNTER <= 100 THEN
$DEST := @C13

ELSE IF %ENCOUNTER >= 95 AND %ENCOUNTER <= 96 AND %DAVEYJONES = 0 THEN
$DEST := @C14

ELSE IF %ENCOUNTER >= 95 AND %ENCOUNTER <= 96 AND %DAVEYJONES = 1 THEN
$DEST := @C5

[Discussion] Else / And / If

18 years ago

Wow. Thats long.

 

Shouldnt this be in the Advanced Editor forum?

[Discussion] Else / And / If

18 years ago
well, it is a question, and i believed that i was missing something stupid, something newb.... lol but you can move it if u like... if i get no responses, i am gonna delete it....

[Discussion] Else / And / If

18 years ago

If i knew anything Id help :S

[Discussion] Else / And / If

18 years ago

First, when you use THEN command, follow it by a BEGIN line, and when you have finished telling it what the THEN should do, place an END line. If you don't, then EVERY line you type will be a part of the first THEN statement. (I think)

Ie,

-----------

IF %VARIABLE = 1 THEN
BEGIN
(what you want to happen)
END
Rest of your script....

--------------

You can have multpile THEN statements that affect each other, so:

--------------

IF %VARIABLE1 = 1 THEN
BEGIN
    IF %VARIABLE2 = 2 THEN
    BEGIN
        Make something happen
    END
END

---------------

Now, here's another statement that is impossible:

IF %ENCOUNTER <= 19 AND %ENCOUNTER >= 60 AND %ENCOUNTER <= 69 AND %ENCOUNTER >= 35 AND %ENCOUNTER <= 44 AND %ENCOUNTER >= 90 AND %ENCOUNTER <= 100 THEN
$DEST := @C5

Basically, a number can not be equal to or less than 19, and also be equal to or greater than 60. It just can't happen. A number is either lower than 19 OR greater than 60, but can not be both. So, make seperate statements:

-----------------

IF %ENCOUNTER <= 19 THEN
BEGIN
$DEST := @C5
END

IF %ENCOUNTER >=60 AND %ENCOUNTER <= 69 THEN
BEGIN
$DEST := @C5
END

IF %ENCOUNTER >=35 AND %ENCOUNTER <=44 THEN
BEGIN
$DEST := @C5
END

IF %ENCOUNTER >=90 AND %ENCOUNTER <=100 THEN
BEGIN
$DEST := @C5
END

----------

Also, don't use twenty ELSE commands. Just write new IF commands. You've got, for example:

IF %ENCOUNTER >= 10 AND %ENCOUNTER <= 14 THEN
$DEST := @C5

ELSE IF %ENCOUNTER <= 9 AND %ENCOUNTER >= 30 AND %ENCOUNTER <= 39 AND %ENCOUNTER >= 70 AND %ENCOUNTER <= 79 THEN
$DEST := @C6

ELSE IF %ENCOUNTER >= 55 AND %ENCOUNTER <= 59 THEN
%DEST := @C7

Make the second and third lines new IF commands, remove the ELSE's. That's not exactly how ELSE's are normally used. If a standard IF command will do the job, then just use an IF command - but remember to seperate the line into seperate IF commands for each group of numbers, or the program won't know what you want it to do.

I won't go through your entire script, but this should get you started. I hope it helps :)

[Discussion] Else / And / If

18 years ago
This has helped tremondously, tsmpaul, thank you very much for your critique. The BEGIN and END are not part of the syntax, i mean, they wont make any difference, but the main thing is, I cant have the less than or equal to 19 AND greater than 60 and less than w/e, i did this last night at 1AM so obviously that didnt get through my mind... lol, thank you very much, i am going to change around my code later this evening. Again, thank you very much tsmpaul!

[Discussion] Else / And / If

18 years ago

are you sure BEGIN and END aren't part of the syntax, because if not, that could cause problems. Take this for example:

IF %VARIABLE1 = 5 THEN
BEGIN
$PAGETEXT := "This is a test"
END
IF %VARIABLE2 = 3 THEN
BEGIN
$PAGETEXT := "This is not a test"
END

IF %VARIABLE1 = 5 THEN
BEGIN
$PAGETEXT := "This is a test"
    IF %VARIABLE2 = 3 THEN
    BEGIN
    $PAGETEXT := "This is not a test"
    END
END

In the first example, in a normal programming language, both variable checks are considered seperate lines, and would both be run by the program. So, whether variable1 = 5 or not, the program would still check to see if variable2 = 3.

In the second example, unless Variable1 = 5, then the check on variable2 would NEVER be run be the program. It would only be run if Variable1 = 5, because it is included in the 'actions' the program takes IF variable1 = 5, because of where the BEGIN and END statements are placed in the script. Do you see what I mean? Do you think you can check for me, if the BEGIN and END commands actually do something or not, because it would have a big impact on the scripts I write, as where those two words are placed could alter the intent of the script entirely.

[Discussion] Else / And / If

18 years ago
I see exactly what you are saying. And when scripting was introduced, alex and I had discussed for hours the potential of scripting, what was needed and etc. and when he told me about BEGIN and END he said they were needed to be used. So i assumed (ass-outof-u-me) that it did not coincide with the syntax rules... but what you are saying is making me think that it does make a difference. We should run your script under a test...

[Discussion] Else / And / If

18 years ago
And again, thank you very much!!!

[Discussion] Else / And / If

18 years ago
Wow, Im not lost.. its weird.

[Discussion] Else / And / If

18 years ago

Alright, so ive changed all my code to what you suggested, and it still does  not work. It does not evaluate past 1D2 for ENCOUNTER. the following is a part one of my code...

IF $CHAPTERID = 4 THEN
BEGIN
%ENCOUNTER := 1D2

IF %ENCOUNTER = 2 AND %SCORE <= 500 THEN
BEGIN
%ENCOUNTER := 1D100

IF %ENCOUNTER <= 19 THEN
BEGIN
$DEST := @C5
END
IF %ENCOUNTER >= 60 AND %ENCOUNTER <= 69 THEN
BEGIN
$DEST := @C5
END
IF %ENCOUNTER >= 35 AND %ENCOUNTER <= 44 THEN
BEGIN
$DEST := @C5
END
IF %ENCOUNTER >= 90 AND %ENCOUNTER <= 100 THEN
BEGIN
$DEST := @C5
END
IF %ENCOUNTER >= 20 AND %ENCOUNTER <= 34 THEN
BEGIN
$DEST := @C6
END
IF %ENCOUNTER >= 70 AND %ENCOUNTER <= 89 THEN
BEGIN
$DEST := @C6
END
IF %ENCOUNTER >= 50 AND %ENCOUNTER <= 59 THEN
BEGIN
$DEST := @C7
END
IF %ENCOUNTER >= 45 AND %ENCOUNTER <= 49 THEN 
BEGIN
$DEST := @C8
END
END
END

[Discussion] Else / And / If

18 years ago
Alright, based on the above code, the BEGIN and END stuff did squat, but if you add for example an extra END at the bottom of that code, it picks it up in the debugger and gives u the syntax error...

[Discussion] Else / And / If

18 years ago
I didnt know AND was valid in scripting.  And thats awesome!

[Discussion] Else / And / If

18 years ago
same with NOT and OR

[Discussion] Else / And / If

18 years ago

Awesome!!

 

Well that script looks completely fine, I dont get it.

[Discussion] Else / And / If

18 years ago

HANG ON.

 

You said Roll Enounter 1D2, what if it rolled a 1?  You only speciifed what happens if it rolls a 2.

[Discussion] Else / And / If

18 years ago
If it rolled a 1, everything would happen like normal, but in the current script that i have, thats been changed around, ive included a variable change (i.e. OUTCOME = 1) if its rolled a 1.... later i will post what i have...

[Discussion] Else / And / If

18 years ago

Now the following script is not evaluating $CHAPTERID = 4, its basically occuring right after i hit the first link in my game, and it keeps evaluating %SEAENCOUNTERS = 2 OR 4 and it keeps going to @C6, always...

%SEAENCOUNTERS := 0
%SEADESCRIPTION := 0
%PIRATEENCOUNTERS := 0 


IF $CHAPTERID = 4 THEN

%SEAENCOUNTERS := 1D4
%LASTPAGEID := $PAGEID

IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 1 OR %SEAENCOUNTERS = 3
THEN
%SEADESCRIPTION := 1D5

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %SCORE <= 500
THEN
%PIRATEENCOUNTERS := 1D100


IF %PIRATEENCOUNTER <= 19 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 69 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 35 AND %PIRATEENCOUNTER <= 44 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 34 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 89 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTER >= 45 AND %PIRATEENCOUNTER <= 49 THEN 
BEGIN
$DEST := @C8
END
#################END LEVEL  1##########################
########################################################
###############BEGIN LEVEL 2############################

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %SCORE > 500 AND %SCORE

<= 2500
THEN
%PIRATEENCOUNTERS := 1D100


IF %PIRATEENCOUNTER <= 9 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 80 AND %PIRATEENCOUNTER <= 89 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 64 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 10 AND %PIRATEENCOUNTER <= 19 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 40 AND %PIRATEENCOUNTER <= 49 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 65 AND %PIRATEENCOUNTER <= 69 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 29 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 79 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTER >= 30 AND %PIRATEENCOUNTER <= 39 THEN
BEGIN
$DEST := @C8
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 94 THEN
BEGIN
$DEST := @C8
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C10
END
#######################END LEVEL 2###############################
#################################################################
###################BEGIN LEVEL 3#################################

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %SCORE > 2500 AND %SCORE

<= 6500
THEN
%PIRATEENCOUNTERS := 1D100


IF %PIRATEENCOUNTER >= 10 AND %PIRATEENCOUNTER <= 14 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 65 AND %PIRATEENCOUNTER <= 69 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 15 AND %PIRATEENCOUNTER <= 19 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 40 AND %PIRATEENCOUNTER <= 49 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER <= 9 THEN
BEGIN
$DEST := @C7 
END
IF %PIRATEENCOUNTER >= 30 AND %PIRATEENCOUNTER <= 39 THEN    
BEGIN
$DEST := @C7 
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
$DEST := @C8  
END
IF %PIRATEENCOUNTER >= 80 AND %PIRATEENCOUNTER <= 86 THEN  
BEGIN
$DEST := @C8  
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 64 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 74 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 87 AND %PIRATEENCOUNTER <= 89 THEN 
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 26 THEN 
BEGIN
$DEST := @C10
END
IF %PIRATEENCOUNTER >= 75 AND %PIRATEENCOUNTER <= 79 THEN
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 27 AND %PIRATEENCOUNTER <= 29 THEN
BEGIN
$DEST := @C12
END
################END LEVEL 3#######################################
##################################################################
################BEGIN LEVEL 4##################################

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %SCORE > 6500
THEN
%PIRATEENCOUNTERS := 1D100


IF %PIRATEENCOUNTER >= 10 AND %PIRATEENCOUNTER <= 14 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER <= 9 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 30 AND %PIRATEENCOUNTER <= 39 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 79 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 55 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
%DEST := @C7
END
IF %PIRATEENCOUNTER >= 40 AND %PIRATEENCOUNTER <= 49 THEN
BEGIN
$DEST := @C8
END
IF %PIRATEENCOUNTER >= 80 AND %PIRATEENCOUNTER <= 89 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 25 AND %PIRATEENCOUNTER <= 29 THEN
BEGIN
$DEST := @C10
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 54 THEN
BEGIN
$DEST := @C10
END
IF %PIRATEENCOUNTER >= 15 AND %PIRATEENCOUNTER <= 19 THEN 
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 69 THEN 
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 94 THEN 
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 24 THEN
BEGIN
$DEST := @C12
END
IF %PIRATEENCOUNTER >= 97 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C13
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 0

THEN
BEGIN
$DEST := @C14
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 1
THEN
BEGIN
$DEST := @C5
END

Debug Another Script

18 years ago
And i know that i do not need so many $CHAPTERID's but, i was trying to get it so it would only work in $CHAPTER = 4, and the very first place where i have that, its not working...

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago

THe following script works :O and i dunno why  and how!!! LOL!!!! omg, im so happy!!!!!!!!!

%SEAENCOUNTERS := 0
%SEADESCRIPTION := 0
%PIRATEENCOUNTERS := 0
%LEVEL := 0 

IF %SCORE <= 500 THEN
%LEVEL := 1
ELSE IF %SCORE > 500 AND %SCORE <= 2500 THEN
%LEVEL := 2
ELSE IF %SCORE > 2500 AND %SCORE <= 6500 THEN
%LEVEL := 3
ELSE IF %SCORE > 6500 THEN
%LEVEL := 4

IF $CHAPTERID = 4 THEN

%SEAENCOUNTERS := 1D4
%LASTPAGEID := $PAGEID

IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 1 OR %SEAENCOUNTERS = 3
THEN
%SEADESCRIPTION := 1D5

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %LEVEL = 1 THEN
BEGIN
%PIRATEENCOUNTERS := 1D100

IF %PIRATEENCOUNTER <= 19 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 69 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 35 AND %PIRATEENCOUNTER <= 44 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 34 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 89 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTER >= 45 AND %PIRATEENCOUNTER <= 49 THEN 
BEGIN
$DEST := @C8
END
END
#################END LEVEL  1##########################
########################################################
###############BEGIN LEVEL 2############################

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %LEVEL = 2 THEN
BEGIN
%PIRATEENCOUNTERS := 1D100

IF %PIRATEENCOUNTER <= 9 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 80 AND %PIRATEENCOUNTER <= 89 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 64 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 10 AND %PIRATEENCOUNTER <= 19 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 40 AND %PIRATEENCOUNTER <= 49 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 65 AND %PIRATEENCOUNTER <= 69 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 29 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 79 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTER >= 30 AND %PIRATEENCOUNTER <= 39 THEN
BEGIN
$DEST := @C8
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 94 THEN
BEGIN
$DEST := @C8
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C10
END
END
#######################END LEVEL 2###############################
#################################################################
###################BEGIN LEVEL 3#################################

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %LEVEL = 3 THEN
BEGIN
%PIRATEENCOUNTERS := 1D100

IF %PIRATEENCOUNTER >= 10 AND %PIRATEENCOUNTER <= 14 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 65 AND %PIRATEENCOUNTER <= 69 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER >= 15 AND %PIRATEENCOUNTER <= 19 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 40 AND %PIRATEENCOUNTER <= 49 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER <= 9 THEN
BEGIN
$DEST := @C7 
END
IF %PIRATEENCOUNTER >= 30 AND %PIRATEENCOUNTER <= 39 THEN    
BEGIN
$DEST := @C7 
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
$DEST := @C8  
END
IF %PIRATEENCOUNTER >= 80 AND %PIRATEENCOUNTER <= 86 THEN  
BEGIN
$DEST := @C8  
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 64 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 74 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 87 AND %PIRATEENCOUNTER <= 89 THEN 
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 26 THEN 
BEGIN
$DEST := @C10
END
IF %PIRATEENCOUNTER >= 75 AND %PIRATEENCOUNTER <= 79 THEN
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 27 AND %PIRATEENCOUNTER <= 29 THEN
BEGIN
$DEST := @C12
END
END
################END LEVEL 3#######################################
##################################################################
################BEGIN LEVEL 4##################################

ELSE IF $CHAPTERID = 4 AND %SEAENCOUNTERS = 2 OR %SEAENCOUNTER = 4 AND %LEVEL = 4 THEN
BEGIN
%PIRATEENCOUNTERS := 1D100

IF %PIRATEENCOUNTER >= 10 AND %PIRATEENCOUNTER <= 14 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTER <= 9 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 30 AND %PIRATEENCOUNTER <= 39 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 70 AND %PIRATEENCOUNTER <= 79 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTER >= 55 AND %PIRATEENCOUNTER <= 59 THEN
BEGIN
%DEST := @C7
END
IF %PIRATEENCOUNTER >= 40 AND %PIRATEENCOUNTER <= 49 THEN
BEGIN
$DEST := @C8
END
IF %PIRATEENCOUNTER >= 80 AND %PIRATEENCOUNTER <= 89 THEN
BEGIN
$DEST := @C9
END
IF %PIRATEENCOUNTER >= 25 AND %PIRATEENCOUNTER <= 29 THEN
BEGIN
$DEST := @C10
END
IF %PIRATEENCOUNTER >= 50 AND %PIRATEENCOUNTER <= 54 THEN
BEGIN
$DEST := @C10
END
IF %PIRATEENCOUNTER >= 15 AND %PIRATEENCOUNTER <= 19 THEN 
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 60 AND %PIRATEENCOUNTER <= 69 THEN 
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 90 AND %PIRATEENCOUNTER <= 94 THEN 
BEGIN
$DEST := @C11
END
IF %PIRATEENCOUNTER >= 20 AND %PIRATEENCOUNTER <= 24 THEN
BEGIN
$DEST := @C12
END
IF %PIRATEENCOUNTER >= 97 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C13
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 0
THEN
BEGIN
$DEST := @C14
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 1
THEN
BEGIN
$DEST := @C5
END
END

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago
Awesome!

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago

IF %SCORE <= 500 THEN
%LEVEL := 1
ELSE IF %SCORE > 500 AND %SCORE <= 2500 THEN
%LEVEL := 2
ELSE IF %SCORE > 2500 AND %SCORE <= 6500 THEN
%LEVEL := 3
ELSE IF %SCORE > 6500 THEN
%LEVEL := 4

I'll just point out again, though I don't know if it would affect it or not, but you don't normally use the ELSE word in this way.

ELSE is where you have a condition, and if it is not met, another action takes place. IE,

----

IF %VARIABLE1 = 1 THEN
$DEST := @C2
ELSE
$DEST := @C3

-----

In this example, if variable 1 = 1, it goes to chapter two. If it doesn't equal 1, it goes to chapter 3 instead.

You don't need to use the ELSE command in front of the IF command in your script. You can just type:

------

IF %SCORE <= 500 THEN %LEVEL := 1
IF %SCORE > 500 AND %SCORE <= 2500 THEN %LEVEL := 2
IF %SCORE > 2500 AND %SCORE <= 6500 THEN %LEVEL := 3
IF %SCORE > 6500 THEN %LEVEL := 4

-------

I am not sure about the syntax of this site's scripting, but usually if only a single action takes place because of the IF, then you don't need to place it on a different line, you can just add it after THEN on the same line. You only need seperate lines if a bunch of things are going to take place. This way, that part of your script is only 4 lines long, and doesn't involve a bunch of ELSE commands being used.

I can't remember if I mentioned that earlier. BEGIN and END are usually used to define a 'block' of actions that you want to tie to the IF THEN comman. If there's only a single action, you should be able to type it on the same line as the IF THEN command, simply following the word THEN. It should simplify a lot of the lines in your script, because most of the time, you only have a single action following the THEN command.

For example, toward the end you have:

----------

IF %PIRATEENCOUNTER >= 97 AND %PIRATEENCOUNTER <= 100 THEN
BEGIN
$DEST := @C13
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 0 THEN
BEGIN
$DEST := @C14
END
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 1
THEN
BEGIN
$DEST := @C5
END

---------

Which you can probably just type as three lines:

----------

IF %PIRATEENCOUNTER >= 97 AND %PIRATEENCOUNTER <= 100 THEN $DEST := @C13
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 0 THEN $DEST := @C14
IF %PIRATEENCOUNTER >= 95 AND %PIRATEENCOUNTER <= 96 AND %DAVEYJONES = 1 THEN $DEST := @C5

---------

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago

I know what you mean with the ELSE, some prog languages have it as: ELSEIF and ELSIF, but anyways... i see what your saying.. but now i would rather not like to touch my code, since it works LOL... i will just leave it...

like they say, "If it ain't broke, don't fix it!"

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago
Ahhh! I see what is wrong, okay, the parser reads ELSEIF and ELSE IF as two different things, that is why my code was all screwy... thank you tsmpaul, thats basically what youve been saying all this time... LOL

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago
okay, this is stupid... its only evaluating up to @C5, no matter what my 1D100 does, it always goes to @C5.

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago

Can someone please telll me what is wrong?               i wanna rip out my hair right now...

 

%SEAENCOUNTERS := 0
%SEADESCRIPTION := 0
%PIRATEENCOUNTER := 0
%LEVEL := 0 

IF %SCORE <= 500 THEN
%LEVEL := 1
IF %SCORE > 500 AND %SCORE <= 2500 THEN
%LEVEL := 2
IF %SCORE > 2500 AND %SCORE <= 6500 THEN
%LEVEL := 3
IF %SCORE > 6500 THEN
%LEVEL := 4

IF $CHAPTERID = 4 THEN
%SEAENCOUNTERS := 1D4
%LASTPAGEID := $PAGEID

IF %SEAENCOUNTERS = 1 OR %SEAENCOUNTERS = 3
THEN
BEGIN
%SEADESCRIPTION := 1D5
END
IF ((%SEAENCOUNTERS = 2) OR (%SEAENCOUNTERS = 4)) AND %LEVEL = 1 THEN
BEGIN
%PIRATEENCOUNTERS := 1D100

IF %PIRATEENCOUNTERS <= 19 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTERS >= 60 AND %PIRATEENCOUNTERS <= 69 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTERS >= 35 AND %PIRATEENCOUNTERS <= 44 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTERS >= 90 AND %PIRATEENCOUNTERS <= 100 THEN
BEGIN
$DEST := @C5
END
IF %PIRATEENCOUNTERS >= 20 AND %PIRATEENCOUNTERS <= 34 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTERS >= 70 AND %PIRATEENCOUNTERS <= 89 THEN
BEGIN
$DEST := @C6
END
IF %PIRATEENCOUNTERS >= 50 AND %PIRATEENCOUNTERS <= 59 THEN
BEGIN
$DEST := @C7
END
IF %PIRATEENCOUNTERS >= 45 AND %PIRATEENCOUNTERS <= 49 THEN 
BEGIN
$DEST := @C8
END
END

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago

-----

IF %SEAENCOUNTERS = 1 OR %SEAENCOUNTERS = 3
THEN
BEGIN
%SEADESCRIPTION := 1D5
END

------

I think you've got the word THEN on a different line here, so it isn't reading it as part of the IF command. That could be bugging the script.

Also, at the bottom you've got IF THEN's with Begin and End, but up the top you don't. Not sure what that will do when the script is read.

For the top ones, I would probably write

IF %SCORE <= 500 THEN
%LEVEL := 1

as

IF %SCORE <= 500 THEN %LEVEL := 1

or

IF %SCORE <= 500 THEN
BEGIN
%LEVEL := 1
END

though I prefer the second one. since line returns (where you press enter)  might affect the script . But I suspect having the word THEN on a different line (in the SEAENCOUNTERS) to the IF could be what is causing the problem.

OMG I AM GONNA RIP MY HAIR OUT!!!

18 years ago

wow.. tahts incredible lol.