Solved Looper Problem

Question that is answered or resolved.

Aerisetta

Active member
Spent hours on this and not sure why

This is my Looper Script, located in my animation script
Code:
void looper(int Frame, int Limit)
{// Loops current animation
    void self = getlocalvar("self");
    void loop = getlocalvar("Loop" + self);

    if(loop==NULL()){ // Localvar empty?
      setlocalvar("Loop" + self, 0);
      loop = 0;
    }
  
    if(loop < Limit){ // loops reach limit?
      setlocalvar("Loop" + self, loop+1); // Increment number of loops
      updateframe(self, Frame); //Change frame
    } else if(loop==Limit){ // loops reach limit?
      setlocalvar("Loop" + self, NULL());
    }
}

This is my attack, I want the enemy to grab the player and keep attacking them. But they just play the animation once and stop.
If I use Loop 1, it works (but wont end, that's a problem)
Can anyone see what's wrong?

Code:
anim    freespecial ##grab attempt
    delay    1
    offense normal1 -1
    offset    80 290
    followcond 2
    followanim 8
    attackone 1
    fastattack    1
    jugglecost    1
    offset    80 290
    bbox    30 5 140 285
    frame    data/chars/aerisetta/grab01.png
    #@cmd    consume 50 0 "ANI_CANT"
    sound    data/sounds/fast.wav
    sound    data/sounds/punch_.wav
    delay    20
    frame    data/chars/aerisetta/grab01.png
    @cmd    dasher 0.1 0 0 1
    delay    6
    frame    data/chars/aerisetta/grab02.png
    attack5 123 20 85 200 0 0 0 0 5 50
    sound    data/sounds/Run.wav
    forcedirection -1
    frame    data/chars/aerisetta/grab03.png
    attack    0
    delay    10
    frame    data/chars/aerisetta/grab04.png   
    sound    data/sounds/A_Pain2.wav
    delay    20
    frame    data/chars/aerisetta/grab04.png   
    
anim    follow8 ##grab successful

    delay    2
    jumpframe    0 0 0
    bbox 0 0 0 0
    @cmd    slamstart2
    offset    770 625
    @cmd    position 0 0 5 -1 1
    frame    data/chars/soldier/S01_01.png
    @cmd     looper 5 5
    sound    data/sounds/stroke2.wav
    @cmd    position 1 0 5 -1 1
    frame    data/chars/soldier/S01_02.png
    @cmd    position 2 0 5 -1 1
    frame    data/chars/soldier/S01_03.png
    @cmd    position 3 0 5 -1 1
    frame    data/chars/soldier/S01_04.png
    @cmd    position 4 0 5 -1 1
    frame    data/chars/soldier/S01_05.png
    @cmd    position 5 0 5 -1 1
    frame    data/chars/soldier/S01_06.png
    @cmd    position 6 0 5 -1 1
    frame    data/chars/soldier/S01_07.png
    @cmd    position 7 0 5 -1 1
    frame    data/chars/soldier/S01_08.png
    @cmd    position 8 0 5 -1 1
    frame    data/chars/soldier/S01_09.png
    @cmd    position 9 0 5 -1 1
    frame    data/chars/soldier/S01_10.png
    @cmd    position 10 0 5 -1 1
    frame    data/chars/soldier/S01_11.png
    @cmd    position 11 0 5 -1 1
    frame    data/chars/soldier/S01_12.png
    @cmd    position 12 0 5 -1 1
    frame    data/chars/soldier/S01_13.png
    @cmd    position 13 0 5 -1 1
    frame    data/chars/soldier/S01_14.png
    @cmd    position 14 0 5 -1 1
    frame    data/chars/soldier/S01_15.png
    @cmd    position 15 0 5 -1 1
    frame    data/chars/soldier/S01_16.png
    @cmd    position 16 0 5 -1 1
    frame    data/chars/soldier/S01_17.png
    @cmd    position 17 0 5 -1 1
    frame    data/chars/soldier/S01_17.png
 
Solution
I am not on my computer right now, but I can point out the problem there. You placed the looper function in the second frame while the looper function is trying to repeat to change frame to sixth frame. Try to place that function to the second or third to the last frame of the animation. The first parameter of looper is to change frame as a beginning of its loop while the second one is for how many times it loops until it expires. O see you want it to loop 5 times while changing back to the start of its sixth frame.

Looper {frame} {limit}

Code:
    anim follow8 ##grab successful

    delay 2
    jumpframe 0 0 0
    bbox 0 0 0 0
    @cmd slamstart2
    offset 770 625
    @cmd position 0 0 5 -1 1
    frame data/chars/soldier/S01_01.png #...
I am not on my computer right now, but I can point out the problem there. You placed the looper function in the second frame while the looper function is trying to repeat to change frame to sixth frame. Try to place that function to the second or third to the last frame of the animation. The first parameter of looper is to change frame as a beginning of its loop while the second one is for how many times it loops until it expires. O see you want it to loop 5 times while changing back to the start of its sixth frame.

Looper {frame} {limit}

Code:
    anim follow8 ##grab successful

    delay 2
    jumpframe 0 0 0
    bbox 0 0 0 0
    @cmd slamstart2
    offset 770 625
    @cmd position 0 0 5 -1 1
    frame data/chars/soldier/S01_01.png # 0
    sound    data/sounds/stroke2.wav
    @cmd position 1 0 5 -1 1
    frame data/chars/soldier/S01_02.png # 1
    @cmd position 2 0 5 -1 1
    frame data/chars/soldier/S01_03.png # 2
    @cmd position 3 0 5 -1 1
    frame data/chars/soldier/S01_04.png # 3
    @cmd position 4 0 5 -1 1
    frame data/chars/soldier/S01_05.png # 4
    @cmd position 5 0 5 -1 1
    frame data/chars/soldier/S01_06.png # 5
    @cmd position 6 0 5 -1 1
    frame data/chars/soldier/S01_07.png # 6
    @cmd position 7 0 5 -1 1
    frame data/chars/soldier/S01_08.png # 7
    @cmd position 8 0 5 -1 1
    frame data/chars/soldier/S01_09.png # 8
    @cmd position 9 0 5 -1 1
    frame data/chars/soldier/S01_10.png # 9
    @cmd position 10 0 5 -1 1
    frame data/chars/soldier/S01_11.png # 10
    @cmd position 11 0 5 -1 1
    frame data/chars/soldier/S01_12.png #11
    @cmd position 12 0 5 -1 1
    frame data/chars/soldier/S01_13.png #12
    @cmd position 13 0 5 -1 1
    frame data/chars/soldier/S01_14.png #13
    @cmd position 14 0 5 -1 1
    frame    data/chars/soldier/S01_15.png #14
    @cmd     looper 5 5
    @cmd    position 15 0 5 -1 1
    frame data/chars/soldier/S01_16.png #15
    @cmd position 16 0 5 -1 1
    frame data/chars/soldier/S01_17.png #16
    @cmd position 17 0 5 -1 1
    frame data/chars/soldier/S01_17.png #17
 
Solution
I am not on my computer right now, but I can point out the problem there. You placed the looper function in the second frame while the looper function is trying to repeat to change frame to sixth frame. Try to place that function to the second or third to the last frame of the animation. The first parameter of looper is to change frame as a beginning of its loop while the second one is for how many times it loops until it expires. O see you want it to loop 5 times while changing back to the start of its sixth frame.

Looper {frame} {limit}

Code:
    anim follow8 ##grab successful

    delay 2
    jumpframe 0 0 0
    bbox 0 0 0 0
    @cmd slamstart2
    offset 770 625
    @cmd position 0 0 5 -1 1
    frame data/chars/soldier/S01_01.png # 0
    sound    data/sounds/stroke2.wav
    @cmd position 1 0 5 -1 1
    frame data/chars/soldier/S01_02.png # 1
    @cmd position 2 0 5 -1 1
    frame data/chars/soldier/S01_03.png # 2
    @cmd position 3 0 5 -1 1
    frame data/chars/soldier/S01_04.png # 3
    @cmd position 4 0 5 -1 1
    frame data/chars/soldier/S01_05.png # 4
    @cmd position 5 0 5 -1 1
    frame data/chars/soldier/S01_06.png # 5
    @cmd position 6 0 5 -1 1
    frame data/chars/soldier/S01_07.png # 6
    @cmd position 7 0 5 -1 1
    frame data/chars/soldier/S01_08.png # 7
    @cmd position 8 0 5 -1 1
    frame data/chars/soldier/S01_09.png # 8
    @cmd position 9 0 5 -1 1
    frame data/chars/soldier/S01_10.png # 9
    @cmd position 10 0 5 -1 1
    frame data/chars/soldier/S01_11.png # 10
    @cmd position 11 0 5 -1 1
    frame data/chars/soldier/S01_12.png #11
    @cmd position 12 0 5 -1 1
    frame data/chars/soldier/S01_13.png #12
    @cmd position 13 0 5 -1 1
    frame data/chars/soldier/S01_14.png #13
    @cmd position 14 0 5 -1 1
    frame    data/chars/soldier/S01_15.png #14
    @cmd     looper 5 5
    @cmd    position 15 0 5 -1 1
    frame data/chars/soldier/S01_16.png #15
    @cmd position 16 0 5 -1 1
    frame data/chars/soldier/S01_17.png #16
    @cmd position 17 0 5 -1 1
    frame data/chars/soldier/S01_17.png #17
it works now! thanks!
 
Back
Top Bottom