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