CCSPlayer::CSWeaponDrop
0x00657a80 · 4448 bytes · __thiscall
_ZN9CCSPlayer12CSWeaponDropEP17CBaseCombatWeaponbbP6Vector
Decompiled
undefined (5 params)
/* CCSPlayer::CSWeaponDrop(CBaseCombatWeapon*, bool, bool, Vector*) */
uint __thiscall
CCSPlayer::CSWeaponDrop
(CCSPlayer *this,CBaseCombatWeapon *param_1,bool param_2,bool param_3,Vector *param_4)
{
float fVar1;
float fVar2;
float fVar3;
float fVar4;
CWeaponSpawn *this_00;
int *piVar5;
CBaseEdict *pCVar6;
code *pcVar7;
CBaseCombatWeapon *pCVar8;
uint uVar9;
char cVar10;
CWeaponCSBase *this_01;
uint uVar11;
int iVar12;
QAngle *pQVar13;
float *pfVar14;
int iVar15;
float *pfVar16;
int iVar17;
int *piVar18;
undefined *puVar19;
int *piVar20;
longdouble lVar21;
float fVar22;
float fVar23;
float fVar24;
undefined4 uStackY_1f8;
undefined4 *local_1b8;
int *local_1b0;
float local_1a4;
float local_1a0;
float local_19c;
float local_198;
float local_194;
float local_190;
float local_18c;
float local_188;
float local_184;
float local_180;
float local_17c;
float local_178;
float local_174;
float local_170;
float local_16c;
float local_168;
float local_164;
float local_160;
undefined4 local_15c;
undefined4 local_158;
undefined4 local_154;
undefined4 local_144;
undefined4 local_140;
undefined4 local_13c;
float local_138;
float local_134;
float local_130;
float local_12c;
float local_128;
float local_124;
CTraceFilterSkipTwoEntities local_fc [48];
float local_cc;
float local_c8;
float local_c4;
float local_bc;
float local_b8;
float local_b4;
float local_ac;
float local_a8;
float local_a4;
float local_9c;
float local_98;
float local_94;
undefined4 local_8c;
undefined1 local_88;
undefined1 local_87;
float local_70;
float local_6c;
float local_68;
float local_64 [4];
float local_54;
float local_44;
char local_39;
if (param_1 == (CBaseCombatWeapon *)0x0) {
return 0;
}
this_01 = (CWeaponCSBase *)__dynamic_cast();
if ((this_01 != (CWeaponCSBase *)0x0) &&
(uVar11 = (**(code **)(*(int *)this_01 + 0x668))(), (char)uVar11 == '\0')) {
return uVar11;
}
iVar12 = CWeaponCSBase::GetCSWpnData(this_01);
iVar12 = CBaseCombatCharacter::GetAmmoCount((CBaseCombatCharacter *)this,*(int *)(iVar12 + 0x850))
;
pQVar13 = (QAngle *)(**(code **)(*(int *)this + 0x238))();
AngleVectors(pQVar13,(Vector *)&local_1a4,(Vector *)0x0,(Vector *)0x0);
pfVar14 = (float *)(**(code **)(*(int *)this + 0x288))();
local_198 = *pfVar14;
local_194 = pfVar14[1];
local_190 = pfVar14[2];
if (param_4 == (Vector *)0x0) {
if (param_3) {
lVar21 = (longdouble)(**(code **)(*(int *)this_01 + 0x650))();
fVar23 = (float)lVar21;
local_194 = local_1a0 * fVar23 + local_194;
local_190 = local_19c * fVar23 + local_190;
local_198 = fVar23 * local_1a4 + local_198;
}
else {
local_6c = -local_1a0;
local_68 = 0.0;
local_70 = -local_1a4;
VectorNormalize((Vector *)&local_70);
local_194 = local_6c * 48.0 + local_194;
local_190 = local_68 * 48.0 + local_190;
local_198 = local_70 * 48.0 + local_198;
}
}
else {
local_198 = *(float *)param_4;
local_194 = *(float *)(param_4 + 4);
local_190 = *(float *)(param_4 + 8);
}
(**(code **)(*(int *)this + 0x470))();
uVar11 = (**(code **)(*(int *)this_01 + 0x64c))();
if ((char)uVar11 != '\0') {
iVar15 = (**(code **)(*(int *)this_01 + 0x530))();
if ((iVar15 == 2) && (iVar12 == 0)) {
UTIL_Remove((CBaseEntity *)this_01);
return uVar11;
}
if (0 < DAT_0100486c) {
iVar12 = 0;
do {
this_00 = *(CWeaponSpawn **)(TheWeaponSpawns + iVar12 * 4);
iVar15 = (**(code **)(*(int *)this_00 + 0x3cc))();
iVar17 = (**(code **)(*(int *)this_01 + 0x638))();
if (((iVar15 == iVar17) && (*(int *)(this_00 + 0x458) == *(int *)(this_01 + 0x458))) ||
(((byte)this_00[0x148] & 4) != 0)) {
pfVar14 = (float *)(**(code **)(*(int *)this + 0x288))();
pfVar16 = (float *)(**(code **)(*(int *)this_00 + 0x288))();
if ((*pfVar16 - *pfVar14) * (*pfVar16 - *pfVar14) +
(pfVar16[2] - pfVar14[2]) * (pfVar16[2] - pfVar14[2]) +
(pfVar16[1] - pfVar14[1]) * (pfVar16[1] - pfVar14[1]) < 40000.0) {
iVar15 = (**(code **)(*(int *)this_01 + 0x55c))();
uVar11 = CWeaponSpawn::AbsorbWeapon(this_00,this_01);
if ((char)uVar11 != '\0') {
iVar12 = 0;
if (iVar15 == -1) {
return uVar11;
}
while ((((uVar9 = *(uint *)(this + iVar12 * 4 + 0x18f4), uVar9 == 0xffffffff ||
(puVar19 = g_pEntityList + (uVar9 & 0xfff) * 0x10,
puVar19 == (undefined *)0xfffffffc)) ||
((*(uint *)(puVar19 + 8) != uVar9 >> 0xc ||
((pCVar8 = *(CBaseCombatWeapon **)(puVar19 + 4), param_1 == pCVar8 ||
(pCVar8 == (CBaseCombatWeapon *)0x0)))))) ||
(iVar17 = (**(code **)(*(int *)pCVar8 + 0x55c))(), iVar15 != iVar17))) {
iVar12 = iVar12 + 1;
if (iVar12 == 0x38) {
pcVar7 = *(code **)(*(int *)this + 0x450);
CBaseCombatCharacter::GetAmmoCount((CBaseCombatCharacter *)this,iVar15);
(*pcVar7)();
return uVar11 & 0xff;
}
}
return uVar11 & 0xff;
}
}
}
iVar12 = iVar12 + 1;
} while (iVar12 < DAT_0100486c);
}
}
CCollisionProperty::SetSolidFlags((CCollisionProperty *)(param_1 + 0x194),0x98);
if (param_1[0x187] != (CBaseCombatWeapon)0x1) {
if (param_1[0x6c] == (CBaseCombatWeapon)0x0) {
pCVar6 = *(CBaseEdict **)(param_1 + 0x30);
if (pCVar6 != (CBaseEdict *)0x0) {
*(uint *)pCVar6 = *(uint *)pCVar6 | 0x101;
iVar12 = CBaseEdict::GetChangeAccessor(pCVar6);
*(undefined2 *)(iVar12 + 2) = 0;
}
}
else {
param_1[0x70] = (CBaseCombatWeapon)((byte)param_1[0x70] | 1);
}
param_1[0x187] = (CBaseCombatWeapon)0x1;
}
pcVar7 = *(code **)(*(int *)this_01 + 0x640);
(**(code **)(*(int *)this_01 + 0x508))();
(*pcVar7)();
iVar12 = (**(code **)(*(int *)this_01 + 0x55c))();
if (iVar12 != -1) {
cVar10 = (**(code **)(*(int *)this + 300))();
if ((cVar10 != '\0') && (0 < *(int *)(this + 0x100))) {
iVar15 = 0;
do {
uVar11 = *(uint *)(this + iVar15 * 4 + 0x18f4);
if (((((uVar11 != 0xffffffff) &&
(puVar19 = g_pEntityList + (uVar11 & 0xfff) * 0x10, puVar19 != (undefined *)0xfffffffc
)) && (*(uint *)(puVar19 + 8) == uVar11 >> 0xc)) &&
((pCVar8 = *(CBaseCombatWeapon **)(puVar19 + 4), param_1 != pCVar8 &&
(pCVar8 != (CBaseCombatWeapon *)0x0)))) &&
(iVar17 = (**(code **)(*(int *)pCVar8 + 0x55c))(), iVar12 == iVar17)) goto LAB_00657d18;
iVar15 = iVar15 + 1;
} while (iVar15 != 0x38);
}
iVar15 = CBaseCombatCharacter::GetAmmoCount((CBaseCombatCharacter *)this,iVar12);
if (iVar15 != *(int *)(this_01 + 0x14fc)) {
if (this_01[0x6c] == (CWeaponCSBase)0x0) {
pCVar6 = *(CBaseEdict **)(this_01 + 0x30);
if (pCVar6 != (CBaseEdict *)0x0) {
*(uint *)pCVar6 = *(uint *)pCVar6 | 0x101;
iVar17 = CBaseEdict::GetChangeAccessor(pCVar6);
*(undefined2 *)(iVar17 + 2) = 0;
}
}
else {
this_01[0x70] = (CWeaponCSBase)((byte)this_01[0x70] | 1);
}
*(int *)(this_01 + 0x14fc) = iVar15;
}
CBaseCombatCharacter::SetAmmoCount((CBaseCombatCharacter *)this,0,iVar12);
}
LAB_00657d18:
uVar11 = (**(code **)(*(int *)this_01 + 0x66c))();
piVar5 = mdlcache;
if ((char)uVar11 == '\0') {
CBaseEntity::StopFollowingEntity((CBaseEntity *)param_1);
if (((byte)param_1[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)param_1);
}
pfVar14 = (float *)(**(code **)(*(int *)param_1 + 0x288))();
fVar23 = *pfVar14;
fVar22 = pfVar14[1];
fVar1 = pfVar14[2];
fVar2 = *(float *)(param_1 + 0x2e0);
fVar3 = *(float *)(param_1 + 0x2e4);
fVar4 = *(float *)(param_1 + 0x2e8);
CBasePlayer::EyeVectors((CBasePlayer *)this,(Vector *)&local_18c,(Vector *)0x0,(Vector *)0x0);
local_184 = local_184 * 0.1;
VectorNormalize((Vector *)&local_18c);
fVar24 = local_184 * 20.0;
(**(code **)(*(int *)this + 0x234))();
piVar5 = *(int **)(param_1 + 0x238);
local_15c = vec3_angle;
local_180 = (local_18c * 20.0 + local_70) - (fVar23 - fVar2);
local_158 = DAT_01053d40;
local_17c = (local_188 * 20.0 + local_6c) - (fVar22 - fVar3);
local_178 = (fVar24 + local_68) - (fVar1 - fVar4);
local_154 = DAT_01053d44;
if (piVar5 == (int *)0x0) {
pfVar14 = (float *)(**(code **)(*(int *)(param_1 + 0x194) + 4))();
local_174 = *pfVar14;
local_170 = pfVar14[1];
local_16c = pfVar14[2];
pfVar14 = (float *)(**(code **)(*(int *)(param_1 + 0x194) + 8))();
local_168 = *pfVar14;
local_164 = pfVar14[1];
local_160 = pfVar14[2];
}
else {
if (((byte)this[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
}
pcVar7 = *(code **)(*physcollision + 0x60);
(**(code **)(*piVar5 + 300))();
(*pcVar7)();
}
local_1b8 = &local_15c;
CTraceFilterSkipTwoEntities::CTraceFilterSkipTwoEntities
(local_fc,(IHandleEntity *)param_1,(IHandleEntity *)this,0);
(**(code **)(*(int *)this + 0x234))();
local_8c = 0;
piVar20 = (int *)&stack0xfffffe0c;
local_bc = local_180 - local_12c;
local_b8 = local_17c - local_128;
local_b4 = local_178 - local_124;
local_9c = (local_168 - local_174) * 0.5;
local_87 = local_b8 * local_b8 + local_bc * local_bc + local_b4 * local_b4 != 0.0;
local_94 = (local_160 - local_16c) * 0.5;
local_98 = (local_164 - local_170) * 0.5;
local_ac = (local_168 + local_174) * 0.5;
local_a8 = (local_164 + local_170) * 0.5;
local_cc = local_12c + local_ac;
local_a4 = (local_160 + local_16c) * 0.5;
local_c8 = local_128 + local_a8;
local_88 = local_98 * local_98 + local_9c * local_9c + local_94 * local_94 < 1e-06;
local_c4 = local_124 + local_a4;
local_ac = -local_ac;
local_a8 = -local_a8;
local_a4 = -local_a4;
uStackY_1f8 = 0x65812d;
(**(code **)(*enginetrace + 0x14))();
if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
uStackY_1f8 = 0x658176;
DebugDrawLine((Vector *)&local_70,(Vector *)local_64,0xff,0xff,0,true,-1.0);
}
if (local_39 != '\0') {
uStackY_1f8 = 0x6588f5;
(**(code **)(*(int *)this + 0x234))();
piVar20 = &uStackY_1f8;
}
iVar12 = *(int *)param_1;
piVar20[3] = 0;
piVar20[2] = (int)local_1b8;
piVar20[1] = (int)&local_180;
*piVar20 = (int)param_1;
pcVar7 = *(code **)(iVar12 + 0x1dc);
piVar20[-1] = 0x6581d4;
(*pcVar7)();
piVar20[1] = (int)&vec3_origin;
*piVar20 = (int)param_1;
piVar20[-1] = 0x6581e7;
CBaseEntity::SetAbsVelocity((CBaseEntity *)*piVar20,(Vector *)piVar20[1]);
piVar20[1] = (int)&vec3_angle;
*piVar20 = (int)param_1;
piVar20[-1] = 0x6581fa;
CBaseEntity::SetLocalAngularVelocity((CBaseEntity *)*piVar20,(QAngle *)piVar20[1]);
if (piVar5 == (int *)0x0) {
return 1;
}
iVar12 = *piVar5;
*piVar20 = (int)piVar5;
piVar20[2] = (int)&local_138;
piVar20[1] = (int)&local_144;
pcVar7 = *(code **)(iVar12 + 0xc4);
piVar20[-1] = 0x658223;
(*pcVar7)();
iVar12 = *piVar5;
piVar20[3] = 1;
*piVar20 = (int)piVar5;
piVar20[2] = (int)local_1b8;
piVar20[1] = (int)&local_144;
pcVar7 = *(code **)(iVar12 + 0xbc);
piVar20[-1] = 0x65824a;
(*pcVar7)();
iVar12 = *piVar5;
piVar20[2] = (int)&vec3_origin;
piVar20[1] = (int)&vec3_origin;
*piVar20 = (int)piVar5;
pcVar7 = *(code **)(iVar12 + 0xd0);
piVar20[-1] = 0x658265;
(*pcVar7)();
if (!param_3) {
return 1;
}
piVar20[3] = 0;
piVar20[2] = 0;
*piVar20 = (int)this;
piVar20[1] = (int)&local_12c;
piVar20[-1] = 0x65895a;
CBasePlayer::EyeVectors
((CBasePlayer *)*piVar20,(Vector *)piVar20[1],(Vector *)piVar20[2],
(Vector *)piVar20[3]);
iVar12 = *piVar5;
*piVar20 = (int)piVar5;
pcVar7 = *(code **)(iVar12 + 0x78);
piVar20[-1] = 0x658962;
lVar21 = (longdouble)(*pcVar7)();
fVar23 = 4.0;
if ((float)lVar21 <= 15.0) {
iVar12 = *piVar5;
*piVar20 = (int)piVar5;
pcVar7 = *(code **)(iVar12 + 0x78);
piVar20[-1] = 0x658b99;
lVar21 = (longdouble)(*pcVar7)();
fVar23 = 0.5;
if (0.5 <= (float)lVar21) {
iVar12 = *piVar5;
*piVar20 = (int)piVar5;
pcVar7 = *(code **)(iVar12 + 0x78);
piVar20[-1] = 0x658bc4;
lVar21 = (longdouble)(*pcVar7)();
fVar23 = ((float)lVar21 + -0.5) * 0.2413793 + 0.5;
}
}
fVar22 = fVar23 * *(float *)(player_throwforce._28_4_ + 0x2c);
local_12c = local_12c * fVar22;
local_128 = local_128 * fVar22;
local_124 = fVar22 * local_124;
iVar12 = *piVar5;
piVar20[1] = (int)&local_12c;
*piVar20 = (int)piVar5;
pcVar7 = *(code **)(iVar12 + 0xf4);
piVar20[-1] = 0x6589eb;
(*pcVar7)();
piVar20[-1] = 0x6589f0;
iVar12 = rand();
piVar20[-1] = 0x6589fb;
iVar15 = rand();
piVar20[-1] = 0x658a02;
iVar17 = rand();
local_cc = ((float)iVar12 * 0.0006103702 + -10.0) * fVar23;
local_c8 = ((float)iVar15 * 0.0006103702 + -10.0) * fVar23;
local_c4 = ((float)iVar17 * 0.0006103702 + -10.0) * fVar23;
iVar12 = *piVar5;
piVar20[1] = (int)&local_cc;
*piVar20 = (int)piVar5;
pcVar7 = *(code **)(iVar12 + 0xfc);
piVar20[-1] = 0x658a77;
(*pcVar7)();
return 1;
}
(**(code **)(*mdlcache + 0x68))();
local_1b0 = *(int **)(param_1 + 0x13e0);
if (local_1b0 == (int *)0x0) {
/* try { // try from 00658557 to 0065859f has its CatchHandler @ 00658c31 */
iVar12 = CBaseEntity::GetModel((CBaseEntity *)param_1);
if (iVar12 != 0) {
CBaseAnimating::LockStudioHdr((CBaseAnimating *)param_1);
}
local_1b0 = *(int **)(param_1 + 0x13e0);
if (local_1b0 != (int *)0x0) goto LAB_006583ec;
}
else {
LAB_006583ec:
iVar12 = *local_1b0;
if ((iVar12 != 0) && (iVar15 = 0, 0 < *(int *)(iVar12 + 0x9c))) {
do {
piVar18 = (int *)(iVar12 + iVar15 * 0xd8 + *(int *)(iVar12 + 0xa0));
/* try { // try from 00658440 to 00658444 has its CatchHandler @ 00658c31 */
iVar12 = CBaseAnimating::LookupBone
((CBaseAnimating *)this,(char *)((int)piVar18 + *piVar18));
if (iVar12 != -1) {
if (iVar15 != *(int *)(*local_1b0 + 0x9c)) goto LAB_006585bd;
goto LAB_0065845e;
}
iVar15 = iVar15 + 1;
iVar12 = *local_1b0;
} while (iVar15 < *(int *)(iVar12 + 0x9c));
if (*(int *)(iVar12 + 0x9c) == iVar15) {
LAB_0065845e:
(**(code **)(*piVar5 + 0x6c))();
return uVar11;
}
/* try { // try from 006588b3 to 006588b7 has its CatchHandler @ 00658c31 */
iVar12 = CBaseAnimating::LookupBone((CBaseAnimating *)this,"ValveBiped.Bip01_R_Hand");
goto LAB_006585a5;
}
}
iVar12 = CBaseAnimating::LookupBone((CBaseAnimating *)this,"ValveBiped.Bip01_R_Hand");
LAB_006585a5:
if (iVar12 != -1) {
LAB_006585bd:
/* try { // try from 006585d4 to 00658816 has its CatchHandler @ 00658c31 */
CBaseAnimating::GetBoneTransformUncached
((CBaseAnimating *)this,iVar12,(matrix3x4_t *)&local_12c);
CBaseEntity::StopFollowingEntity((CBaseEntity *)param_1);
local_70 = 0.0;
local_6c = 0.0;
local_68 = 0.0;
CBaseEntity::SetAbsOrigin((CBaseEntity *)param_1,(Vector *)&local_70);
local_70 = 0.0;
local_6c = 0.0;
local_68 = 0.0;
CBaseEntity::SetAbsAngles((CBaseEntity *)param_1,(QAngle *)&local_70);
CBaseAnimating::InvalidateBoneCache((CBaseAnimating *)param_1);
(**(code **)(*(int *)param_1 + 0x358))();
MatrixInvert((matrix3x4_t *)local_fc,(matrix3x4_t *)&local_cc);
ConcatTransforms((matrix3x4_t *)&local_12c,(matrix3x4_t *)&local_cc,(matrix3x4_t *)&local_70);
MatrixAngles((matrix3x4_t *)&local_70,&local_168);
local_174 = local_64[0];
local_170 = local_54;
local_16c = local_44;
(**(code **)(*(int *)param_1 + 0x1dc))();
piVar18 = *(int **)(param_1 + 0x238);
if (piVar18 != (int *)0x0) {
(**(code **)(*piVar18 + 0xc4))();
(**(code **)(*piVar18 + 0xbc))();
local_144 = 0;
local_140 = 0;
local_13c = 0;
if (((byte)this[0x14d] & 0x10) != 0) {
CBaseEntity::CalcAbsoluteVelocity((CBaseEntity *)this);
}
local_138 = local_1a4 * 64.0 + *(float *)(this + 0x274);
local_134 = local_1a0 * 64.0 + *(float *)(this + 0x278);
local_130 = local_19c * 64.0 + *(float *)(this + 0x27c);
(**(code **)(*piVar18 + 0xd8))();
}
}
(**(code **)(*piVar5 + 0x6c))();
return 1;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.