Results 1 to 6 of 6

Thread: What's wrong with this script

  
  1. #1

    Default What's wrong with this script

    Code:
    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
    Last edited by kix; March 12th, 2019 at 23:27.

  2. #2

    Default Re: What's wrong with this script

    What's the problem you're having?

  3. #3

    Default Re: What's wrong with this script

    Quote Originally Posted by YourMaster View Post
    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.
    Last edited by kix; March 13th, 2019 at 12:58.

  4. #4

    Default Re: What's wrong with this script

    Ok I simplified the code to this:
    Code:
    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:

    Code:
    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?
    Last edited by kix; March 13th, 2019 at 12:57.

  5. #5

    Default Re: What's wrong with this script

    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.

  6. #6

    Default Re: What's wrong with this script

    Thanks, for some reason I thought it handles the whole script in one turn.

Similar Threads

  1. Colors a little wrong when importing sprites
    By Daver690 in forum KeeperFX
    Replies: 1
    Last Post: October 12th, 2014, 17:45
  2. Map Rules what´s wrong?
    By Endrix in forum DK1 Mapmaking
    Replies: 3
    Last Post: June 27th, 2014, 07:01
  3. Bug : minimap colors wrong and windows mode
    By edorien in forum KeeperFX
    Replies: 2
    Last Post: June 22nd, 2014, 09:31
  4. KeeperFX runs the wrong campain?!
    By creme83 in forum KeeperFX
    Replies: 2
    Last Post: January 27th, 2013, 23:22
  5. What Can Go Wrong in a Dungeon?
    By Rephath in forum Dungeon Keeper RPG - The Awakening
    Replies: 2
    Last Post: January 9th, 2013, 02:07

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •