L L4D2node

SurvivorAttack::EquipBestWeapon

0x0091ac40 · 947 bytes · __thiscall

_ZNK14SurvivorAttack15EquipBestWeaponEP11SurvivorBot

Decompiled

undefined (2 params)

/* SurvivorAttack::EquipBestWeapon(SurvivorBot*) const */

void __thiscall SurvivorAttack::EquipBestWeapon(SurvivorAttack *this,SurvivorBot *param_1)

{
  float fVar1;
  byte bVar2;
  char cVar3;
  int iVar4;
  CWeaponCSBase *this_00;
  CWeaponCSBase *pCVar5;
  CBaseEntity *this_01;
  longdouble lVar6;
  CWeaponCSBase *local_28;
  CWeaponCSBase *local_24;
  
  if (param_1 == (SurvivorBot *)0x0) {
    return;
  }
  iVar4 = CBaseCombatCharacter::GetActiveWeapon((CBaseCombatCharacter *)param_1);
  if (iVar4 == 0) {
    return;
  }
  if ((0.0 < *(float *)(param_1 + 0x1ab98)) &&
     (lVar6 = (longdouble)IntervalTimer::Now(), (float)lVar6 - *(float *)(param_1 + 0x1ab98) < 5.0))
  {
    return;
  }
  this_00 = (CWeaponCSBase *)(**(code **)(*(int *)param_1 + 0x484))(param_1,0);
  pCVar5 = (CWeaponCSBase *)(**(code **)(*(int *)param_1 + 0x484))(param_1,1);
  bVar2 = CDirector::IsFinale(TheDirector);
  if (pCVar5 == (CWeaponCSBase *)0x0) {
LAB_0091ae38:
    local_24 = (CWeaponCSBase *)0x0;
    local_28 = (CWeaponCSBase *)0x0;
  }
  else {
    iVar4 = CWeaponCSBase::GetCSWpnData(pCVar5);
    local_24 = (CWeaponCSBase *)0x0;
    local_28 = pCVar5;
    if (*(int *)(iVar4 + 0x894) != 0) {
      iVar4 = CWeaponCSBase::GetCSWpnData(pCVar5);
      if ((*(int *)(iVar4 + 0x894) != 10) &&
         (iVar4 = CWeaponCSBase::GetCSWpnData(pCVar5), *(int *)(iVar4 + 0x894) != 0xb))
      goto LAB_0091ae38;
      local_28 = (CWeaponCSBase *)0x0;
      local_24 = pCVar5;
    }
  }
  if ((this_00 == (CWeaponCSBase *)0x0) ||
     (cVar3 = (**(code **)(*(int *)this_00 + 0x3c8))(this_00), cVar3 == '\0')) {
LAB_0091add8:
    (**(code **)(*(int *)param_1 + 0x474))(param_1,pCVar5,0);
    return;
  }
  this_01 = (CBaseEntity *)SelectTarget(this,param_1);
  if (this_01 != (CBaseEntity *)0x0) {
    lVar6 = (longdouble)(**(code **)(*(int *)(param_1 + 0x4028) + 0x124))(param_1 + 0x4028,this_01);
    fVar1 = (float)lVar6;
    iVar4 = CWeaponCSBase::GetCSWpnData(this_00);
    if (*(int *)(iVar4 + 0x894) == 3) {
      iVar4 = CBaseEntity::GetTeamNumber(this_01);
      if (((iVar4 != 3) || (iVar4 = (**(code **)(*(int *)this_01 + 0x544))(this_01), iVar4 != 8)) &&
         ((iVar4 = CBaseEntity::GetTeamNumber(this_01), iVar4 != 3 ||
          (iVar4 = (**(code **)(*(int *)this_01 + 0x544))(this_01), iVar4 != 7)))) {
        if ((750.0 < fVar1) && (local_28 != (CWeaponCSBase *)0x0)) {
          (**(code **)(*(int *)param_1 + 0x474))(param_1,local_28,0);
          return;
        }
        if (((fVar1 < 180.0) && (local_24 != (CWeaponCSBase *)0x0)) && ((bVar2 ^ 1) != 0)) {
          (**(code **)(*(int *)param_1 + 0x474))(param_1,local_24,0);
          return;
        }
        if (500.0 <= fVar1) {
          return;
        }
      }
      goto LAB_0091adab;
    }
    iVar4 = CWeaponCSBase::GetCSWpnData(this_00);
    if (*(int *)(iVar4 + 0x894) == 4) {
      iVar4 = CBaseEntity::GetTeamNumber(this_01);
      if (((iVar4 != 3) || (iVar4 = (**(code **)(*(int *)this_01 + 0x544))(this_01), iVar4 != 8)) &&
         ((iVar4 = CBaseEntity::GetTeamNumber(this_01), iVar4 != 3 ||
          (iVar4 = (**(code **)(*(int *)this_01 + 0x544))(this_01), iVar4 != 7)))) {
        if ((fVar1 < 300.0) && (local_28 != (CWeaponCSBase *)0x0)) goto LAB_0091add8;
        if (((fVar1 < 180.0) && (local_24 != (CWeaponCSBase *)0x0)) && ((bVar2 ^ 1) != 0)) {
          (**(code **)(*(int *)param_1 + 0x474))(param_1,local_24,0);
          return;
        }
        if (fVar1 <= 500.0) {
          return;
        }
      }
      goto LAB_0091adab;
    }
  }
  pCVar5 = (CWeaponCSBase *)CBaseCombatCharacter::GetActiveWeapon((CBaseCombatCharacter *)param_1);
  if (this_00 == pCVar5) {
    return;
  }
  iVar4 = CBaseCombatCharacter::GetActiveWeapon((CBaseCombatCharacter *)param_1);
  if (*(char *)(iVar4 + 0x1459) != '\0') {
    return;
  }
LAB_0091adab:
  (**(code **)(*(int *)param_1 + 0x474))(param_1,this_00,0);
  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)