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)
35 entity e = new(ons_ray);
36 setmodel(e, MDL_ONS_RAY);
38 e.angles = randomvec() * 360;
40 e.movetype = MOVETYPE_NONE;
42 e.scale = random() * 5 + 8;
43 e.move_time = time + 0.05;
44 e.drawmask = MASK_NORMAL;
45 e.draw = ons_generator_ray_draw;
48 void generator_draw(entity this)
50 if(time < self.move_time)
55 // damaged fx (less probable the more damaged is the generator)
56 if(random() < 0.9 - self.health / self.max_health)
59 pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
60 sound(self, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
63 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_DAMAGED), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
65 self.move_time = time + 0.1;
77 if(self.count==40||self.count==20)
79 sound(self, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
80 pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), self.origin, '0 0 0', 6);
86 ons_generator_ray_spawn(self.origin);
92 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
93 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_GIB), org, '0 0 0', 1);
96 // Short explosion sound + small explosion
99 te_explosion(self.origin);
100 sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
104 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
105 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE), org, '0 0 0', 1);
112 pointparticles(particleeffectnum(EFFECT_ONS_GENERATOR_EXPLODE2), org, '0 0 0', 1);
113 sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
116 self.move_time = time + 0.05;
121 void generator_damage(float hp)
124 setmodel(self, MDL_ONS_GEN_DEAD);
125 else if(hp < self.max_health * 0.10)
126 setmodel(self, MDL_ONS_GEN9);
127 else if(hp < self.max_health * 0.20)
128 setmodel(self, MDL_ONS_GEN8);
129 else if(hp < self.max_health * 0.30)
130 setmodel(self, MDL_ONS_GEN7);
131 else if(hp < self.max_health * 0.40)
132 setmodel(self, MDL_ONS_GEN6);
133 else if(hp < self.max_health * 0.50)
134 setmodel(self, MDL_ONS_GEN5);
135 else if(hp < self.max_health * 0.60)
136 setmodel(self, MDL_ONS_GEN4);
137 else if(hp < self.max_health * 0.70)
138 setmodel(self, MDL_ONS_GEN3);
139 else if(hp < self.max_health * 0.80)
140 setmodel(self, MDL_ONS_GEN2);
141 else if(hp < self.max_health * 0.90)
142 setmodel(self, MDL_ONS_GEN1);
143 else if(hp <= self.max_health || hp >= self.max_health)
144 setmodel(self, MDL_ONS_GEN);
146 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
149 void generator_construct()
151 self.netname = "Generator";
152 self.classname = "onslaught_generator";
154 setorigin(self, self.origin);
155 setmodel(self, MDL_ONS_GEN);
156 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
158 self.move_movetype = MOVETYPE_NOCLIP;
159 self.solid = SOLID_BBOX;
160 self.movetype = MOVETYPE_NOCLIP;
161 self.move_origin = self.origin;
162 self.move_time = time;
163 self.drawmask = MASK_NORMAL;
165 self.draw = generator_draw;
169 void generator_changeteam()
173 self.glowmod = Team_ColorRGB(self.team - 1);
174 self.teamradar_color = Team_ColorRGB(self.team - 1);
175 self.colormap = 1024 + (self.team - 1) * 17;
179 self.colormap = 1024;
180 self.glowmod = '1 1 0';
181 self.teamradar_color = '1 1 0';
191 self.origin_x = ReadCoord();
192 self.origin_y = ReadCoord();
193 self.origin_z = ReadCoord();
194 setorigin(self, self.origin);
196 self.health = ReadByte();
197 self.max_health = ReadByte();
198 self.count = ReadByte();
199 self.team = ReadByte();
204 generator_changeteam();
205 generator_construct();
212 if(_tmp != self.team)
215 generator_changeteam();
220 if(_tmp != self.health)
221 generator_damage(_tmp);