• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Solved Get "falling death" direction from an Obstacle?

Question that is answered or resolved.

Crimsondeath

Active member
Hi again,
When I kill an obstacle their "parts" are throw away in the same direction he is facing (I'm using the tosser & tosserAnim script):
C++:
void tosser(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Tossing bomb with desired speed
   void self = getlocalvar("self");
   void candamage  = getentityproperty(self, "candamage");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void Shot;

   if (Direction == 0){ //Is entity facing left?               
      dx = -dx; //Reverse X direction to match facing
   }

   Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   tossentity(Shot, Vy, Vx, Vz);
   changeentityproperty(Shot, "speed", Vx);
   changeentityproperty(Shot, "owner", self);
   changeentityproperty(Shot, "candamage", candamage);
}

void tosserAnim(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz, char next_anim)
{ // Tossing special bomb with speed control and same remap
   void self = getlocalvar("self");
   void candamage  = getentityproperty(self, "candamage");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void Shot;

   if (Direction == 0){ //Is entity facing left?
      dx = -dx; //Reverse X direction to match facing
   }
 
   Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   tossentity(Shot, Vy, Vx, Vz);
   changeentityproperty(Shot, "animation", openborconstant(next_anim));
   changeentityproperty(Shot, "speed", Vx);
   changeentityproperty(Shot, "owner", self);
   changeentityproperty(Shot, "candamage", candamage);
}

I think the issue is when the obstacle dies (and fall) he always face the same direction while falling, no matters if the hit comes from left or right:
sCiBXxm.gif

It's suppose that tires spawned by "tosserAnim" and "tosser" must fall in the opposite direction from the obstacle impact.

The Tires falling code:
Code:
anim    fall
    loop    0
    delay    1
    offset    22 51
    fshadow    3
    @cmd    tosser "Debris_burning_tires" 0 9 0 0.44 2.5 0
    @cmd    tosserAnim "Debris_burning_tires" 0 20 0 0.48 3 0 "ANI_FOLLOW1"
    @cmd    tosserAnim "Debris_burning_tires" 0 29 0 0.52 3.5 0 "ANI_FOLLOW2"
    @cmd    tosserAnim "Debris_burning_tires" 0 38 0 0.56 4 0 "ANI_FOLLOW3"
    @cmd    spawn01 "Debris_burning_tires_flame" -8 52 1
    @cmd    spawn01 "Debris_burning_tires_flame" 9 48 1
    @cmd    spawn01 "Debris_burning_tires_flame" 10 60 0
    frame    data/chars/obstacles/tires/fall.gif
    frame    data/chars/obstacles/tires/fall.gif
    frame    data/chars/obstacles/tires/fall.gif

It's possible to get the obstacle falling direction (or change the obstacle direction to face the player just at falling)?

Thanks :D .
 
Last edited:
Did you check this one yet?

 
Hi again,
When I kill an obstacle their "parts" are throw away in the same direction he is facing (I'm using the tosser & tosserAnim script):
C++:
void tosser(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Tossing bomb with desired speed
   void self = getlocalvar("self");
   void candamage  = getentityproperty(self, "candamage");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void Shot;

   if (Direction == 0){ //Is entity facing left?              
      dx = -dx; //Reverse X direction to match facing
   }

   Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   tossentity(Shot, Vy, Vx, Vz);
   changeentityproperty(Shot, "speed", Vx);
   changeentityproperty(Shot, "owner", self);
   changeentityproperty(Shot, "candamage", candamage);
}

void tosserAnim(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz, char next_anim)
{ // Tossing special bomb with speed control and same remap
   void self = getlocalvar("self");
   void candamage  = getentityproperty(self, "candamage");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void Shot;

   if (Direction == 0){ //Is entity facing left?
      dx = -dx; //Reverse X direction to match facing
   }
 
   Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   tossentity(Shot, Vy, Vx, Vz);
   changeentityproperty(Shot, "animation", openborconstant(next_anim));
   changeentityproperty(Shot, "speed", Vx);
   changeentityproperty(Shot, "owner", self);
   changeentityproperty(Shot, "candamage", candamage);
}

I think the issue is when the obstacle dies (and fall) he always face the same direction while falling, no matters if the hit comes from left or right:
sCiBXxm.gif

It's suppose that tires spawned by "tosserAnim" and "tosser" must fall in the opposite direction from the obstacle impact.

The Tires falling code:
Code:
anim    fall
    loop    0
    delay    1
    offset    22 51
    fshadow    3
    @cmd    tosser "Debris_burning_tires" 0 9 0 0.44 2.5 0
    @cmd    tosserAnim "Debris_burning_tires" 0 20 0 0.48 3 0 "ANI_FOLLOW1"
    @cmd    tosserAnim "Debris_burning_tires" 0 29 0 0.52 3.5 0 "ANI_FOLLOW2"
    @cmd    tosserAnim "Debris_burning_tires" 0 38 0 0.56 4 0 "ANI_FOLLOW3"
    @cmd    spawn01 "Debris_burning_tires_flame" -8 52 1
    @cmd    spawn01 "Debris_burning_tires_flame" 9 48 1
    @cmd    spawn01 "Debris_burning_tires_flame" 10 60 0
    frame    data/chars/obstacles/tires/fall.gif
    frame    data/chars/obstacles/tires/fall.gif
    frame    data/chars/obstacles/tires/fall.gif

It's possible to get the obstacle falling direction (or change the obstacle direction to face the player just at falling)?

Thanks :D .
Commonly I flip obstacles in the takedamage event but in certain situations I use this dirFlip script, which works based on the current velocity direction in X axis:

Code:
void dirFlip()
{//FLIP ENTITY BASED ON THE "XDIR" VALUE
    void self    = getlocalvar("self");
    int xDir    = getentityproperty(self,"xdir");
    int dir        = 1;

    if(xDir > 0){dir = 0;}
    changeentityproperty(self, "direction", dir);
}

This way you will first change the main obstacle entity direction according to his flying direction and then the debris will follow the same.
Code:
anim    fall
    loop    0
    delay    1
    offset    22 51
    fshadow    3
    @cmd    dirFlip
    @cmd    tosser "Debris_burning_tires" 0 9 0 0.44 2.5 0
    @cmd    tosserAnim "Debris_burning_tires" 0 20 0 0.48 3 0 "ANI_FOLLOW1"
    @cmd    tosserAnim "Debris_burning_tires" 0 29 0 0.52 3.5 0 "ANI_FOLLOW2"
    @cmd    tosserAnim "Debris_burning_tires" 0 38 0 0.56 4 0 "ANI_FOLLOW3"
    @cmd    spawn01 "Debris_burning_tires_flame" -8 52 1
    @cmd    spawn01 "Debris_burning_tires_flame" 9 48 1
    @cmd    spawn01 "Debris_burning_tires_flame" 10 60 0
    frame    data/chars/obstacles/tires/fall.gif
    frame    data/chars/obstacles/tires/fall.gif
    frame    data/chars/obstacles/tires/fall.gif
 
Back
Top Bottom