59 if (
IS_SPEC(client) && client.enemy ==
this.owner)
86 if (this.
owner.(weaponentity) !=
this)
118 else if (this.
owner.alpha != 0)
135 if (this.
owner.exteriorweaponentity !=
this)
145 if (this.
weaponname != w_ent.weaponname ||
this.dmg != w_ent.modelindex ||
this.deadflag != w_ent.deadflag)
148 this.
dmg = w_ent.modelindex;
150 if (w_ent.weaponname !=
"")
152 _setmodel(
this,
W_Model(
strcat(
"v_", w_ent.weaponname,
".md3")));
153 setsize(
this,
'0 0 0',
'0 0 0');
165 setattachment(
this, this.
owner,
"bip01 r hand");
172 else if (this.
owner.alpha != 0)
181 this.
skin = w_ent.skin;
189 entity w_ent = actor.(weaponentity) =
new(weaponentity);
193 setorigin(w_ent,
'0 0 0');
194 w_ent.weaponentity_fld = weaponentity;
196 w_ent.nextthink =
time;
197 w_ent.viewmodelforclient = actor;
207 exterior.owner = actor;
209 exterior.weaponentity_fld = weaponentity;
210 setorigin(exterior,
'0 0 0');
212 exterior.nextthink =
time;
221 entity w_ent = actor.(weaponentity);
224 w_ent.m_weapon = WEP_Null;
225 w_ent.m_switchingweapon = WEP_Null;
233 entity w_ent = actor.(weaponentity);
245 bool ammo = (secondary)
251 if (thiswep == WEP_MINE_LAYER)
252 IL_EACH(
g_mines, it.owner == actor && it.weaponentity_fld == weaponentity,
return false);
254 if (thiswep == WEP_SHOTGUN
255 && !secondary &&
WEP_CVAR(WEP_SHOTGUN, secondary) == 1)
258 if (thiswep == actor.(weaponentity).m_switchweapon &&
time - actor.prevdryfire > 1)
261 actor.prevdryfire =
time;
265 bool ammo_other = (secondary)
270 if (
time - actor.prevwarntime > 1)
271 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_WEAPON_PRIMORSEC, thiswep.
m_id, secondary, (1 - secondary));
272 actor.prevwarntime =
time;
283 if (actor.weaponentity ==
NULL)
297 if (actor.(weaponentity).m_switchweapon != actor.(weaponentity).m_weapon)
303 if (
ATTACK_FINISHED(actor, weaponentity) >
time + actor.(weaponentity).weapon_frametime * 0.5)
305 entity this = actor.(weaponentity);
307 if (!actor.vehicle &&
this.state !=
WS_READY)
315 entity this = actor.(weaponentity);
342 if (actor.(wepent) && actor.(wepent).m_weapon != WEP_Null)
372 .
entity weaponentity,
int fire) func)
374 entity this = actor.(weaponentity);
378 if (fr == WFRAME_DONTCHANGE)
381 if (this.
wframe == WFRAME_DONTCHANGE)
382 this.
wframe = WFRAME_IDLE;
387 restartanim = fr != WFRAME_IDLE;
392 backtrace(
"Tried to override initial weapon think function - should this really happen?");
397 if (this.weapon_think ==
w_ready)
409 this.weapon_think = func;
415 if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
423 actor.anim_upper_action = 0;
449 preferred_alignment = 3;
455 if (player.(weaponentity))
463 if (player.(weaponentity))
474 entity this = actor.(weaponentity);
485 button_atck = button_atck2 = 0;
491 w_ready(wpn, actor, weaponentity, button_atck | (button_atck2 << 1));
498 entity wep1 = actor.(wepe1);
501 if (!(this.m_switchweapon.spawnflags &
WEP_FLAG_DUALWIELD) && !(store.dual_weapons & wep1.m_switchweapon.m_wepset))
505 this.m_switchweapon = WEP_Null;
516 w_ready(this.
m_weapon, actor, weaponentity, button_atck | (button_atck2 << 1));
534 LOG_WARNF(
"unhandled weaponentity (%i) state for player (%i): %d",
this, actor, this.
state);
549 newwep.
wr_setup(newwep, actor, weaponentity);
608 bool block_weapon =
false;
614 Weapon off = actor.offhand;
617 if (off.offhand_think)
618 off.offhand_think(off, actor, key_pressed);
622 if (key_pressed && this.
m_switchweapon != WEP_HOOK && !actor.hook_switchweapon)
624 actor.hook_switchweapon = key_pressed;
626 block_weapon = (this.
m_weapon == h && (button_atck || key_pressed));
627 h.
wr_think(h, actor, weaponentity, block_weapon ? 1 : 0);
640 e.
wr_think(e, actor, weaponentity, button_atck | (button_atck2 << 1));
647 if (this.weapon_think)
653 this.weapon_think(wpn, actor, weaponentity, button_atck | (button_atck2 << 1));
656 bprint(
"\{1}^1ERROR: undefined weapon think function for ", actor.
netname,
"\n");
664 flash.angles_z =
random() * 360;
666 entity w_ent = actor.(weaponentity);
667 entity exterior = actor.exteriorweaponentity;
669 setattachment(flash, w_ent, (
gettagindex(w_ent,
"shot") ?
"shot" :
"tag_shot"));
670 setorigin(flash, offset);
675 flash.viewmodelforclient = actor;
677 if (w_ent.oldorigin.x > 0)
679 setattachment(xflash, exterior,
"");
680 setorigin(xflash, w_ent.oldorigin + offset);
684 setattachment(xflash, exterior, (
gettagindex(exterior,
"shot") ?
"shot" :
"tag_shot"));
685 setorigin(xflash, offset);
696 ammo_use =
M_ARGV(2,
float);
698 entity w_ent = actor.(weaponentity);
701 if (wep.reloading_ammo)
703 w_ent.clip_load -= ammo_use;
704 w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load;
711 "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... "
712 "Please notify the developers immediately with a copy of this backtrace!\n",
728 entity w_ent = actor.(weaponentity);
729 Weapon wpn = w_ent.m_weapon;
731 w_ent.clip_load = w_ent.old_clip_load;
734 if (!w_ent.reload_ammo_min || (actor.items &
IT_UNLIMITED_AMMO) || wpn.ammo_type == RES_NONE)
735 w_ent.clip_load = w_ent.reload_ammo_amount;
740 float load =
min(w_ent.reload_ammo_amount - w_ent.clip_load,
ammo);
741 w_ent.clip_load += load;
744 w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load;
759 entity this = actor.(weaponentity);
765 this.reload_ammo_min = sent_ammo_min;
767 this.reload_time = e.reloading_time;
773 LOG_TRACE(
"Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");
786 if (e.ammo_type != RES_NONE
787 && !
GetResource(actor, e.ammo_type) &&
this.reload_ammo_min
795 sprint(actor,
strcat(
"You don't have enough ammo to reload the ^2", this.
m_weapon.m_name,
"\n"));
796 actor.reload_complain =
time + 1;
799 if (!(e.wr_checkammo1(e, actor, weaponentity) + e.wr_checkammo2(e, actor, weaponentity)))
808 if (this.
wframe == WFRAME_RELOAD)
837 w.event(w, player, weaponentity);
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
void animdecide_setaction(entity e, float action, float restart)
const int ANIMACTION_MELEE
const int ANIMACTION_SHOOT
#define MUTATOR_CALLHOOK(id,...)
int W_GunAlign(entity this, int preferred_align)
bool drag_undraggable(entity draggee, entity dragger)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
string netname
Client name.
Purpose: common player state, usable on client and server Client: singleton representing the viewed p...
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
virtual void wr_setup()
(SERVER) setup weapon data
virtual void wr_think()
(SERVER) logic to run every frame
Resource ammo_type
M: ammotype : main ammo type.
string mdl
M: modelname : name of model (without g_ v_ or h_ prefixes)
virtual void wr_checkammo2()
(SERVER) checks ammo for weapon second
string netname
M: refname : reference name name.
int spawnflags
M: flags : WEPSPAWNFLAG_... combined.
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
virtual void wr_gonethink()
(SERVER) logic to run when weapon is lost
const int IT_UNLIMITED_AMMO
#define setmodel(this, m)
#define PHYS_INPUT_BUTTON_HOOK(s)
#define PHYS_INPUT_BUTTON_ATCK(s)
#define PHYS_INPUT_BUTTON_ATCK2(s)
#define CSQCMODEL_AUTOUPDATE(e)
#define CSQCMODEL_AUTOINIT(e)
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
#define MAKE_VECTORS(angles, forward, right, up)
Same as the makevectors builtin but uses the provided locals instead of the v_* globals.
entity viewmodelforclient
#define IL_EACH(this, cond, body)
string W_Model(string w_mdl)
@ STATUSEFFECT_REMOVE_CLEAR
Effect is being forcibly removed without calling any additional mechanics.
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
void copyentity_qc(entity src, entity dst)
#define REGISTRY_GET(id, i)
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
bool W_SwitchWeapon(entity this, Weapon w,.entity weaponentity)
void W_SwitchToOtherWeapon(entity this,.entity weaponentity)
Perform weapon to attack (weaponstate and attack_finished check is here)
#define w_getbestweapon(ent, wepent)
bool autocvar_g_weaponswitch_debug
bool autocvar_g_weaponswitch_debug_alternate
const float TIMEOUT_ACTIVE
bool W_DualWielding(entity player)
const int CH_WEAPON_SINGLE
#define Sound_fixpath(this)
#define _sound(e, c, s, v, a)
#define sound(e, c, s, v, a)
void play2(entity e, string filename)
void StatusEffects_remove(StatusEffect this, entity actor, int removal_type)
bool StatusEffects_active(StatusEffect this, entity actor)
Header file that describes the resource system.
#define IS_REAL_CLIENT(v)
#define FOREACH_CLIENT(cond, body)
void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim)
void CL_WeaponEntity_SetModel(entity this, string name, bool _anim)
supported formats:
vector weaponentity_glowmod(Weapon wep, int c, entity wepent)
entity exteriorweaponentity
#define WEP_CVAR(wep, name)
#define WepSet_FromWeapon(it)
const int MAX_WEAPONSLOTS
const int WEP_FLAG_RELOADABLE
const int WS_READY
idle frame
const int WEP_TYPE_MELEE_PRI
entity weaponentities[MAX_WEAPONSLOTS]
const int WS_CLEAR
no weapon selected
const int WS_RAISE
raise frame
const int WS_INUSE
fire state
const int WEP_FLAG_DUALWIELD
const int WEP_TYPE_MELEE_SEC
int weaponslot(.entity weaponentity)
const int WS_DROP
deselecting frame
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)
float W_WeaponSpeedFactor(entity this)
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
void CL_Weaponentity_Think(entity this)
bool weaponUseForbidden(entity player)
vector CL_Weapon_GetShotOrg(int wpn)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
void w_clear(Weapon thiswep, entity actor,.entity weaponentity, int fire)
void W_AttachToShotorg(entity actor,.entity weaponentity, entity flash, vector offset)
void weapon_prepareattack_do(entity actor,.entity weaponentity, bool secondary, float attacktime)
void W_DropEvent(.void(Weapon, entity actor,.entity) event, entity player, int weapon_type, entity weapon_item,.entity weaponentity)
void W_WeaponFrame(Player actor,.entity weaponentity)
void W_ReloadedAndReady(Weapon thiswep, entity actor,.entity weaponentity, int fire)
Finish the reloading process, and do the ammo transfer.
float W_WeaponRateFactor(entity this)
void CL_SpawnWeaponentity(entity actor,.entity weaponentity)
Spawn weaponentity for client.
bool weapon_prepareattack_check(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary,.entity weaponentity)
bool weaponLocked(entity player)
void CL_ExteriorWeaponentity_Think(entity this)
void W_ResetGunAlign(entity player, int preferred_alignment)
bool CL_Weaponentity_CustomizeEntityForClient(entity this, entity client)
entity weapon_dropevent_item
float autocvar_g_weaponspeedfactor
#define ATTACK_FINISHED(ent, w)
float autocvar_g_weaponratefactor
float weapon_load[REGISTRY_MAX(Weapons)]
#define INDEPENDENT_ATTACK_FINISHED
void wepent_link(entity wep)
float default_weapon_alpha
float default_player_alpha
bool sv_ready_restart_after_countdown