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