1 #include "generator.qh"
3 #include "teamradar.qh"
4 #include "../common/movetypes/movetypes.qh"
11 void ons_generator_ray_draw(entity this)
13 if(time < self.move_time)
16 self.move_time = time + 0.05;
33 void ons_generator_ray_spawn(vector org)
37 e.classname = "ons_ray";
38 setmodel(e, MDL_ONS_RAY);
40 e.angles = randomvec() * 360;
42 e.movetype = MOVETYPE_NONE;
44 e.scale = random() * 5 + 8;
45 e.move_time = time + 0.05;
46 e.drawmask = MASK_NORMAL;
47 e.draw = ons_generator_ray_draw;
50 void generator_draw(entity this)
52 if(time < self.move_time)
57 // damaged fx (less probable the more damaged is the generator)
58 if(random() < 0.9 - self.health / self.max_health)
61 pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
62 sound(self, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
65 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_DAMAGED), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
67 self.move_time = time + 0.1;
79 if(self.count==40||self.count==20)
81 sound(self, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
82 pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), self.origin, '0 0 0', 6);
88 ons_generator_ray_spawn(self.origin);
94 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
95 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_GIB), org, '0 0 0', 1);
98 // Short explosion sound + small explosion
101 te_explosion(self.origin);
102 sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
106 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
107 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE), org, '0 0 0', 1);
114 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE2), org, '0 0 0', 1);
115 sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
118 self.move_time = time + 0.05;
123 void generator_damage(float hp)
126 setmodel(self, MDL_ONS_GEN_DEAD);
127 else if(hp < self.max_health * 0.10)
128 setmodel(self, MDL_ONS_GEN9);
129 else if(hp < self.max_health * 0.20)
130 setmodel(self, MDL_ONS_GEN8);
131 else if(hp < self.max_health * 0.30)
132 setmodel(self, MDL_ONS_GEN7);
133 else if(hp < self.max_health * 0.40)
134 setmodel(self, MDL_ONS_GEN6);
135 else if(hp < self.max_health * 0.50)
136 setmodel(self, MDL_ONS_GEN5);
137 else if(hp < self.max_health * 0.60)
138 setmodel(self, MDL_ONS_GEN4);
139 else if(hp < self.max_health * 0.70)
140 setmodel(self, MDL_ONS_GEN3);
141 else if(hp < self.max_health * 0.80)
142 setmodel(self, MDL_ONS_GEN2);
143 else if(hp < self.max_health * 0.90)
144 setmodel(self, MDL_ONS_GEN1);
145 else if(hp <= self.max_health || hp >= self.max_health)
146 setmodel(self, MDL_ONS_GEN);
148 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
151 void generator_construct()
153 self.netname = "Generator";
154 self.classname = "onslaught_generator";
156 setorigin(self, self.origin);
157 setmodel(self, MDL_ONS_GEN);
158 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
160 self.move_movetype = MOVETYPE_NOCLIP;
161 self.solid = SOLID_BBOX;
162 self.movetype = MOVETYPE_NOCLIP;
163 self.move_origin = self.origin;
164 self.move_time = time;
165 self.drawmask = MASK_NORMAL;
167 self.draw = generator_draw;
171 void generator_changeteam()
175 self.glowmod = Team_ColorRGB(self.team - 1);
176 self.teamradar_color = Team_ColorRGB(self.team - 1);
177 self.colormap = 1024 + (self.team - 1) * 17;
181 self.colormap = 1024;
182 self.glowmod = '1 1 0';
183 self.teamradar_color = '1 1 0';
193 self.origin_x = ReadCoord();
194 self.origin_y = ReadCoord();
195 self.origin_z = ReadCoord();
196 setorigin(self, self.origin);
198 self.health = ReadByte();
199 self.max_health = ReadByte();
200 self.count = ReadByte();
201 self.team = ReadByte();
206 generator_changeteam();
207 generator_construct();
214 if(_tmp != self.team)
217 generator_changeteam();
222 if(_tmp != self.health)
223 generator_damage(_tmp);