1 #include "cl_generator.qh"
8 void ons_generator_ray_draw(entity this)
10 if(time < this.move_time)
13 this.move_time = time + 0.05;
30 void ons_generator_ray_spawn(vector org)
32 entity e = new(ons_ray);
33 setmodel(e, MDL_ONS_RAY);
35 e.angles = randomvec() * 360;
37 e.movetype = MOVETYPE_NONE;
39 e.scale = random() * 5 + 8;
40 e.move_time = time + 0.05;
41 e.drawmask = MASK_NORMAL;
42 e.draw = ons_generator_ray_draw;
45 void generator_draw(entity this)
47 if(time < this.move_time)
52 // damaged fx (less probable the more damaged is the generator)
53 if(random() < 0.9 - this.health / this.max_health)
56 pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
57 sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
60 pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
62 this.move_time = time + 0.1;
74 if(this.count==40||this.count==20)
76 sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
77 pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
83 ons_generator_ray_spawn(this.origin);
89 org = this.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
90 pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
93 // Short explosion sound + small explosion
96 te_explosion(this.origin);
97 sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
101 org = this.origin + randompos(this.mins + '8 8 8', this.maxs + '-8 -8 -8');
102 pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
109 pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
110 sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
113 this.move_time = time + 0.05;
118 void generator_damage(entity this, float hp)
121 setmodel(this, MDL_ONS_GEN_DEAD);
122 else if(hp < this.max_health * 0.10)
123 setmodel(this, MDL_ONS_GEN9);
124 else if(hp < this.max_health * 0.20)
125 setmodel(this, MDL_ONS_GEN8);
126 else if(hp < this.max_health * 0.30)
127 setmodel(this, MDL_ONS_GEN7);
128 else if(hp < this.max_health * 0.40)
129 setmodel(this, MDL_ONS_GEN6);
130 else if(hp < this.max_health * 0.50)
131 setmodel(this, MDL_ONS_GEN5);
132 else if(hp < this.max_health * 0.60)
133 setmodel(this, MDL_ONS_GEN4);
134 else if(hp < this.max_health * 0.70)
135 setmodel(this, MDL_ONS_GEN3);
136 else if(hp < this.max_health * 0.80)
137 setmodel(this, MDL_ONS_GEN2);
138 else if(hp < this.max_health * 0.90)
139 setmodel(this, MDL_ONS_GEN1);
140 else if(hp <= this.max_health || hp >= this.max_health)
141 setmodel(this, MDL_ONS_GEN);
143 setsize(this, GENERATOR_MIN, GENERATOR_MAX);
146 void generator_construct(entity this)
148 this.netname = "Generator";
149 this.classname = "onslaught_generator";
151 setorigin(this, this.origin);
152 setmodel(this, MDL_ONS_GEN);
153 setsize(this, GENERATOR_MIN, GENERATOR_MAX);
155 this.move_movetype = MOVETYPE_NOCLIP;
156 this.solid = SOLID_BBOX;
157 this.movetype = MOVETYPE_NOCLIP;
158 this.move_origin = this.origin;
159 this.move_time = time;
160 this.drawmask = MASK_NORMAL;
162 this.draw = generator_draw;
166 void generator_changeteam(entity this)
170 this.glowmod = Team_ColorRGB(this.team - 1);
171 this.teamradar_color = Team_ColorRGB(this.team - 1);
172 this.colormap = 1024 + (this.team - 1) * 17;
176 this.colormap = 1024;
177 this.glowmod = '1 1 0';
178 this.teamradar_color = '1 1 0';
182 NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
189 this.origin_x = ReadCoord();
190 this.origin_y = ReadCoord();
191 this.origin_z = ReadCoord();
192 setorigin(this, this.origin);
194 this.health = ReadByte();
195 this.max_health = ReadByte();
196 this.count = ReadByte();
197 this.team = ReadByte();
202 generator_changeteam(this);
203 generator_construct(this);
210 if(_tmp != this.team)
213 generator_changeteam(this);
218 if(_tmp != this.health)
219 generator_damage(this, _tmp);