if(this.count > 10)
{
- remove(this);
+ IL_REMOVE(g_drawables, this);
+ delete(this);
return;
}
setmodel(e, MDL_ONS_RAY);
setorigin(e, org);
e.angles = randomvec() * 360;
- e.move_movetype = MOVETYPE_NONE;
+ set_movetype(e, MOVETYPE_NONE);
e.alpha = 0;
e.scale = random() * 5 + 8;
e.move_time = time + 0.05;
e.drawmask = MASK_NORMAL;
e.draw = ons_generator_ray_draw;
+ IL_PUSH(g_drawables, e);
}
void generator_draw(entity this)
if(time < this.move_time)
return;
- if(this.health > 0)
+ if(GetResource(this, RES_HEALTH) > 0)
{
// damaged fx (less probable the more damaged is the generator)
- if(random() < 0.9 - this.health / this.max_health)
+ if(random() < 0.9 - GetResource(this, RES_HEALTH) / this.max_health)
if(random() < 0.01)
{
pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
setsize(this, GENERATOR_MIN, GENERATOR_MAX);
}
-void generator_construct(entity this)
+void generator_construct(entity this, bool isnew)
{
this.netname = "Generator";
this.classname = "onslaught_generator";
+ if(isnew)
+ {
+ IL_PUSH(g_onsgenerators, this);
+ IL_PUSH(g_drawables, this);
+ }
+
setorigin(this, this.origin);
setmodel(this, MDL_ONS_GEN);
setsize(this, GENERATOR_MIN, GENERATOR_MAX);
- this.move_movetype = MOVETYPE_NOCLIP;
+ set_movetype(this, MOVETYPE_NOCLIP);
this.solid = SOLID_BBOX;
- this.move_movetype = MOVETYPE_NOCLIP;
+ set_movetype(this, MOVETYPE_NOCLIP);
this.move_time = time;
this.drawmask = MASK_NORMAL;
this.alpha = 1;
if(sf & GSF_SETUP)
{
- this.origin_x = ReadCoord();
- this.origin_y = ReadCoord();
- this.origin_z = ReadCoord();
+ this.origin = ReadVector();
setorigin(this, this.origin);
- this.health = ReadByte();
+ SetResource(this, RES_HEALTH, ReadByte());
this.max_health = ReadByte();
this.count = ReadByte();
this.team = ReadByte();
this.count = 40;
generator_changeteam(this);
- generator_construct(this);
+ generator_construct(this, isnew);
}
if(sf & GSF_STATUS)
_tmp = ReadByte();
- if(_tmp != this.health)
+ if(_tmp != GetResource(this, RES_HEALTH))
generator_damage(this, _tmp);
- this.health = _tmp;
+ SetResource(this, RES_HEALTH, _tmp);
}
}