help @cmd attack1

monomartin

Active member
hello friends need help
I want to add two parameters to this
keep it like this but if Player 1 detects that exists within the range change the animation
and if it detects that there are two players at a time within the range , player 1 and player 2 switch to another animation


the idea is that if a player approaches change the animation, but if there are two players in the game , wait for
the two players are in the range x z and switch to another animation

I hope I understand thanks


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
      }
    }
}
 
Bloodbane said:
You know, I think you'll need special function for this
But before that, what is exactly you are trying to make here?


hello  Bloodbane friend first of all thanks for your help and attention , I feel very grateful.
the idea is on a gate in the game, you asked me if playing two players worked and what I thought
attack1 change was to detect if there is 1 player in the game change to an animation and if 2 judaores switch to another .
always being near the door . animation change would close the door, the rest I do.
basically if there are two players on the screen door you have to wait for the two players are close ,
within the range x, z to change the animation, and do the same if there is only one player in the game .
detect if there is within the range x, z , a player or two and change the animation . so I thought I'd add that parameter to attack1
if one exists judaor x, z , change animation and if player one two there change animation
 
Hmmm... since the script is specific for two players, why don't you check both players instead?

Here's an example to check for both players:
Code:
name    	Tunggu
health	 	10
type    	enemy
hostile		none
nomove  	1
stealth		350


anim spawn
	delay	10
	offset	15 27
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

anim idle
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");
    int Play = openborvariant("count_players");
    int x = getentityproperty(self,"x");
    int y = getentityproperty(self,"a");
    int Dir = getentityproperty(self,"direction");

    if(Play==1 && (P1 || P2)){
      int Px;
      int Py;

      if(P1){
        Px = getentityproperty(P1,"x");
        Py = getentityproperty(P1,"a");
      } else if(P2){
        Px = getentityproperty(P2,"x");
        Py = getentityproperty(P2,"a");
      }

      if(Py <= y+60 && Py >= y-5){
        if(Dir==0 && Px <= x){
          killentity(self); //Suicide!
        } else if(Dir==1 && Px >= x){
          killentity(self); //Suicide!
        }
      }
    } else if(Play==2 && P1 && P2){
      int P1x = getentityproperty(P1,"x");
      int P1y = getentityproperty(P1,"a");
      int P2x = getentityproperty(P2,"x");
      int P2y = getentityproperty(P2,"a");

      if(P1y <= y+60 && P1y >= y-5 && P2y <= y+60 && P2y >= y-5){
        if(Dir==0 && P1x <= x && P2x <= x){
          killentity(self); //Suicide!
        } else if(Dir==1 && P1x >= x && P2x >= x){
          killentity(self); //Suicide!
        }
      }
    }
@end_script
	loop	1
	delay	5
	offset	15 27
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

This Tunggu entity works by preventing enemy spawns until players walk close to Tunggu. When players are close enough to Tunggu, it will remove itself
BTW tunggu means wait in Indonesia language

You can copy and modify the code to change animation instead of suicide
 
Bloodbane said:
Hmmm... since the script is specific for two players, why don't you check both players instead?

Here's an example to check for both players:
Code:
name    	Tunggu
health	 	10
type    	enemy
hostile		none
nomove  	1
stealth		350


anim spawn
	delay	10
	offset	15 27
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

anim idle
@script
    void self = getlocalvar("self");
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");
    int Play = openborvariant("count_players");
    int x = getentityproperty(self,"x");
    int y = getentityproperty(self,"a");
    int Dir = getentityproperty(self,"direction");

    if(Play==1 && (P1 || P2)){
      int Px;
      int Py;

      if(P1){
        Px = getentityproperty(P1,"x");
        Py = getentityproperty(P1,"a");
      } else if(P2){
        Px = getentityproperty(P2,"x");
        Py = getentityproperty(P2,"a");
      }

      if(Py <= y+60 && Py >= y-5){
        if(Dir==0 && Px <= x){
          killentity(self); //Suicide!
        } else if(Dir==1 && Px >= x){
          killentity(self); //Suicide!
        }
      }
    } else if(Play==2 && P1 && P2){
      int P1x = getentityproperty(P1,"x");
      int P1y = getentityproperty(P1,"a");
      int P2x = getentityproperty(P2,"x");
      int P2y = getentityproperty(P2,"a");

      if(P1y <= y+60 && P1y >= y-5 && P2y <= y+60 && P2y >= y-5){
        if(Dir==0 && P1x <= x && P2x <= x){
          killentity(self); //Suicide!
        } else if(Dir==1 && P1x >= x && P2x >= x){
          killentity(self); //Suicide!
        }
      }
    }
@end_script
	loop	1
	delay	5
	offset	15 27
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

This Tunggu entity works by preventing enemy spawns until players walk close to Tunggu. When players are close enough to Tunggu, it will remove itself
BTW tunggu means wait in Indonesia language

You can copy and modify the code to change animation instead of suicide


hello  Bloodbane friend as always thanks for your help and I tell you that already have a very special place in the credits of the game
I will test and tell you the results soon.
 
modify the script and it works perfect , the door recognizes whether there is one or two players in the game and hopes to close if the two players are in position , thank you very much for your help Bloodbane  :)

https://www.youtube.com/watch?v=F09nPGweuf8&feature=youtu.be
 
Back
Top Bottom