2 float generator_precached;
4 void generator_precache()
6 if(generator_precached)
7 return; // already precached
9 precache_model("models/onslaught/generator.md3");
10 precache_model("models/onslaught/generator_dead.md3");
11 precache_model("models/onslaught/generator_dmg1.md3");
12 precache_model("models/onslaught/generator_dmg2.md3");
13 precache_model("models/onslaught/generator_dmg3.md3");
14 precache_model("models/onslaught/generator_dmg4.md3");
15 precache_model("models/onslaught/generator_dmg5.md3");
16 precache_model("models/onslaught/generator_dmg6.md3");
17 precache_model("models/onslaught/generator_dmg7.md3");
18 precache_model("models/onslaught/generator_dmg8.md3");
19 precache_model("models/onslaught/generator_dmg9.md3");
20 precache_model("models/onslaught/generator_dead.md3");
22 generator_precached = TRUE;
25 void generator_draw() { } // TODO
28 void generator_damage(float hp)
31 setmodel(self, "models/onslaught/generator_dead.md3");
32 else if(hp < self.max_health * 0.10)
33 setmodel(self, "models/onslaught/generator_dmg9.md3");
34 else if(hp < self.max_health * 0.20)
35 setmodel(self, "models/onslaught/generator_dmg8.md3");
36 else if(hp < self.max_health * 0.30)
37 setmodel(self, "models/onslaught/generator_dmg7.md3");
38 else if(hp < self.max_health * 0.40)
39 setmodel(self, "models/onslaught/generator_dmg6.md3");
40 else if(hp < self.max_health * 0.50)
41 setmodel(self, "models/onslaught/generator_dmg5.md3");
42 else if(hp < self.max_health * 0.60)
43 setmodel(self, "models/onslaught/generator_dmg4.md3");
44 else if(hp < self.max_health * 0.70)
45 setmodel(self, "models/onslaught/generator_dmg3.md3");
46 else if(hp < self.max_health * 0.80)
47 setmodel(self, "models/onslaught/generator_dmg2.md3");
48 else if(hp < self.max_health * 0.90)
49 setmodel(self, "models/onslaught/generator_dmg1.md3");
50 else if(hp <= self.max_health || hp >= self.max_health)
51 setmodel(self, "models/onslaught/generator.md3");
53 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
56 void generator_construct()
58 self.netname = "Generator";
60 setorigin(self, self.origin);
61 setmodel(self, "models/onslaught/generator.md3");
62 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
64 self.move_movetype = MOVETYPE_NOCLIP;
65 self.solid = SOLID_BBOX;
66 self.movetype = MOVETYPE_NOCLIP;
67 self.move_origin = self.origin;
68 self.move_time = time;
69 self.drawmask = MASK_NORMAL;
71 self.draw = generator_draw;
75 void generator_changeteam()
77 self.glowmod = Team_ColorRGB(self.team - 1);
78 self.teamradar_color = Team_ColorRGB(self.team - 1);
81 self.colormap = 1024 + (self.team - 1) * 17;
91 self.origin_x = ReadCoord();
92 self.origin_y = ReadCoord();
93 self.origin_z = ReadCoord();
94 setorigin(self, self.origin);
96 self.health = ReadByte();
97 self.max_health = ReadByte();
100 generator_construct();
101 self.colormap = 1024;
102 self.glowmod = '1 1 0';
109 if(_tmp != self.team)
112 generator_changeteam();
117 if(_tmp != self.health)
118 generator_damage(_tmp);
120 //if(_tmp == 0 && self.health != 0)
129 float generator_send(entity to, float sf)
131 WriteByte(MSG_ENTITY, ENT_CLIENT_GENERATOR);
132 WriteByte(MSG_ENTITY, sf);
135 WriteCoord(MSG_ENTITY, self.origin_x);
136 WriteCoord(MSG_ENTITY, self.origin_y);
137 WriteCoord(MSG_ENTITY, self.origin_z);
139 WriteByte(MSG_ENTITY, self.health);
140 WriteByte(MSG_ENTITY, self.max_health);
145 WriteByte(MSG_ENTITY, self.team);
148 WriteByte(MSG_ENTITY, 0);
150 WriteByte(MSG_ENTITY, ceil((self.health / self.max_health) * 255));
156 void generator_link(void() spawnproc)
158 Net_LinkEntity(self, TRUE, 0, generator_send);
159 self.think = spawnproc;
160 self.nextthink = time;