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;
36 e.move_movetype = MOVETYPE_NONE;
38 e.scale = random() * 5 + 8;
39 e.move_time = time + 0.05;
40 e.drawmask = MASK_NORMAL;
41 e.draw = ons_generator_ray_draw;
44 void generator_draw(entity this)
46 if(time < this.move_time)
51 // damaged fx (less probable the more damaged is the generator)
52 if(random() < 0.9 - this.health / this.max_health)
55 pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
56 sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
59 pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
61 this.move_time = time + 0.1;
73 if(this.count==40||this.count==20)
75 sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
76 pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
82 ons_generator_ray_spawn(this.origin);
88 org = this.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
89 pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
92 // Short explosion sound + small explosion
95 te_explosion(this.origin);
96 sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
100 org = this.origin + randompos(this.mins + '8 8 8', this.maxs + '-8 -8 -8');
101 pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
108 pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
109 sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
112 this.move_time = time + 0.05;
117 void generator_damage(entity this, float hp)
120 setmodel(this, MDL_ONS_GEN_DEAD);
121 else if(hp < this.max_health * 0.10)
122 setmodel(this, MDL_ONS_GEN9);
123 else if(hp < this.max_health * 0.20)
124 setmodel(this, MDL_ONS_GEN8);
125 else if(hp < this.max_health * 0.30)
126 setmodel(this, MDL_ONS_GEN7);
127 else if(hp < this.max_health * 0.40)
128 setmodel(this, MDL_ONS_GEN6);
129 else if(hp < this.max_health * 0.50)
130 setmodel(this, MDL_ONS_GEN5);
131 else if(hp < this.max_health * 0.60)
132 setmodel(this, MDL_ONS_GEN4);
133 else if(hp < this.max_health * 0.70)
134 setmodel(this, MDL_ONS_GEN3);
135 else if(hp < this.max_health * 0.80)
136 setmodel(this, MDL_ONS_GEN2);
137 else if(hp < this.max_health * 0.90)
138 setmodel(this, MDL_ONS_GEN1);
139 else if(hp <= this.max_health || hp >= this.max_health)
140 setmodel(this, MDL_ONS_GEN);
142 setsize(this, GENERATOR_MIN, GENERATOR_MAX);
145 void generator_construct(entity this)
147 this.netname = "Generator";
148 this.classname = "onslaught_generator";
150 setorigin(this, this.origin);
151 setmodel(this, MDL_ONS_GEN);
152 setsize(this, GENERATOR_MIN, GENERATOR_MAX);
154 this.move_movetype = MOVETYPE_NOCLIP;
155 this.solid = SOLID_BBOX;
156 this.move_movetype = MOVETYPE_NOCLIP;
157 this.move_time = time;
158 this.drawmask = MASK_NORMAL;
160 this.draw = generator_draw;
164 void generator_changeteam(entity this)
168 this.glowmod = Team_ColorRGB(this.team - 1);
169 this.teamradar_color = Team_ColorRGB(this.team - 1);
170 this.colormap = 1024 + (this.team - 1) * 17;
174 this.colormap = 1024;
175 this.glowmod = '1 1 0';
176 this.teamradar_color = '1 1 0';
180 NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
187 this.origin_x = ReadCoord();
188 this.origin_y = ReadCoord();
189 this.origin_z = ReadCoord();
190 setorigin(this, this.origin);
192 this.health = ReadByte();
193 this.max_health = ReadByte();
194 this.count = ReadByte();
195 this.team = ReadByte();
200 generator_changeteam(this);
201 generator_construct(this);
208 if(_tmp != this.team)
211 generator_changeteam(this);
216 if(_tmp != this.health)
217 generator_damage(this, _tmp);