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