SurvivorBot::FindScavengeItem
0x009635b0 · 2477 bytes · __thiscall
_ZNK11SurvivorBot16FindScavengeItemEf
Decompiled
undefined (2 params)
/* WARNING: Removing unreachable block (ram,0x00963d09) */
/* SurvivorBot::FindScavengeItem(float) const */
undefined4 __thiscall SurvivorBot::FindScavengeItem(SurvivorBot *this,float param_1)
{
float fVar1;
float fVar2;
float fVar3;
CBaseEntity CVar4;
int *piVar5;
char cVar6;
byte bVar7;
uint uVar8;
int iVar9;
int iVar10;
int iVar11;
int *piVar12;
TerrorNavArea *this_00;
TerrorNavArea *pTVar13;
undefined *puVar14;
CBaseEntity *pCVar15;
int iVar16;
float fVar17;
ScavengeScan *this_01;
int *local_364;
CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>> *local_360;
int local_35c;
int local_358;
undefined4 local_354;
int local_350;
float local_34c;
float local_348;
float local_344;
float local_340;
float local_33c;
float local_338;
CBaseEntity *local_334 [2];
float local_32c;
SurvivorBot *local_328;
int *local_234;
int local_230;
int local_22c;
undefined4 local_228;
int local_224 [128];
int local_24;
int *local_20;
local_234 = local_224;
local_230 = 0x40;
local_22c = -1;
local_228 = 0;
local_24 = 0;
local_20 = local_234;
if (((byte)this[0x14d] & 8) == 0) {
local_340 = *(float *)(this + 0x2e0);
local_34c = local_340 - param_1;
local_33c = *(float *)(this + 0x2e4);
local_348 = local_33c - param_1;
local_338 = *(float *)(this + 0x2e8);
local_344 = local_338 - param_1;
}
else {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
local_340 = *(float *)(this + 0x2e0);
local_34c = local_340 - param_1;
local_33c = *(float *)(this + 0x2e4);
local_348 = local_33c - param_1;
local_338 = *(float *)(this + 0x2e8);
local_344 = local_338 - param_1;
if ((*(uint *)(this + 0x14c) & 0x800) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
local_340 = *(float *)(this + 0x2e0);
local_33c = *(float *)(this + 0x2e4);
local_338 = *(float *)(this + 0x2e8);
}
}
local_340 = local_340 + param_1;
local_33c = local_33c + param_1;
local_338 = local_338 + param_1;
if (0 < DAT_0100486c) {
iVar16 = 0;
do {
while( true ) {
pCVar15 = *(CBaseEntity **)(TheWeaponSpawns + iVar16 * 4);
/* try { // try from 009636ac to 00963f37 has its CatchHandler @ 00963f56 */
uVar8 = (**(code **)(*(int *)pCVar15 + 0xa4))(pCVar15);
if ((uVar8 & 0x10) != 0) break;
LAB_00963690:
iVar16 = iVar16 + 1;
if (DAT_0100486c <= iVar16) goto LAB_00963790;
}
if (((byte)pCVar15[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar15);
}
cVar6 = IsPointInBox((Vector *)(pCVar15 + 0x2e0),(Vector *)&local_34c,(Vector *)&local_340);
iVar10 = local_24;
if (cVar6 == '\0') goto LAB_00963690;
CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>>::GrowVector
((CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>> *)
&local_234,1);
CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>>::ShiftElementsRight
((CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>> *)
&local_234,iVar10,1);
piVar12 = local_234;
local_234[iVar10 * 2] = (int)pCVar15;
iVar9 = (**(code **)(*(int *)pCVar15 + 0x3cc))(pCVar15);
piVar12[iVar10 * 2 + 1] = iVar9;
if (((iVar9 != 0xc) && (iVar9 != 0x17)) && (iVar9 != 0xf)) goto LAB_00963690;
CDirectorItemManager::GetNavAreaForScavengeItem
(*(CDirectorItemManager **)(TheDirector + 0x62c),
(CBaseEntity *)local_234[iVar10 * 2]);
iVar16 = iVar16 + 1;
} while (iVar16 < DAT_0100486c);
}
LAB_00963790:
local_360 = (CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>> *)
&local_234;
iVar9 = 0x40;
this_01 = (ScavengeScan *)local_334;
iVar10 = CBaseCombatWeapon::GetAvailableWeaponsInBox
((CBaseCombatWeapon **)local_334,0x40,(Vector *)&local_34c,(Vector *)&local_340
);
iVar16 = iVar10 + local_24;
if ((local_230 < iVar16) &&
((-1 < local_22c ||
((CUtlMemory<scavengelist_t,int>::ConvertToGrowableMemory
((CUtlMemory<scavengelist_t,int> *)this_01,iVar9), local_230 < iVar16 &&
(-1 < local_22c)))))) {
local_230 = iVar16;
if (local_234 == (int *)0x0) {
local_234 = malloc(iVar16 * 8);
}
else {
local_234 = realloc(local_234,iVar16 * 8);
}
}
local_20 = local_234;
if (0 < iVar10) {
iVar16 = 0;
while( true ) {
iVar9 = local_24;
CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>>::GrowVector
(local_360,1);
CUtlVector<scavengelist_t,CUtlMemoryFixedGrowable<scavengelist_t,64u,int>>::ShiftElementsRight
(local_360,iVar9,1);
piVar5 = local_234;
local_234[iVar9 * 2] = *(int *)((ScavengeScan *)local_334 + iVar16 * 4);
piVar12 = *(int **)((ScavengeScan *)local_334 + iVar16 * 4);
iVar11 = (**(code **)(*piVar12 + 0x638))(piVar12);
piVar5[iVar9 * 2 + 1] = iVar11;
if (((iVar11 == 0xc) || (iVar11 == 0x17)) || (iVar11 == 0xf)) {
CDirectorItemManager::GetNavAreaForScavengeItem
(*(CDirectorItemManager **)(TheDirector + 0x62c),
(CBaseEntity *)local_234[iVar9 * 2]);
}
if (iVar16 + 1 == iVar10) break;
iVar16 = iVar16 + 1;
}
}
if (local_24 == 0) {
pCVar15 = (CBaseEntity *)0;
}
else {
local_334[1] = (CBaseEntity *)0x0;
local_32c = 3.4028235e+38;
local_334[0] = (CBaseEntity *)this;
cVar6 = (**(code **)(*(int *)this + 0x16c))(this);
iVar16 = local_24;
local_364 = local_234;
pCVar15 = local_334[0];
local_328 = (SurvivorBot *)0x0;
if (cVar6 != '\0') {
local_328 = this;
}
if (((byte)local_334[0][0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(local_334[0]);
}
fVar1 = *(float *)(pCVar15 + 0x2e0);
fVar2 = *(float *)(pCVar15 + 0x2e4);
fVar3 = *(float *)(pCVar15 + 0x2e8);
pCVar15 = local_334[1];
if (0 < iVar16) {
iVar10 = 0;
do {
iVar9 = local_364[1];
pCVar15 = (CBaseEntity *)*local_364;
if (iVar9 == 0x36) {
LAB_00963b29:
if (iVar9 == 0x20) {
LAB_00963d10:
cVar6 = CTerrorPlayer::OwnsWeaponOfType((CTerrorPlayer *)local_334[0],10);
if ((cVar6 == '\0') ||
(iVar9 = GetTeamSituation((SurvivorBot *)local_334[0]),
*(int *)(survivorbot_max_team_melee_weapons._28_4_ + 0x30) < *(int *)(iVar9 + 0x84)))
{
iVar9 = local_364[1];
if (iVar9 != 1) goto LAB_00963b3b;
CVar4 = pCVar15[0x14d];
goto joined_r0x00963d49;
}
}
else {
LAB_00963b32:
if (iVar9 == 1) goto LAB_00963d10;
LAB_00963b3b:
iVar9 = CTerrorPlayer::GetTerrorWeapon((CTerrorPlayer *)local_334[0],iVar9);
if ((iVar9 == 0) ||
((((piVar12 = (int *)*local_364, piVar12 != (int *)0x0 &&
(piVar12 = (int *)(**(code **)(*piVar12 + 0x188))(piVar12), piVar12 != (int *)0x0)
) && (local_334[0][0x4304] != (CBaseEntity)0x0)) &&
(iVar9 = (**(code **)(*piVar12 + 0x530))(piVar12), iVar9 == 0)))) {
CVar4 = pCVar15[0x14d];
joined_r0x00963d49:
if (((byte)CVar4 & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar15);
}
fVar17 = SQRT((*(float *)(pCVar15 + 0x2e4) - fVar2) *
(*(float *)(pCVar15 + 0x2e4) - fVar2) +
(*(float *)(pCVar15 + 0x2e0) - fVar1) *
(*(float *)(pCVar15 + 0x2e0) - fVar1) +
(*(float *)(pCVar15 + 0x2e8) - fVar3) *
(*(float *)(pCVar15 + 0x2e8) - fVar3));
if (fVar17 <= local_32c) {
this_00 = (TerrorNavArea *)
CDirectorItemManager::GetNavAreaForScavengeItem
(*(CDirectorItemManager **)(TheDirector + 0x62c),pCVar15);
pTVar13 = (TerrorNavArea *)(**(code **)(*(int *)local_334[0] + 0x52c))(local_334[0])
;
if ((pTVar13 != (TerrorNavArea *)0x0) && (this_00 != (TerrorNavArea *)0x0)) {
cVar6 = CDirector::HasAnySurvivorLeftSafeArea(TheDirector);
if ((cVar6 == '\0') ||
((((byte)this_00[0x12d] & 8) == 0 || (((byte)pTVar13[0x12d] & 8) != 0)))) {
if (TheDirector[0x161] == (CDirector)0x0) {
if (((byte)pTVar13[0x12d] & 8) != 0) {
bVar7 = (byte)this_00[0x12d] & 8;
goto joined_r0x00963f3a;
}
}
else {
bVar7 = TerrorNavArea::IsPotentiallyVisible(this_00,pTVar13,false);
joined_r0x00963f3a:
if (bVar7 == 0) goto LAB_00963a90;
}
ScavengeScan::ChooseItem((ScavengeScan *)local_334,pCVar15,local_364[1],fVar17);
}
}
}
}
}
}
else {
if ((iVar9 == 0x37) && (*(int *)(survivorbot_use_upgrades._28_4_ + 0x30) != 0))
goto LAB_00963b32;
iVar11 = GetWeaponInfo(iVar9);
if ((iVar11 == 0) || ((iVar9 == 0x18 || (iVar9 - 0x1eU < 2)))) goto LAB_00963a90;
cVar6 = CTerrorGameRules::IsScavengeMode();
if (((cVar6 != '\0') || (cVar6 = CTerrorGameRules::IsSurvivalMode(), cVar6 != '\0')) &&
(((iVar9 == 0xf || (iVar9 == 0xc)) || (iVar9 == 0x17)))) {
LAB_00963b20:
iVar9 = local_364[1];
goto LAB_00963b29;
}
uVar8 = *(uint *)(iVar11 + 0x158);
if (uVar8 == 3) {
local_358 = 0;
local_35c = iVar9;
ForEachSurvivor<NumHumansWithoutItemScan>((NumHumansWithoutItemScan *)&local_35c);
iVar11 = local_358;
LAB_00963a60:
iVar9 = CDirectorItemManager::GetCountOfProspectiveScavengeItem
(*(CDirectorItemManager **)(TheDirector + 0x62c),iVar9);
if (iVar11 < iVar9) goto LAB_00963b20;
}
else if ((int)uVar8 < 4) {
if ((uVar8 < 2) &&
(((uVar8 = *(uint *)(pCVar15 + 0x220), uVar8 == 0xffffffff ||
(puVar14 = g_pEntityList + (uVar8 & 0xfff) * 0x10,
puVar14 == (undefined *)0xfffffffc)) ||
((*(uint *)(puVar14 + 8) != uVar8 >> 0xc ||
((piVar12 = *(int **)(puVar14 + 4), piVar12 == (int *)0x0 ||
(cVar6 = (**(code **)(*piVar12 + 300))(piVar12), cVar6 == '\0'))))))))
goto LAB_00963b20;
}
else if (uVar8 == 4) {
local_354 = 4;
local_350 = 0;
ForEachSurvivor<NumHumansWithoutItemInSlotScan>
((NumHumansWithoutItemInSlotScan *)&local_354);
iVar11 = local_350;
goto LAB_00963a60;
}
}
LAB_00963a90:
local_364 = local_364 + 2;
iVar10 = iVar10 + 1;
pCVar15 = local_334[1];
} while (iVar10 != iVar16);
}
}
local_24 = 0;
CUtlMemory<scavengelist_t,int>::Purge((CUtlMemory<scavengelist_t,int> *)local_360);
local_20 = local_234;
CUtlMemory<scavengelist_t,int>::Purge((CUtlMemory<scavengelist_t,int> *)local_360);
return pCVar15;
}
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.