How do I figure out if the origin is comming up as 0,0,0 (or nothing and it's using the map origin instead)?
I want to make the debris launch from entity center point if no origin was set.
I need to find out the entity's center to do this, and I need to know if it doesn't have an origin.
I guess I will assume there is no origin if the origin comes up as 0 0 0 (but what is the if/then for this? if (self.orgin == '0 0 0')?
is abs min/max it?
- Code: Select all
void LaunchDebris (string debrisname) =
{
local entity dbr;
dbr = spawn();
dbr.origin = self.origin + self.absmin
+ '1 0 0' * random() * (self.absmax_x - self.absmin_x)
+ '0 1 0' * random() * (self.absmax_y - self.absmin_y)
+ '0 0 1' * random() * (self.absmax_z - self.absmin_z);
setmodel (dbr, debrisname );
dbr.movetype = MOVETYPE_BOUNCE;
dbr.solid = SOLID_NOT;
// TODO parametrize this
dbr.velocity_x = 70 * crandom();
dbr.velocity_y = 70 * crandom();
dbr.velocity_z = 140 + 70 * random();
dbr.avelocity_x = random()*600;
dbr.avelocity_y = random()*600;
dbr.avelocity_z = random()*600;
SUB_SetFade(dbr, time + 1 + random() * 5, 1);
};