Crimsondeath
Active member
Hi to everyone,
Is there a way to send a negative value from a variable with random value to the tossentity function?
The script work fine when I input the number manually:
But didn't work if I send it from the variable
:
The values I need in tossentity Z are the ones from -0.95 to 0.
Everything else is working fine.
EDIT: I miss miscategorize this post can some mod move it to Ask and Answer?
Sorry.
Is there a way to send a negative value from a variable with random value to the tossentity function?
Code:
void tosserRandom(void Bomb, float dx, float dy, float dz, int Negative)
{
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");
float Vx = rand()%9+9;
float Vy = 2;
float Vz = rand()%95+95;
void Shot;
if (Vx < 1){
Vx = 1/10;
}else{
Vx = Vx/10;
}
if (Negative == 1){
Vz = Vz/100;
Vz = -Vz; //negative value?
}else{
Vz = Vz/100;
}
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); // <----- here :(
changeentityproperty(Shot, "speed", Vx);
changeentityproperty(Shot, "owner", self);
changeentityproperty(Shot, "candamage", candamage);
}
The script work fine when I input the number manually:
Code:
...
Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
tossentity(Shot, Vy, Vx, -0.65); // the bomb fly away from the screen :D
changeentityproperty(Shot, "speed", Vx);
changeentityproperty(Shot, "owner", self);
changeentityproperty(Shot, "candamage", candamage);
...
But didn't work if I send it from the variable

Code:
...
float Vx = rand()%9+9;
float Vy = 2;
float Vz = rand()%95+95; // From here x.x
void Shot;
...
The values I need in tossentity Z are the ones from -0.95 to 0.
Everything else is working fine.
EDIT: I miss miscategorize this post can some mod move it to Ask and Answer?

Last edited: