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