67 CL_WeaponEntity_SetModel(e, wi.mdl,
false);
69 CL_WeaponEntity_SetModel(e,
"",
false);
82 if (game_stopped) this.
frame = this.anim_idle.x;
84 if (this.
owner.(weaponentity) !=
this)
87 if (this.weaponchild)
delete(this.weaponchild);
96 if (this.weaponchild) this.weaponchild.model =
"";
106 CL_WeaponEntity_SetModel(
this, this.weaponname,
true);
115 if (this.weaponchild)
117 this.weaponchild.alpha = this.
alpha;
118 this.weaponchild.effects = this.
effects;
127 if (this.
owner.exteriorweaponentity !=
this)
137 if (this.weaponname != w_ent.weaponname ||
this.dmg != w_ent.modelindex ||
this.deadflag != w_ent.deadflag)
139 this.weaponname = w_ent.weaponname;
140 this.
dmg = w_ent.modelindex;
142 if (w_ent.weaponname !=
"")
144 _setmodel(
this,
W_Model(
strcat(
"v_", w_ent.weaponname,
".md3")));
145 setsize(
this,
'0 0 0',
'0 0 0');
147 else this.
model =
"";
157 setattachment(
this, this.
owner,
"bip01 r hand");
168 if (wep) this.
glowmod = weaponentity_glowmod(wep, this.
owner, this.
owner.clientcolors,
this.owner.(weaponentity));
170 this.
skin = w_ent.skin;
172 CSQCMODEL_AUTOUPDATE(
this);
178 entity w_ent = actor.(weaponentity) =
new(weaponentity);
183 w_ent.weaponentity_fld = weaponentity;
185 w_ent.nextthink =
time;
186 w_ent.viewmodelforclient = actor;
194 entity exterior = actor.exteriorweaponentity =
new(exteriorweaponentity);
196 exterior.owner = actor;
198 exterior.weaponentity_fld = weaponentity;
201 exterior.nextthink =
time;
203 CSQCMODEL_AUTOINIT(exterior);
210 entity w_ent = actor.(weaponentity);
213 w_ent.m_weapon = WEP_Null;
214 w_ent.m_switchingweapon = WEP_Null;
222 entity w_ent = actor.(weaponentity);
231 if ((actor.items & IT_UNLIMITED_AMMO))
return true;
233 if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
234 else ammo = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
235 if (ammo)
return true;
237 if (thiswep == WEP_MINE_LAYER)
239 IL_EACH(g_mines, it.owner == actor && it.weaponentity_fld == weaponentity,
245 if (thiswep == WEP_SHOTGUN)
246 if (!secondary &&
WEP_CVAR(shotgun, secondary) == 1)
return false;
248 if (thiswep == actor.(weaponentity).m_switchweapon &&
time - actor.prevdryfire > 1)
251 actor.prevdryfire =
time;
255 bool ammo_other =
false;
256 if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
257 else ammo_other = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
260 if (
time - actor.prevwarntime > 1)
261 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_WEAPON_PRIMORSEC, thiswep.
m_id, secondary, (1 - secondary));
262 actor.prevwarntime =
time;
275 if (actor.weaponentity ==
NULL)
return true;
280 if (
time < game_starttime ||
time < actor.race_penalty)
return false;
286 if (actor.(weaponentity).m_switchweapon != actor.(weaponentity).m_weapon)
return false;
292 entity this = actor.(weaponentity);
301 entity this = actor.(weaponentity);
302 if (
this ==
NULL)
return;
305 if(StatusEffects_active(STATUSEFFECT_SpawnShield, actor))
327 if(actor.(wepent) && actor.(wepent).m_weapon != WEP_Null)
357 .
entity weaponentity,
int fire) func)
359 entity this = actor.(weaponentity);
360 if (
this ==
NULL)
return;
362 if (fr == WFRAME_DONTCHANGE)
365 if (this.wframe == WFRAME_DONTCHANGE)
366 this.wframe = WFRAME_IDLE;
372 restartanim = fr != WFRAME_IDLE;
378 backtrace(
"Tried to override initial weapon think function - should this really happen?");
383 if (this.weapon_think ==
w_ready)
389 if (this.weapon_nextthink < time - w_frametime_limit || this.weapon_nextthink >
time + w_frametime_limit)
395 this.weapon_think = func;
401 if(it == actor || (
IS_SPEC(it) && it.enemy == actor))
406 if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
415 actor.anim_upper_action = 0;
429 if (player.player_blocked)
return true;
430 if (game_stopped)
return true;
431 if (STAT(FROZEN, player))
return true;
439 preferred_alignment = 3;
445 if (player.(weaponentity))
446 player.(weaponentity).m_gunalign = 0;
453 if (player.(weaponentity))
454 player.(weaponentity).m_gunalign =
W_GunAlign(player.(weaponentity), preferred_alignment);
464 entity this = actor.(weaponentity);
473 button_atck = button_atck2 = 0;
479 Weapon wpn = this.m_weapon;
480 w_ready(wpn, actor, weaponentity, button_atck | (button_atck2 << 1));
488 entity wep1 = actor.(wepe1);
489 this.m_switchweapon = wep1.m_switchweapon;
491 if(!(this.m_switchweapon.spawnflags &
WEP_FLAG_DUALWIELD) && !(store.dual_weapons & wep1.m_switchweapon.m_wepset))
493 this.m_weapon = WEP_Null;
494 this.m_switchingweapon = WEP_Null;
495 this.m_switchweapon = WEP_Null;
497 this.weaponname =
"";
503 if (this.m_switchweapon == WEP_Null)
506 w_ready(this.m_weapon, actor, weaponentity, button_atck | (button_atck2 << 1));
507 this.m_weapon = WEP_Null;
508 this.m_switchingweapon = WEP_Null;
510 this.weaponname =
"";
516 MAKE_VECTORS(actor.
v_angle, fo, ri, up);
519 if (this.m_weapon != this.m_switchweapon)
524 LOG_WARNF(
"unhandled weaponentity (%i) state for player (%i): %d",
this, actor, this.
state);
532 Weapon newwep = this.m_switchweapon;
533 this.m_switchingweapon = newwep;
536 this.m_weapon = newwep;
537 this.weaponname = newwep.
mdl;
539 newwep.wr_setup(newwep, actor, weaponentity);
559 this.m_switchingweapon = this.m_switchweapon;
565 this.m_switchingweapon = this.m_switchweapon;
566 entity oldwep = this.m_weapon;
593 if (this.m_weapon == this.m_switchweapon)
602 bool block_weapon =
false;
608 Weapon off = actor.offhand;
611 if (off.offhand_think) off.offhand_think(off, actor, key_pressed);
615 if (key_pressed && this.m_switchweapon != WEP_HOOK && !actor.hook_switchweapon)
617 actor.hook_switchweapon = key_pressed;
619 block_weapon = (this.m_weapon == h && (button_atck || key_pressed));
620 h.wr_think(h, actor, weaponentity, block_weapon ? 1 : 0);
634 e.wr_think(e, actor, weaponentity, button_atck | (button_atck2 << 1));
638 e.wr_gonethink(e, actor, weaponentity);
644 if (this.weapon_think)
649 Weapon wpn = this.m_weapon;
650 this.weapon_think(wpn, actor, weaponentity, button_atck | (button_atck2 << 1));
654 bprint(
"\{1}^1ERROR: undefined weapon think function for ", actor.
netname,
"\n");
663 flash.angles_z =
random() * 360;
665 entity w_ent = actor.(weaponentity);
666 entity exterior = actor.exteriorweaponentity;
668 if (
gettagindex(w_ent,
"shot")) setattachment(flash, w_ent,
"shot");
669 else setattachment(flash, w_ent,
"tag_shot");
675 flash.viewmodelforclient = actor;
677 if (w_ent.oldorigin.x > 0)
679 setattachment(xflash, exterior,
"");
680 setorigin(xflash, w_ent.oldorigin + offset);
684 if (
gettagindex(exterior,
"shot")) setattachment(xflash, exterior,
"shot");
685 else setattachment(xflash, exterior,
"tag_shot");
693 if ((actor.items & IT_UNLIMITED_AMMO) && !wep.reloading_ammo)
return;
695 ammo_use =
M_ARGV(2,
float);
697 entity w_ent = actor.(weaponentity);
700 if (wep.reloading_ammo)
702 w_ent.clip_load -= ammo_use;
703 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",
729 entity w_ent = actor.(weaponentity);
730 Weapon wpn = w_ent.m_weapon;
732 w_ent.clip_load = w_ent.old_clip_load;
735 if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_AMMO) || wpn.ammo_type == RES_NONE)
737 w_ent.clip_load = w_ent.reload_ammo_amount;
743 float load =
min(w_ent.reload_ammo_amount - w_ent.clip_load, ammo);
744 w_ent.clip_load += load;
747 w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load;
762 entity this = actor.(weaponentity);
767 this.reload_ammo_min = sent_ammo_min;
769 this.reload_time = e.reloading_time;
776 "Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");
787 if (e.ammo_type != RES_NONE)
789 if (!
GetResource(actor, e.ammo_type) &&
this.reload_ammo_min)
791 if (!(actor.items & IT_UNLIMITED_AMMO))
797 play2(actor,
SND(UNAVAILABLE));
798 sprint(actor,
strcat(
"You don't have enough ammo to reload the ^2", this.m_weapon.m_name,
"\n"));
799 actor.reload_complain =
time + 1;
802 if (!(e.wr_checkammo1(e, actor, weaponentity) + e.wr_checkammo2(e, actor, weaponentity)))
813 if (this.wframe == WFRAME_RELOAD)
return;
840 w.event(w, player, weaponentity);
#define PHYS_INPUT_BUTTON_ATCK2(s)
#define round_handler_IsActive()
#define IL_EACH(this, cond, body)
float weapon_load[REGISTRY_MAX(Weapons)]
string W_Model(string w_mdl)
void W_AttachToShotorg(entity actor,.entity weaponentity, entity flash, vector offset)
const int WEP_FLAG_RELOADABLE
float autocvar_g_weaponratefactor
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
const int WS_RAISE
raise frame
#define PHYS_INPUT_BUTTON_HOOK(s)
void W_WeaponFrame(Player actor,.entity weaponentity)
string GetAmmoPicture(Resource ammotype)
Header file that describes the resource system.
void W_SwitchToOtherWeapon(entity this,.entity weaponentity)
bool weaponUseForbidden(entity player)
#define w_getbestweapon(ent, wepent)
#define Sound_fixpath(this)
const int WS_CLEAR
no weapon selected
void CL_ExteriorWeaponentity_Think(entity this)
#define REGISTRY_GET(id, i)
#define FOREACH_CLIENT(cond, body)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
void W_ReloadedAndReady(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define WEP_CVAR(wepname, name)
void W_ResetGunAlign(entity player, int preferred_alignment)
bool weapon_prepareattack_check(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
const float TIMEOUT_ACTIVE
const int WS_DROP
deselecting frame
int W_GunAlign(entity this, int preferred_align)
#define round_handler_IsRoundStarted()
const int WS_READY
idle frame
#define IS_REAL_CLIENT(v)
int weaponslot(.entity weaponentity)
#define INDEPENDENT_ATTACK_FINISHED
string netname
M: refname : reference name name.
void W_DropEvent(.void(Weapon, entity actor,.entity) event, entity player, float weapon_type, entity weapon_item,.entity weaponentity)
#define setmodel(this, m)
int spawnflags
M: flags : WEPSPAWNFLAG_...
bool weaponLocked(entity player)
Effect is being forcibly removed without calling any additional mechanics.
void CL_Weaponentity_Think(entity this)
bool autocvar_g_weaponswitch_debug
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
bool W_DualWielding(entity player)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
const int MAX_WEAPONSLOTS
Resource ammo_type
M: ammotype : main ammo type.
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
const int CH_WEAPON_SINGLE
entity viewmodelforclient
void animdecide_setaction(entity e, float action, float restart)
const int WEP_TYPE_MELEE_SEC
entity weapon_dropevent_item
#define PHYS_INPUT_BUTTON_ATCK(s)
const int ANIMACTION_SHOOT
vector CL_Weapon_GetShotOrg(int wpn)
Purpose: common player state, usable on client and server Client: singleton representing the viewed p...
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int WS_INUSE
fire state
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
float W_WeaponSpeedFactor(entity this)
void CL_SpawnWeaponentity(entity actor,.entity weaponentity)
bool sv_ready_restart_after_countdown
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
#define _sound(e, c, s, v, a)
bool W_SwitchWeapon(entity this, Weapon w,.entity weaponentity)
float autocvar_g_weaponspeedfactor
#define MUTATOR_CALLHOOK(id,...)
bool drag_undraggable(entity draggee, entity dragger)
bool CL_Weaponentity_CustomizeEntityForClient(entity this, entity client)
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
entity weaponentities[MAX_WEAPONSLOTS]
void w_clear(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define ATTACK_FINISHED(ent, w)
const int ANIMACTION_MELEE
float default_player_alpha
void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use,.entity weaponentity)
#define WepSet_FromWeapon(it)
#define sound(e, c, s, v, a)
const int WEP_FLAG_DUALWIELD
void weapon_prepareattack_do(entity actor,.entity weaponentity, bool secondary, float attacktime)
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
bool autocvar_g_weaponswitch_debug_alternate
string netname
Client name.
float default_weapon_alpha
string mdl
M: modelname : name of model (without g_ v_ or h_ prefixes)
float W_WeaponRateFactor(entity this)
const int WEP_TYPE_MELEE_PRI
void W_Reload(entity actor,.entity weaponentity, float sent_ammo_min, Sound sent_sound)
bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary,.entity weaponentity)