change all function declarations (except builtins and data types) to ANSI C-like...
[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         self.event_damage = SUB_Null;
8         if (self.movetype == MOVETYPE_BOUNCE)
9         {
10                 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
11                 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"), IT_ELECTRO);
12         }
13         else
14         {
15                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
16                 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"), IT_ELECTRO);
17         }
18         sound (self, CHAN_BODY, "weapons/electro_impact.wav", 1, ATTN_NORM);
19
20         remove (self);
21 }
22
23 void W_Plasma_Explode_Combo (void) {
24         vector org2;
25
26         org2 = findbetterlocation (self.origin, 8);
27         pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
28
29         sound (self, CHAN_BODY, "weapons/electro_impact_combo.wav", 1, ATTN_NORM);
30
31         self.event_damage = SUB_Null;
32         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"), IT_ELECTRO);
33         remove (self);
34 }
35
36 void W_Plasma_Touch (void)
37 {
38         entity o;
39         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
40         {
41                 sound (self, CHAN_BODY, "misc/null.wav", 1, ATTN_NORM);
42                 remove(self);
43                 return;
44         }
45         if (other.takedamage == DAMAGE_AIM) {
46                 o = self.owner;
47                 W_Plasma_Explode ();
48                 if(other.classname == "player")
49                         if(IsDifferentTeam(o, other))
50                                 if(IsFlying(other))
51                                         announce(o, "announcer/male/electrobitch.ogg");
52         } else {
53                 sound (self, CHAN_IMPACT, "weapons/electro_bounce.wav", 1, ATTN_NORM);
54         }
55 }
56
57 void W_Plasma_TouchExplode (void)
58 {
59         entity o;
60         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
61         {
62                 sound (self, CHAN_BODY, "misc/null.wav", 1, ATTN_NORM);
63                 remove(self);
64                 return;
65         }
66         o = self.owner;
67         W_Plasma_Explode ();
68         if(other.takedamage == DAMAGE_AIM)
69                 if(other.classname == "player")
70                         if(IsDifferentTeam(o, other))
71                                 if(IsFlying(other))
72                                         announce(o, "announcer/male/electrobitch.ogg");
73 }
74
75 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
76 {
77         self.health = self.health - damage;
78         if (self.health <= 0)
79         {
80                 self.takedamage = DAMAGE_NO;
81                 self.nextthink = time;
82                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
83                 {
84                         // change owner to whoever caused the combo explosion
85                         self.owner = inflictor.owner;
86                         self.classname = "plasma_chain";
87                         self.think = W_Plasma_Explode_Combo;
88                 }
89                 else
90                         self.think = W_Plasma_Explode;
91         }
92 }
93
94 void() W_Electro_Attack
95 {
96         local entity proj;
97
98         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/electro_fire.wav");
99
100         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
101
102         proj = spawn ();
103         proj.classname = "plasma_prim";
104         proj.owner = self;
105         proj.bot_dodge = TRUE;
106         proj.bot_dodgerating = cvar("g_balance_electro_primary_damage");
107         proj.think = W_Plasma_Explode;
108         proj.nextthink = time + cvar("g_balance_electro_primary_lifetime");
109         proj.solid = SOLID_BBOX;
110         setorigin(proj, w_shotorg);
111
112         if (cvar("g_use_ammunition"))
113                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_primary_ammo");
114         proj.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
115         proj.movetype = MOVETYPE_FLY;
116         proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
117         W_SetupProjectileVelocity(proj);
118         proj.angles = vectoangles(proj.velocity);
119         proj.touch = W_Plasma_TouchExplode;
120         proj.flags = FL_PROJECTILE;
121         setmodel(proj, "models/elaser.mdl"); // precision set above
122         setsize(proj, '0 0 0', '0 0 0');
123
124         // LordHavoc: disabled because no one likes this sound and it sometimes never stops due to packet loss
125         //sound (proj, CHAN_BODY, "weapons/electro_fly.wav", 1, ATTN_NORM);
126 }
127
128 void() W_Electro_Attack2
129 {
130         local entity proj;
131
132         W_SetupShot (self, '25 8 -8', FALSE, 2, "weapons/electro_fire2.wav");
133
134         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
135
136         proj = spawn ();
137         proj.classname = "plasma";
138         proj.owner = self;
139         proj.think = W_Plasma_Explode;
140         proj.bot_dodge = TRUE;
141         proj.bot_dodgerating = cvar("g_balance_electro_secondary_damage");
142         proj.nextthink = time + cvar("g_balance_electro_secondary_lifetime");
143         proj.solid = SOLID_BBOX;
144         setorigin(proj, w_shotorg);
145
146         if (cvar("g_use_ammunition"))
147                 self.ammo_cells = self.ammo_cells - cvar("g_balance_electro_secondary_ammo");
148         proj.effects = EF_LOWPRECISION;
149         //proj.glow_size = 50;
150         //proj.glow_color = 45;
151         proj.movetype = MOVETYPE_BOUNCE;
152         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");
153         W_SetupProjectileVelocity(proj);
154         proj.touch = W_Plasma_Touch;
155         setmodel(proj, "models/ebomb.mdl"); // precision set above
156         setsize(proj, '0 0 -3', '0 0 -3');
157         proj.takedamage = DAMAGE_YES;
158         proj.damageforcescale = 4;
159         proj.health = 5;
160         proj.event_damage = W_Plasma_Damage;
161         proj.flags = FL_PROJECTILE;
162
163         // LordHavoc: disabled because no one likes this sound and it sometimes never stops due to packet loss
164         //sound (proj, CHAN_BODY, "weapons/electro_fly.wav", 1, ATTN_NORM);
165 }
166
167 .float bot_secondary_electromooth;
168 float w_electro(float req)
169 {
170         if (req == WR_AIM)
171         {
172                 self.BUTTON_ATCK=FALSE;
173                 self.BUTTON_ATCK2=FALSE;
174                 if(vlen(self.origin-self.enemy.origin) > 1000)
175                         self.bot_secondary_electromooth = 0;
176                 if(self.bot_secondary_electromooth == 0)
177                 {
178                         if(bot_aim(cvar("g_balance_electro_primary_speed"), 0, cvar("g_balance_electro_primary_lifetime"), FALSE))
179                         {
180                                 self.BUTTON_ATCK = TRUE;
181                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
182                         }
183                 }
184                 else
185                 {
186                         if(bot_aim(cvar("g_balance_electro_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_electro_secondary_lifetime"), TRUE))
187                         {
188                                 self.BUTTON_ATCK2 = TRUE;
189                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
190                         }
191                 }
192         }
193         else if (req == WR_THINK)
194         {
195                 if (self.BUTTON_ATCK)
196                 if (weapon_prepareattack(0, cvar("g_balance_electro_primary_refire")))
197                 {
198                         W_Electro_Attack();
199                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_primary_animtime"), w_ready);
200                 }
201                 if (self.BUTTON_ATCK2)
202                 if (weapon_prepareattack(1, cvar("g_balance_electro_secondary_refire")))
203                 {
204                         W_Electro_Attack2();
205                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_electro_secondary_animtime"), w_ready);
206                 }
207         }
208         else if (req == WR_PRECACHE)
209         {
210                 precache_model ("models/ebomb.mdl");
211                 precache_model ("models/elaser.mdl");
212                 precache_model ("models/weapons/g_electro.md3");
213                 precache_model ("models/weapons/v_electro.md3");
214                 precache_model ("models/weapons/w_electro.zym");
215                 precache_sound ("weapons/electro_bounce.wav");
216                 precache_sound ("weapons/electro_fire.wav");
217                 precache_sound ("weapons/electro_fire2.wav");
218                 precache_sound ("weapons/electro_fly.wav");
219                 precache_sound ("weapons/electro_impact.wav");
220                 precache_sound ("weapons/electro_impact_combo.wav");
221         }
222         else if (req == WR_SETUP)
223                 weapon_setup(WEP_ELECTRO, "electro", IT_CELLS);
224         else if (req == WR_CHECKAMMO1)
225                 return self.ammo_cells >= cvar("g_balance_electro_primary_ammo");
226         else if (req == WR_CHECKAMMO2)
227                 return self.ammo_cells >= cvar("g_balance_electro_secondary_ammo");
228         else if (req == WR_REGISTER)
229                 weapon_register(WEP_ELECTRO, min(cvar("g_balance_electro_primary_ammo"), cvar("g_balance_electro_secondary_ammo")));
230         return TRUE;
231 };