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