Results 1 to 7 of 7

Thread: loop problems

  
  1. #1

    Default loop problems

    im having problems with loops for a level im making, i want to make a group of fairies spawn continuously until the hero dungeon heart is destroyed
    and i can't seem to get the loop to end.
    SET_FLAG(PLAYER0,FLAG0,0)

    CREATE_PARTY(SUPER_FAIRY)
    ADD_TO_PARTY(SUPER_FAIRY,FAIRY,7,500,ATTACK_ENEM IES,0)

    SET_TIMER(PLAYER0,TIMER0)

    IF_ACTION_POINT(1,PLAYER0)
    IF(PLAYER_GOOD,FLAG0 == 0)
    IF(PLAYER0,TIMER0 >= 150)
    NEXT_COMMAND_REUSABLE
    ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SUPER_FAIRY,-1,1)
    NEXT_COMMAND_REUSABLE
    SET_TIMER(PLAYER0,TIMER0)
    *IF_ACTION_POINT(2,PLAYER0)*
    *SET_FLAG(PLAYER0,FLAG0,1)*
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF

    this is what i have, like i can get the loop to work np but getting it to end is not working. this is just a test run ive been using to figure out how to end it
    the last 2 before the ENDIFs are encased in "*" because those are the lines im trying to use to get the loop to end. I know its not the dungeon being destroyed im just using an action point till i can figure out how to end it.
    thanks for any help you can provide

  2. #2
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: loop problems

    Try looking at keeperfx.log, maybe there's some script error message when the map is being loaded.

  3. #3
    Elite Dragon Mothrayas's Avatar
    Join Date
    Nov 2009
    Location
    The Netherlands
    Posts
    1,635

    Default Re: loop problems

    First off: Indentation. Use it. It really helps with making script code clear, especially if you have multiple nested if statements.

    Code:
    SET_FLAG(PLAYER0,FLAG0,0)
    
    CREATE_PARTY(SUPER_FAIRY)
    ADD_TO_PARTY(SUPER_FAIRY,FAIRY,7,500,ATTACK_ENEM IES,0)
    
    SET_TIMER(PLAYER0,TIMER0)
    
    IF_ACTION_POINT(1,PLAYER0)
        IF(PLAYER_GOOD,FLAG0 == 0)
            IF(PLAYER0,TIMER0 >= 150)
                NEXT_COMMAND_REUSABLE
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SUPER_FAIRY,-1,1)
                NEXT_COMMAND_REUSABLE
                SET_TIMER(PLAYER0,TIMER0)
                *IF_ACTION_POINT(2,PLAYER0)*
                    *SET_FLAG(PLAYER0,FLAG0,1)*
                ENDIF
            ENDIF
        ENDIF
    ENDIF
    ENDIF
    This already shows to start off that you have one ENDIF statement too many, which can break things.

    Anyway, you have two IF_ACTION_POINT statements nested in another. IF_ACTION_POINT only triggers once, which means that the SET_FLAG will only run if both action point statements are triggered at the exact same time - which is nearly impossible to time right.

    You should put the second IF_ACTION_POINT and SET_FLAG statement outside the code block.
    Last edited by Mothrayas; July 18th, 2013 at 11:53.

    The Awakening


  4. #4

    Default Re: loop problems

    i always indent my work but it was indented when i copied and pasted it, then i noticed it wasn't when it posted. Sorry i shouldve fixed it, and the "IF_ACTION_POINT(2,PLAYER0) was tabbed which is why i had one more endif.
    also i tried putting the last 2 lines after the loop itself
    so after the endifs i put
    *IF_ACTION_POINT(2,PLAYER0)*
    *SET_FLAG(PLAYER0,FLAG0,1)*
    i figured that would changed flag0s value and make the requirements for the loop null, but it still continues, could it be because the timer is set to repeat the loop every 150 game ticks?(i have it like that for testing purposes)

  5. #5
    KeeperFX Author mefistotelis's Avatar
    Join Date
    Sep 2009
    Location
    Poland
    Posts
    1,242

    Default Re: loop problems

    You are setting flag for PLAYER0 and checking IF (PLAYER_GOOD,..).

    Each player has its own, separate flags set.

  6. #6

    Default Re: loop problems

    LOL how did i not notice this ahahahah a dur a dur, i was using the code from level 11 as a template for my loop and i forgot to switch out player good
    ILL give it a test now thanks both of you for helping

    edit: yes that got it working the way i wanted it to.
    Last edited by veroba; July 18th, 2013 at 20:09.

  7. #7
    Dragon DragonsLover's Avatar
    Join Date
    Aug 2009
    Location
    Quebec
    Posts
    1,490
    Gamer IDs

    Steam ID: dragonslover

    Default Re: loop problems

    There was also a space in ATTACK_ENEM IES.
    I like dragons! They're the center of my life! I'll never forget them...



Similar Threads

  1. problems with Ai
    By darkkingkongman in forum DK2 Troubleshooting
    Replies: 6
    Last Post: June 11th, 2013, 11:17
  2. Map problems
    By themightyevil in forum Dungeon Keeper 2
    Replies: 1
    Last Post: November 1st, 2011, 16:24
  3. Problems while building SVN
    By Георгий Платонов in forum KeeperFX
    Replies: 23
    Last Post: October 1st, 2011, 08:52
  4. 2 Problems
    By Randy19 in forum DK1 Mapmaking
    Replies: 11
    Last Post: September 2nd, 2011, 09:31
  5. DK2 v1.3 problems..
    By Keeper_Infernal in forum DK2 Troubleshooting
    Replies: 14
    Last Post: June 28th, 2010, 14:22

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
  •