L L4D2node

CTerrorPlayer::PreThink

0x009d7e00 · 1075 bytes · __thiscall

_ZN13CTerrorPlayer8PreThinkEv

Decompiled

undefined (1 param)

/* CTerrorPlayer::PreThink() */

void __thiscall CTerrorPlayer::PreThink(CTerrorPlayer *this)

{
  float fVar1;
  code *pcVar2;
  char cVar3;
  int iVar4;
  int *piVar5;
  longdouble lVar6;
  undefined4 local_6c;
  undefined4 local_68;
  float local_64;
  Vector local_60 [32];
  float local_40;
  float local_34;
  char local_2a;
  char local_29;
  
  UpdateZombieClassState(this);
  CCSPlayer::PreThink((CCSPlayer *)this);
  iVar4 = (**(code **)(*(int *)this + 0x52c))();
  if ((iVar4 != 0) && (*(int *)(ZombieShowLastArea._28_4_ + 0x30) != 0)) {
    cVar3 = (**(code **)(*(int *)this + 300))();
    if (cVar3 != '\0') {
      iVar4 = (**(code **)(*(int *)this + 0x52c))();
      if (((byte)this[0x14d] & 8) != 0) {
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
      }
      NDebugOverlay::Line((Vector *)(this + 0x2e0),(Vector *)(iVar4 + 0x2c),0,0xff,0,true,0.1);
    }
  }
  piVar5 = (int *)&stack0xffffff64;
  if (*(int *)(SurvivorDebugInCombat._28_4_ + 0x30) != 0) {
    cVar3 = IsInCombat(this,false);
    piVar5 = (int *)&stack0xffffff64;
    if (cVar3 != '\0') {
      (**(code **)(*(int *)this + 0x234))();
      piVar5 = (int *)&stack0xffffff60;
      NDebugOverlay::Circle(local_60,10.0,0xff,0,0,0xff,true,0.1);
    }
  }
  iVar4 = *(int *)this;
  *piVar5 = (int)this;
  pcVar2 = *(code **)(iVar4 + 0x778);
  piVar5[-1] = 0x9d7e58;
  cVar3 = (*pcVar2)();
  if (cVar3 != '\0') goto LAB_009d7ea0;
  if (*(float *)(this + 0x3fd8) <= 0.0) {
LAB_009d7f20:
    piVar5[-1] = 0x9d7f25;
    cVar3 = CTerrorGameRules::HasPlayerControlledZombies();
    if (cVar3 != '\0') goto LAB_009d7ea0;
    *piVar5 = TheDirector;
    piVar5[-1] = 0x9d7f3a;
    cVar3 = CDirector::IsFinaleEscapeInProgress((CDirector *)*piVar5);
    if (cVar3 != '\0') goto LAB_009d7ea0;
    *piVar5 = TheDirector;
    piVar5[-1] = 0x9d7f4f;
    cVar3 = CDirector::IsFinaleWon((CDirector *)*piVar5);
    if (cVar3 != '\0') goto LAB_009d7ea0;
    *piVar5 = (int)this;
    piVar5[-1] = 0x9d7f5f;
    cVar3 = IsAwayFromKeyboard((CTerrorPlayer *)*piVar5);
    if (cVar3 == '\0') goto LAB_009d7ea0;
    *piVar5 = (int)this;
    piVar5[-1] = 0x9d7f6f;
    iVar4 = CBaseEntity::GetTeamNumber((CBaseEntity *)*piVar5);
    if (iVar4 != 2) goto LAB_009d7ea0;
    iVar4 = *(int *)this;
    *piVar5 = (int)this;
    pcVar2 = *(code **)(iVar4 + 300);
    piVar5[-1] = 0x9d7f83;
    cVar3 = (*pcVar2)();
    if (cVar3 == '\0') goto LAB_009d7ea0;
    if (-1 < *(int *)(DirectorAFKTimeout._28_4_ + 0x30)) {
      *piVar5 = TheDirector;
      piVar5[-1] = 0x9d7fa4;
      cVar3 = CDirector::NoSurvivorBots((CDirector *)*piVar5);
      if (cVar3 != '\0') goto LAB_009d7ea0;
      piVar5[1] = 1;
      *piVar5 = 2;
      piVar5[-1] = 0x9d7fc0;
      iVar4 = UTIL_HumansOnTeam(*piVar5,SUB41(piVar5[1],0));
      if (iVar4 < 2) goto LAB_009d7ea0;
    }
    iVar4 = *(int *)this;
    *piVar5 = (int)this;
    pcVar2 = *(code **)(iVar4 + 0xb8);
    piVar5[-1] = 0x9d7fd4;
    iVar4 = (*pcVar2)();
    piVar5[5] = 0;
    piVar5[4] = 0;
    piVar5[3] = 0;
    piVar5[2] = iVar4;
    piVar5[1] = (int)"#L4D_idle_spectator";
    *piVar5 = 3;
    piVar5[-1] = 0x9d8004;
    UTIL_ClientPrintAll(*piVar5,(char *)piVar5[1],(char *)piVar5[2],(char *)piVar5[3],
                        (char *)piVar5[4],(char *)piVar5[5]);
  }
  else {
    *piVar5 = (int)(this + 0x3fd0);
    piVar5[-1] = 0x9d7e7a;
    lVar6 = (longdouble)CountdownTimer::Now();
    if ((float)lVar6 < *(float *)(this + 0x3fd8)) goto LAB_009d7f20;
  }
  *piVar5 = (int)this;
  piVar5[-1] = 0x9d7e97;
  GoAwayFromKeyboard((CTerrorPlayer *)*piVar5);
LAB_009d7ea0:
  iVar4 = *(int *)this;
  *piVar5 = (int)this;
  pcVar2 = *(code **)(iVar4 + 300);
  piVar5[-1] = 0x9d7eab;
  cVar3 = (*pcVar2)();
  if (((cVar3 != '\0') && (this[0x186] == (CTerrorPlayer)0x9)) &&
     ((*(uint *)(this + 0x1cb0) & 0x801) != 0)) {
    iVar4 = *(int *)this;
    piVar5[1] = 0;
    *piVar5 = (int)this;
    pcVar2 = *(code **)(iVar4 + 0x7a0);
    piVar5[-1] = 0x9d8143;
    iVar4 = (*pcVar2)();
    if (((byte)this[0x14d] & 8) == 0) {
      local_6c = *(undefined4 *)(this + 0x2e0);
      local_68 = *(undefined4 *)(this + 0x2e4);
      local_64 = *(float *)(this + 0x2e8) - 100.0;
    }
    else {
      *piVar5 = (int)this;
      piVar5[-1] = 0x9d8210;
      CBaseEntity::CalcAbsolutePosition((CBaseEntity *)*piVar5);
      local_6c = *(undefined4 *)(this + 0x2e0);
      local_68 = *(undefined4 *)(this + 0x2e4);
      local_64 = *(float *)(this + 0x2e8) - 100.0;
      if ((*(uint *)(this + 0x14c) & 0x800) != 0) {
        *piVar5 = (int)this;
        piVar5[-1] = 0x9d8257;
        CBaseEntity::CalcAbsolutePosition((CBaseEntity *)*piVar5);
      }
    }
    piVar5[3] = iVar4;
    piVar5[4] = (int)local_60;
    piVar5[2] = (int)&local_6c;
    piVar5[1] = (int)(this + 0x2e0);
    *piVar5 = (int)this;
    piVar5[-1] = 0x9d81a5;
    UTIL_TraceEntity((CBaseEntity *)*piVar5,(Vector *)piVar5[1],(Vector *)piVar5[2],piVar5[3],
                     (CGameTrace *)piVar5[4]);
    if ((((local_34 < 1.0) || (local_2a != '\0')) || (local_29 != '\0')) && (0.7 < local_40)) {
      piVar5[2] = 0;
      piVar5[1] = 2;
      *piVar5 = (int)this;
      piVar5[-1] = 0x9d81ed;
      CBaseEntity::SetMoveType();
      *(uint *)(this + 0x1cb0) = *(uint *)(this + 0x1cb0) & 0xfffff7fe;
      *piVar5 = (int)this;
      piVar5[-1] = 0x9d81ff;
      UpdateWeaponEquipage((CTerrorPlayer *)*piVar5);
    }
  }
  fVar1 = *(float *)(this + 0x3fbc);
  if ((0.0 < fVar1) && (fVar1 < *(float *)(gpGlobals + 0xc) || fVar1 == *(float *)(gpGlobals + 0xc))
     ) {
    *piVar5 = (int)this;
    piVar5[-1] = 0x9d7ee8;
    iVar4 = CBaseEntity::GetTeamNumber((CBaseEntity *)*piVar5);
    *piVar5 = iVar4;
    piVar5[-1] = 0x9d7ef0;
    cVar3 = IsASurvivorTeam(iVar4);
    if (cVar3 == '\0') {
      piVar5[1] = 4;
      *piVar5 = (int)this;
      piVar5[-1] = 0x9d7f08;
      CBaseEntity::AddEffects((CBaseEntity *)*piVar5,piVar5[1]);
    }
    else {
      iVar4 = *(int *)this;
      piVar5[1] = 0;
      *piVar5 = (int)this;
      pcVar2 = *(code **)(iVar4 + 0x5f8);
      piVar5[-1] = 0x9d8113;
      (*pcVar2)();
    }
    *(undefined4 *)(this + 0x3fbc) = 0;
    return;
  }
  return;
}

SourceMod gamedata

paste into addons/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.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)