Solved toss grenade like keyshoot?

Question that is answered or resolved.

dantedevil

Well-known member
It is possible to add to this script the key based speed control of the keyshoot?

I want use left of right to change to change the speed of the grenade , like the keymove script in the characters.


Code:
void toss(void Bomb, float dx, float dy, float dz)
{ // Tossing bomb
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");

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

   projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
}


- keyshoot {projectilename} {x} {y} {z} {Vx} {Vz}
Shooting projectile with key based speed control. Up or down key moves the projectile up or down respectively. Projectile moves forward whether up or down is pressed or not
projectilename = name of shot projectile
x = x distance relative to char
y = y distance relative to char
z = z distance relative to char
Vx = x velocity
Vz = z velocity
 
Last edited:
Solution
You can try this:

Code:
void toss(void Bomb, float dx, float dy, float dz)
{ // Tossing bomb
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void vShot;

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

   vShot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   return vShot;
}

void keytoss(void Bomb, float dx, float dy, float dz, float Vx, float Vz)
{ // Tossing bomb with key based speed control
    void self = getlocalvar("self");
    int iPIndex =...
You can try this:

Code:
void toss(void Bomb, float dx, float dy, float dz)
{ // Tossing bomb
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void vShot;

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

   vShot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   return vShot;
}

void keytoss(void Bomb, float dx, float dy, float dz, float Vx, float Vz)
{ // Tossing bomb with key based speed control
    void self = getlocalvar("self");
    int iPIndex = getentityproperty(self,"playerindex"); //Get player index
    void vShot = toss(Bomb, dx, dy, dz);

    if (playerkeys(iPIndex, 0, "moveup")){
      changeentityproperty(vShot, "velocity", Vx, -Vz);
    } else if (playerkeys(iPIndex, 0, "movedown")){
      changeentityproperty(vShot, "velocity", Vx, Vz);
    } else {
      changeentityproperty(vShot, "velocity", Vx, 0);
    }
    changeentityproperty(vShot, "speed", Vx);
}

I included toss function cause keytoss function calls the former. Also the former has simple yet important update so replace the old one if you have it
Haven't tested it yet though
 
Solution
Back
Top Bottom