5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_NORMAL,
8 /* rating */ BOT_PICKUP_RATING_HIGH,
11 /* crosshair */ "gfx/crosshairhlac 0.7",
13 /* fullname */ _("Arc")
16 #define ARC_SETTINGS(w_cvar,w_prop) ARC_SETTINGS_LIST(w_cvar, w_prop, ARC, arc)
17 #define ARC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
18 w_cvar(id, sn, BOTH, ammo) \
19 w_cvar(id, sn, PRI, animtime) \
20 w_cvar(id, sn, PRI, damage) \
21 w_cvar(id, sn, PRI, falloff_halflifedist) \
22 w_cvar(id, sn, PRI, falloff_maxdist) \
23 w_cvar(id, sn, PRI, falloff_mindist) \
24 w_cvar(id, sn, PRI, force) \
25 w_cvar(id, sn, PRI, range) \
26 w_cvar(id, sn, PRI, refire) \
27 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
28 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
29 w_prop(id, sn, string, weaponreplace, weaponreplace) \
30 w_prop(id, sn, float, weaponstart, weaponstart) \
31 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
34 vector arc_shotorigin[4];
37 ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
39 .vector hook_start, hook_end; // used for beam
40 .entity arc_beam; // used for beam
41 .float BUTTON_ATCK_prev; // for better animation control
42 .float lg_fire_prev; // for better animation control
46 void spawnfunc_weapon_arc() { weapon_defaultspawnfunc(WEP_ARC); }
48 float W_Arc_Beam_Send(entity to, float sf)
50 WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
52 if(sound_allowed(MSG_BROADCAST, self.owner))
54 WriteByte(MSG_ENTITY, sf);
57 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
58 WriteCoord(MSG_ENTITY, WEP_CVAR_PRI(arc, range));
62 WriteCoord(MSG_ENTITY, self.hook_start_x);
63 WriteCoord(MSG_ENTITY, self.hook_start_y);
64 WriteCoord(MSG_ENTITY, self.hook_start_z);
68 WriteCoord(MSG_ENTITY, self.hook_end_x);
69 WriteCoord(MSG_ENTITY, self.hook_end_y);
70 WriteCoord(MSG_ENTITY, self.hook_end_z);
75 void W_Arc_Beam_Think()
77 self.owner.lg_fire_prev = time;
78 if (self != self.owner.arc_beam)
83 if (self.owner.weaponentity.state != WS_INUSE || (self.owner.WEP_AMMO(ARC) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)) || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK || self.owner.freezetag_frozen)
85 if(self == self.owner.arc_beam)
86 self.owner.arc_beam = world;
91 self.nextthink = time;
93 makevectors(self.owner.v_angle);
97 if(!(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
99 if(WEP_CVAR_PRI(arc, ammo))
101 dt = min(dt, self.owner.WEP_AMMO(ARC) / WEP_CVAR_PRI(arc, ammo));
102 self.owner.WEP_AMMO(ARC) = max(0, self.owner.WEP_AMMO(ARC) - WEP_CVAR_PRI(arc, ammo) * frametime);
106 W_SetupShot_Range(self.owner, TRUE, 0, "", 0, WEP_CVAR_PRI(arc, damage) * dt, WEP_CVAR_PRI(arc, range));
107 WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
113 force = w_shotdir * WEP_CVAR_PRI(arc, force);
115 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));
117 if(accuracy_isgooddamage(self.owner, trace_ent))
118 accuracy_add(self.owner, WEP_ARC, 0, WEP_CVAR_PRI(arc, damage) * dt * f);
119 Damage (trace_ent, self.owner, self.owner, WEP_CVAR_PRI(arc, damage) * dt * f, WEP_ARC, trace_endpos, force * dt);
123 if(w_shotorg != self.hook_start)
126 self.hook_start = w_shotorg;
128 if(w_shotend != self.hook_end)
131 self.hook_end = w_shotend;
135 // Attack functions =========================
136 void W_Arc_Attack1 (void)
138 // only play fire sound if 0.5 sec has passed since player let go the fire button
139 if(time - self.lg_fire_prev > 0.5)
140 sound (self, CH_WEAPON_A, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM);
142 entity beam, oldself;
144 self.arc_beam = beam = spawn();
145 beam.classname = "W_Arc_Beam";
146 beam.solid = SOLID_NOT;
147 beam.think = W_Arc_Beam_Think;
149 beam.movetype = MOVETYPE_NONE;
150 beam.shot_spread = 1;
151 beam.bot_dodge = TRUE;
152 beam.bot_dodgerating = WEP_CVAR_PRI(arc, damage);
153 Net_LinkEntity(beam, FALSE, 0, W_Arc_Beam_Send);
161 float W_Arc(float req)
167 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
169 self.BUTTON_ATCK=FALSE;
170 self.BUTTON_ATCK2=FALSE;
171 if(vlen(self.origin-self.enemy.origin) > 1000)
172 self.bot_aim_whichfiretype = 0;
173 if(self.bot_aim_whichfiretype == 0)
177 if(autocvar_g_balance_arc_primary_speed)
178 shoot = bot_aim(autocvar_g_balance_arc_primary_speed, 0, autocvar_g_balance_arc_primary_lifetime, FALSE);
180 shoot = bot_aim(1000000, 0, 0.001, FALSE);
184 self.BUTTON_ATCK = TRUE;
185 if(random() < 0.01) self.bot_aim_whichfiretype = 1;
190 //if(bot_aim(autocvar_g_balance_arc_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_arc_secondary_lifetime, TRUE))
192 // self.BUTTON_ATCK2 = TRUE;
193 // if(random() < 0.03) self.bot_aim_whichfiretype = 0;
202 if (self.BUTTON_ATCK)
204 if(self.BUTTON_ATCK_prev) // TODO: Find another way to implement this!
205 /*if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
206 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
208 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
210 if (weapon_prepareattack(0, 0))
212 if ((!self.arc_beam) || wasfreed(self.arc_beam))
215 if(!self.BUTTON_ATCK_prev)
217 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
218 self.BUTTON_ATCK_prev = 1;
224 if (self.BUTTON_ATCK_prev != 0)
226 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
227 ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(arc, refire) * W_WeaponRateFactor();
229 self.BUTTON_ATCK_prev = 0;
232 //if (self.BUTTON_ATCK2)
233 //if (weapon_prepareattack(1, autocvar_g_balance_arc_secondary_refire))
236 // self.arc_count = autocvar_g_balance_arc_secondary_count;
237 // weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
238 // self.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor();
245 precache_model ("models/weapons/g_arc.md3");
246 precache_model ("models/weapons/v_arc.md3");
247 precache_model ("models/weapons/h_arc.iqm");
248 //precache_sound ("weapons/arc_bounce.wav");
249 precache_sound ("weapons/arc_fire.wav");
250 precache_sound ("weapons/arc_fire2.wav");
251 precache_sound ("weapons/arc_impact.wav");
252 //precache_sound ("weapons/arc_impact_combo.wav");
253 //precache_sound ("weapons/W_Arc_Beam_fire.wav");
258 return !WEP_CVAR_PRI(arc, ammo) || (self.WEP_AMMO(ARC) > 0);
262 return self.WEP_AMMO(ARC) >= WEP_CVAR_SEC(arc, ammo);
266 ARC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
271 if(w_deathtype & HITTYPE_SECONDARY)
273 return WEAPON_ELECTRO_MURDER_ORBS;
277 if(w_deathtype & HITTYPE_BOUNCE)
278 return WEAPON_ELECTRO_MURDER_COMBO;
280 return WEAPON_ELECTRO_MURDER_BOLT;
285 //self.arc_secondarytime = time;
294 WEP_ACTION(WEP_ARC, WR_INIT);
295 arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 1);
296 arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 2);
297 arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 3);
298 arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 4);
299 ARC_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
303 float W_Arc(float req)
307 case WR_IMPACTEFFECT:
310 org2 = w_org + w_backoff * 6;
312 if(w_deathtype & HITTYPE_SECONDARY)
314 pointparticles(particleeffectnum("arc_ballexplode"), org2, '0 0 0', 1);
316 sound(self, CH_SHOTS, "weapons/arc_impact.wav", VOL_BASE, ATTN_NORM);
320 pointparticles(particleeffectnum("arc_impact"), org2, '0 0 0', 1);
322 sound(self, CH_SHOTS, "weapons/arc_impact.wav", VOL_BASE, ATTN_NORM);
329 precache_sound("weapons/arc_impact.wav");
330 precache_sound("weapons/arc_impact_combo.wav");
335 // no weapon specific image for this weapon