]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_electro.qc
add warmup support to clan arena
[divverent/nexuiz.git] / data / qcsrc / server / w_electro.qc
1 .float electro_count;
2 .float electro_secondarytime;
3
4 void W_Plasma_Explode_Combo (void);
5
6 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
7 {
8         local entity e;
9         e = findradius(org, rad);
10         while (e)
11         {
12                 if (e.classname == "plasma")
13                 {
14                         // see if there is line of sight to the combo ball
15                         traceline(org, e.origin, MOVE_NOMONSTERS, e);
16                         if (trace_fraction == 1 || trace_ent == e)
17                         {
18                                 // change owner to whoever caused the combo explosion
19                                 e.owner = own;
20                                 e.takedamage = DAMAGE_NO;
21                                 e.classname = "plasma_chain";
22                                 e.think = W_Plasma_Explode_Combo;
23                                 e.nextthink = time + vlen(e.origin - org) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
24                         }
25                 }
26                 e = e.chain;
27         }
28 }
29
30 void W_Plasma_Explode (void)
31 {
32         if(other.takedamage == DAMAGE_AIM)
33                 if(other.classname == "player")
34                         if(IsDifferentTeam(self.owner, other))
35                                 if(other.deadflag == DEAD_NO)
36                                         if(IsFlying(other))
37                                                 announce(self.owner, "announcer/male/electrobitch.wav");
38
39         self.event_damage = SUB_Null;
40         self.takedamage = DAMAGE_NO;
41         if (self.movetype == MOVETYPE_BOUNCE)
42         {
43                 RadiusDamage (self, self.owner, cvar("g_balance_electro_secondary_damage"), cvar("g_balance_electro_secondary_edgedamage"), cvar("g_balance_electro_secondary_radius"), world, cvar("g_balance_electro_secondary_force"), self.projectiledeathtype, other);
44         }
45         else
46         {
47                 W_Plasma_TriggerCombo(self.origin, cvar("g_balance_electro_primary_comboradius"), self.owner);
48                 RadiusDamage (self, self.owner, cvar("g_balance_electro_primary_damage"), cvar("g_balance_electro_primary_edgedamage"), cvar("g_balance_electro_primary_radius"), world, cvar("g_balance_electro_primary_force"), self.projectiledeathtype, other);
49         }
50
51         remove (self);
52 }
53
54 void W_Plasma_Explode_Combo (void)
55 {
56
57         W_Plasma_TriggerCombo(self.origin, cvar("g_balance_electro_combo_comboradius"), self.owner);
58
59         self.event_damage = SUB_Null;
60         RadiusDamage (self, self.owner, cvar("g_balance_electro_combo_damage"), cvar("g_balance_electro_combo_edgedamage"), cvar("g_balance_electro_combo_radius"), world, cvar("g_balance_electro_combo_force"), WEP_ELECTRO | HITTYPE_BOUNCE, world); // use THIS type for a combo because primary can't bounce
61         remove (self);
62 }
63
64 void W_Plasma_Touch (void)
65 {
66         PROJECTILE_TOUCH;
67         if (other.takedamage == DAMAGE_AIM) {
68                 W_Plasma_Explode ();
69         } else {
70                 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
71                 self.projectiledeathtype |= HITTYPE_BOUNCE;
72         }
73 }
74
75 void W_Plasma_TouchExplode (void)
76 {
77         PROJECTILE_TOUCH;
78         W_Plasma_Explode ();
79 }
80
81 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
82 {
83         if(self.health <= 0)
84                 return;
85         // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
86         self.health = self.health - damage;
87         if (self.health <= 0)
88         {
89                 self.takedamage = DAMAGE_NO;
90                 self.nextthink = time;
91                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
92                 {
93                         // change owner to whoever caused the combo explosion
94                         self.owner = inflictor.owner;
95                         self.classname = "plasma_chain";
96                         self.think = W_Plasma_Explode_Combo;
97                         self.nextthink = time + vlen(self.origin - inflictor.origin) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
98                 }
99                 else
100                 {
101                         self.use = W_Plasma_Explode;
102                         self.think = adaptor_think2use;
103                 }
104         }
105 }
106
107 void W_Electro_Attack()
108 {
109         local entity proj;
110
111         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", cvar("g_balance_electro_primary_damage"));
112
113         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
114
115         proj = spawn ();
116         proj.classname = "plasma_prim";
117         proj.owner = self;
118         proj.bot_dodge = TRUE;
119         proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
120         proj.use = W_Plasma_Explode;
121         proj.think = adaptor_think2use;
122         proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
123         PROJECTILE_MAKETRIGGER(proj);
124         proj.projectiledeathtype = WEP_ELECTRO;
125         setorigin(proj, w_shotorg);
126
127         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
128                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
129         proj.movetype = MOVETYPE_FLY;
130         W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
131         proj.angles = vectoangles(proj.velocity);
132         proj.touch = W_Plasma_TouchExplode;
133         setsize(proj, '0 0 -3', '0 0 -3');
134         proj.flags = FL_PROJECTILE;
135
136         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
137         //sounds bad
138
139         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
140 }
141
142 void W_Electro_Attack2()
143 {
144         local entity proj;
145
146         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire2.wav", cvar("g_balance_electro_secondary_damage"));
147         w_shotdir = v_forward; // no TrueAim for grenades please
148
149         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
150
151         proj = spawn ();
152         proj.classname = "plasma";
153         proj.owner = self;
154         proj.use = W_Plasma_Explode;
155         proj.think = adaptor_think2use;
156         proj.bot_dodge = TRUE;
157         proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
158         proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
159         PROJECTILE_MAKETRIGGER(proj);
160         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
161         setorigin(proj, w_shotorg);
162
163         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
164                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
165         //proj.glow_size = 50;
166         //proj.glow_color = 45;
167         proj.movetype = MOVETYPE_BOUNCE;
168         W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
169         proj.touch = W_Plasma_Touch;
170         setsize(proj, '0 0 -3', '0 0 -3');
171         proj.takedamage = DAMAGE_YES;
172         proj.damageforcescale = cvar("g_balance_electro_secondary_damageforcescale");
173         proj.health = cvar("g_balance_electro_secondary_health");
174         proj.event_damage = W_Plasma_Damage;
175         proj.flags = FL_PROJECTILE;
176
177 #if 0
178         entity p2;
179         p2 = spawn();
180         copyentity(proj, p2);
181         setmodel(p2, "models/ebomb.mdl");
182         setsize(p2, proj.mins, proj.maxs);
183 #endif
184
185         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
186 }
187
188 void spawnfunc_weapon_electro (void)
189 {
190         weapon_defaultspawnfunc(WEP_ELECTRO);
191 }
192
193 void w_electro_checkattack()
194 {
195         if(self.electro_count > 1)
196         if(self.BUTTON_ATCK2)
197         if(weapon_prepareattack(1, -1))
198         {
199                 W_Electro_Attack2();
200                 self.electro_count -= 1;
201                 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_electro_checkattack);
202                 return;
203         }
204
205         w_ready();
206 }
207
208 .float bot_secondary_electromooth;
209 float w_electro(float req)
210 {
211         if (req == WR_AIM)
212         {
213                 self.BUTTON_ATCK=FALSE;
214                 self.BUTTON_ATCK2=FALSE;
215                 if(vlen(self.origin-self.enemy.origin) > 1000)
216                         self.bot_secondary_electromooth = 0;
217                 if(self.bot_secondary_electromooth == 0)
218                 {
219                         if(bot_aim(cvar("g_balance_electro_primary_speed"), 0, cvar("g_balance_electro_primary_lifetime"), FALSE))
220                         {
221                                 self.BUTTON_ATCK = TRUE;
222                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
223                         }
224                 }
225                 else
226                 {
227                         if(bot_aim(cvar("g_balance_electro_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_electro_secondary_lifetime"), TRUE))
228                         {
229                                 self.BUTTON_ATCK2 = TRUE;
230                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
231                         }
232                 }
233         }
234         else if (req == WR_THINK)
235         {
236                 if (self.BUTTON_ATCK)
237                 if (weapon_prepareattack(0, cvar("g_balance_electro_primary_refire")))
238                 {
239                         W_Electro_Attack();
240                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_primary_animtime"), w_ready);
241                 }
242                 if (self.BUTTON_ATCK2)
243                 if (time >= self.electro_secondarytime)
244                 if (weapon_prepareattack(1, cvar("g_balance_electro_secondary_refire")))
245                 {
246                         W_Electro_Attack2();
247                         self.electro_count = cvar("g_balance_electro_secondary_count");
248                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_electro_checkattack);
249                         self.electro_secondarytime = time + cvar("g_balance_electro_secondary_refire2");
250                 }
251         }
252         else if (req == WR_PRECACHE)
253         {
254                 precache_model ("models/weapons/g_electro.md3");
255                 precache_model ("models/weapons/v_electro.md3");
256                 precache_model ("models/weapons/h_electro.dpm");
257                 precache_sound ("weapons/electro_bounce.wav");
258                 precache_sound ("weapons/electro_fire.wav");
259                 precache_sound ("weapons/electro_fire2.wav");
260                 precache_sound ("weapons/electro_impact.wav");
261                 precache_sound ("weapons/electro_impact_combo.wav");
262         }
263         else if (req == WR_SETUP)
264                 weapon_setup(WEP_ELECTRO);
265         else if (req == WR_CHECKAMMO1)
266                 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
267         else if (req == WR_CHECKAMMO2)
268                 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
269         else if (req == WR_SUICIDEMESSAGE)
270         {
271                 if(w_deathtype & HITTYPE_SECONDARY)
272                         w_deathtypestring = "could not remember where they put plasma";
273                 else
274                         w_deathtypestring = "played with plasma";
275         }
276         else if (req == WR_KILLMESSAGE)
277         {
278                 if(w_deathtype & HITTYPE_SECONDARY)
279                 {
280                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
281                                 w_deathtypestring = "just noticed #'s blue ball";
282                         else // unchecked: BOUNCE
283                                 w_deathtypestring = "got in touch with #'s blue ball";
284                 }
285                 else
286                 {
287                         if(w_deathtype & HITTYPE_BOUNCE) // combo
288                                 w_deathtypestring = "felt the electrifying air of #'s combo";
289                         else if(w_deathtype & HITTYPE_SPLASH)
290                                 w_deathtypestring = "got too close to #'s blue beam";
291                         else
292                                 w_deathtypestring = "was blasted by #'s blue beam";
293                 }
294         }
295         else if (req == WR_RESETPLAYER)
296         {
297                 self.electro_secondarytime = time;
298         }
299         return TRUE;
300 };