L L4D2node

ScavengeScan::ChooseItem

0x00964180 · 1536 bytes · __thiscall

_ZN12ScavengeScan10ChooseItemEP11CBaseEntity10CSWeaponIDf

Decompiled

undefined (4 params)

/* ScavengeScan::ChooseItem(CBaseEntity*, CSWeaponID, float) */

void __thiscall
ScavengeScan::ChooseItem
          (ScavengeScan *this,CBaseUpgradeItem *param_1,int param_3,undefined4 param_4)

{
  code *pcVar1;
  char cVar2;
  int *piVar3;
  int iVar4;
  CNavArea *this_00;
  undefined4 uVar5;
  undefined4 *puVar6;
  int iVar7;
  CWeaponCSBase *pCVar8;
  char *pcVar9;
  CBaseCombatWeapon *this_01;
  undefined4 uVar10;
  
  cVar2 = CDirectorChallengeMode::ShouldAvoidItem
                    (*(CDirectorChallengeMode **)(TheDirector + 0x648),param_3);
  if (cVar2 != '\0') {
    return;
  }
  cVar2 = CTerrorPlayer::CanUseWeapon(*(CTerrorPlayer **)this,param_3);
  if (cVar2 == '\0') {
    return;
  }
  piVar3 = (int *)(**(code **)(**(int **)this + 0x9a8))(*(int **)this);
  iVar4 = 0;
  if (*(int *)this != 0) {
    iVar4 = *(int *)this + 0x4028;
  }
  iVar4 = (**(code **)(*piVar3 + 0xb4))(piVar3,iVar4,param_1);
  if (iVar4 == 0) {
    return;
  }
  iVar4 = GetWeaponInfo(param_3);
  if (((iVar4 == 0) || (*(int *)(iVar4 + 0xbe8) != 1)) || (*(int *)(iVar4 + 0x158) != 0)) {
    iVar4 = GetWeaponInfo(param_3);
    if (((iVar4 != 0) && (*(int *)(iVar4 + 0xbe8) == 2)) && (*(int *)(iVar4 + 0x158) == 0)) {
      pCVar8 = (CWeaponCSBase *)(**(code **)(**(int **)this + 0x484))(*(int **)this,0);
      if ((pCVar8 != (CWeaponCSBase *)0x0) &&
         (iVar4 = CWeaponCSBase::GetCSWpnData(pCVar8), *(int *)(iVar4 + 0xbe8) == 2)) {
        if (0 < *(int *)(*(int *)this + 0x4308)) {
          return;
        }
        if (*(char *)(*(int *)this + 0x4304) == '\0') {
          cVar2 = IsFavoriteWeapon(this,param_3);
          goto joined_r0x0096452d;
        }
      }
      goto LAB_009642e0;
    }
    iVar4 = GetWeaponInfo(param_3);
    if ((iVar4 != 0) && (*(int *)(iVar4 + 0x894) == 7)) {
      iVar4 = (**(code **)(**(int **)this + 0x484))(*(int **)this,2);
joined_r0x0096454f:
      if (iVar4 != 0) {
        return;
      }
      goto LAB_009642e0;
    }
    if ((param_3 == 0x17) || (param_3 == 0xf)) {
      iVar4 = (**(code **)(**(int **)this + 0x484))(*(int **)this,4);
      goto joined_r0x0096454f;
    }
    if (param_3 == 0xc) {
      piVar3 = (int *)(**(code **)(**(int **)this + 0x484))(*(int **)this,3);
      if ((piVar3 != (int *)0x0) && (iVar4 = (**(code **)(*piVar3 + 0x638))(piVar3), iVar4 == 0xc))
      {
        return;
      }
      goto LAB_009642e0;
    }
    if (param_3 == 0x20) {
      iVar4 = ConvertToExternalCharacter(*(undefined4 *)(*(int *)this + 0x2ba0));
      if (iVar4 - 5U < 2) {
        return;
      }
      if (iVar4 - 2U < 2) {
        return;
      }
      goto LAB_009642e0;
    }
    iVar4 = GetWeaponInfo(param_3);
    if ((iVar4 != 0) && (*(int *)(iVar4 + 0x894) == 0)) {
      piVar3 = (int *)(**(code **)(**(int **)this + 0x484))(*(int **)this,1);
      if ((piVar3 != (int *)0x0) &&
         (piVar3 = (int *)(**(code **)(*piVar3 + 0x500))(piVar3), piVar3 != (int *)0x0)) {
        cVar2 = (**(code **)(*piVar3 + 0x674))(piVar3);
        if (cVar2 != '\0') {
          return;
        }
        cVar2 = (**(code **)(*piVar3 + 0x70c))(piVar3);
        goto joined_r0x0096452d;
      }
      goto LAB_009642e0;
    }
    if (param_3 == 0x13) {
      iVar4 = SurvivorBot::GetTeamSituation(*(SurvivorBot **)this);
      if (*(int *)(survivorbot_max_team_melee_weapons._28_4_ + 0x30) <= *(int *)(iVar4 + 0x84)) {
        return;
      }
      goto LAB_009642e0;
    }
    if (param_3 == 0x36) {
      this_01 = (CBaseCombatWeapon *)(**(code **)(**(int **)this + 0x484))(*(int **)this,0);
      if (this_01 == (CBaseCombatWeapon *)0x0) {
        return;
      }
      cVar2 = CBaseCombatWeapon::UsesPrimaryAmmo(this_01);
      if (cVar2 == '\0') {
        return;
      }
      puVar6 = (undefined4 *)GetAmmoDef();
      uVar5 = *(undefined4 *)this;
      pcVar1 = *(code **)*puVar6;
      uVar10 = (**(code **)(*(int *)this_01 + 0x55c))(this_01);
      iVar4 = (*pcVar1)(puVar6,uVar10,uVar5);
      iVar7 = (**(code **)(*(int *)this_01 + 0x55c))(this_01);
      iVar7 = CBaseCombatCharacter::GetAmmoCount(*(CBaseCombatCharacter **)this,iVar7);
      if ((float)iVar4 * 0.8 < (float)iVar7) {
        return;
      }
      if (iVar4 < 1) {
        return;
      }
      goto LAB_009642e0;
    }
    if (param_3 != 0x37) {
      if (param_3 != 0x14) {
        return;
      }
      pcVar9 = (char *)CDirector::GetGameMode();
      if (pcVar9 != "mutation7") {
        iVar4 = _V_stricmp(pcVar9,"mutation7");
        goto joined_r0x0096454f;
      }
      goto LAB_009642e0;
    }
    piVar3 = (int *)(**(code **)(**(int **)this + 0x484))(*(int **)this,0);
    if (piVar3 == (int *)0x0) {
      return;
    }
    if (param_1 == (CBaseUpgradeItem *)0x0) {
      return;
    }
    pcVar1 = *(code **)(*piVar3 + 0x6b4);
    uVar5 = (**(code **)(*(int *)param_1 + 0x3f0))(param_1);
    cVar2 = (*pcVar1)(piVar3,uVar5);
    if (cVar2 != '\0') {
      return;
    }
    cVar2 = (**(code **)(*(int *)param_1 + 0x3f4))(param_1);
    if ((cVar2 != '\0') &&
       (cVar2 = CBaseUpgradeItem::HasBeenUsedBySurvivor
                          (param_1,*(undefined4 *)(*(int *)this + 0x2ba0)), cVar2 != '\0')) {
      return;
    }
  }
  else {
    pCVar8 = (CWeaponCSBase *)(**(code **)(**(int **)this + 0x484))(*(int **)this,0);
    if (((pCVar8 != (CWeaponCSBase *)0x0) &&
        (iVar4 = CWeaponCSBase::GetCSWpnData(pCVar8), *(int *)(iVar4 + 0xbe8) == 1)) ||
       ((pCVar8 = (CWeaponCSBase *)(**(code **)(**(int **)this + 0x484))(*(int **)this,0),
        pCVar8 != (CWeaponCSBase *)0x0 &&
        (iVar4 = CWeaponCSBase::GetCSWpnData(pCVar8), *(int *)(iVar4 + 0xbe8) == 2)))) {
      cVar2 = *(char *)(*(int *)this + 0x4304);
joined_r0x0096452d:
      if (cVar2 == '\0') {
        return;
      }
    }
LAB_009642e0:
    if (param_1 == (CBaseUpgradeItem *)0x0) goto LAB_00964350;
  }
  piVar3 = (int *)(**(code **)(*(int *)param_1 + 0x188))(param_1);
  if (piVar3 != (int *)0x0) {
    iVar4 = (**(code **)(*piVar3 + 0x530))(piVar3);
    if ((iVar4 == 0) && (iVar4 = (**(code **)(**(int **)this + 0x484))(*(int **)this,0), iVar4 != 0)
       ) {
      iVar4 = piVar3[0x53f];
      uVar5 = (**(code **)(*piVar3 + 0x55c))(piVar3);
      puVar6 = (undefined4 *)GetAmmoDef();
      iVar7 = (**(code **)*puVar6)(puVar6,uVar5,*(undefined4 *)this);
      if (iVar7 < 0) {
        iVar7 = iVar7 + 3;
      }
      if (iVar4 < iVar7 >> 2) {
        return;
      }
    }
    iVar4 = (**(code **)(*piVar3 + 0x5e0))(piVar3);
    if (iVar4 == *(int *)this) {
      return;
    }
    iVar4 = (**(code **)(*piVar3 + 0x5e0))(piVar3);
    if ((iVar4 != 0) && (iVar4 = (**(code **)(*piVar3 + 0x5e0))(piVar3), iVar4 != *(int *)this)) {
      return;
    }
  }
LAB_00964350:
  this_00 = (CNavArea *)CNavMesh::GetNearestNavArea(TheNavMesh,(CBaseEntity *)param_1,1,250.0);
  if (((this_00 == (CNavArea *)0x0) ||
      ((*(int *)(this_00 + 0x70) < *(int *)(gpGlobals + 0x18) &&
       (cVar2 = CNavArea::IsBlocked(this_00,2,false), cVar2 == '\0')))) &&
     (cVar2 = SurvivorBot::IsReachable(*(SurvivorBot **)this,(CBaseEntity *)param_1), cVar2 != '\0')
     ) {
    *(undefined4 *)(this + 8) = param_4;
    *(CBaseUpgradeItem **)(this + 4) = param_1;
  }
  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)