]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_electro.qc
actually read sv_clforceplayermodels
[divverent/nexuiz.git] / data / qcsrc / server / w_electro.qc
1
2 void W_Plasma_Explode (void)
3 {
4         if(other.takedamage == DAMAGE_AIM)
5                 if(other.classname == "player")
6                         if(IsDifferentTeam(self.owner, other))
7                                 if(IsFlying(other))
8                                         announce(self.owner, "announcer/male/electrobitch.wav");
9
10         self.event_damage = SUB_Null;
11         if (self.movetype == MOVETYPE_BOUNCE)
12         {
13                 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);
14         }
15         else
16         {
17                 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);
18         }
19
20         remove (self);
21 }
22
23 void W_Plasma_Explode_Combo (void) {
24         self.event_damage = SUB_Null;
25         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
26         remove (self);
27 }
28
29 void W_Plasma_Touch (void)
30 {
31         PROJECTILE_TOUCH;
32         if (other.takedamage == DAMAGE_AIM) {
33                 W_Plasma_Explode ();
34         } else {
35                 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
36                 self.projectiledeathtype |= HITTYPE_BOUNCE;
37         }
38 }
39
40 void W_Plasma_TouchExplode (void)
41 {
42         PROJECTILE_TOUCH;
43         W_Plasma_Explode ();
44 }
45
46 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
47 {
48         if(self.health <= 0)
49                 return;
50         self.health = self.health - damage;
51         if (self.health <= 0)
52         {
53                 self.takedamage = DAMAGE_NO;
54                 self.nextthink = time;
55                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
56                 {
57                         // change owner to whoever caused the combo explosion
58                         self.owner = inflictor.owner;
59                         self.classname = "plasma_chain";
60                         self.think = W_Plasma_Explode_Combo;
61                         self.nextthink = time + vlen(self.origin - inflictor.origin) / cvar("g_balance_electro_combo_speed"); // delay combo chains, looks cooler
62                 }
63                 else
64                         self.think = W_Plasma_Explode;
65         }
66 }
67
68 void W_Electro_Attack()
69 {
70         local entity proj;
71
72         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", cvar("g_balance_electro_primary_damage"));
73
74         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
75
76         proj = spawn ();
77         proj.classname = "plasma_prim";
78         proj.owner = self;
79         proj.bot_dodge = TRUE;
80         proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
81         proj.use = W_Plasma_Explode;
82         proj.think = adaptor_think2use;
83         proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
84         proj.solid = SOLID_BBOX;
85         proj.projectiledeathtype = WEP_ELECTRO;
86         setorigin(proj, w_shotorg);
87
88         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
89                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
90         proj.movetype = MOVETYPE_FLY;
91         proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
92         W_SetupProjectileVelocity(proj);
93         proj.angles = vectoangles(proj.velocity);
94         proj.touch = W_Plasma_TouchExplode;
95         setsize(proj, '0 0 -3', '0 0 -3');
96         proj.flags = FL_PROJECTILE;
97
98         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
99         //sounds bad
100
101         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
102 }
103
104 void W_Electro_Attack2()
105 {
106         local entity proj;
107
108         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire2.wav", cvar("g_balance_electro_secondary_damage"));
109         w_shotdir = v_forward; // no TrueAim for grenades please
110
111         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
112
113         proj = spawn ();
114         proj.classname = "plasma";
115         proj.owner = self;
116         proj.use = W_Plasma_Explode;
117         proj.think = adaptor_think2use;
118         proj.bot_dodge = TRUE;
119         proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
120         proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
121         proj.solid = SOLID_BBOX;
122         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
123         setorigin(proj, w_shotorg);
124
125         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
126                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
127         //proj.glow_size = 50;
128         //proj.glow_color = 45;
129         proj.movetype = MOVETYPE_BOUNCE;
130         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");
131         W_SetupProjectileVelocity(proj);
132         proj.touch = W_Plasma_Touch;
133         setsize(proj, '0 0 -3', '0 0 -3');
134         proj.takedamage = DAMAGE_YES;
135         proj.damageforcescale = cvar("g_balance_electro_secondary_damageforcescale");
136         proj.health = cvar("g_balance_electro_secondary_health");
137         proj.event_damage = W_Plasma_Damage;
138         proj.flags = FL_PROJECTILE;
139
140 #if 0
141         entity p2;
142         p2 = spawn();
143         copyentity(proj, p2);
144         setmodel(p2, "models/ebomb.mdl");
145         setsize(p2, proj.mins, proj.maxs);
146 #endif
147
148         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
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_FIRE2, cvar("g_balance_electro_secondary_animtime"), w_ready);
195                 }
196         }
197         else if (req == WR_PRECACHE)
198         {
199                 precache_model ("models/weapons/g_electro.md3");
200                 precache_model ("models/weapons/v_electro.md3");
201                 precache_model ("models/weapons/h_electro.dpm");
202                 precache_sound ("weapons/electro_bounce.wav");
203                 precache_sound ("weapons/electro_fire.wav");
204                 precache_sound ("weapons/electro_fire2.wav");
205                 precache_sound ("weapons/electro_impact.wav");
206                 precache_sound ("weapons/electro_impact_combo.wav");
207         }
208         else if (req == WR_SETUP)
209                 weapon_setup(WEP_ELECTRO);
210         else if (req == WR_CHECKAMMO1)
211                 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
212         else if (req == WR_CHECKAMMO2)
213                 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
214         else if (req == WR_SUICIDEMESSAGE)
215         {
216                 if(w_deathtype & HITTYPE_SECONDARY)
217                         w_deathtypestring = "could not remember where he put plasma";
218                 else
219                         w_deathtypestring = "played with plasma";
220         }
221         else if (req == WR_KILLMESSAGE)
222         {
223                 if(w_deathtype & HITTYPE_SECONDARY)
224                 {
225                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
226                                 w_deathtypestring = "just noticed #'s blue ball";
227                         else // unchecked: BOUNCE
228                                 w_deathtypestring = "got in touch with #'s blue ball";
229                 }
230                 else
231                 {
232                         if(w_deathtype & HITTYPE_BOUNCE) // combo
233                                 w_deathtypestring = "felt the electrifying air of #'s combo";
234                         else if(w_deathtype & HITTYPE_SPLASH)
235                                 w_deathtypestring = "got too close to #'s blue beam";
236                         else
237                                 w_deathtypestring = "was blasted by #'s blue beam";
238                 }
239         }
240         return TRUE;
241 };