L L4D2node

CTerrorPlayer::GiveNamedItem

0x0099b7e0 · 2572 bytes · __thiscall

_ZN13CTerrorPlayer13GiveNamedItemEPKcibP11CBaseEntity

Decompiled

undefined (5 params)

/* CTerrorPlayer::GiveNamedItem(char const*, int, bool, CBaseEntity*) */

undefined4 __thiscall
CTerrorPlayer::GiveNamedItem
          (CTerrorPlayer *this,char *param_1,int param_2,bool param_3,CBaseEntity *param_4)

{
  uint uVar1;
  code *pcVar2;
  CBaseEdict *pCVar3;
  char cVar4;
  ushort uVar5;
  ushort uVar6;
  int iVar7;
  int iVar8;
  int *piVar9;
  uint *puVar10;
  undefined4 uVar11;
  CAmmoDef *this_00;
  CBaseEntity *pCVar12;
  int iVar13;
  CTerrorPlayer *pCVar14;
  CTerrorMeleeWeapon *this_01;
  undefined4 *puVar15;
  uint uVar16;
  undefined *puVar17;
  undefined1 *puVar18;
  undefined1 *puVar19;
  uint uVar20;
  CBaseCombatWeapon *this_02;
  CGlowProperty *this_03;
  int in_GS_OFFSET;
  char *local_154;
  undefined4 local_140 [4];
  uchar local_12e;
  uchar local_12d;
  Vector local_12c [12];
  char local_120 [256];
  int local_20;
  
  puVar19 = &stack0xfffffe94;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  puVar18 = &stack0xfffffe94;
  if ((param_1 != (char *)0x0) && (puVar18 = &stack0xfffffe94, *param_1 != '\0')) {
    if ((param_1 == "health") || (iVar7 = _V_stricmp(param_1,"health"), iVar7 == 0)) {
      iVar7 = (**(code **)(*(int *)this + 0x1fc))();
      if (iVar7 != *(int *)(this + 0x100)) {
        (**(code **)(*(int *)this + 0x214))();
        *(int *)(this + 0x100) = iVar7;
      }
      cVar4 = (**(code **)(*(int *)this + 300))();
      puVar18 = &stack0xfffffe94;
      if (cVar4 != '\0') {
        cVar4 = (**(code **)(*(int *)this + 0x7e8))();
        if (cVar4 != '\0') {
          (**(code **)(*(int *)this + 0x924))();
        }
        pcVar2 = *(code **)(*(int *)this + 0x128);
        (**(code **)(*(int *)this + 0x1fc))();
        (*pcVar2)();
        uVar11 = 0;
        goto LAB_0099b9db;
      }
    }
    else if ((param_1 == "ammo") || (iVar7 = _V_stricmp(param_1,"ammo"), iVar7 == 0)) {
      iVar7 = 0;
      do {
        this_00 = (CAmmoDef *)GetAmmoDef();
        iVar8 = CAmmoDef::GetAmmoOfIndex(this_00,iVar7);
        if ((iVar8 != 0) && ((*(byte *)(iVar8 + 4) & 2) != 0)) {
          (**(code **)(*(int *)this + 0x44c))();
        }
        iVar7 = iVar7 + 1;
        puVar18 = &stack0xfffffe94;
      } while (iVar7 != 0x20);
    }
    else {
      iVar7 = CMeleeWeaponInfoStore::GetInfoHandle
                        ((CMeleeWeaponInfoStore *)g_MeleeWeaponInfoStore,param_1);
      iVar8 = CMeleeWeaponInfoStore::GetInvalidHandle();
      if (iVar7 == iVar8) {
        iVar8 = V_strncasecmp(param_1,"weapon_",7);
        if (iVar8 == 0) {
          V_strncpy(local_120,param_1,0x100);
        }
        else {
          V_snprintf(local_120,0x100,"weapon_%s");
        }
      }
      else {
        V_strncpy(local_120,"weapon_melee",0x100);
      }
      local_154 = local_120;
      _V_strlower(local_154);
      iVar8 = _V_stricmp(local_154,"weapon_melee");
      if ((iVar8 != 0) ||
         (iVar8 = CMeleeWeaponInfoStore::GetInvalidHandle(), puVar18 = &stack0xfffffe94,
         iVar7 != iVar8)) {
        AllocPooledString((char *)local_140);
        piVar9 = (int *)CreateEntityByName(local_154,-1,true);
        if (piVar9 != (int *)0x0) {
          puVar10 = (uint *)(**(code **)(*piVar9 + 0xc))();
          uVar20 = *puVar10;
          if (uVar20 != 0xffffffff) {
            uVar16 = uVar20 & 0xfff;
            puVar17 = g_pEntityList + uVar16 * 0x10;
            if (((puVar17 != (undefined *)0xfffffffc) &&
                (uVar1 = *(uint *)(puVar17 + 8), uVar1 == uVar20 >> 0xc)) &&
               (*(int *)(puVar17 + 4) != 0)) {
              (**(code **)(*(int *)this + 0x234))();
              puVar17 = g_pEntityList + uVar16 * 0x10;
              if ((puVar17 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar17 + 8))) {
                pCVar12 = (CBaseEntity *)0x0;
              }
              else {
                pCVar12 = *(CBaseEntity **)(puVar17 + 4);
              }
              CBaseEntity::SetLocalOrigin(pCVar12,local_12c);
              piVar9 = (int *)(g_pEntityList + uVar16 * 0x10 + 4);
              if ((piVar9 == (int *)0x0) || (uVar1 != *(uint *)(g_pEntityList + uVar16 * 0x10 + 8)))
              {
                iVar8 = 0;
              }
              else {
                iVar8 = *(int *)(g_pEntityList + uVar16 * 0x10 + 4);
              }
              uVar20 = *(uint *)(iVar8 + 0x148) | 0x40000000;
              if (*(uint *)(iVar8 + 0x148) != uVar20) {
                if (*(char *)(iVar8 + 0x6c) == '\0') {
                  pCVar3 = *(CBaseEdict **)(iVar8 + 0x30);
                  if (pCVar3 != (CBaseEdict *)0x0) {
                    *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
                    iVar13 = CBaseEdict::GetChangeAccessor(pCVar3);
                    *(undefined2 *)(iVar13 + 2) = 0;
                    piVar9 = (int *)(g_pEntityList + uVar16 * 0x10 + 4);
                  }
                }
                else {
                  *(byte *)(iVar8 + 0x70) = *(byte *)(iVar8 + 0x70) | 1;
                }
                *(uint *)(iVar8 + 0x148) = uVar20;
              }
              if (param_4 != (CBaseEntity *)0x0) {
                if ((piVar9 == (int *)0x0) || (uVar1 != piVar9[1])) {
                  iVar8 = 0;
                }
                else {
                  iVar8 = *piVar9;
                }
                if (iVar8 != -0x1f0) {
                  this_03 = (CGlowProperty *)(param_4 + 0x1f0);
                  iVar8 = CGlowProperty::GetGlowState(this_03);
                  puVar17 = g_pEntityList + uVar16 * 0x10;
                  if ((puVar17 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar17 + 8))) {
                    iVar13 = 0;
                  }
                  else {
                    iVar13 = *(int *)(puVar17 + 4);
                  }
                  CGlowProperty::SetGlowState((CGlowProperty *)(iVar13 + 0x1f0),iVar8);
                  iVar8 = CGlowProperty::GetGlowRange(this_03);
                  puVar17 = g_pEntityList + uVar16 * 0x10;
                  if ((puVar17 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar17 + 8))) {
                    iVar13 = 0;
                  }
                  else {
                    iVar13 = *(int *)(puVar17 + 4);
                  }
                  CGlowProperty::SetGlowRange((CGlowProperty *)(iVar13 + 0x1f0),iVar8);
                  iVar8 = CGlowProperty::GetGlowRangeMin(this_03);
                  puVar17 = g_pEntityList + uVar16 * 0x10;
                  if ((puVar17 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar17 + 8))) {
                    iVar13 = 0;
                  }
                  else {
                    iVar13 = *(int *)(puVar17 + 4);
                  }
                  CGlowProperty::SetGlowRangeMin((CGlowProperty *)(iVar13 + 0x1f0),iVar8);
                  CGlowProperty::GetGlowColorOverride
                            (this_03,&local_12e,&local_12d,(uchar *)local_12c);
                  CGlowProperty::SetGlowColorOverride();
                  piVar9 = (int *)(g_pEntityList + uVar16 * 0x10 + 4);
                }
              }
              if (param_2 == 0) {
LAB_0099bd49:
                if (piVar9 != (int *)0x0) goto LAB_0099bc30;
LAB_0099bd51:
                this_02 = (CBaseCombatWeapon *)0x0;
              }
              else {
                if (piVar9 == (int *)0x0) goto LAB_0099bd51;
                if ((((uVar1 == piVar9[1]) && (*piVar9 != 0)) &&
                    (iVar8 = __dynamic_cast(), iVar8 != 0)) && (*(char *)(iVar8 + 0x17e2) != '\0'))
                {
                  if (*(char *)(iVar8 + 0x6c) == '\0') {
                    pCVar3 = *(CBaseEdict **)(iVar8 + 0x30);
                    if (pCVar3 != (CBaseEdict *)0x0) {
                      *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
                      iVar13 = CBaseEdict::GetChangeAccessor(pCVar3);
                      *(undefined2 *)(iVar13 + 2) = 0;
                      piVar9 = (int *)(g_pEntityList + uVar16 * 0x10 + 4);
                    }
                  }
                  else {
                    *(byte *)(iVar8 + 0x70) = *(byte *)(iVar8 + 0x70) | 1;
                  }
                  *(undefined1 *)(iVar8 + 0x17e2) = 0;
                  goto LAB_0099bd49;
                }
LAB_0099bc30:
                if (((uVar1 == piVar9[1]) && (*piVar9 != 0)) &&
                   (this_02 = (CBaseCombatWeapon *)__dynamic_cast(),
                   this_02 != (CBaseCombatWeapon *)0x0)) {
                  iVar8 = CMeleeWeaponInfoStore::GetInvalidHandle();
                  if ((iVar7 != iVar8) &&
                     (this_01 = (CTerrorMeleeWeapon *)__dynamic_cast(),
                     this_01 != (CTerrorMeleeWeapon *)0x0)) {
                    AllocPooledString((char *)local_140);
                    *(undefined4 *)(this_01 + 0x17e4) = local_140[0];
                    CTerrorMeleeWeapon::SetMeleeWeaponInfoHandle(this_01,iVar7);
                  }
                  puVar17 = g_pEntityList + uVar16 * 0x10;
                  if ((puVar17 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar17 + 8))) {
                    pCVar12 = (CBaseEntity *)0x0;
                  }
                  else {
                    pCVar12 = *(CBaseEntity **)(puVar17 + 4);
                  }
                  DispatchSpawn(pCVar12,true);
                  uVar5 = LookupWeaponInfoSlot(local_154);
                  uVar6 = GetInvalidWeaponInfoHandle();
                  if (uVar5 != uVar6) {
                    iVar7 = GetFileWeaponInfoFromHandle(uVar5);
                    if (iVar7 == 0) {
                      iVar7 = 0;
                    }
                    else {
                      iVar7 = __dynamic_cast();
                    }
                    puVar15 = (undefined4 *)GetAmmoDef();
                    iVar8 = (**(code **)*puVar15)();
                    if (((0 < iVar8) && (0 < *(int *)(iVar7 + 0x160))) &&
                       (iVar8 != *(int *)(this_02 + 0x14fc))) {
                      if (this_02[0x6c] == (CBaseCombatWeapon)0x0) {
                        pCVar3 = *(CBaseEdict **)(this_02 + 0x30);
                        if (pCVar3 != (CBaseEdict *)0x0) {
                          *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
                          iVar7 = CBaseEdict::GetChangeAccessor(pCVar3);
                          *(undefined2 *)(iVar7 + 2) = 0;
                        }
                      }
                      else {
                        this_02[0x70] = (CBaseCombatWeapon)((byte)this_02[0x70] | 1);
                      }
                      *(int *)(this_02 + 0x14fc) = iVar8;
                    }
                  }
                  this_02[0x150c] = (CBaseCombatWeapon)0x1;
                  if ((this[0x3f5c] != (CTerrorPlayer)0x0) &&
                     (this_02[0x1538] != (CBaseCombatWeapon)0x1)) {
                    if (this_02[0x6c] == (CBaseCombatWeapon)0x0) {
                      pCVar3 = *(CBaseEdict **)(this_02 + 0x30);
                      if (pCVar3 != (CBaseEdict *)0x0) {
                        *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
                        iVar7 = CBaseEdict::GetChangeAccessor(pCVar3);
                        *(undefined2 *)(iVar7 + 2) = 0;
                      }
                    }
                    else {
                      this_02[0x70] = (CBaseCombatWeapon)((byte)this_02[0x70] | 1);
                    }
                    this_02[0x1538] = (CBaseCombatWeapon)0x1;
                  }
                  this[0x299d] = (CTerrorPlayer)0x1;
                  piVar9 = (int *)(g_pEntityList + uVar16 * 0x10 + 4);
                  if (piVar9 == (int *)0x0) goto LAB_0099bc57;
                }
                else {
                  this[0x299d] = (CTerrorPlayer)0x1;
                  this_02 = (CBaseCombatWeapon *)0x0;
                }
                if (((uVar1 == piVar9[1]) && (piVar9 = (int *)*piVar9, piVar9 != (int *)0x0)) &&
                   ((*(byte *)(piVar9 + 0x53) & 1) == 0)) {
                  piVar9 = (int *)(**(code **)(*piVar9 + 0x188))();
                  if (piVar9 == (int *)0x0) {
                    puVar17 = g_pEntityList + uVar16 * 0x10;
                    if ((puVar17 == (undefined *)0xfffffffc) || (uVar1 != *(uint *)(puVar17 + 8))) {
                      piVar9 = (int *)0x0;
                    }
                    else {
                      piVar9 = *(int **)(puVar17 + 4);
                    }
                    (**(code **)(*piVar9 + 0x1b4))();
                  }
                  else {
                    cVar4 = (**(code **)(*(int *)this + 0x6ac))();
                    if (cVar4 != '\0') {
                      (**(code **)(*piVar9 + 0x4e4))();
                    }
                  }
                }
              }
LAB_0099bc57:
              this[0x299d] = (CTerrorPlayer)0x0;
              if (this_02 != (CBaseCombatWeapon *)0x0) {
                this_02[0x150c] = (CBaseCombatWeapon)0x0;
              }
              if ((param_3) &&
                 (pCVar14 = (CTerrorPlayer *)CBaseCombatWeapon::GetOwner(this_02), this != pCVar14))
              {
                UTIL_Remove((CBaseEntity *)this_02);
                puVar18 = &stack0xfffffe90;
              }
              else {
                puVar17 = g_pEntityList + uVar16 * 0x10;
                puVar18 = &stack0xfffffe90;
                if ((puVar17 != (undefined *)0xfffffffc) &&
                   (puVar18 = &stack0xfffffe90, uVar1 == *(uint *)(puVar17 + 8))) {
                  uVar11 = *(undefined4 *)(puVar17 + 4);
                  puVar19 = &stack0xfffffe90;
                  goto LAB_0099b9db;
                }
              }
              goto LAB_0099b9d9;
            }
          }
        }
        Msg();
        uVar11 = 0;
        puVar19 = &stack0xfffffe94;
        goto LAB_0099b9db;
      }
    }
  }
LAB_0099b9d9:
  uVar11 = 0;
  puVar19 = puVar18;
LAB_0099b9db:
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return uVar11;
  }
                    /* WARNING: Subroutine does not return */
  *(undefined **)(puVar19 + -4) = &UNK_0099c1f5;
  __stack_chk_fail();
}

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)