64 return '0 0 1' *
BIT(a);
66 return '0 1 0' *
BIT(a);
68 return '1 0 0' *
BIT(a);
75 else WriteInt24_t(dst, w.x);
85 return STAT(WEAPONSINMAP);
105 if (wi != WEP_Null)
return wi.netname;
116 if (s ==
"0" ||
stof(s))
return s;
117 FOREACH(
Weapons, it != WEP_Null && (it.netname == s || it.m_deprecated_netname == s),
return ftos(i));
141 if (d != 0)
return -d;
143 return strstrofs(s, sprintf(
" %d ", si), 0)
175 for (
int j = 0; j < n; ++j)
179 if (remaining & (it.m_wepset))
195 LOG_WARNF(
"Invalid ammo type %d ", ammotype.m_id);
201 FOREACH(Resources, it.netname == ammotype.netname,
219 case RES_FUEL:
return STAT_FUEL.m_id;
227 string output =
strcat(
"weapons/", w_snd);
234 string output =
strcat(
"models/weapons/", w_mdl);
269 else if (
STAT(SHOOTFROMEYE))
273 else if (
STAT(SHOOTFROMCENTER))
281 if (y_is_right) v.y = -v.y;
282 if (v.x != 0) vecs.x = v.x;
353 setsize(
this, oldmin, oldmax);
404 setsize(
this,
'0 0 0',
'0 0 0');
405 setorigin(
this,
'0 0 0');
426 LOG_WARNF(
"weapon model %s does not support the 'shot' tag, will display shots TOTALLY wrong",
446 LOG_WARNF(
"weapon model %s does not support the 'shell' tag, will display casings wrong",
470 "weapon model %s does not support the 'handle' tag "
471 "and neither does the v_ model support the 'shot' tag, "
472 "will display muzzle flashes TOTALLY wrong\n",
537 this.
wframe = WFRAME_IDLE;
553 if(fr == WFRAME_IDLE)
554 wepent.animstate_looping =
false;
561 case WFRAME_IDLE: a = wepent.anim_idle;
break;
562 case WFRAME_FIRE1: a = wepent.anim_fire1;
break;
563 case WFRAME_FIRE2: a = wepent.anim_fire2;
break;
564 case WFRAME_RELOAD: a = wepent.anim_reload;
break;
567 anim_set(wepent, a, !restartanim, restartanim, restartanim);
571 switch (wepent.state)
574 wepent.weapon_switchdelay = wepent.switchweapon.switchdelay_raise;
577 wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_drop;
580 wepent.weapon_switchdelay = 0;
595 WriteFloat(channel, attackrate);
599 WriteFloat(channel, weaponentity.weapon_nextthink);
613void w_whereis(
Weapon this)
646 LOG_HELP(
"Usage:^3 cl_cmd weapon_find <weapon>");
647 LOG_HELP(
" Where <weapon> is the lowercase weapon name, 'all' or 'unowned'.");
658 flash.angles_z =
random() * 360;
660 entity view = actor.(weaponentity);
661 entity exterior = actor.exteriorweaponentity;
663 if (view.oldorigin.x > 0)
665 setattachment(flash, exterior,
"");
666 setorigin(flash, view.oldorigin + offset);
670 if (
gettagindex(exterior,
"shot")) setattachment(flash, exterior,
"shot");
671 else setattachment(flash, exterior,
"tag_shot");
672 setorigin(flash, offset);
678 flash.owner = wepent;
679 flash.angles_z =
random() * 360;
681 if (
gettagindex(wepent,
"shot")) setattachment(flash, wepent,
"shot");
682 else setattachment(flash, wepent,
"tag_shot");
683 setorigin(flash, offset);
705 if(wepent.muzzle_flash ==
NULL)
706 wepent.muzzle_flash =
spawn();
708 entity flash = wepent.muzzle_flash;
713 flash.nextthink =
time + 0.02;
716 flash.angles_z =
random() * 180;
718 flash.owner = flash.realowner = wepent;
744 if(!IS_REAL_CLIENT(it))
746 int channel = MSG_ONE;
748 WriteHeader(channel, w_muzzleflash);
749 WriteByte(channel, thiswep.m_id);
750 WriteByte(channel, weaponslot(weaponentity));
751 WriteVector(channel, shotorg);
764 vector forward, right, up;
771 pointparticles(thiswep.m_muzzleeffect, sv_shotorg, forward * 1000, 1);
782 vector md = wepent.movedir_aligned;
783 vector dv = forward * md.x + right * -md.y + up * md.z;
784 vector org = rlplayer.origin + rlplayer.view_ofs + dv;
811REPLICATE(cvar_cl_accuracy_data_share,
bool,
"cl_accuracy_data_share");
812REPLICATE(cvar_cl_accuracy_data_receive,
bool,
"cl_accuracy_data_receive");
817REPLICATE(cvar_cl_weapon_switch_reload,
bool,
"cl_weapon_switch_reload");
818REPLICATE(cvar_cl_weapon_switch_fallback_to_impulse,
bool,
"cl_weapon_switch_fallback_to_impulse");
819REPLICATE(cvar_cl_weaponimpulsemode,
int,
"cl_weaponimpulsemode");
838 string command, key, keys =
"";
841 const bool joy_active =
cvar(
"joy_active");
843 for (
int cmd_type = 0; cmd_type < 2; ++cmd_type)
848 n =
tokenize(findkeysforcommand(command, 0));
850 for (j = 0; j < n; ++j)
863 keys =
strcat(keys,
"^7, ^3", key);
868 return _(
"This weapon has not been bound directly.");
869 return sprintf(_(
"You have bound this weapon to: %s."),
strcat(keys,
"^7"));
873#define COLORED_DAMAGE(dmg) strcat("^9", dmg, "^7")
875#define DPS_ONE(mode) sprintf(_("(DPS: %.2f)"), mode##rft <= 0 ? 1337 : stof(mode##dmg_s) / mode##rft)
876#define DPS_MUL(mode) sprintf(_("(DPS: %.2f)"), mode##rft <= 0 ? 1337 : stof(mode##dmg_s) / mode##rft * stof(mode##shots_s))
878#define pri_str _("primary")
879#define sec_str _("secondary")
880#define _IT_DOES_MSG() strcat("\n* ", sprintf(_("It does %s damage"), COLORED_DAMAGE(dmg_s)), " ", DPS_ONE())
881#define _IT_SHOOTS_MSG() strcat("\n* ", sprintf(_("It shoots %s shots doing %s damage each"), shots_s, COLORED_DAMAGE(dmg_s)), " ", DPS_MUL())
882#define _DOES_MSG(mode) strcat("\n* ", sprintf(_("The %s does %s damage"), mode##str, COLORED_DAMAGE(mode##dmg_s)), " ", DPS_ONE(mode))
883#define _DOES_PERSEC_MSG(mode) strcat("\n* ", sprintf(_("The %s does %s damage per second"), mode##str, COLORED_DAMAGE(mode##dmg_s)))
884#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))
885#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))
888#define IT_DOES() _IT_DOES_MSG()
889#define IT_SHOOTS() _IT_SHOOTS_MSG()
890#define THE_PRIMARY_DOES() _DOES_MSG(pri_)
891#define THE_PRIMARY_SHOOTS() _SHOOTS_MSG(pri_)
892#define THE_PRIMARY_SHOOTS_UPTO() _SHOOTS_UPTO_MSG(pri_)
893#define THE_PRIMARY_DOES_PERSEC() _DOES_PERSEC_MSG(pri_)
894#define THE_SECONDARY_DOES() _DOES_MSG(sec_)
895#define THE_SECONDARY_SHOOTS() _SHOOTS_MSG(sec_)
896#define THE_SECONDARY_SHOOTS_UPTO() _SHOOTS_UPTO_MSG(sec_)
897#define THE_SECONDARY_DOES_PERSEC() _DOES_PERSEC_MSG(sec_)
903 const string wepbal_s =
strcat(
"g_balance_",
name);
907 const string dir_dps = sprintf(_(
"(DPS: %.2f)"), rft <= 0 ? 1337 :
stof(dmg2_s) / rft);
908 return strcat(_(
"Default damage stats:"),
915 const string wepbal_s =
strcat(
"g_balance_",
name);
918 return strcat(_(
"Default damage stats:"),
934 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
939 return strcat(_(
"Default damage stats:"),
946 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
953 return strcat(_(
"Default damage stats:"),
960 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
963 return strcat(_(
"Default damage stats:"),
969 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
976 sec_dmg_s = pri_dmg_s;
977 const float num_shots =
stof(sec_shots_s);
980 return strcat(_(
"Default damage stats:"),
987 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
993 const float num_shots =
stof(pri_shots_s);
996 return strcat(_(
"Default damage stats:"),
1003 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
1007 const float num_shots =
stof(shots_s);
1010 return strcat(_(
"Default damage stats:"),
1016 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
1023 const float num_shots =
stof(sec_shots_s);
1024 float combo_t =
max(pri_rft, sec_rft);
1027 const float sec_rft2 = sec_rft;
1029 combo_t =
max(combo_t, num_shots * sec_rft + sec_rft2);
1030 sec_rft = (num_shots - 1) * sec_rft + sec_rft2;
1032 const string DPS_combo = sprintf(_(
"(total DPS: %.2f)"),
1033 combo_t <= 0 ? 1337 : (
stof(pri_dmg_s) +
stof(sec_dmg_s) * num_shots +
stof(cmb_dmg_s)) / combo_t);
1034 return strcat(_(
"Default damage stats:"),
1037 strcat(
"\n* ", sprintf(_(
"The combo adds an extra %s damage"),
COLORED_DAMAGE(cmb_dmg_s)),
" ", DPS_combo)
1042 const string wepbal_s =
strcat(
"g_balance_",
name,
"_");
1046 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