]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_electro.qc
more death types (now weapons know whether the hit was primary or secondary, whether...
[divverent/nexuiz.git] / data / qcsrc / server / w_electro.qc
1
2 void W_Plasma_Explode (void)
3 {
4         vector org2;
5         org2 = findbetterlocation (self.origin, 8);
6
7         self.event_damage = SUB_Null;
8         if (self.movetype == MOVETYPE_BOUNCE)
9         {
10                 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
11                 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);
12         }
13         else
14         {
15                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
16                 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);
17         }
18         sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
19
20         remove (self);
21 }
22
23 void W_Plasma_Explode_Combo (void) {
24         vector org2;
25
26         org2 = findbetterlocation (self.origin, 8);
27         pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
28
29         sound (self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
30
31         self.event_damage = SUB_Null;
32         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, other); // use THIS type for a combo because primary can't bounce
33         remove (self);
34 }
35
36 void W_Plasma_Touch (void)
37 {
38         entity o;
39         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
40         {
41                 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
42                 remove(self);
43                 return;
44         }
45         if (other.takedamage == DAMAGE_AIM) {
46                 o = self.owner;
47                 W_Plasma_Explode ();
48                 if(other.classname == "player")
49                         if(IsDifferentTeam(o, other))
50                                 if(IsFlying(other))
51                                         announce(o, "announcer/male/electrobitch.ogg");
52         } else {
53                 sound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
54                 self.projectiledeathtype |= HITTYPE_BOUNCE;
55         }
56 }
57
58 void W_Plasma_TouchExplode (void)
59 {
60         entity o;
61         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
62         {
63                 sound (self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
64                 remove(self);
65                 return;
66         }
67         o = self.owner;
68         W_Plasma_Explode ();
69         if(other.takedamage == DAMAGE_AIM)
70                 if(other.classname == "player")
71                         if(IsDifferentTeam(o, other))
72                                 if(IsFlying(other))
73                                         announce(o, "announcer/male/electrobitch.ogg");
74 }
75
76 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
77 {
78         self.health = self.health - damage;
79         if (self.health <= 0)
80         {
81                 self.takedamage = DAMAGE_NO;
82                 self.nextthink = time;
83                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
84                 {
85                         // change owner to whoever caused the combo explosion
86                         self.owner = inflictor.owner;
87                         self.classname = "plasma_chain";
88                         self.think = W_Plasma_Explode_Combo;
89                 }
90                 else
91                         self.think = W_Plasma_Explode;
92         }
93 }
94
95 void W_Electro_Attack()
96 {
97         local entity proj;
98
99         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/electro_fire.wav");
100
101         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
102
103         proj = spawn ();
104         proj.classname = "plasma_prim";
105         proj.owner = self;
106         proj.bot_dodge = TRUE;
107         proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
108         proj.use = W_Plasma_Explode;
109         proj.think = adaptor_think2use;
110         proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
111         proj.solid = SOLID_BBOX;
112         proj.projectiledeathtype = WEP_ELECTRO;
113         setorigin(proj, w_shotorg);
114
115         if not(self.items & IT_UNLIMITED_AMMO)
116                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
117         proj.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
118         proj.movetype = MOVETYPE_FLY;
119         proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
120         W_SetupProjectileVelocity(proj);
121         proj.angles = vectoangles(proj.velocity);
122         proj.touch = W_Plasma_TouchExplode;
123         proj.flags = FL_PROJECTILE;
124         setmodel(proj, "models/elaser.mdl"); // precision set above
125         setsize(proj, '0 0 0', '0 0 0');
126
127         // LordHavoc: disabled because no one likes this sound and it sometimes never stops due to packet loss
128         //sound (proj, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
129 }
130
131 void W_Electro_Attack2()
132 {
133         local entity proj;
134
135         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/electro_fire2.wav");
136
137         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
138
139         proj = spawn ();
140         proj.classname = "plasma";
141         proj.owner = self;
142         proj.use = W_Plasma_Explode;
143         proj.think = adaptor_think2use;
144         proj.bot_dodge = TRUE;
145         proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
146         proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
147         proj.solid = SOLID_BBOX;
148         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
149         setorigin(proj, w_shotorg);
150
151         if not(self.items & IT_UNLIMITED_AMMO)
152                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
153         proj.effects = EF_LOWPRECISION;
154         //proj.glow_size = 50;
155         //proj.glow_color = 45;
156         proj.movetype = MOVETYPE_BOUNCE;
157         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");
158         W_SetupProjectileVelocity(proj);
159         proj.touch = W_Plasma_Touch;
160         setmodel(proj, "models/ebomb.mdl"); // precision set above
161         setsize(proj, '0 0 -3', '0 0 -3');
162         proj.takedamage = DAMAGE_YES;
163         proj.damageforcescale = 4;
164         proj.health = cvar("g_balance_electro_secondary_health");
165         proj.event_damage = W_Plasma_Damage;
166         proj.flags = FL_PROJECTILE;
167
168         // LordHavoc: disabled because no one likes this sound and it sometimes never stops due to packet loss
169         //sound (proj, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
170 }
171
172 void spawnfunc_weapon_electro (void)
173 {
174         weapon_defaultspawnfunc(WEP_ELECTRO);
175 }
176
177 .float bot_secondary_electromooth;
178 float w_electro(float req)
179 {
180         if (req == WR_AIM)
181         {
182                 self.BUTTON_ATCK=FALSE;
183                 self.BUTTON_ATCK2=FALSE;
184                 if(vlen(self.origin-self.enemy.origin) > 1000)
185                         self.bot_secondary_electromooth = 0;
186                 if(self.bot_secondary_electromooth == 0)
187                 {
188                         if(bot_aim(cvar("g_balance_electro_primary_speed"), 0, cvar("g_balance_electro_primary_lifetime"), FALSE))
189                         {
190                                 self.BUTTON_ATCK = TRUE;
191                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
192                         }
193                 }
194                 else
195                 {
196                         if(bot_aim(cvar("g_balance_electro_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_electro_secondary_lifetime"), TRUE))
197                         {
198                                 self.BUTTON_ATCK2 = TRUE;
199                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
200                         }
201                 }
202         }
203         else if (req == WR_THINK)
204         {
205                 if (self.BUTTON_ATCK)
206                 if (weapon_prepareattack(0, cvar("g_balance_electro_primary_refire")))
207                 {
208                         W_Electro_Attack();
209                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_primary_animtime"), w_ready);
210                 }
211                 if (self.BUTTON_ATCK2)
212                 if (weapon_prepareattack(1, cvar("g_balance_electro_secondary_refire")))
213                 {
214                         W_Electro_Attack2();
215                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_secondary_animtime"), w_ready);
216                 }
217         }
218         else if (req == WR_PRECACHE)
219         {
220                 precache_model ("models/ebomb.mdl");
221                 precache_model ("models/elaser.mdl");
222                 precache_model ("models/weapons/g_electro.md3");
223                 precache_model ("models/weapons/v_electro.md3");
224                 precache_model ("models/weapons/w_electro.zym");
225                 precache_sound ("weapons/electro_bounce.wav");
226                 precache_sound ("weapons/electro_fire.wav");
227                 precache_sound ("weapons/electro_fire2.wav");
228                 precache_sound ("weapons/electro_fly.wav");
229                 precache_sound ("weapons/electro_impact.wav");
230                 precache_sound ("weapons/electro_impact_combo.wav");
231         }
232         else if (req == WR_SETUP)
233                 weapon_setup(WEP_ELECTRO);
234         else if (req == WR_CHECKAMMO1)
235                 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
236         else if (req == WR_CHECKAMMO2)
237                 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
238         else if (req == WR_SUICIDEMESSAGE)
239         {
240                 if(w_deathtype & HITTYPE_SECONDARY)
241                         w_deathtypestring = "could not remember where he put plasma";
242                 else
243                         w_deathtypestring = "played with plasma";
244         }
245         else if (req == WR_KILLMESSAGE)
246         {
247                 if(w_deathtype & HITTYPE_SECONDARY)
248                 {
249                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
250                                 w_deathtypestring = "just noticed #'s blue ball";
251                         else // unchecked: BOUNCE
252                                 w_deathtypestring = "got in touch with #'s blue ball";
253                 }
254                 else
255                 {
256                         if(w_deathtype & HITTYPE_BOUNCE) // combo
257                                 w_deathtypestring = "felt the electrifying air of #'s combo";
258                         else if(w_deathtype & HITTYPE_SPLASH)
259                                 w_deathtypestring = "got too close to #'s blue beam";
260                         else
261                                 w_deathtypestring = "was blasted by #'s blue beam";
262                 }
263         }
264         return TRUE;
265 };