Possible to loop entire attack animation for number of times?

haxpor

New member
Hi, imagine the case I need to shoot a bullet 3 times in which I have a shoot animation thus I want to repeat it without duplicate lines over. Is there any command I can use to set it to loop for N number of times?

Thanks!

PS. I saw loop but that's for either endless loop, or just once.
 
AFAIK, you can use looper animation script. That's for looping how many times you want in an animation before ending it.

Example:

Code:
anim	follow1
@script
    void self = getlocalvar("self");

    if(frame==0){ // bbox is inactive yet
      changeentityproperty(self, "Subject_to_Gravity", 0);
      changeentityproperty(self, "Subject_to_Wall", 0);
      changeentityproperty(self, "Subject_to_MinZ", 0);
      changeentityproperty(self, "Subject_to_MaxZ", 0);
    }
    if(frame==9){ // this when enemy's bbox is active
      changeentityproperty(self, "Subject_to_Wall", 1);
      changeentityproperty(self, "Subject_to_MinZ", 1);
      changeentityproperty(self, "Subject_to_MaxZ", 1);
      changeentityproperty(self, "Subject_to_Gravity", 1);
    }
	@end_script	
	delay	9
	offset	18 73
	jumpframe	4 0 0 0.6
	frame	data/chars/Billy/1.gif
	offset	18 71
	frame	data/chars/Billy/2.gif
	offset	18 71
	frame	data/chars/Billy/3.gif
	offset	18 71
	frame	data/chars/Billy/2.gif
	@cmd	looper 0 30
	delay	8
	offset	18 72
	frame	data/chars/Billy/7.gif
	offset	18 73
	frame	data/chars/Billy/8.gif
	offset	18 73
	frame	data/chars/Billy/9.gif
	offset	18 75
	frame	data/chars/Billy/10.gif
	offset	18 76
	frame	data/chars/Billy/11.gif
	offset	17 76
	frame	data/chars/Billy/12.gif

In an 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());
    }
}

But if you're talking about shooting a number of times depending on the bullets available (as a weapon model/character), then I dunno.
 
Lovely and thank you so much for your prompt reply!
Now I noticed there's looper() function to do the work, as well as your code demonstrates that I can put a raw script right inside there via @script / @end. I'm still gradually learning. Thanks.
 
Yes you can use inline scripts, but it isn't something we advice to do, unless you have no other option. Function is the right way to go and, if I remember well, inline scripts consume more resources.
 
Just FYI, inline scripts do not automatically consume more resources, it's really the same. But by their nature you almost always have to write them in a less optimal way. For this and several other reasons it is best to declare and call functions.

DC
 
No problem.

EDIT: My real main point in showing you was not about inline scripts seen as "@script and @end_script" tag, but the use of @cmd via an animation script file for looping desired number of times. (It's from Bloodbane, not mine, but I did edit it though.)
 
Damon Caskey said:
Just FYI, inline scripts do not automatically consume more resources, it's really the same. But by their nature you almost always have to write them in a less optimal way. For this and several other reasons it is best to declare and call functions.

DC
I think I misunderstood something you said long time ago.
Thanks
 
O Ilusionista said:
Damon Caskey said:
Just FYI, inline scripts do not automatically consume more resources, it's really the same. But by their nature you almost always have to write them in a less optimal way. For this and several other reasons it is best to declare and call functions.

DC
I think I misunderstood something you said long time ago.
Thanks

I'll give a more detailed answer in another thread so not to hijack this one.
 
Back
Top Bottom