self.health = _tmp;
}
}
+
+void td_generator_precache()
+{
+ precache_model("models/onslaught/generator.md3");
+ precache_model("models/onslaught/generator_dead.md3");
+ precache_sound("onslaught/generator_underattack.wav");
+}
+
+void td_generator_die()
+{
+ setmodel(self, "models/onslaught/generator_dead.md3");
+ pointparticles(particleeffectnum("explosion_medium"), self.origin, '0 0 0', 1);
+}
+
+void td_generator_draw() { } // TODO
+
+void td_generator_construct()
+{
+ self.netname = "Generator";
+
+ setorigin(self, self.origin);
+ setmodel(self, "models/onslaught/generator.md3");
+ setsize(self, GENERATOR_MIN, GENERATOR_MAX);
+
+ self.move_movetype = MOVETYPE_NOCLIP;
+ self.health = 255;
+ self.solid = SOLID_BBOX;
+ self.movetype = MOVETYPE_NOCLIP;
+ self.move_origin = self.origin;
+ self.move_time = time;
+ self.drawmask = MASK_NORMAL;
+ self.alpha = 1;
+ self.draw = td_generator_draw;
+}
+
+void ent_td_generator()
+{
+ float sf;
+ sf = ReadByte();
+
+ if(sf & MSF_SETUP)
+ {
+ self.origin_x = ReadCoord();
+ self.origin_y = ReadCoord();
+ self.origin_z = ReadCoord();
+ setorigin(self, self.origin);
+
+ td_generator_precache();
+ td_generator_construct();
+ self.colormap = 1024;
+ self.glowmod = '1 1 0';
+ }
+
+ if(sf & MSF_STATUS)
+ {
+ float _tmp = ReadByte();
+
+ if(_tmp == 0 && self.health != 0)
+ td_generator_die();
+
+ self.health = _tmp;
+ }
+}
+
Send_Notification(NOTIF_ALL, world, MSG_MULTI, MULTI_TD_GENDESTROYED);
- setmodel(self, "models/onslaught/generator_dead.md3");
self.solid = SOLID_NOT;
self.takedamage = DAMAGE_NO;
self.event_damage = func_null;
self.enemy = world;
td_gencount -= 1;
-
- pointparticles(particleeffectnum("explosion_medium"), self.origin, '0 0 0', 1);
WaypointSprite_Kill(self.sprite);
}
if(self.health <= 0)
td_generator_die();
+
+ self.SendFlags |= MSF_STATUS;
}
-void spawnfunc_td_generator()
+float td_generator_send(entity to, float sf)
{
- if not(g_td) { remove(self); return; }
-
- gendestroyed = FALSE;
-
- if not(self.health)
- self.health = autocvar_g_td_generator_health;
+ WriteByte(MSG_ENTITY, ENT_CLIENT_GENERATOR);
+ WriteByte(MSG_ENTITY, sf);
+ if(sf & MSF_SETUP)
+ {
+ WriteCoord(MSG_ENTITY, self.origin_x);
+ WriteCoord(MSG_ENTITY, self.origin_y);
+ WriteCoord(MSG_ENTITY, self.origin_z);
+ }
+
+ if(sf & MSF_STATUS)
+ {
+ if(self.health <= 0)
+ WriteByte(MSG_ENTITY, 0);
+ else
+ WriteByte(MSG_ENTITY, ceil((self.health / self.max_health) * 255));
+ }
+
+ return TRUE;
+}
- // precache generator model
- precache_model("models/onslaught/generator.md3");
- precache_model("models/onslaught/generator_dead.md3");
+void td_generator_think()
+{
+ self.think = td_generator_think;
+ self.nextthink = time + 0.5;
+}
+
+void td_generator_setup()
+{
+
+ self.think = td_generator_think;
+ self.nextthink = time + 0.1;
- self.model = "models/onslaught/generator.md3";
- setmodel(self, self.model);
- self.classname = "td_generator";
self.solid = SOLID_BBOX;
self.takedamage = DAMAGE_AIM;
self.event_damage = td_generator_damage;
self.enemy = world;
- self.nextthink = -1;
- self.think = func_null;
self.max_health = self.health;
self.movetype = MOVETYPE_NONE;
self.monster_attack = TRUE;
- td_gencount += 1;
self.netname = "Generator";
- setsize(self, GENERATOR_MIN, GENERATOR_MAX);
-
- droptofloor();
+ self.SendFlags |= MSF_SETUP;
WaypointSprite_SpawnFixed(self.netname, self.origin + '0 0 60', self, sprite, RADARICON_OBJECTIVE, '1 0.5 0');
WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
WaypointSprite_UpdateHealth(self.sprite, self.health);
}
+void td_generator_link()
+{
+ Net_LinkEntity(self, TRUE, 0, td_generator_send);
+ self.think = td_generator_setup;
+ self.nextthink = time;
+}
+
+void spawnfunc_td_generator()
+{
+ if not(g_td) { remove(self); return; }
+
+ gendestroyed = FALSE;
+
+ if not(self.health)
+ self.health = autocvar_g_td_generator_health;
+
+ self.classname = "td_generator";
+ td_gencount += 1;
+
+ setsize(self, GENERATOR_MIN, GENERATOR_MAX);
+
+ droptofloor();
+
+ td_generator_link();
+}
+
entity PickGenerator()
{
entity generator, head;