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