]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_electro.qc
handle RL, Seeker and Electro projectiles completely on the client, to prevent the...
[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                 stopsound (self, CHAN_PAIN);
19         }
20         else
21         {
22                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
23                 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);
24                 //stopsound (self, CHAN_PAIN);
25         }
26
27         sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
28
29         remove (self);
30 }
31
32 void W_Plasma_Explode_Combo (void) {
33         vector org2;
34
35         org2 = findbetterlocation (self.origin, 8);
36         pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
37
38         stopsound (self, CHAN_PAIN);
39         sound (self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
40
41         self.event_damage = SUB_Null;
42         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
43         remove (self);
44 }
45
46 void W_Plasma_Touch (void)
47 {
48         UpdateCSQCProjectile(self);
49
50         PROJECTILE_TOUCH_NOSOUND;
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         PROJECTILE_TOUCH;
62         W_Plasma_Explode ();
63 }
64
65 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
66 {
67         if(self.health <= 0)
68                 return;
69         self.health = self.health - damage;
70         if (self.health <= 0)
71         {
72                 self.takedamage = DAMAGE_NO;
73                 self.nextthink = time;
74                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
75                 {
76                         // change owner to whoever caused the combo explosion
77                         self.owner = inflictor.owner;
78                         self.classname = "plasma_chain";
79                         self.think = W_Plasma_Explode_Combo;
80                         self.nextthink = time + vlen(self.origin - inflictor.origin) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
81                 }
82                 else
83                         self.think = W_Plasma_Explode;
84         }
85 }
86
87 void W_Electro_Attack()
88 {
89         local entity proj;
90
91         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/electro_fire.wav");
92
93         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
94
95         proj = spawn ();
96         proj.classname = "plasma_prim";
97         proj.owner = self;
98         proj.bot_dodge = TRUE;
99         proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
100         proj.use = W_Plasma_Explode;
101         proj.think = adaptor_think2use;
102         proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
103         proj.solid = SOLID_BBOX;
104         proj.projectiledeathtype = WEP_ELECTRO;
105         setorigin(proj, w_shotorg);
106
107         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
108                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
109         proj.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
110         proj.movetype = MOVETYPE_FLY;
111         proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
112         W_SetupProjectileVelocity(proj);
113         proj.angles = vectoangles(proj.velocity);
114         proj.touch = W_Plasma_TouchExplode;
115         proj.flags = FL_PROJECTILE;
116         setmodel(proj, "models/elaser.mdl"); // precision set above
117         setsize(proj, '0 0 0', '0 0 0');
118
119         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
120         //sounds bad
121 }
122
123 void W_Electro_Attack2()
124 {
125         local entity proj;
126
127         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/electro_fire2.wav");
128
129         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
130
131         proj = spawn ();
132         proj.classname = "plasma";
133         proj.owner = self;
134         proj.use = W_Plasma_Explode;
135         proj.think = adaptor_think2use;
136         proj.bot_dodge = TRUE;
137         proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
138         proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
139         proj.solid = SOLID_BBOX;
140         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
141         setorigin(proj, w_shotorg);
142
143         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
144                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
145         proj.effects = EF_LOWPRECISION;
146         //proj.glow_size = 50;
147         //proj.glow_color = 45;
148         proj.movetype = MOVETYPE_BOUNCE;
149         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");
150         W_SetupProjectileVelocity(proj);
151         proj.touch = W_Plasma_Touch;
152         setmodel(proj, "models/ebomb.mdl"); // precision set above
153         setsize(proj, '0 0 -3', '0 0 -3');
154         proj.takedamage = DAMAGE_YES;
155         proj.damageforcescale = 4;
156         proj.health = cvar("g_balance_electro_secondary_health");
157         proj.event_damage = W_Plasma_Damage;
158         proj.flags = FL_PROJECTILE;
159
160         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
161
162         CSQCProjectile(proj);
163         proj.csqcprojectile_clientanimate = 1;
164         proj.gravity = 1;
165         proj.csqcprojectile_flysound = 1;
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 };