SurvivorAttack::Update
0x0091b100 · 3227 bytes · __thiscall
_ZN14SurvivorAttack6UpdateEP11SurvivorBotf
Decompiled
undefined (3 params)
/* SurvivorAttack::Update(SurvivorBot*, float) */
SurvivorAttack * __thiscall
SurvivorAttack::Update(SurvivorAttack *this,SurvivorBot *param_1,float param_2)
{
uint uVar1;
int *piVar2;
bool bVar3;
char cVar4;
int *piVar5;
int iVar6;
CBaseEntity *pCVar7;
Vector *pVVar8;
Vector *pVVar9;
SurvivorIntention *pSVar10;
SurvivorAmbushBoomer *this_00;
undefined4 uVar11;
SurvivorLegsApproach *this_01;
undefined4 *puVar12;
int iVar13;
undefined *puVar14;
CBaseEntity *pCVar15;
int iVar16;
CTerrorPlayer *pCVar17;
longdouble lVar18;
float fVar19;
float fVar20;
float fVar21;
float fVar22;
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0x9a0))(param_2);
cVar4 = (**(code **)(*piVar5 + 0x114))(piVar5);
if (cVar4 != '\0') {
lVar18 = (longdouble)CTerrorPlayer::GetTimeSinceAttackedByEnemy((CTerrorPlayer *)param_2);
if ((float)lVar18 < 1.0) {
(**(code **)(*(int *)param_2 + 0x978))(param_2,0xbf800000);
}
goto LAB_0091b147;
}
cVar4 = IsBlindedByVomit((SurvivorAttack *)param_1,(SurvivorBot *)param_2);
if (cVar4 != '\0') {
lVar18 = (longdouble)CountdownTimer::Now();
if (*(float *)(param_1 + 0x7c) <= (float)lVar18) {
lVar18 = (longdouble)RandomFloat(0x3f000000,0x3f800000);
fVar22 = (float)lVar18;
lVar18 = (longdouble)CountdownTimer::Now();
if ((float)lVar18 + fVar22 != *(float *)(param_1 + 0x7c)) {
(**(code **)(*(int *)(param_1 + 0x74) + 4))(param_1 + 0x74,param_1 + 0x7c);
*(float *)(param_1 + 0x7c) = (float)lVar18 + fVar22;
}
if (fVar22 != *(float *)(param_1 + 0x78)) {
(**(code **)(*(int *)(param_1 + 0x74) + 4))(param_1 + 0x74,param_1 + 0x78);
*(float *)(param_1 + 0x78) = fVar22;
}
(**(code **)(*(int *)param_2 + 0x940))(param_2,0xbf800000);
SurvivorBot::LookAtRandomSpot((SurvivorBot *)param_2);
}
goto LAB_0091b147;
}
if (*(int *)(sb_melee_approach_victim._28_4_ + 0x30) != 0) {
cVar4 = (**(code **)(*(int *)param_2 + 0x908))(param_2,10);
if (((((cVar4 == '\0') &&
(cVar4 = (**(code **)(*(int *)param_2 + 0x908))(param_2,0xb), cVar4 == '\0')) ||
(uVar1 = *(uint *)(param_1 + 0x4c), uVar1 == 0xffffffff)) ||
((puVar14 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar14 == (undefined *)0xfffffffc ||
(*(uint *)(puVar14 + 8) != uVar1 >> 0xc)))) ||
(pCVar7 = *(CBaseEntity **)(puVar14 + 4), pCVar7 == (CBaseEntity *)0x0)) {
if (param_1[0x80] != (SurvivorBot)0x0) {
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0x9a8))(param_2);
iVar6 = piVar5[0x18];
if (iVar6 < 1) {
piVar5 = (int *)(**(code **)(*piVar5 + 0xb0))(piVar5);
uVar11 = (**(code **)(*piVar5 + 0x13c))(piVar5);
DevMsg("%3.2f: %s: PopLegsStack: Underflow\n",(double)*(float *)(gpGlobals + 0xc),uVar11);
}
else {
iVar16 = iVar6 + -1;
piVar5[0x18] = iVar16;
piVar2 = (int *)piVar5[iVar6 + 8];
if (piVar2 != (int *)0x0) {
(**(code **)(*piVar2 + 4))(piVar2);
iVar16 = piVar5[0x18];
}
if ((Behavior<SurvivorBot> *)piVar5[iVar16 + 8] != (Behavior<SurvivorBot> *)0x0) {
Behavior<SurvivorBot>::Resume
((Behavior<SurvivorBot> *)piVar5[iVar16 + 8],(SurvivorBot *)piVar5[6]);
}
}
param_1[0x80] = (SurvivorBot)0x0;
}
}
else if (param_1[0x80] == (SurvivorBot)0x0) {
this_01 = ::operator_new(0x9050);
/* try { // try from 0091b8c8 to 0091b8cc has its CatchHandler @ 0091be1a */
SurvivorLegsApproach::SurvivorLegsApproach(this_01,pCVar7);
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0x9a8))(param_2);
if (piVar5[0x18] < 0xf) {
puVar12 = ::operator_new(0x38);
*puVar12 = &PTR__Behavior_00d00308;
puVar12[1] = &PTR__Behavior_00d003d0;
/* try { // try from 0091b916 to 0091b91a has its CatchHandler @ 0091bdf8 */
CFmtStrN<32>::CFmtStrN((CFmtStrN<32> *)(puVar12 + 3),"%s");
puVar12[2] = this_01;
iVar6 = piVar5[0x18];
piVar5[0x18] = iVar6 + 1;
piVar5[iVar6 + 9] = (int)puVar12;
}
else {
piVar5 = (int *)(**(code **)(*piVar5 + 0xb0))(piVar5);
uVar11 = (**(code **)(*piVar5 + 0x13c))(piVar5);
DevMsg("%3.2f: %s: PushLegsStack: Overflow\n",(double)*(float *)(gpGlobals + 0xc),uVar11);
if (this_01 != (SurvivorLegsApproach *)0x0) {
(**(code **)(*(int *)this_01 + 4))(this_01);
}
}
param_1[0x80] = (SurvivorBot)0x1;
}
}
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0x9ac))(param_2);
iVar6 = SurvivorBot::GetTeamSituation((SurvivorBot *)param_2);
pCVar7 = (CBaseEntity *)SelectTarget((SurvivorAttack *)param_1,(SurvivorBot *)param_2);
if ((pCVar7 != (CBaseEntity *)0x0) &&
(cVar4 = INextBot::IsDebugging((INextBot *)((int)param_2 + 0x4028),3), cVar4 != '\0')) {
pVVar8 = (Vector *)(**(code **)(*(int *)pCVar7 + 0x288))(pCVar7);
pVVar9 = (Vector *)(**(code **)(*(int *)param_2 + 0x288))(param_2);
NDebugOverlay::HorzArrow(pVVar9,pVVar8,2.0,0xff,0,0,0xff,true,0.01023);
}
EquipBestWeapon((SurvivorAttack *)param_1,(SurvivorBot *)param_2);
AimWeapon((SurvivorAttack *)param_1,(SurvivorBot *)param_2);
lVar18 = (longdouble)CountdownTimer::Now();
if (*(float *)(param_1 + 0x70) <= (float)lVar18) {
if (*(int *)(param_1 + 100) != 0) {
*(int *)(param_1 + 100) = *(int *)(param_1 + 100) + -1;
}
lVar18 = (longdouble)CountdownTimer::Now();
fVar22 = *(float *)(param_1 + 0x6c);
if ((float)lVar18 + fVar22 != *(float *)(param_1 + 0x70)) {
(**(code **)(*(int *)(param_1 + 0x68) + 4))(param_1 + 0x68,param_1 + 0x70);
*(float *)(param_1 + 0x70) = (float)lVar18 + fVar22;
}
}
if (pCVar7 == (CBaseEntity *)0x0) goto LAB_0091b147;
pSVar10 = (SurvivorIntention *)(**(code **)(*(int *)param_2 + 0x9a8))(param_2);
cVar4 = SurvivorIntention::IsDangerousTo
(pSVar10,(CTerrorPlayer *)param_2,(CBaseCombatCharacter *)pCVar7);
if (cVar4 == '\0') {
if (0 < *(int *)(iVar6 + 0xc4)) {
iVar16 = 0;
do {
pCVar17 = (CTerrorPlayer *)0x0;
uVar1 = *(uint *)(iVar6 + 0x88 + iVar16 * 4);
if (((uVar1 != 0xffffffff) &&
(puVar14 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar14 != (undefined *)0xfffffffc))
&& (*(uint *)(puVar14 + 8) == uVar1 >> 0xc)) {
pCVar17 = *(CTerrorPlayer **)(puVar14 + 4);
}
pSVar10 = (SurvivorIntention *)(**(code **)(*(int *)param_2 + 0x9a8))(param_2);
cVar4 = SurvivorIntention::IsDangerousTo(pSVar10,pCVar17,(CBaseCombatCharacter *)pCVar7);
if (cVar4 != '\0') goto LAB_0091b473;
iVar16 = iVar16 + 1;
} while (iVar16 < *(int *)(iVar6 + 0xc4));
}
cVar4 = INextBot::IsDebugging((INextBot *)((int)param_2 + 0x4028),1);
if (cVar4 != '\0') {
uVar11 = (**(code **)(*(int *)param_2 + 0x9b8))(param_2);
DevMsg("%3.2f: %s: NOT FIRING because threat is not dangerous\n",
(double)*(float *)(gpGlobals + 0xc),uVar11);
}
goto LAB_0091b147;
}
LAB_0091b473:
iVar16 = CTerrorPlayer::ClassifyZombie(pCVar7);
if ((((iVar16 == 2) && (cVar4 = (**(code **)(*(int *)pCVar7 + 0x16c))(pCVar7), cVar4 != '\0')) &&
((*(int *)(pCVar7 + 0x338c) < *(int *)(pCVar7 + 0x337c) + -1 ||
((((iVar13 = CBaseEntity::GetTeamNumber(pCVar7), iVar13 != 3 ||
(iVar13 = (**(code **)(*(int *)pCVar7 + 0x544))(pCVar7), iVar13 != 2)) &&
((iVar13 = CBaseEntity::GetTeamNumber(pCVar7), iVar13 != 3 ||
(iVar13 = (**(code **)(*(int *)pCVar7 + 0x544))(pCVar7), iVar13 != 1)))) &&
((iVar13 = CBaseEntity::GetTeamNumber(pCVar7), iVar13 != 3 ||
(iVar13 = (**(code **)(*(int *)pCVar7 + 0x544))(pCVar7), iVar13 != 3)))))))) &&
(lVar18 = (longdouble)CountdownTimer::Now(), *(float *)(pCVar7 + 0x32dc) <= (float)lVar18)) {
fVar22 = *(float *)(ZombieExplodingOuterRadius._28_4_ + 0x2c) * 0.8;
if (((byte)pCVar7[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar7);
}
if ((*(byte *)((int)param_2 + 0x14d) & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)param_2);
}
fVar19 = *(float *)((int)param_2 + 0x2e4) - *(float *)(pCVar7 + 0x2e4);
fVar21 = *(float *)((int)param_2 + 0x2e8) - *(float *)(pCVar7 + 0x2e8);
fVar20 = *(float *)((int)param_2 + 0x2e0) - *(float *)(pCVar7 + 0x2e0);
if (((fVar19 * fVar19 + fVar21 * fVar21 + fVar20 * fVar20 < fVar22 * fVar22) &&
(cVar4 = (**(code **)(*(int *)param_2 + 0x908))(param_2,10), cVar4 == '\0')) &&
(cVar4 = (**(code **)(*(int *)param_2 + 0x908))(param_2,0xb), cVar4 == '\0')) {
this_00 = ::operator_new(0x6c);
/* try { // try from 0091b5a7 to 0091b5ab has its CatchHandler @ 0091bde6 */
SurvivorAmbushBoomer::SurvivorAmbushBoomer(this_00,pCVar7);
*(undefined4 *)(param_1 + 0x20) = 0;
*(undefined4 *)(param_1 + 0x24) = 0;
*(undefined4 *)(param_1 + 0x28) = 0;
*(undefined4 *)(param_1 + 0x2c) = 0;
*(undefined4 *)this = 2;
*(SurvivorAmbushBoomer **)(this + 4) = this_00;
*(char **)(this + 8) = "Ambushing a nearby Boomer";
return this;
}
}
cVar4 = (**(code **)(*piVar5 + 0xe4))(piVar5,pCVar7);
if (cVar4 == '\0') goto LAB_0091b6c0;
if (iVar16 - 7U < 2) {
bVar3 = false;
LAB_0091b874:
if (iVar16 == 5) goto LAB_0091bbe9;
if (iVar16 != 0) {
if (iVar16 == 6) goto LAB_0091b72a;
goto LAB_0091b720;
}
lVar18 = (longdouble)CountdownTimer::Now();
if ((*(float *)(param_1 + 0x7c) <= (float)lVar18) ||
((iVar13 = CBaseCombatCharacter::GetActiveWeapon((CBaseCombatCharacter *)param_2),
iVar13 != 0 && (*(char *)(iVar13 + 0x1459) != '\0')))) goto LAB_0091b720;
}
else {
cVar4 = (**(code **)(*(int *)param_2 + 0x7e8))(param_2);
if (cVar4 == '\0') {
uVar1 = *(uint *)((int)param_2 + 0x2e28);
bVar3 = true;
if (((uVar1 != 0xffffffff) &&
(puVar14 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar14 != (undefined *)0xfffffffc)) &&
((*(uint *)(puVar14 + 8) == uVar1 >> 0xc && (*(int *)(puVar14 + 4) != 0))))
goto LAB_0091b6c0;
}
else {
LAB_0091b6c0:
bVar3 = false;
}
if (iVar16 == 2) {
cVar4 = (**(code **)(*(int *)pCVar7 + 0x16c))(pCVar7);
pCVar15 = (CBaseEntity *)0x0;
if (cVar4 != '\0') {
pCVar15 = pCVar7;
}
if ((*(int *)(pCVar15 + 0x338c) < *(int *)(pCVar15 + 0x337c) + -1) ||
(((iVar13 = CBaseEntity::GetTeamNumber(pCVar15), iVar13 != 3 ||
(iVar13 = (**(code **)(*(int *)pCVar15 + 0x544))(pCVar15), iVar13 != 2)) &&
(((iVar13 = CBaseEntity::GetTeamNumber(pCVar15), iVar13 != 3 ||
(iVar13 = (**(code **)(*(int *)pCVar15 + 0x544))(pCVar15), iVar13 != 1)) &&
((iVar13 = CBaseEntity::GetTeamNumber(pCVar15), iVar13 != 3 ||
(iVar13 = (**(code **)(*(int *)pCVar15 + 0x544))(pCVar15), iVar13 != 3))))))))
goto LAB_0091b720;
goto LAB_0091b72a;
}
if (iVar16 != 3) goto LAB_0091b874;
cVar4 = (**(code **)(*(int *)pCVar7 + 0x16c))(pCVar7);
pCVar15 = (CBaseEntity *)0x0;
if (cVar4 != '\0') {
pCVar15 = pCVar7;
}
uVar1 = *(uint *)(pCVar15 + 0x3e64);
if ((((uVar1 == 0xffffffff) ||
(puVar14 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar14 == (undefined *)0xfffffffc)) ||
(*(uint *)(puVar14 + 8) != uVar1 >> 0xc)) || (*(int *)(puVar14 + 4) == 0))
goto LAB_0091b720;
LAB_0091bbe9:
lVar18 = (longdouble)RandomFloat(0,0x42c80000);
if ((float)lVar18 <= 25.0) {
LAB_0091b720:
if (bVar3) {
if (((byte)pCVar7[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar7);
}
if ((*(byte *)((int)param_2 + 0x14d) & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)param_2);
}
fVar22 = *(float *)((int)param_2 + 0x2e0) - *(float *)(pCVar7 + 0x2e0);
fVar20 = *(float *)((int)param_2 + 0x2e8) - *(float *)(pCVar7 + 0x2e8);
fVar19 = *(float *)((int)param_2 + 0x2e4) - *(float *)(pCVar7 + 0x2e4);
if (fVar22 * fVar22 + fVar20 * fVar20 + fVar19 * fVar19 < 2500.0) {
if ((iVar16 == 2) ||
((cVar4 = (**(code **)(*(int *)param_2 + 0x908))(param_2,10), cVar4 == '\0' &&
(cVar4 = (**(code **)(*(int *)param_2 + 0x908))(param_2,0xb), cVar4 == '\0')))) {
(**(code **)(*(int *)param_2 + 0x940))(param_2,0xbf800000);
}
else {
(**(code **)(*(int *)param_2 + 0x938))(param_2,0xbf800000);
}
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0x9a4))(param_2);
(**(code **)(*piVar5 + 0xc4))
(piVar5,pCVar7,3,0x3f000000,0,"Looking at melee shove target",1,0x3e800000);
lVar18 = (longdouble)RandomFloat(0x3f800000,0x40000000);
fVar22 = (float)lVar18;
lVar18 = (longdouble)CountdownTimer::Now();
if ((float)lVar18 + fVar22 != *(float *)(param_1 + 0x7c)) {
(**(code **)(*(int *)(param_1 + 0x74) + 4))(param_1 + 0x74,param_1 + 0x7c);
*(float *)(param_1 + 0x7c) = (float)lVar18 + fVar22;
}
if (fVar22 != *(float *)(param_1 + 0x78)) {
(**(code **)(*(int *)(param_1 + 0x74) + 4))(param_1 + 0x74,param_1 + 0x78);
*(float *)(param_1 + 0x78) = fVar22;
}
if ((2 < *(int *)(param_1 + 100)) && (*(int *)(iVar6 + 0xc4) != 0)) {
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0x9ac))(param_2);
iVar6 = (**(code **)(*piVar5 + 0xc0))(piVar5,3);
if (3 < iVar6) {
lVar18 = (longdouble)RandomFloat(0,0x3f800000);
SurvivorBot::Say((SurvivorBot *)param_2,"SurvivorBotHelpOverwhelmed",2,(float)lVar18,0
);
}
}
}
}
}
}
LAB_0091b72a:
FireWeapon((SurvivorAttack *)param_1,(SurvivorBot *)param_2);
LAB_0091b147:
*(undefined4 *)this = 0;
*(undefined4 *)(this + 4) = 0;
*(undefined4 *)(this + 8) = 0;
return this;
}
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.