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