1 #include "generator.qh"
3 bool generator_precached;
7 void generator_precache()
9 if(generator_precached)
10 return; // already precached
12 precache_sound("onslaught/shockwave.wav");
13 precache_sound(W_Sound("grenade_impact"));
14 precache_sound(W_Sound("rocket_impact"));
15 precache_sound("onslaught/electricity_explode.wav");
17 generator_precached = true;
20 void ons_generator_ray_draw()
22 if(time < self.move_time)
25 self.move_time = time + 0.05;
42 void ons_generator_ray_spawn(vector org)
46 e.classname = "ons_ray";
47 setmodel(e, MDL_ONS_RAY);
49 e.angles = randomvec() * 360;
51 e.movetype = MOVETYPE_NONE;
53 e.scale = random() * 5 + 8;
54 e.move_time = time + 0.05;
55 e.drawmask = MASK_NORMAL;
56 e.draw = ons_generator_ray_draw;
61 if(time < self.move_time)
66 // damaged fx (less probable the more damaged is the generator)
67 if(random() < 0.9 - self.health / self.max_health)
70 pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
71 sound(self, CH_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);
74 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_DAMAGED), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
76 self.move_time = time + 0.1;
88 if(self.count==40||self.count==20)
90 sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTEN_NORM);
91 pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), self.origin, '0 0 0', 6);
97 ons_generator_ray_spawn(self.origin);
103 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
104 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_GIB), org, '0 0 0', 1);
107 // Short explosion sound + small explosion
110 te_explosion(self.origin);
111 sound(self, CH_TRIGGER, W_Sound("grenade_impact"), VOL_BASE, ATTEN_NORM);
115 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
116 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE), org, '0 0 0', 1);
123 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE2), org, '0 0 0', 1);
124 sound(self, CH_TRIGGER, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
127 self.move_time = time + 0.05;
132 void generator_damage(float hp)
135 setmodel(self, MDL_ONS_GEN_DEAD);
136 else if(hp < self.max_health * 0.10)
137 setmodel(self, MDL_ONS_GEN9);
138 else if(hp < self.max_health * 0.20)
139 setmodel(self, MDL_ONS_GEN8);
140 else if(hp < self.max_health * 0.30)
141 setmodel(self, MDL_ONS_GEN7);
142 else if(hp < self.max_health * 0.40)
143 setmodel(self, MDL_ONS_GEN6);
144 else if(hp < self.max_health * 0.50)
145 setmodel(self, MDL_ONS_GEN5);
146 else if(hp < self.max_health * 0.60)
147 setmodel(self, MDL_ONS_GEN4);
148 else if(hp < self.max_health * 0.70)
149 setmodel(self, MDL_ONS_GEN3);
150 else if(hp < self.max_health * 0.80)
151 setmodel(self, MDL_ONS_GEN2);
152 else if(hp < self.max_health * 0.90)
153 setmodel(self, MDL_ONS_GEN1);
154 else if(hp <= self.max_health || hp >= self.max_health)
155 setmodel(self, MDL_ONS_GEN);
157 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
160 void generator_construct()
162 self.netname = "Generator";
163 self.classname = "onslaught_generator";
165 setorigin(self, self.origin);
166 setmodel(self, MDL_ONS_GEN);
167 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
169 self.move_movetype = MOVETYPE_NOCLIP;
170 self.solid = SOLID_BBOX;
171 self.movetype = MOVETYPE_NOCLIP;
172 self.move_origin = self.origin;
173 self.move_time = time;
174 self.drawmask = MASK_NORMAL;
176 self.draw = generator_draw;
180 void generator_changeteam()
184 self.glowmod = Team_ColorRGB(self.team - 1);
185 self.teamradar_color = Team_ColorRGB(self.team - 1);
186 self.colormap = 1024 + (self.team - 1) * 17;
190 self.colormap = 1024;
191 self.glowmod = '1 1 0';
192 self.teamradar_color = '1 1 0';
202 self.origin_x = ReadCoord();
203 self.origin_y = ReadCoord();
204 self.origin_z = ReadCoord();
205 setorigin(self, self.origin);
207 self.health = ReadByte();
208 self.max_health = ReadByte();
209 self.count = ReadByte();
210 self.team = ReadByte();
215 generator_changeteam();
216 generator_precache();
217 generator_construct();
224 if(_tmp != self.team)
227 generator_changeteam();
232 if(_tmp != self.health)
233 generator_damage(_tmp);