L L4D2node

CSingleplayRules::GetNextBestWeapon

0x004b1a80 · 304 bytes · __thiscall

_ZN16CSingleplayRules17GetNextBestWeaponEP20CBaseCombatCharacterP17CBaseCombatWeapon

Decompiled

undefined (3 params)

/* CSingleplayRules::GetNextBestWeapon(CBaseCombatCharacter*, CBaseCombatWeapon*) */

int * __thiscall
CSingleplayRules::GetNextBestWeapon
          (CSingleplayRules *this,CBaseCombatCharacter *param_1,CBaseCombatWeapon *param_2)

{
  uint uVar1;
  int *piVar2;
  char cVar3;
  int iVar4;
  undefined *puVar5;
  CBaseCombatCharacter *pCVar6;
  int *local_28;
  int local_24;
  
  if ((param_2 != (CBaseCombatWeapon *)0x0) &&
     (cVar3 = (**(code **)(*(int *)param_2 + 0x528))(param_2), cVar3 == '\0')) {
    return (int *)0x0;
  }
  local_24 = -1;
  pCVar6 = param_1 + 0x18f4;
  local_28 = (int *)0x0;
  do {
    while (((((uVar1 = *(uint *)pCVar6, uVar1 != 0xffffffff &&
              (puVar5 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar5 != (undefined *)0xfffffffc))
             && (*(uint *)(puVar5 + 8) == uVar1 >> 0xc)) &&
            (piVar2 = *(int **)(puVar5 + 4), piVar2 != (int *)0x0)) &&
           (((param_2 == (CBaseCombatWeapon *)0x0 ||
             (cVar3 = (**(code **)(*piVar2 + 0x524))(piVar2), cVar3 != '\0')) &&
            ((cVar3 = (**(code **)(*(int *)param_1 + 0x47c))(param_1,piVar2), cVar3 != '\0' &&
             (iVar4 = (**(code **)(*piVar2 + 0x520))(piVar2), local_24 < iVar4))))))) {
      cVar3 = (**(code **)(*piVar2 + 0x548))(piVar2);
      if ((cVar3 != '\0') && (piVar2[0x508] < 1)) {
        iVar4 = (**(code **)(*piVar2 + 0x55c))(piVar2);
        iVar4 = CBaseCombatCharacter::GetAmmoCount(param_1,iVar4);
        if (iVar4 == 0) break;
      }
      pCVar6 = pCVar6 + 4;
      local_24 = (**(code **)(*piVar2 + 0x520))(piVar2);
      local_28 = piVar2;
      if (pCVar6 == param_1 + 0x19d4) {
        return piVar2;
      }
    }
    pCVar6 = pCVar6 + 4;
    if (pCVar6 == param_1 + 0x19d4) {
      return local_28;
    }
  } while( true );
}

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)