64 return '0 0 1' *
BIT(a);
66 return '0 1 0' *
BIT(a);
68 return '1 0 0' *
BIT(a);
71 void WriteWepSet(
float dst,
WepSet w)
74 else if (
REGISTRY_MAX(Weapons) > 24) WriteInt48_t(dst, w);
75 else WriteInt24_t(dst, w.x);
79 WepSet WepSet_GetFromStat()
83 WepSet WepSet_GetFromStat_InMap()
85 return STAT(WEAPONSINMAP);
91 return ReadInt24_t() *
'1 0 0';
105 if (wi != WEP_Null)
return wi.netname;
114 case "nex":
return "vortex";
115 case "rocketlauncher":
return "devastator";
116 case "laser":
return "blaster";
117 case "minstanex":
return "vaporizer";
118 case "grenadelauncher":
return "mortar";
119 case "uzi":
return "machinegun";
120 case "hmg":
return "okhmg";
121 case "rpc":
return "okrpc";
131 if (s ==
"0" ||
stof(s))
return s;
133 FOREACH(Weapons, it != WEP_Null && it.netname == s,
return ftos(i));
157 if (d != 0)
return -d;
159 return strstrofs(s, sprintf(
" %d ", si), 0)
191 for (
int j = 0; j < n; ++j)
194 FOREACH(Weapons, it != WEP_Null, {
195 if (remaining & (it.m_wepset))
210 case RES_SHELLS:
return ITEM_Shells.m_icon;
211 case RES_BULLETS:
return ITEM_Bullets.m_icon;
212 case RES_ROCKETS:
return ITEM_Rockets.m_icon;
213 case RES_CELLS:
return ITEM_Cells.m_icon;
214 case RES_PLASMA:
return ITEM_Plasma.m_icon;
215 case RES_FUEL:
return ITEM_JetpackFuel.m_icon;
224 case RES_SHELLS:
return ITEM_Shells.m_name;
225 case RES_BULLETS:
return ITEM_Bullets.m_name;
226 case RES_ROCKETS:
return ITEM_Rockets.m_name;
227 case RES_CELLS:
return ITEM_Cells.m_name;
228 case RES_PLASMA:
return ITEM_Plasma.m_name;
229 case RES_FUEL:
return ITEM_JetpackFuel.m_name;
230 default:
return "batteries";
238 case RES_SHELLS:
return ITEM_Shells;
239 case RES_BULLETS:
return ITEM_Bullets;
240 case RES_ROCKETS:
return ITEM_Rockets;
241 case RES_CELLS:
return ITEM_Cells;
242 case RES_PLASMA:
return ITEM_Plasma;
243 case RES_FUEL:
return ITEM_JetpackFuel;
245 LOG_WARNF(
"Invalid ammo type %d ", ammotype.m_id);
256 case 0:
return RES_SHELLS;
257 case 1:
return RES_BULLETS;
258 case 2:
return RES_ROCKETS;
259 case 3:
return RES_CELLS;
260 case 4:
return RES_PLASMA;
261 case 5:
return RES_FUEL;
262 default:
return RES_NONE;
274 case RES_PLASMA:
return STAT_PLASMA.m_id;
275 case RES_FUEL:
return STAT_FUEL.m_id;
283 string output =
strcat(
"weapons/", w_snd);
290 string output =
strcat(
"models/weapons/", w_mdl);
296 vector shotorg_adjustfromclient(
vector vecs,
float y_is_right,
float algn)
318 vector shotorg_adjust_values(
vector vecs,
bool y_is_right,
bool visual,
int algn)
323 vecs = shotorg_adjustfromclient(vecs, y_is_right, algn);
325 else if (STAT(SHOOTFROMEYE))
329 else if (STAT(SHOOTFROMCENTER))
334 else if ((s = G_SHOOTFROMFIXEDORIGIN) !=
"")
337 if (y_is_right) v.y = -v.y;
338 if (v.x != 0) vecs.x = v.x;
344 vecs = shotorg_adjustfromclient(vecs, y_is_right, algn);
350 #define shotorg_adjust shotorg_adjust_values 403 void CL_WeaponEntity_SetModel(
entity this,
string name,
bool _anim)
409 setsize(
this, oldmin, oldmax);
410 if (this.weaponchild)
delete(this.weaponchild);
411 this.weaponchild =
NULL;
413 this.spawnorigin =
'0 0 0';
415 this.anim_fire1 =
'0 1 0.01';
416 this.anim_fire2 =
'0 1 0.01';
417 this.anim_idle =
'0 1 0.01';
418 this.anim_reload =
'0 1 0.01';
423 if (this.weaponchild) this.weaponchild.model =
"";
430 this.anim_fire1 = animfixfps(
this,
'0 1 0.01',
'0 0 0');
431 this.anim_fire2 = animfixfps(
this,
'1 1 0.01',
'0 0 0');
432 this.anim_idle = animfixfps(
this,
'2 1 0.01',
'0 0 0');
433 this.anim_reload = animfixfps(
this,
'3 1 0.01',
'0 0 0');
440 if (!this.weaponchild)
442 this.weaponchild =
new(weaponchild);
449 setsize(this.weaponchild,
'0 0 0',
'0 0 0');
450 setattachment(this.weaponchild,
this, t);
454 if (this.weaponchild)
delete(this.weaponchild);
455 this.weaponchild =
NULL;
458 setsize(
this,
'0 0 0',
'0 0 0');
480 LOG_WARNF(
"weapon model %s does not support the 'shot' tag, will display shots TOTALLY wrong",
489 && ((idx =
gettagindex(this.weaponchild,
"shell")) || (idx =
gettagindex(this.weaponchild,
"tag_shell"))))
491 this.spawnorigin =
gettaginfo(this.weaponchild, idx);
499 LOG_WARNF(
"weapon model %s does not support the 'shell' tag, will display casings wrong",
501 this.spawnorigin = this.
movedir;
511 if (this.weaponchild)
522 "weapon model %s does not support the 'handle' tag " 523 "and neither does the v_ model support the 'shot' tag, " 524 "will display muzzle flashes TOTALLY wrong\n",
538 this.movedir_aligned = this.
movedir;
545 this.m_gunalign = algn;
548 this.
movedir = shotorg_adjust(v,
false,
false, algn);
549 this.movedir_aligned = shotorg_adjust(v,
false,
true, algn);
550 this.
view_ofs = shotorg_adjust(v,
false,
true, algn) -
v;
556 if (this.
owner) STAT(SHOTORG, this.
owner) = compressed_shotorg;
566 this.wframe = WFRAME_IDLE;
567 setanim(
this, this.anim_idle,
true,
false,
true);
577 WFRAME fr = ReadByte();
578 float t = ReadFloat();
579 int slot = ReadByte();
580 bool restartanim = ReadByte();
582 if(fr == WFRAME_IDLE)
583 wepent.animstate_looping =
false;
590 case WFRAME_IDLE: a = wepent.anim_idle;
break;
591 case WFRAME_FIRE1: a = wepent.anim_fire1;
break;
592 case WFRAME_FIRE2: a = wepent.anim_fire2;
break;
593 case WFRAME_RELOAD: a = wepent.anim_reload;
break;
596 anim_set(wepent, a, !restartanim, restartanim, restartanim);
598 wepent.state = ReadByte();
599 wepent.weapon_nextthink = ReadFloat();
600 switch (wepent.state)
603 wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_raise;
606 wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_drop;
609 wepent.weapon_switchdelay = 0;
617 void wframe_send(
entity actor,
entity weaponentity,
int wepframe,
float attackrate,
bool restartanim)
622 WriteHeader(channel, wframe);
624 WriteFloat(channel, attackrate);
628 WriteFloat(channel, weaponentity.weapon_nextthink);
642 void w_whereis(
Weapon this)
644 int channel = MSG_C2S;
645 WriteHeader(channel, w_whereis);
657 FOREACH(Weapons, it != WEP_Null, w_whereis(it));
662 FOREACH(Weapons, it != WEP_Null && !(STAT(WEAPONS) & it.m_wepset), w_whereis(it));
665 FOREACH(Weapons, it != WEP_Null && it.netname == s,
675 LOG_HELP(
"Usage:^3 cl_cmd weapon_find <weapon>");
676 LOG_HELP(
" Where <weapon> is the lowercase weapon name, 'all' or 'unowned'.");
687 flash.angles_z =
random() * 360;
689 entity view = actor.(weaponentity);
690 entity exterior = actor.exteriorweaponentity;
692 if (view.oldorigin.x > 0)
694 setattachment(flash, exterior,
"");
695 setorigin(flash, view.oldorigin + offset);
699 if (
gettagindex(exterior,
"shot")) setattachment(flash, exterior,
"shot");
700 else setattachment(flash, exterior,
"tag_shot");
707 flash.owner = wepent;
708 flash.angles_z =
random() * 360;
710 if (
gettagindex(wepent,
"shot")) setattachment(flash, wepent,
"shot");
711 else setattachment(flash, wepent,
"tag_shot");
716 void W_MuzzleFlash_Model_Think(
entity this)
732 void W_MuzzleFlash_Model(
entity wepent,
entity muzzlemodel)
734 if(wepent.muzzle_flash ==
NULL)
735 wepent.muzzle_flash =
spawn();
737 entity flash = wepent.muzzle_flash;
741 setthink(flash, W_MuzzleFlash_Model_Think);
742 flash.nextthink =
time + 0.02;
745 flash.angles_z =
random() * 180;
747 flash.owner = flash.realowner = wepent;
762 Send_Effect_Except(thiswep.m_muzzleeffect,
shotorg, shotdir * 1000, 1, actor);
764 if(thiswep.m_muzzlemodel != MDL_Null)
766 W_MuzzleFlash_Model(actor.exteriorweaponentity, thiswep.m_muzzlemodel);
767 W_MuzzleFlash_Model_AttachToShotorg(actor, weaponentity, actor.exteriorweaponentity.muzzle_flash,
'5 0 0');
773 if(!IS_REAL_CLIENT(it))
775 int channel = MSG_ONE;
777 WriteHeader(channel, w_muzzleflash);
778 WriteByte(channel, thiswep.m_id);
779 WriteByte(channel, weaponslot(weaponentity));
780 WriteVector(channel, shotorg);
787 int weapon_id = ReadByte();
788 int slot = ReadByte();
789 vector sv_shotorg = ReadVector();
793 vector forward, right, up;
794 MAKE_VECTORS(viewangles, forward, right, up);
800 pointparticles(thiswep.m_muzzleeffect, sv_shotorg, forward * 1000, 1);
811 vector md = wepent.movedir_aligned;
812 vector vecs = ((md.x > 0) ? md :
'0 0 0');
813 vector dv = forward * vecs.x + right * -vecs.y + up * vecs.z;
814 vector org = rlplayer.origin + rlplayer.view_ofs + dv;
818 if(thiswep.m_muzzlemodel != MDL_Null)
820 W_MuzzleFlash_Model(wepent, thiswep.m_muzzlemodel);
821 W_MuzzleFlash_Model_AttachToShotorg(wepent, wepent.muzzle_flash,
'5 0 0');
832 string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(
entity this,
string wo)
841 REPLICATE(cvar_cl_accuracy_data_share,
bool,
"cl_accuracy_data_share");
842 REPLICATE(cvar_cl_accuracy_data_receive,
bool,
"cl_accuracy_data_receive");
846 REPLICATE(cvar_cl_gunalign,
int,
"cl_gunalign");
847 REPLICATE(cvar_cl_weapon_switch_reload,
bool,
"cl_weapon_switch_reload");
848 REPLICATE(cvar_cl_weapon_switch_fallback_to_impulse,
bool,
"cl_weapon_switch_fallback_to_impulse");
849 REPLICATE(cvar_cl_weaponimpulsemode,
int,
"cl_weaponimpulsemode");
850 REPLICATE(cvar_cl_weaponpriority,
string,
"cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
entity GetAmmoItem(Resource ammotype)
string W_FixWeaponOrder(string order, float complete)
WepSet W_RandomWeapons(entity e, WepSet remaining, int n)
const int WS_RAISE
raise frame
entity CSQCModel_server2csqc(int i)
#define WEP_IMPULSE_BEGIN
string GetAmmoPicture(Resource ammotype)
const float VF_CL_VIEWANGLES
const int CMD_REQUEST_USAGE
#define REGISTER_NET_C2S(id)
ERASEABLE void RandomSelection_Init()
entity viewmodels[MAX_WEAPONSLOTS]
#define REGISTRY_GET(id, i)
string GetAmmoName(Resource ammotype)
#define FOREACH_CLIENT(cond, body)
REPLICATE(cvar_cl_casings, bool, "cl_casings")
#define NET_HANDLE(id, param)
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
void anim_set(entity e, vector anim, bool looping, bool override, bool restart)
#define WriteRegistered(r, to, it)
const int WS_DROP
deselecting frame
int W_GunAlign(entity this, int preferred_align)
#define CLIENT_COMMAND(id, description)
string mapPriorityList(string order, string(string) mapfunc)
string W_FixWeaponOrder_ForceComplete(string order)
vector decompressShotOrigin(int f)
float W_FixWeaponOrder_BuildImpulseList_buf[REGISTRY_MAX(Weapons)]
#define IS_REAL_CLIENT(v)
float compressShotOrigin(vector v)
int weaponslot(.entity weaponentity)
#define setmodel(this, m)
#define RandomSelection_AddEnt(e, weight, priority)
string W_NumberWeaponOrder(string order)
const float EF_FULLBRIGHT
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
string W_Model(string w_mdl)
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"))
entity viewmodelforclient
string W_FixWeaponOrder_BuildImpulseList(string o)
entity RandomSelection_chosen_ent
int impulse
M: impulse : weapon impulse.
string W_NameWeaponOrder_MapFunc(string s)
const int CMD_REQUEST_COMMAND
string fixPriorityList(string order, float from, float to, float subtract, float complete)
string W_FixWeaponOrder_BuildImpulseList_order
WepSet _WepSet_FromWeapon(int a)
#define ReadRegistered(r)
string W_UndeprecateName(string s)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool autocvar_r_drawviewmodel
string W_Sound(string w_snd)
void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
string W_NameWeaponOrder(string order)
string W_FixWeaponOrder_AllowIncomplete(entity this, string order)
#define MUTATOR_CALLHOOK(id,...)
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
#define REGISTER_NET_TEMP(id)
int autocvar_chase_active
#define WepSet_FromWeapon(it)
void Weapon_whereis(Weapon this, entity cl)
Header file that describes the functions related to game items.
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
#define pass(name, colormin, colormax)
#define FOREACH(list, cond, body)
string weaponorder_byimpulse
string W_NumberWeaponOrder_MapFunc(string s)