5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_NORMAL,
8 /* rating */ BOT_PICKUP_RATING_HIGH,
10 /* modelname */ "hlac",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairhlac 0.7",
13 /* wepimg */ "weaponhlac",
15 /* wepname */ _("Arc")
18 #define ARC_SETTINGS(w_cvar,w_prop) ARC_SETTINGS_LIST(w_cvar, w_prop, ARC, arc)
19 #define ARC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, BOTH, ammo) \
21 w_cvar(id, sn, PRI, animtime) \
22 w_cvar(id, sn, PRI, damage) \
23 w_cvar(id, sn, PRI, falloff_halflifedist) \
24 w_cvar(id, sn, PRI, falloff_maxdist) \
25 w_cvar(id, sn, PRI, falloff_mindist) \
26 w_cvar(id, sn, PRI, force) \
27 w_cvar(id, sn, PRI, range) \
28 w_cvar(id, sn, PRI, refire) \
29 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
30 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
31 w_prop(id, sn, string, weaponreplace, weaponreplace) \
32 w_prop(id, sn, float, weaponstart, weaponstart) \
33 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
34 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
37 vector arc_shotorigin[4];
40 ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
42 .vector hook_start, hook_end; // used for beam
43 .entity arc_beam; // used for beam
44 .float BUTTON_ATCK_prev; // for better animation control
45 .float lg_fire_prev; // for better animation control
49 void spawnfunc_weapon_arc(void) { weapon_defaultspawnfunc(WEP_ARC); }
51 float W_Arc_Beam_Send(entity to, float sf)
53 WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
55 if(sound_allowed(MSG_BROADCAST, self.owner))
57 WriteByte(MSG_ENTITY, sf);
60 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
61 WriteCoord(MSG_ENTITY, WEP_CVAR_PRI(arc, range));
65 WriteCoord(MSG_ENTITY, self.hook_start_x);
66 WriteCoord(MSG_ENTITY, self.hook_start_y);
67 WriteCoord(MSG_ENTITY, self.hook_start_z);
71 WriteCoord(MSG_ENTITY, self.hook_end_x);
72 WriteCoord(MSG_ENTITY, self.hook_end_y);
73 WriteCoord(MSG_ENTITY, self.hook_end_z);
78 void W_Arc_Beam_Think(void)
80 print("W_Arc_Beam_Think();\n");
81 self.owner.lg_fire_prev = time;
82 if (self != self.owner.arc_beam)
85 print("W_Arc_Beam_Think(): EXPIRING BEAM #1\n");
88 if ((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)
90 if(self == self.owner.arc_beam)
91 self.owner.arc_beam = world;
93 print("W_Arc_Beam_Think(): EXPIRING BEAM #2\n");
97 self.nextthink = time;
99 makevectors(self.owner.v_angle);
103 if(!(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
105 if(WEP_CVAR_PRI(arc, ammo))
107 dt = min(dt, self.owner.WEP_AMMO(ARC) / WEP_CVAR_PRI(arc, ammo));
108 self.owner.WEP_AMMO(ARC) = max(0, self.owner.WEP_AMMO(ARC) - WEP_CVAR_PRI(arc, ammo) * frametime);
112 W_SetupShot_Range(self.owner, TRUE, 0, "", 0, WEP_CVAR_PRI(arc, damage) * dt, WEP_CVAR_PRI(arc, range));
113 WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
119 force = w_shotdir * WEP_CVAR_PRI(arc, force);
121 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));
123 if(accuracy_isgooddamage(self.owner, trace_ent))
124 accuracy_add(self.owner, WEP_ARC, 0, WEP_CVAR_PRI(arc, damage) * dt * f);
125 Damage (trace_ent, self.owner, self.owner, WEP_CVAR_PRI(arc, damage) * dt * f, WEP_ARC, trace_endpos, force * dt);
129 if(w_shotorg != self.hook_start)
132 self.hook_start = w_shotorg;
134 if(w_shotend != self.hook_end)
137 self.hook_end = w_shotend;
141 // Attack functions =========================
142 void W_Arc_Beam(void)
144 print("W_Arc_Beam();\n");
145 // only play fire sound if 0.5 sec has passed since player let go the fire button
146 if(time - self.lg_fire_prev > 0.5)
147 sound (self, CH_WEAPON_A, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM);
149 entity beam, oldself;
151 self.arc_beam = beam = spawn();
152 beam.classname = "W_Arc_Beam";
153 beam.solid = SOLID_NOT;
154 beam.think = W_Arc_Beam_Think;
156 beam.movetype = MOVETYPE_NONE;
157 beam.shot_spread = 1;
158 beam.bot_dodge = TRUE;
159 beam.bot_dodgerating = WEP_CVAR_PRI(arc, damage);
160 Net_LinkEntity(beam, FALSE, 0, W_Arc_Beam_Send);
168 float W_Arc(float req)
174 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
176 self.BUTTON_ATCK=FALSE;
177 self.BUTTON_ATCK2=FALSE;
178 if(vlen(self.origin-self.enemy.origin) > 1000)
179 self.bot_aim_whichfiretype = 0;
180 if(self.bot_aim_whichfiretype == 0)
184 if(autocvar_g_balance_arc_primary_speed)
185 shoot = bot_aim(autocvar_g_balance_arc_primary_speed, 0, autocvar_g_balance_arc_primary_lifetime, FALSE);
187 shoot = bot_aim(1000000, 0, 0.001, FALSE);
191 self.BUTTON_ATCK = TRUE;
192 if(random() < 0.01) self.bot_aim_whichfiretype = 1;
197 //if(bot_aim(autocvar_g_balance_arc_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_arc_secondary_lifetime, TRUE))
199 // self.BUTTON_ATCK2 = TRUE;
200 // if(random() < 0.03) self.bot_aim_whichfiretype = 0;
211 if(self.BUTTON_ATCK_prev) // TODO: Find another way to implement this!
212 /*if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
213 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
215 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
217 if(weapon_prepareattack(0, 0))
219 if ((!self.arc_beam) || wasfreed(self.arc_beam))
222 if(!self.BUTTON_ATCK_prev)
224 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
225 self.BUTTON_ATCK_prev = 1;
231 if (self.BUTTON_ATCK_prev != 0)
233 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(arc, animtime), w_ready);
234 ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(arc, refire) * W_WeaponRateFactor();
236 self.BUTTON_ATCK_prev = 0;
239 //if (self.BUTTON_ATCK2)
240 //if (weapon_prepareattack(1, autocvar_g_balance_arc_secondary_refire))
243 // self.arc_count = autocvar_g_balance_arc_secondary_count;
244 // weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
245 // self.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor();
252 precache_model ("models/weapons/g_arc.md3");
253 precache_model ("models/weapons/v_arc.md3");
254 precache_model ("models/weapons/h_arc.iqm");
255 //precache_sound ("weapons/arc_bounce.wav");
256 precache_sound ("weapons/arc_fire.wav");
257 precache_sound ("weapons/arc_fire2.wav");
258 precache_sound ("weapons/arc_impact.wav");
259 //precache_sound ("weapons/arc_impact_combo.wav");
260 //precache_sound ("weapons/W_Arc_Beam_fire.wav");
265 return !WEP_CVAR_PRI(arc, ammo) || (self.WEP_AMMO(ARC) > 0);
269 return self.WEP_AMMO(ARC) >= WEP_CVAR_SEC(arc, ammo);
273 ARC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
278 if(w_deathtype & HITTYPE_SECONDARY)
280 return WEAPON_ELECTRO_MURDER_ORBS;
284 if(w_deathtype & HITTYPE_BOUNCE)
285 return WEAPON_ELECTRO_MURDER_COMBO;
287 return WEAPON_ELECTRO_MURDER_BOLT;
292 //self.arc_secondarytime = time;
301 WEP_ACTION(WEP_ARC, WR_INIT);
302 arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 1);
303 arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 2);
304 arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 3);
305 arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 4);
306 ARC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
310 float W_Arc(float req)
314 case WR_IMPACTEFFECT:
317 org2 = w_org + w_backoff * 6;
319 if(w_deathtype & HITTYPE_SECONDARY)
321 pointparticles(particleeffectnum("arc_ballexplode"), org2, '0 0 0', 1);
323 sound(self, CH_SHOTS, "weapons/arc_impact.wav", VOL_BASE, ATTN_NORM);
327 pointparticles(particleeffectnum("arc_impact"), org2, '0 0 0', 1);
329 sound(self, CH_SHOTS, "weapons/arc_impact.wav", VOL_BASE, ATTN_NORM);
336 precache_sound("weapons/arc_impact.wav");
337 precache_sound("weapons/arc_impact_combo.wav");
342 // no weapon specific image for this weapon