PDA

View Full Version : What's wrong with this script



kix
March 12th, 2019, 23:22
LEVEL_VERSION(1)
START_MONEY(PLAYER0,4444)
SET_FLAG(PLAYER0,FLAG1,0)

CREATE_PARTY(C1)
ADD_TO_PARTY(C1,FAIRY,1,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(C1,FAIRY,1,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(C2)
ADD_TO_PARTY(C2,FAIRY,8,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(C2,FAIRY,8,0,ATTACK_DUNGEON_HEART,0)

CREATE_PARTY(C3)
ADD_TO_PARTY(C3,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)
ADD_TO_PARTY(C3,WITCH,10,0,ATTACK_DUNGEON_HEART,0)

MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)

IF(PLAYER0,FLAG1 == 1)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(3,"debug: flag condition ok",ALL_PLAYERS)
IF(PLAYER0,GAME_TURN <= 25000)
NEXT_COMMAND_REUSABLE
ADD_PARTY_TO_LEVEL(PLAYER_GOOD,C1,-1,1)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(5,"debug: <25",ALL_PLAYERS)
ENDIF
IF(PLAYER0,GAME_TURN > 25000)
NEXT_COMMAND_REUSABLE
ADD_PARTY_TO_LEVEL(PLAYER_GOOD,C2,-1,1)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(6,"debug: >25",ALL_PLAYERS)
ENDIF
IF(PLAYER0,GAME_TURN > 75000)
NEXT_COMMAND_REUSABLE
ADD_PARTY_TO_LEVEL(PLAYER_GOOD,C3,-1,5)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(7,"debug: >75 !!",ALL_PLAYERS)
ENDIF
NEXT_COMMAND_REUSABLE
SET_FLAG(PLAYER0,FLAG1,0)
ENDIF

IF(PLAYER0,TIMER0 > 200)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(1,"debug: TIMER",ALL_PLAYERS)
IF(PLAYER_GOOD,TOTAL_CREATURES>=1)
QUICK_INFORMATION(11,"debug: at least one",ALL_PLAYERS)
ENDIF
IF(PLAYER_GOOD,TOTAL_CREATURES<1)
NEXT_COMMAND_REUSABLE
SET_FLAG(PLAYER0,FLAG1,1)
ENDIF
NEXT_COMMAND_REUSABLE
BONUS_LEVEL_TIME(200)
NEXT_COMMAND_REUSABLE
SET_TIMER(PLAYER0,TIMER0)
ENDIF

IF(PLAYER0,IMP > 0)
BONUS_LEVEL_TIME(200)
SET_TIMER(PLAYER0,TIMER0)
ENDIF

IF(PLAYER0,TORTURE>33)
WIN_GAME
ENDIF


Result
200 turns: debug: timer
another 200 turns: debug: timer, debug: flag condition ok
another 200 turns: debug: timer, debug: flag condition ok, debug: <25
and then they spawn

this is not the first time I have encountered this. Do I have some dumb ass mistake in there or what is happening
log is clear

YourMaster
March 13th, 2019, 08:55
What's the problem you're having?

kix
March 13th, 2019, 10:29
What's the problem you're having?

player0 summons imp, timer starts
some time passes
game turn is >200
that triggers the timer condition, quick info with debug timer comes up. that is correct. Player_good has 0 creatures so the flag1 is set to 1.
game turn is approx>201
flag1 is set to 1 so I should see the other condition fulfill bringing up quick info about flag condition ok. But it wont show up, in fact, only the second time the timer is over (when it is restarted and game turn is >400), but even then, it stops there and won't spawn the parties and won't bring quick info about debug <25.
After the timer is triggered the third time - after being restarted twice, then it starts working as expected.

I'm pretty sure I'm missing something obvious here but I cant figure out what.

kix
March 13th, 2019, 11:14
Ok I simplified the code to this:


LEVEL_VERSION(1)
START_MONEY(PLAYER0,4444)

CREATE_PARTY(C3)
ADD_TO_PARTY(C3,FAIRY,10,0,ATTACK_DUNGEON_HEART,0)

MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)

IF(PLAYER0,IMP > 0)
BONUS_LEVEL_TIME(200)
SET_TIMER(PLAYER0,TIMER0)
ENDIF

IF(PLAYER0,TIMER0 > 200)
IF(PLAYER0,MONEY<1000)
NEXT_COMMAND_REUSABLE
ADD_PARTY_TO_LEVEL(PLAYER_GOOD,C3,-1,1)
ENDIF
IF(PLAYER0,MONEY>=1000)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(1,"HAS MONEY",ALL_PLAYERS)
ENDIF
NEXT_COMMAND_REUSABLE
BONUS_LEVEL_TIME(200)
NEXT_COMMAND_REUSABLE
SET_TIMER(PLAYER0,TIMER0)
ENDIF

IF(PLAYER0,TORTURE>33)
WIN_GAME
ENDIF


After 200 turns, it just starts over. No quick info, no party spawn.
After another 200 turns, it says players has money, as expected.
However if I write this:



IF(PLAYER0,TIMER0 > 200)
IF(PLAYER0,MONEY<1000)
NEXT_COMMAND_REUSABLE
ADD_PARTY_TO_LEVEL(PLAYER_GOOD,C3,-1,1)

NEXT_COMMAND_REUSABLE
BONUS_LEVEL_TIME(200)
NEXT_COMMAND_REUSABLE
SET_TIMER(PLAYER0,TIMER0)
ENDIF
IF(PLAYER0,MONEY>=1000)
NEXT_COMMAND_REUSABLE
QUICK_INFORMATION(1,"HAS MONEY",ALL_PLAYERS)

NEXT_COMMAND_REUSABLE
BONUS_LEVEL_TIME(200)
NEXT_COMMAND_REUSABLE
SET_TIMER(PLAYER0,TIMER0)
ENDIF
ENDIF


then it works as expected and says has money after 200 game turns straight away. Why is that?

YourMaster
March 13th, 2019, 13:38
The game will handle 1 line of script per game turn, and will cycle through the script from top to bottom. So you've got to make sure that everything you want to happen under a condition is finished before you remove the condition.

It is a script, not a programming language.

kix
March 13th, 2019, 14:13
Thanks, for some reason I thought it handles the whole script in one turn.