5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_NORMAL,
8 /* rating */ BOT_PICKUP_RATING_HIGH,
11 /* fullname */ _("Arc")
14 #define ARC_SETTINGS(w_cvar,w_prop) ARC_SETTINGS_LIST(w_cvar, w_prop, ARC, arc)
15 #define ARC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, BOTH, ammo) \
17 w_cvar(id, sn, PRI, animtime) \
18 w_cvar(id, sn, PRI, damage) \
19 w_cvar(id, sn, PRI, falloff_halflifedist) \
20 w_cvar(id, sn, PRI, falloff_maxdist) \
21 w_cvar(id, sn, PRI, falloff_mindist) \
22 w_cvar(id, sn, PRI, force) \
23 w_cvar(id, sn, PRI, range) \
24 w_cvar(id, sn, PRI, refire) \
25 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
26 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
27 w_prop(id, sn, string, weaponreplace, weaponreplace) \
28 w_prop(id, sn, float, weaponstart, weaponstart) \
29 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
32 vector arc_shotorigin[4];
35 ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
37 .vector hook_start, hook_end; // used for beam
38 .entity arc_beam; // used for beam
39 .float BUTTON_ATCK_prev; // for better animation control
40 .float lg_fire_prev; // for better animation control
44 void spawnfunc_weapon_arc() { weapon_defaultspawnfunc(WEP_ARC); }
46 float W_Arc_Beam_Send(entity to, float sf)
48 WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
50 if(sound_allowed(MSG_BROADCAST, self.owner))
52 WriteByte(MSG_ENTITY, sf);
55 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
56 WriteCoord(MSG_ENTITY, WEP_CVAR_PRI(arc, range));
60 WriteCoord(MSG_ENTITY, self.hook_start_x);
61 WriteCoord(MSG_ENTITY, self.hook_start_y);
62 WriteCoord(MSG_ENTITY, self.hook_start_z);
66 WriteCoord(MSG_ENTITY, self.hook_end_x);
67 WriteCoord(MSG_ENTITY, self.hook_end_y);
68 WriteCoord(MSG_ENTITY, self.hook_end_z);
73 void W_Arc_Beam_Think()
75 self.owner.lg_fire_prev = time;
76 if (self != self.owner.arc_beam)
81 if (self.owner.weaponentity.state != WS_INUSE || (self.owner.AMMO_VAL(WEP_ARC) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)) || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK || self.owner.freezetag_frozen)
83 if(self == self.owner.arc_beam)
84 self.owner.arc_beam = world;
89 self.nextthink = time;
91 makevectors(self.owner.v_angle);
95 if(!(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
97 if(WEP_CVAR_PRI(arc, ammo))
99 dt = min(dt, self.owner.AMMO_VAL(WEP_ARC) / WEP_CVAR_PRI(arc, ammo));
100 self.owner.AMMO_VAL(WEP_ARC) = max(0, self.owner.AMMO_VAL(WEP_ARC) - WEP_CVAR_PRI(arc, ammo) * frametime);
104 W_SetupShot_Range(self.owner, TRUE, 0, "", 0, WEP_CVAR_PRI(arc, damage) * dt, WEP_CVAR_PRI(arc, range));
105 WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
111 force = w_shotdir * WEP_CVAR_PRI(arc, force);
113 f = ExponentialFalloff(WEP_CVAR_PRI(arc, falloff_mindist), WEP_CVAR_PRI(arc, falloff_maxdist), WEP_CVAR_PRI(arc, falloff_halflifedist), vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos) - w_shotorg));
115 if(accuracy_isgooddamage(self.owner, trace_ent))
116 accuracy_add(self.owner, WEP_ARC, 0, WEP_CVAR_PRI(arc, damage) * dt * f);
117 Damage (trace_ent, self.owner, self.owner, WEP_CVAR_PRI(arc, damage) * dt * f, WEP_ARC, trace_endpos, force * dt);
121 if(w_shotorg != self.hook_start)
124 self.hook_start = w_shotorg;
126 if(w_shotend != self.hook_end)
129 self.hook_end = w_shotend;
133 // Attack functions =========================
134 void W_Arc_Attack1 (void)
136 // only play fire sound if 0.5 sec has passed since player let go the fire button
137 if(time - self.lg_fire_prev > 0.5)
138 sound (self, CH_WEAPON_A, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM);
140 entity beam, oldself;
142 self.arc_beam = beam = spawn();
143 beam.classname = "W_Arc_Beam";
144 beam.solid = SOLID_NOT;
145 beam.think = W_Arc_Beam_Think;
147 beam.movetype = MOVETYPE_NONE;
148 beam.shot_spread = 1;
149 beam.bot_dodge = TRUE;
150 beam.bot_dodgerating = WEP_CVAR_PRI(arc, damage);
151 Net_LinkEntity(beam, FALSE, 0, W_Arc_Beam_Send);
159 float w_arc(float req)
165 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
167 self.BUTTON_ATCK=FALSE;
168 self.BUTTON_ATCK2=FALSE;
169 if(vlen(self.origin-self.enemy.origin) > 1000)
170 self.bot_aim_whichfiretype = 0;
171 if(self.bot_aim_whichfiretype == 0)
175 if(autocvar_g_balance_arc_primary_speed)
176 shoot = bot_aim(autocvar_g_balance_arc_primary_speed, 0, autocvar_g_balance_arc_primary_lifetime, FALSE);
178 shoot = bot_aim(1000000, 0, 0.001, FALSE);
182 self.BUTTON_ATCK = TRUE;
183 if(random() < 0.01) self.bot_aim_whichfiretype = 1;
188 //if(bot_aim(autocvar_g_balance_arc_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_arc_secondary_lifetime, TRUE))
190 // self.BUTTON_ATCK2 = TRUE;
191 // if(random() < 0.03) self.bot_aim_whichfiretype = 0;
200 if (self.BUTTON_ATCK)
202 if(self.BUTTON_ATCK_prev) // TODO: Find another way to implement this!
203 /*if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
204 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
206 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
208 if (weapon_prepareattack(0, 0))
210 if ((!self.arc_beam) || wasfreed(self.arc_beam))
213 if(!self.BUTTON_ATCK_prev)
215 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
216 self.BUTTON_ATCK_prev = 1;
222 if (self.BUTTON_ATCK_prev != 0)
224 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
225 ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(arc, refire) * W_WeaponRateFactor();
227 self.BUTTON_ATCK_prev = 0;
230 //if (self.BUTTON_ATCK2)
231 //if (weapon_prepareattack(1, autocvar_g_balance_arc_secondary_refire))
234 // self.arc_count = autocvar_g_balance_arc_secondary_count;
235 // weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
236 // self.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor();
243 precache_model ("models/weapons/g_arc.md3");
244 precache_model ("models/weapons/v_arc.md3");
245 precache_model ("models/weapons/h_arc.iqm");
246 //precache_sound ("weapons/arc_bounce.wav");
247 precache_sound ("weapons/arc_fire.wav");
248 precache_sound ("weapons/arc_fire2.wav");
249 precache_sound ("weapons/arc_impact.wav");
250 //precache_sound ("weapons/arc_impact_combo.wav");
251 //precache_sound ("weapons/W_Arc_Beam_fire.wav");
256 return !WEP_CVAR_PRI(arc, ammo) || (self.AMMO_VAL(WEP_ARC) > 0);
260 return self.AMMO_VAL(WEP_ARC) >= WEP_CVAR_SEC(arc, ammo);
264 ARC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
269 if(w_deathtype & HITTYPE_SECONDARY)
271 return WEAPON_ELECTRO_MURDER_ORBS;
275 if(w_deathtype & HITTYPE_BOUNCE)
276 return WEAPON_ELECTRO_MURDER_COMBO;
278 return WEAPON_ELECTRO_MURDER_BOLT;
283 //self.arc_secondarytime = time;
292 WEP_ACTION(WEP_ARC, WR_INIT);
293 arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 1);
294 arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 2);
295 arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 3);
296 arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 4);
297 ARC_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
301 float w_arc(float req)
305 case WR_IMPACTEFFECT:
308 org2 = w_org + w_backoff * 6;
310 if(w_deathtype & HITTYPE_SECONDARY)
312 pointparticles(particleeffectnum("arc_ballexplode"), org2, '0 0 0', 1);
314 sound(self, CH_SHOTS, "weapons/arc_impact.wav", VOL_BASE, ATTN_NORM);
318 pointparticles(particleeffectnum("arc_impact"), org2, '0 0 0', 1);
320 sound(self, CH_SHOTS, "weapons/arc_impact.wav", VOL_BASE, ATTN_NORM);
327 precache_sound("weapons/arc_impact.wav");
328 precache_sound("weapons/arc_impact_combo.wav");