62 return '0 0 1' *
BIT(a);
64 return '0 1 0' *
BIT(a);
66 return '1 0 0' *
BIT(a);
76 WriteInt24_t(dst, w.x);
86 return STAT(WEAPONSINMAP);
121 if (s ==
"0" ||
stof(s))
123 FOREACH(
Weapons, it != WEP_Null && (it.netname == s || it.m_deprecated_netname == s),
return ftos(i));
149 return strstrofs(s, sprintf(
" %d ", si), 0)
181 for (
int j = 0; j < n; ++j)
186 if (remaining & (it.m_wepset))
199 LOG_WARNF(
"Invalid ammo type %d ", ammotype.m_id);
205 FOREACH(Resources, it.netname == ammotype.netname,
return it);
220 case RES_FUEL:
return STAT_FUEL.m_id;
228 string output =
strcat(
"weapons/", w_snd);
235 string output =
strcat(
"models/weapons/", w_mdl);
265 else if (
STAT(SHOOTFROMEYE))
267 else if (
STAT(SHOOTFROMCENTER))
348 setsize(
this, oldmin, oldmax);
402 setsize(
this,
'0 0 0',
'0 0 0');
403 setorigin(
this,
'0 0 0');
420 LOG_WARNF(
"weapon model %s does not support the 'shot' tag, will display shots TOTALLY wrong",
436 LOG_WARNF(
"weapon model %s does not support the 'shell' tag, will display casings wrong",
456 "weapon model %s does not support the 'handle' tag "
457 "and neither does the v_ model support the 'shot' tag, "
458 "will display muzzle flashes TOTALLY wrong\n",
496 STAT(SHOTORG, this.
owner) = compressed_shotorg;
526 this.
wframe = WFRAME_IDLE;
542 if (fr == WFRAME_IDLE)
543 wepent.animstate_looping =
false;
550 case WFRAME_IDLE: a = wepent.anim_idle;
break;
551 case WFRAME_FIRE1: a = wepent.anim_fire1;
break;
552 case WFRAME_FIRE2: a = wepent.anim_fire2;
break;
553 case WFRAME_RELOAD: a = wepent.anim_reload;
break;
556 anim_set(wepent, a, !restartanim, restartanim, restartanim);
560 switch (wepent.state)
563 wepent.weapon_switchdelay = wepent.switchweapon.switchdelay_raise;
566 wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_drop;
569 wepent.weapon_switchdelay = 0;
585 WriteFloat(channel, attackrate);
589 WriteFloat(channel, weaponentity.weapon_nextthink);
604void w_whereis(
Weapon this)
606 int channel = MSG_C2S;
636 LOG_HELP(
"Usage:^3 cl_cmd weapon_find <weapon>");
637 LOG_HELP(
" Where <weapon> is the lowercase weapon name, 'all' or 'unowned'.");
647 flash.angles.z =
random() * 360;
649 entity view = actor.(weaponentity);
650 entity exterior = actor.exteriorweaponentity;
652 if (view.oldorigin.x > 0)
654 setattachment(flash, exterior,
"");
655 setorigin(flash, view.oldorigin + offset);
659 setattachment(flash, exterior, (
gettagindex(exterior,
"shot") ?
"shot" :
"tag_shot"));
660 setorigin(flash, offset);
666 flash.owner = wepent;
667 flash.angles.z =
random() * 360;
669 setattachment(flash, wepent, (
gettagindex(wepent,
"shot")) ?
"shot" :
"tag_shot");
670 setorigin(flash, offset);
692 if (wepent.muzzle_flash ==
NULL)
693 wepent.muzzle_flash =
spawn();
695 entity flash = wepent.muzzle_flash;
700 flash.nextthink =
time + 0.02;
703 flash.angles.z =
random() * 180;
705 flash.owner = flash.realowner = wepent;
731 if (!IS_REAL_CLIENT(it))
733 int channel = MSG_ONE;
735 WriteHeader(channel, w_muzzleflash);
736 WriteRegistered(Weapons, channel, thiswep);
737 WriteByte(channel, weaponslot(weaponentity));
738 WriteVector(channel, shotorg);
751 vector forward, right, up;
758 pointparticles(thiswep.m_muzzleeffect, sv_shotorg, forward * 1000, 1);
770 vector md = wepent.movedir_aligned;
771 vector dv = forward * md.x + right * -md.y + up * md.z;
772 vector org = rlplayer.origin + rlplayer.view_ofs + dv;
799REPLICATE(cvar_cl_accuracy_data_share,
bool,
"cl_accuracy_data_share");
800REPLICATE(cvar_cl_accuracy_data_receive,
bool,
"cl_accuracy_data_receive");
805REPLICATE(cvar_cl_weapon_switch_reload,
bool,
"cl_weapon_switch_reload");
806REPLICATE(cvar_cl_weapon_switch_fallback_to_impulse,
bool,
"cl_weapon_switch_fallback_to_impulse");
807REPLICATE(cvar_cl_weaponimpulsemode,
int,
"cl_weaponimpulsemode");
826 string command, key, keys =
"";
829 const bool joy_active =
cvar(
"joy_active");
831 for (
int cmd_type = 0; cmd_type < 2; ++cmd_type)
836 n =
tokenize(findkeysforcommand(command, 0));
838 for (j = 0; j < n; ++j)
851 keys =
strcat(keys,
"^7, ^3", key);
856 return _(
"This weapon has not been bound directly.");
857 return sprintf(_(
"You have bound this weapon to: %s."),
strcat(keys,
"^7"));
861#define COLORED_DAMAGE(dmg) strcat("^9", dmg, "^7")
863#define DPS_ONE(mode) sprintf(_("(DPS: %.2f)"), mode##rft <= 0 ? 1337 : stof(mode##dmg_s) / mode##rft)
864#define DPS_MUL(mode) sprintf(_("(DPS: %.2f)"), mode##rft <= 0 ? 1337 : stof(mode##dmg_s) / mode##rft * stof(mode##shots_s))
866#define pri_str _("primary")
867#define sec_str _("secondary")
868#define _IT_DOES_MSG() strcat("\n* ", sprintf(_("It does %s damage"), COLORED_DAMAGE(dmg_s)), " ", DPS_ONE())
869#define _IT_SHOOTS_MSG() strcat("\n* ", sprintf(_("It shoots %s shots doing %s damage each"), shots_s, COLORED_DAMAGE(dmg_s)), " ", DPS_MUL())
870#define _DOES_MSG(mode) strcat("\n* ", sprintf(_("The %s does %s damage"), mode##str, COLORED_DAMAGE(mode##dmg_s)), " ", DPS_ONE(mode))
871#define _DOES_PERSEC_MSG(mode) strcat("\n* ", sprintf(_("The %s does %s damage per second"), mode##str, COLORED_DAMAGE(mode##dmg_s)))
872#define _SHOOTS_MSG(mode) strcat("\n* ", sprintf(_("The %s shoots %s shots doing %s damage each"), mode##str, mode##shots_s, COLORED_DAMAGE(mode##dmg_s)), " ", DPS_MUL(mode))
873#define _SHOOTS_UPTO_MSG(mode) strcat("\n* ", sprintf(_("The %s shoots up to %s shots doing %s damage each"), mode##str, mode##shots_s, COLORED_DAMAGE(mode##dmg_s)), " ", DPS_MUL(mode))
876#define IT_DOES() _IT_DOES_MSG()
877#define IT_SHOOTS() _IT_SHOOTS_MSG()
878#define THE_PRIMARY_DOES() _DOES_MSG(pri_)
879#define THE_PRIMARY_SHOOTS() _SHOOTS_MSG(pri_)
880#define THE_PRIMARY_SHOOTS_UPTO() _SHOOTS_UPTO_MSG(pri_)
881#define THE_PRIMARY_DOES_PERSEC() _DOES_PERSEC_MSG(pri_)
882#define THE_SECONDARY_DOES() _DOES_MSG(sec_)
883#define THE_SECONDARY_SHOOTS() _SHOOTS_MSG(sec_)
884#define THE_SECONDARY_SHOOTS_UPTO() _SHOOTS_UPTO_MSG(sec_)
885#define THE_SECONDARY_DOES_PERSEC() _DOES_PERSEC_MSG(sec_)
891 const string wepbal_s =
strcat(
"g_balance_",
name);
895 const string dir_dps = sprintf(_(
"(DPS: %.2f)"), rft <= 0 ? 1337 :
stof(dmg2_s) / rft);
896 return strcat(_(
"Default damage stats:"),
903 const string wepbal_s =
strcat(
"g_balance_",
name);
906 return strcat(_(
"Default damage stats:"),
922 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
927 return strcat(_(
"Default damage stats:"),
934 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
941 return strcat(_(
"Default damage stats:"),
948 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
951 return strcat(_(
"Default damage stats:"),
957 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
964 sec_dmg_s = pri_dmg_s;
965 const float num_shots =
stof(sec_shots_s);
968 return strcat(_(
"Default damage stats:"),
975 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
981 const float num_shots =
stof(pri_shots_s);
984 return strcat(_(
"Default damage stats:"),
991 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
995 const float num_shots =
stof(shots_s);
998 return strcat(_(
"Default damage stats:"),
1004 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
1011 const float num_shots =
stof(sec_shots_s);
1012 float combo_t =
max(pri_rft, sec_rft);
1015 const float sec_rft2 = sec_rft;
1017 combo_t =
max(combo_t, num_shots * sec_rft + sec_rft2);
1018 sec_rft = (num_shots - 1) * sec_rft + sec_rft2;
1020 const string DPS_combo = sprintf(_(
"(total DPS: %.2f)"),
1021 combo_t <= 0 ? 1337 : (
stof(pri_dmg_s) +
stof(sec_dmg_s) * num_shots +
stof(cmb_dmg_s)) / combo_t);
1022 return strcat(_(
"Default damage stats:"),
1025 strcat(
"\n* ", sprintf(_(
"The combo adds an extra %s damage"),
COLORED_DAMAGE(cmb_dmg_s)),
" ", DPS_combo)
1030 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
1034 return strcat(_(
"Default damage stats:"),
void anim_set(entity e, vector anim, bool looping, bool override, bool restart)
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
#define MUTATOR_CALLHOOK(id,...)
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
int W_GunAlign(entity this, int preferred_align)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define CLIENT_COMMAND(id, description)
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
int impulse
M: impulse : weapon impulse.
string netname
M: refname : reference name name.
entity m_muzzlemodel
M: flash model MDL_id_MUZZLEFLASH.
const int CMD_REQUEST_COMMAND
const int CMD_REQUEST_USAGE
#define setmodel(this, m)
string fixPriorityList(string order, float from, float to, float subtract, float complete)
float compressShotOrigin(vector v)
string translate_key(string key)
string mapPriorityList(string order, string(string) mapfunc)
vector decompressShotOrigin(int f)
const float VF_CL_VIEWANGLES
const float EF_FULLBRIGHT
void SUB_Remove(entity this)
Remove entity.
#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 pointparticles(effect, org, vel, howmany)
#define pass(name, colormin, colormax)
void Send_Effect_Except(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, vector eff_col_min, vector eff_col_max, entity ignore)
entity CSQCModel_server2csqc(int i)
Header file that describes the functions related to game items.
#define FOREACH(list, cond, body)
#define NET_HANDLE(id, param)
#define ReadRegistered(r)
#define WriteHeader(to, id)
#define REGISTER_NET_C2S(id)
#define WriteRegistered(r, to, it)
#define REGISTER_NET_TEMP(id)
#define REPLICATE(...)
Replicates a client cvar into a server field.
vector animfixfps(entity e, vector a, vector b)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
ERASEABLE void RandomSelection_Init()
#define RandomSelection_AddEnt(e, weight, priority)
entity RandomSelection_chosen_ent
#define REGISTRY_GET(id, i)
string weaponorder_byimpulse
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
#define startsWith(haystack, needle)
#define IS_REAL_CLIENT(v)
#define FOREACH_CLIENT(cond, body)
int autocvar_chase_active
bool autocvar_r_drawviewmodel
entity viewmodels[MAX_WEAPONSLOTS]
string W_FixWeaponOrder_ForceComplete(string order)
string W_FixWeaponOrder_AllowIncomplete(entity this, string order)
vector shotorg_adjustfromclient(vector vecs, float y_is_right, float algn)
void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim)
string W_Model(string w_mdl)
string W_Guide_Keybinds(Weapon wep)
#define COLORED_DAMAGE(dmg)
string W_Guide_DPS_primaryMultishot(string name, string pri, string sec, string shots, string refire2)
void CL_WeaponEntity_SetModel(entity this, string name, bool _anim)
supported formats:
WepSet WepSet_GetFromStat_InMap()
string W_Guide_DPS_secondaryMultishot(string name, string pri, string sec, string shots, string refire2, bool sec_variable)
void WriteWepSet(float dst, WepSet w)
int GetAmmoStat(Resource ammotype)
void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
entity GetAmmoResource(Ammo ammotype)
float W_FixWeaponOrder_BuildImpulseList_buf[REGISTRY_MAX(Weapons)]
void W_MuzzleFlash_Model_Think(entity this)
float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
string W_NumberWeaponOrder(string order)
string W_FixWeaponOrder_BuildImpulseList(string o)
string W_Guide_DPS(string name, string pri, string sec)
#define THE_SECONDARY_DOES()
string W_NumberWeaponOrder_MapFunc(string s)
string W_Sound(string w_snd)
string W_Guide_DPS_bothMultishot(string name, string pri, string sec)
string W_NameWeaponOrder(string order)
string W_Guide_DPS_onlySecondary(string name, string sec)
void Weapon_whereis(Weapon this, entity cl)
void W_MuzzleFlash_Model(entity wepent, entity muzzlemodel)
string W_Guide_DPS_onlyOne_andDirectHit(string name, string fire)
void W_MuzzleFlash(Weapon thiswep, entity actor,.entity weaponentity, vector shotorg, vector shotdir)
#define THE_SECONDARY_SHOOTS_UPTO()
string W_NameWeaponOrder_MapFunc(string s)
string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo)
string W_Guide_DPS_secondaryMultishotWithCombo(string name, string pri, string sec, string shots, string refire2, string combo, bool sec_variable)
#define THE_PRIMARY_SHOOTS()
WepSet WepSet_GetFromStat()
string W_Guide_DPS_onlyOneMultishot(string name, string fire, string shots, string refire2)
WepSet _WepSet_FromWeapon(int a)
#define THE_PRIMARY_DOES_PERSEC()
string W_Guide_DPS_onlyOne_unnamed(string name)
void W_MuzzleFlash_Model_AttachToShotorg(entity actor,.entity weaponentity, entity flash, vector offset)
string W_FixWeaponOrder(string order, float complete)
string W_Guide_DPS_onlyOne(string name, string fire)
string W_Guide_DPS_primaryDPS(string name, string pri, string sec)
string W_FixWeaponOrder_BuildImpulseList_order
entity GetAmmoItem(Resource ammotype)
#define THE_SECONDARY_SHOOTS()
vector shotorg_adjust(vector vecs, bool y_is_right, bool visual, int algn)
string W_Guide_DPS_onlyOne_unnamed_andDirectHit(string name)
WepSet W_RandomWeapons(entity e, WepSet remaining, int n)
#define THE_PRIMARY_DOES()
#define G_SHOOTFROMFIXEDORIGIN
#define WEP_IMPULSE_BEGIN
#define WepSet_FromWeapon(it)
const int WS_RAISE
raise frame
int weaponslot(.entity weaponentity)
const int WS_DROP
deselecting frame