Attack1 script question

mtrain

New member
I`m trying to make a "sitting-standing" move for enemy using @cmd attack1 script.

Here is the script:

void attack1(int RxMin, int RxMax, int Rz, void Ani)
{// Attack interruption with range check
    void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");

    if(target!=NULL()){
      float Tx = getentityproperty(target, "x");
      float Tz = getentityproperty(target, "z");
      float Disx = Tx - x;
      float Disz = Tz - z;

      if(Disz < 0){
        Disz = -Disz;
      }

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1) // Target within range on right facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0) // Target within range on left facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      }
    }
}

Here is the enemy code:

anim follow10
#custom spawn 0 sitting
loop 1
offset  290  275
delay  5
        frame data/chars/Galsia/110.gif
@cmd  attack1 100 200 100 "ANI_Follow11"
        frame data/chars/Galsia/110.gif

The question is:
Can you help me modify script, that he will allow to stop at the 0 frame and if player will be in defined range animation will continue from the 1st frame? To avoid of creating additional follows? I think that this is imposible because follow10 must be updating by looping, but maybe you have any other ideas?
 
I noticed follow anim will not stay in loop forever, other logic must make them switch back to walking or idle.

I used the attack01 script but I add it to SPAWN anim, when player approaches it switches to a follow anim.  If you want to spawn them normally then use this method in level.txt

Code:
spawn   MrX
@script void main() {
   performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW10"));
} @end_script
flip    1
map     1
health  50
coords  -1480 470 71
at      1010

Where FOLLOW10 is the 'Reaction' anim, in my case a very quick one frame idle so they start chasing player when they're in range.
 
Can you help me modify script, that he will allow to stop at the 0 frame and if player will be in defined range animation will continue from the 1st frame?

it's kinda confusing but I think I understand
I have solution for this but I won't worry about number of follow animations since we can have as many as we want
 
I noticed follow anim will not stay in loop forever

i think this can be achieved with something next:

anim    follow10
#custom spawn 0 sitting
        loop  0
        offset  290  275
        delay  5
        frame  data/chars/Galsia/siting.gif
      @cmd  gotoframe 100 200 100 2
#go to 2nd frame when the range will reach
        frame  data/chars/Galsia/siting.gif
      @cmd  goto "ANI_FOLLOW10"
#loop 1st script if range not reached
        frame  data/chars/Galsia/stand.gif
        frame  data/chars/Galsia/go.gif

Now we need to get gotoframe and goto scripts.

I won't worry about number of follow animations since we can have as many as we want
Yeah, it is not a big problem anymore, but for me it will be more convenient for organize many spawns this way. Just trying out)
 
mtrain said:
I noticed follow anim will not stay in loop forever

i think this can be achieved with something next:

I should of thought of this earlier,

Code:
anim    follow10
#custom spawn 0 sitting
        loop   0
        offset  290  275
        delay  5
        @cmd   attack1 100 200 100 "ANI_FOLLOW11"
        frame   data/chars/Galsia/siting.gif
        frame   data/chars/Galsia/siting.gif
	@script
	{
   	performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW10"));
	}
	@end_script
        frame   data/chars/Galsia/stand.gif

attack1 command to make it switch when player is in range.  @script section to repeat the animation when not in range.
 
I should of thought of this earlier,

Again, this requires 2 follow anims (as i wrote earlier), and topic is about how make it within 1 animation :P
I think my algorithm in 3rd reply could work, i need a look of a "scripter" on that, can it be achieved (because i am not much strong at scripts))
 
Back
Top Bottom