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