L L4D2node

SurvivorBot::LookAtRandomSpot

0x0093a1d0 · 978 bytes · __thiscall

_ZN11SurvivorBot16LookAtRandomSpotEv

Decompiled

undefined (1 param)

/* SurvivorBot::LookAtRandomSpot() */

void __thiscall SurvivorBot::LookAtRandomSpot(SurvivorBot *this)

{
  code *pcVar1;
  char cVar2;
  int *piVar3;
  int *piVar4;
  float *pfVar5;
  int iVar6;
  SurvivorTeamSituation *this_00;
  longdouble lVar7;
  longdouble lVar8;
  float fVar9;
  float fVar10;
  float fVar11;
  float local_58;
  float local_54;
  float local_50;
  float local_4c;
  float local_48;
  float local_44;
  float local_40;
  float local_3c;
  float local_38;
  float local_34;
  float local_30;
  float local_2c;
  float local_28;
  float local_24;
  float local_20;
  
  lVar7 = (longdouble)CountdownTimer::Now();
  if (*(float *)(this + 0x8b50) <= (float)lVar7) {
    lVar7 = (longdouble)RandomFloat(0x40400000,0x40a00000);
    fVar10 = (float)lVar7;
    lVar7 = (longdouble)CountdownTimer::Now();
    if ((float)lVar7 + fVar10 != *(float *)(this + 0x8b50)) {
      (**(code **)(*(int *)(this + 0x8b48) + 4))(this + 0x8b48,this + 0x8b50);
      *(float *)(this + 0x8b50) = (float)lVar7 + fVar10;
    }
    if (fVar10 != *(float *)(this + 0x8b4c)) {
      (**(code **)(*(int *)(this + 0x8b48) + 4))(this + 0x8b48,this + 0x8b4c);
      *(float *)(this + 0x8b4c) = fVar10;
    }
    piVar3 = (int *)(**(code **)(*(int *)this + 0x9a4))(this);
    piVar4 = (int *)(**(code **)(*(int *)this + 0x9ac))(this);
    lVar7 = (longdouble)RandomFloat(0,0x42c80000);
    if ((float)lVar7 < 33.0) {
      this_00 = (SurvivorTeamSituation *)GetTeamSituation(this);
      iVar6 = SurvivorTeamSituation::GetRandomVisibleFriend(this_00);
      if (iVar6 != 0) {
        fVar10 = *(float *)(this + 0x8b50);
        pcVar1 = *(code **)(*piVar3 + 0xc4);
        lVar7 = (longdouble)CountdownTimer::Now();
        (*pcVar1)(piVar3,iVar6,0,fVar10 - (float)lVar7,0,"Looking around at friend",1,0x3e800000);
        return;
      }
    }
    pfVar5 = (float *)(**(code **)(*piVar3 + 0xbc))(piVar3);
    local_58 = *pfVar5;
    local_54 = pfVar5[1];
    local_50 = pfVar5[2];
    local_44 = 0.0;
    local_4c = local_58;
    local_48 = local_54;
    VectorNormalize((Vector *)&local_4c);
    local_40 = -local_48;
    local_38 = 0.0;
    local_3c = local_4c;
    VectorNormalize((Vector *)&local_40);
    iVar6 = RandomInt(0,100);
    fVar10 = 1.0;
    if (iVar6 < 0x32) {
      fVar10 = -1.0;
    }
    lVar7 = (longdouble)RandomFloat(0xbf000000,0x3f000000);
    lVar8 = (longdouble)RandomFloat(0x3f000000,0x40000000);
    fVar10 = (float)lVar8 * fVar10;
    local_50 = (float)lVar7 + local_44 + local_38 * fVar10;
    local_54 = local_3c * fVar10 + local_48;
    local_58 = fVar10 * local_40 + local_4c;
    VectorNormalize((Vector *)&local_58);
    fVar9 = local_58 * 300.0;
    fVar11 = local_54 * 300.0;
    fVar10 = local_50 * 300.0;
    (**(code **)(*(int *)this + 0x234))(&local_28,this);
    local_34 = fVar9 + local_28;
    local_30 = fVar11 + local_24;
    local_2c = fVar10 + local_20;
    cVar2 = (**(code **)(*piVar4 + 0xf4))(piVar4,&local_34);
    if (cVar2 != '\0') {
      fVar10 = *(float *)(this + 0x8b50);
      pcVar1 = *(code **)(*piVar3 + 0xc0);
      lVar7 = (longdouble)CountdownTimer::Now();
      (*pcVar1)(piVar3,&local_34,0,fVar10 - (float)lVar7,0,"Looking around at random spot",1,
                0x3e800000);
    }
  }
  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)