L L4D2node

CMultiplayRules::GetNextBestWeapon

0x0046e170 · 386 bytes · __thiscall

_ZN15CMultiplayRules17GetNextBestWeaponEP20CBaseCombatCharacterP17CBaseCombatWeapon

Decompiled

undefined (3 params)

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

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

{
  uint uVar1;
  CBaseCombatWeapon *pCVar2;
  char cVar3;
  int iVar4;
  undefined *puVar5;
  CBaseCombatCharacter *pCVar6;
  CBaseCombatWeapon *local_2c;
  int local_28;
  int local_24;
  
  if (param_2 == (CBaseCombatWeapon *)0x0) {
    local_28 = -1;
  }
  else {
    cVar3 = (**(code **)(*(int *)param_2 + 0x528))(param_2);
    if ((cVar3 == '\0') || (cVar3 = (**(code **)(*(int *)param_2 + 0x418))(param_2), cVar3 == '\0'))
    {
      return (CBaseCombatWeapon *)0x0;
    }
    local_28 = (**(code **)(*(int *)param_2 + 0x520))(param_2);
  }
  local_24 = -1;
  local_2c = (CBaseCombatWeapon *)0x0;
  pCVar6 = param_1;
  do {
    uVar1 = *(uint *)(pCVar6 + 0x18f4);
    if (((((uVar1 != 0xffffffff) &&
          (puVar5 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar5 != (undefined *)0xfffffffc)) &&
         (*(uint *)(puVar5 + 8) == uVar1 >> 0xc)) &&
        (pCVar2 = *(CBaseCombatWeapon **)(puVar5 + 4), pCVar2 != (CBaseCombatWeapon *)0x0)) &&
       ((param_2 == (CBaseCombatWeapon *)0x0 ||
        (cVar3 = (**(code **)(*(int *)pCVar2 + 0x524))(pCVar2), cVar3 != '\0')))) {
      iVar4 = (**(code **)(*(int *)pCVar2 + 0x520))(pCVar2);
      if ((iVar4 < 0) || (iVar4 = (**(code **)(*(int *)pCVar2 + 0x520))(pCVar2), local_28 != iVar4))
      {
        iVar4 = (**(code **)(*(int *)pCVar2 + 0x520))(pCVar2);
        if (((local_24 < iVar4) && (param_2 != pCVar2)) &&
           (cVar3 = (**(code **)(*(int *)pCVar2 + 0x40c))(pCVar2), cVar3 != '\0')) {
          local_24 = (**(code **)(*(int *)pCVar2 + 0x520))(pCVar2);
          local_2c = pCVar2;
        }
      }
      else if (param_2 == pCVar2) {
        (**(code **)(*(int *)param_2 + 0x520))(param_2);
      }
      else {
        cVar3 = (**(code **)(*(int *)pCVar2 + 0x40c))(pCVar2);
        if ((cVar3 != '\0') &&
           (cVar3 = (**(code **)(*(int *)param_1 + 0x47c))(param_1,pCVar2), cVar3 != '\0')) {
          return pCVar2;
        }
      }
    }
    pCVar6 = pCVar6 + 4;
    if (pCVar6 == param_1 + 0xe0) {
      return local_2c;
    }
  } 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)