animation loop in certain frames

jonsilva

New member
hi
iam trying to loop an animation only in certain frames...
i needed to get at least a loop of 15 seconds this could make the character txt file very big
anim follow12
loop 0
delay 15
offset 101 190
bbox 0 0 0 0
@script
    void self = getlocalvar("self");

    if(frame==20){ // set local variable at 1st frame
      setlocalvar("Flag" + self,1);
    }
@end_script
frame data/chars/3crazyjoe/rise3.gif
@cmd targetPos 2 835 390
@cmd leap 6
delay 9
frame data/chars/3crazyjoe/jump00.gif
frame data/chars/3crazyjoe/jump01.gif
delay 6
frame data/chars/3crazyjoe/roll02.gif
frame data/chars/3crazyjoe/roll03.gif
frame data/chars/3crazyjoe/roll04.gif
frame data/chars/3crazyjoe/roll01.gif
frame data/chars/3crazyjoe/roll02.gif
frame data/chars/3crazyjoe/roll03.gif
frame data/chars/3crazyjoe/roll04.gif
frame data/chars/3crazyjoe/roll01.gif
frame data/chars/3crazyjoe/roll02.gif
frame data/chars/3crazyjoe/roll03.gif
@cmd targetPos 5 700 390
@cmd leap 1
frame data/chars/3crazyjoe/roll04.gif
frame data/chars/3crazyjoe/roll01.gif
frame data/chars/3crazyjoe/roll02.gif
frame data/chars/3crazyjoe/roll03.gif
frame data/chars/3crazyjoe/roll04.gif
delay 15
frame data/chars/3crazyjoe/rise3.gif
@cmd spawn01 "dust" 1 1 1
frame data/chars/3crazyjoe/rise2.gif
delay 150
frame data/chars/3crazyjoe/rise3.gif
delay 12
------------------------------///----------------------------> LOOP begin
frame data/chars/3crazyjoe/taunt01.gif
frame data/chars/3crazyjoe/taunt02.gif
frame data/chars/3crazyjoe/taunt03.gif
frame data/chars/3crazyjoe/taunt04.gif
frame data/chars/3crazyjoe/taunt05.gif
frame data/chars/3crazyjoe/taunt06.gif #25
frame data/chars/3crazyjoe/taunt01.gif
frame data/chars/3crazyjoe/taunt02.gif
frame data/chars/3crazyjoe/taunt03.gif
frame data/chars/3crazyjoe/taunt04.gif
frame data/chars/3crazyjoe/taunt05.gif
frame data/chars/3crazyjoe/taunt06.gif
frame data/chars/3crazyjoe/taunt01.gif
frame data/chars/3crazyjoe/taunt02.gif
frame data/chars/3crazyjoe/taunt03.gif
frame data/chars/3crazyjoe/taunt04.gif
frame data/chars/3crazyjoe/taunt05.gif
frame data/chars/3crazyjoe/taunt06.gif
frame data/chars/3crazyjoe/taunt01.gif
frame data/chars/3crazyjoe/taunt02.gif
frame data/chars/3crazyjoe/taunt03.gif
frame data/chars/3crazyjoe/taunt04.gif
frame data/chars/3crazyjoe/taunt05.gif #42
-------------------------------//--------------------------------> LOOP end
@cmd looper 42 10
delay 200
frame data/chars/3crazyjoe/taunt06.gif

ive tried the looper script but it doesnt have a start frame
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?
      updateframe(self, Frame); //Change frame
      setlocalvar("Loop" + self, loop+1); // Increment number of loops
    } else if(loop==Limit){ // loops reach limit?
      setlocalvar("Loop" + self, NULL());
    }
}

iam trying to avoid change the animation to another anim follow and loop it there...

anyone knows if it can be done ?
 
looper function doesn't have end frame actually cause it is declared at end of loop.
The 1st parameter defines frame to loop to while the 2nd one defines how many looping to be done before resuming the animation (NOT counting the 1st run)

So in your case it should be like this:

anim  follow12
  loop  0
  delay  15
  offset  101 190
  bbox  0 0 0 0
@script
    void self = getlocalvar("self");

    if(frame==20){ // set local variable at 1st frame
      setlocalvar("Flag" + self,1);
    }
  @end_script 
  frame  data/chars/3crazyjoe/rise3.gif
  @cmd  targetPos 2 835 390
  @cmd  leap 6
  delay  9
  frame  data/chars/3crazyjoe/jump00.gif
  frame  data/chars/3crazyjoe/jump01.gif
  delay  6
  frame  data/chars/3crazyjoe/roll02.gif
  frame  data/chars/3crazyjoe/roll03.gif
  frame  data/chars/3crazyjoe/roll04.gif
  frame  data/chars/3crazyjoe/roll01.gif
  frame  data/chars/3crazyjoe/roll02.gif
  frame  data/chars/3crazyjoe/roll03.gif
  frame  data/chars/3crazyjoe/roll04.gif
  frame  data/chars/3crazyjoe/roll01.gif
  frame  data/chars/3crazyjoe/roll02.gif
  frame  data/chars/3crazyjoe/roll03.gif
  @cmd  targetPos 5 700 390
  @cmd  leap 1
  frame  data/chars/3crazyjoe/roll04.gif
  frame  data/chars/3crazyjoe/roll01.gif
  frame  data/chars/3crazyjoe/roll02.gif
  frame  data/chars/3crazyjoe/roll03.gif
  frame  data/chars/3crazyjoe/roll04.gif
  delay  15
  frame  data/chars/3crazyjoe/rise3.gif
  @cmd  spawn01 "dust" 1 1 1
  frame  data/chars/3crazyjoe/rise2.gif
  delay  150
  frame  data/chars/3crazyjoe/rise3.gif
  delay  12
------------------------------///----------------------------> LOOP begin
  frame  data/chars/3crazyjoe/taunt01.gif
  frame  data/chars/3crazyjoe/taunt02.gif
  frame  data/chars/3crazyjoe/taunt03.gif
  frame  data/chars/3crazyjoe/taunt04.gif
  frame  data/chars/3crazyjoe/taunt05.gif
  frame  data/chars/3crazyjoe/taunt06.gif #25
  frame  data/chars/3crazyjoe/taunt01.gif
  frame  data/chars/3crazyjoe/taunt02.gif
  frame  data/chars/3crazyjoe/taunt03.gif
  frame  data/chars/3crazyjoe/taunt04.gif
  frame  data/chars/3crazyjoe/taunt05.gif
  frame  data/chars/3crazyjoe/taunt06.gif
  frame  data/chars/3crazyjoe/taunt01.gif
  frame  data/chars/3crazyjoe/taunt02.gif
  frame  data/chars/3crazyjoe/taunt03.gif
  frame  data/chars/3crazyjoe/taunt04.gif
  frame  data/chars/3crazyjoe/taunt05.gif
  frame  data/chars/3crazyjoe/taunt06.gif
  frame  data/chars/3crazyjoe/taunt01.gif
  frame  data/chars/3crazyjoe/taunt02.gif
  frame  data/chars/3crazyjoe/taunt03.gif
  frame  data/chars/3crazyjoe/taunt04.gif
  frame  data/chars/3crazyjoe/taunt05.gif #42
-------------------------------//--------------------------------> LOOP end
  @cmd  looper 21 9
  delay  200
  frame  data/chars/3crazyjoe/taunt06.gif

I'm not sure how much value I should give for 2nd parameter but I assume you want it to loop for 10 times so excluding the 1st run, 2nd parameter should be 9.
 
I was trying to do this too,

How do I make it so walking anim will skip the first frame when looped?

So when you first walk it plays

frame 1
frame 2
frame 4
etc.

But when it loops after that it skips the first frame

frame 2
frame 3
frame 4
etc.

I diddn't quite understand the script to edit it accordingly.
 
Thanks, I thought there was something hardcoded for this.  My bad I was looking for a separate function when searching manual, forgot this is part of loop function. I kept thinking of 'looper' command than saw this post. 

The problem with me taking long breaks from modding, forget a lot of updates and revert to 2005 limitations :p
 
thanks
I'm not sure how much value I should give for 2nd parameter but I assume you want it to loop for 10 times so excluding the 1st run, 2nd parameter should be 9.

ive got it working but i cant make the 2nd parameter work
delay 150
frame data/chars/3crazyjoe/rise3.gif
delay 8
frame data/chars/3crazyjoe/taunt01.gif
frame data/chars/3crazyjoe/taunt02.gif
frame data/chars/3crazyjoe/taunt03.gif
frame data/chars/3crazyjoe/taunt04.gif
frame data/chars/3crazyjoe/taunt05.gif
frame data/chars/3crazyjoe/taunt06.gif #25
@cmd looper 21 5
delay 20
frame data/chars/3crazyjoe/taunt06.gif

the animation keeps looping forever and doesnt stop...
ive already changed the 2nd number to 2, 3, 5 but it doesnt seem to stop at end of 5 loops
 
Ah yes, there's a change in OpenBoR build which causes that bug.
To solve that, simpy edit looper function to this:

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());
    }
}
 
I want to use this script but I'm not sure if it applies to exactly what I want to do.  I want to set a 5 second loop to start at frame 5 and skip frame 0 and go back to frame 1 and once the 5 seconds are up continue with the animation will this work for that?

Code:
anim	freespecial3
	com	A2 freespecial3
	energycost	35
	mponly	1
	@cmd	setglobalvar "zoomentity" getlocalvar("self")
	@cmd	setglobalvar "zoomvalue" 250
	@cmd	setglobalvar "zoomx" 0
	@cmd	setglobalvar "zoomy" -100
	@cmd	paus0001 1 100
	fastattack	1
	delay	20
	offset	23 67
	sound	data/chars/yususke/yususke/EnergyWave3.wav
	frame	data/chars/yususke/rp1.png
	delay	2
	frame	data/chars/yususke/shotgun1.png
	delay	2
	frame	data/chars/yususke/shotgun2.png
	delay	2
	frame	data/chars/yususke/shotgun3.png
	delay	2
	frame	data/chars/yususke/shotgun5.png
	delay	2
	frame	data/chars/yususke/shotgun4.png
 	delay	5
	offset	19 53
	@cmd	setglobalvar "zoomvalue" 250
	frame	data/chars/yususke/sr1.png
	delay	5
	@cmd	setglobalvar "zoomentity" NULL()
	frame	data/chars/yususke/sr2.png
	attack	37 35 23 32 90 2 1 0 0 0
	dropv	3 2 0
	delay	3
	offset	20 76
	frame	data/chars/yususke/sr3.png
	attack	0 0 0 0 0 0 0 0 0 0
	delay	1
	frame	data/chars/yususke/sr3.png
	attack	43 24 25 44 10 1 1 0 0 20
	dropv	1 3 0
	delay	3
	frame	data/chars/yususke/sr4.png
	delay	1
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/yususke/sr4.png
	attack	62 24 36 64 10 1 1 0 0 30
	dropv	1 3 0
	delay	3
	offset	19 96
	frame	data/chars/yususke/sr5.png
	delay	1
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/yususke/sr5.png
	attack	112 22 41 99 10 1 1 0 0 60
	dropv	1 3 0
	delay	3
	offset	19 126
	movea	0
	frame	data/chars/yususke/sr6.png
	delay	1
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/yususke/sr6.png
	attack	126 4 29 117 0 0 1 0 0 90
	dropv	3 4 0
	delay	3
	frame	data/chars/yususke/sr7.png
	delay	3
	frame	data/chars/yususke/sr8.png
	delay	3
	frame	data/chars/yususke/sr9.png
	delay	3
	frame	data/chars/yususke/sr10.png
	delay	5
	frame	data/chars/yususke/sr11.png
 
You can use looper function that I posted above like this:

anim freespecial3
com A2 freespecial3
energycost 35
mponly 1
@cmd setglobalvar "zoomentity" getlocalvar("self")
@cmd setglobalvar "zoomvalue" 250
@cmd setglobalvar "zoomx" 0
@cmd setglobalvar "zoomy" -100
@cmd paus0001 1 100
fastattack 1
delay 20
offset 23 67
sound data/chars/yususke/yususke/EnergyWave3.wav
frame data/chars/yususke/rp1.png
delay 2
frame data/chars/yususke/shotgun1.png
delay 2
frame data/chars/yususke/shotgun2.png
delay 2
frame data/chars/yususke/shotgun3.png
delay 2
frame data/chars/yususke/shotgun5.png
delay 2
frame data/chars/yususke/shotgun4.png
delay 5
@cmd looper 1 49
offset 19 53
@cmd setglobalvar "zoomvalue" 250
frame data/chars/yususke/sr1.png
delay 5
@cmd setglobalvar "zoomentity" NULL()
frame data/chars/yususke/sr2.png
attack 37 35 23 32 90 2 1 0 0 0
dropv 3 2 0
delay 3
offset 20 76
frame data/chars/yususke/sr3.png
attack 0 0 0 0 0 0 0 0 0 0
delay 1
frame data/chars/yususke/sr3.png
attack 43 24 25 44 10 1 1 0 0 20
dropv 1 3 0
delay 3
frame data/chars/yususke/sr4.png
delay 1
attack 0 0 0 0 0 0 0 0 0 0
frame data/chars/yususke/sr4.png
attack 62 24 36 64 10 1 1 0 0 30
dropv 1 3 0
delay 3
offset 19 96
frame data/chars/yususke/sr5.png
delay 1
attack 0 0 0 0 0 0 0 0 0 0
frame data/chars/yususke/sr5.png
attack 112 22 41 99 10 1 1 0 0 60
dropv 1 3 0
delay 3
offset 19 126
movea 0
frame data/chars/yususke/sr6.png
delay 1
attack 0 0 0 0 0 0 0 0 0 0
frame data/chars/yususke/sr6.png
attack 126 4 29 117 0 0 1 0 0 90
dropv 3 4 0
delay 3
frame data/chars/yususke/sr7.png
delay 3
frame data/chars/yususke/sr8.png
delay 3
frame data/chars/yususke/sr9.png
delay 3
frame data/chars/yususke/sr10.png
delay 5
frame data/chars/yususke/sr11.png

The looper function above replays 1st to 5th frames 49 times before it lets animations to play the remaining frames.
Total time of the 5 frames are 10 centiseconds. You want 5 seconds, so those 5 frames must be replayed for 500/10 = 50 times. Since those 5 frames would have been played once before looper function is run, it's set to 49 times (50-1)

HTH
 
Back
Top Bottom