L L4D2node

CBaseEntity::OnTakeDamage

0x00601dc0 · 1602 bytes · __thiscall

_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo

Decompiled

undefined (2 params)

/* WARNING: Removing unreachable block (ram,0x00602123) */
/* WARNING: Removing unreachable block (ram,0x0060209b) */
/* WARNING: Removing unreachable block (ram,0x00602017) */
/* WARNING: Removing unreachable block (ram,0x00602427) */
/* WARNING: Removing unreachable block (ram,0x00602419) */
/* WARNING: Removing unreachable block (ram,0x00602412) */
/* CBaseEntity::OnTakeDamage(CTakeDamageInfo const&) */

undefined4 __thiscall CBaseEntity::OnTakeDamage(CBaseEntity *this,CTakeDamageInfo *param_1)

{
  float fVar1;
  float fVar2;
  float fVar3;
  float fVar4;
  float fVar5;
  float fVar6;
  float fVar7;
  uint uVar8;
  undefined4 uVar9;
  undefined *puVar10;
  float *pfVar11;
  float *pfVar12;
  int iVar13;
  int *piVar14;
  int iVar15;
  bool bVar16;
  float local_34;
  float local_30;
  float local_2c;
  float local_28;
  float local_24;
  float local_20;
  
  uVar9 = 0;
  if ((*(int *)(this + 0x30) != 0) && (this[0x105] != (CBaseEntity)0x0)) {
    uVar8 = *(uint *)(param_1 + 0x30);
    if ((uVar8 == 0xffffffff) ||
       (((puVar10 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar10 == (undefined *)0xfffffffc ||
         (*(uint *)(puVar10 + 8) != uVar8 >> 0xc)) || (*(int *)(puVar10 + 4) == 0)))) {
      g_vecAttackDir = 1.0;
      DAT_00fe36bc = 0.0;
      DAT_00fe36b8 = DAT_00fe36bc;
    }
    else {
      pfVar11 = (float *)(**(code **)(*(int *)this + 0x288))(this);
      piVar14 = (int *)0x0;
      uVar8 = *(uint *)(param_1 + 0x30);
      if (((uVar8 != 0xffffffff) &&
          (puVar10 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)) &&
         (*(uint *)(puVar10 + 8) == uVar8 >> 0xc)) {
        piVar14 = *(int **)(puVar10 + 4);
      }
      pfVar12 = (float *)(**(code **)(*piVar14 + 0x288))(piVar14);
      g_vecAttackDir = *pfVar12 - *pfVar11;
      DAT_00fe36b8 = pfVar12[1] - pfVar11[1];
      DAT_00fe36bc = pfVar12[2] - pfVar11[2];
    }
    VectorNormalize((Vector *)&g_vecAttackDir);
    if (-1 < *(int *)(this + 0x14c)) {
      if (this[0x186] == (CBaseEntity)0x6) {
        (**(code **)(*(int *)this + 0x2a0))(this,param_1);
      }
      else {
        uVar8 = *(uint *)(param_1 + 0x30);
        if (((uVar8 != 0xffffffff) &&
            (puVar10 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc))
           && ((*(uint *)(puVar10 + 8) == uVar8 >> 0xc &&
               ((*(int *)(puVar10 + 4) != 0 && ((byte)((char)this[0x186] - 2U) < 2)))))) {
          iVar13 = 0;
          uVar8 = *(uint *)(param_1 + 0x34);
          if ((uVar8 != 0xffffffff) &&
             ((puVar10 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc
              && (*(uint *)(puVar10 + 8) == uVar8 >> 0xc)))) {
            iVar13 = *(int *)(puVar10 + 4);
          }
          if ((*(byte *)(iVar13 + 0x1b4) & 8) == 0) {
            pfVar11 = (float *)(**(code **)(*(int *)this + 0x288))(this);
            piVar14 = (int *)0x0;
            local_34 = *pfVar11;
            local_30 = pfVar11[1];
            local_2c = pfVar11[2];
            uVar8 = *(uint *)(param_1 + 0x30);
            if (((uVar8 != 0xffffffff) &&
                (puVar10 = g_pEntityList + (uVar8 & 0xfff) * 0x10,
                puVar10 != (undefined *)0xfffffffc)) && (*(uint *)(puVar10 + 8) == uVar8 >> 0xc)) {
              piVar14 = *(int **)(puVar10 + 4);
            }
            pfVar11 = (float *)(**(code **)(*piVar14 + 0x288))(piVar14);
            local_34 = local_34 - *pfVar11;
            local_30 = local_30 - pfVar11[1];
            local_2c = local_2c - pfVar11[2];
            VectorNormalize((Vector *)&local_34);
            fVar1 = *(float *)(param_1 + 0x3c);
            if ((AllocTempVector()::s_vecTemp == '\0') &&
               (iVar13 = __cxa_guard_acquire(&AllocTempVector()::s_vecTemp), iVar13 != 0)) {
              __cxa_guard_release(&AllocTempVector()::s_vecTemp);
            }
            if ((AllocTempVector()::s_nIndex == '\0') &&
               (iVar13 = __cxa_guard_acquire(&AllocTempVector()::s_nIndex), iVar13 != 0)) {
              AllocTempVector()::s_nIndex = 0;
              __cxa_guard_release(&AllocTempVector()::s_nIndex);
            }
            AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
            LOCK();
            UNLOCK();
            fVar2 = *(float *)(this + 0x1a8);
            iVar13 = AllocTempVector()::s_nIndex * 0xc;
            bVar16 = AllocTempVector()::s_vecTemp == '\0';
            fVar3 = *(float *)(this + 0x19c);
            *(float *)(AllocTempVector()::s_vecTemp + iVar13) = fVar2 - fVar3;
            *(float *)(AllocTempVector()::s_vecTemp + iVar13 + 4) =
                 *(float *)(this + 0x1ac) - *(float *)(this + 0x1a0);
            *(float *)(AllocTempVector()::s_vecTemp + iVar13 + 8) =
                 *(float *)(this + 0x1b0) - *(float *)(this + 0x1a4);
            if ((bVar16) &&
               (iVar13 = __cxa_guard_acquire(&AllocTempVector()::s_vecTemp), iVar13 != 0)) {
              __cxa_guard_release(&AllocTempVector()::s_vecTemp);
            }
            if ((AllocTempVector()::s_nIndex == '\0') &&
               (iVar13 = __cxa_guard_acquire(&AllocTempVector()::s_nIndex), iVar13 != 0)) {
              AllocTempVector()::s_nIndex = 0;
              __cxa_guard_release(&AllocTempVector()::s_nIndex);
            }
            AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
            LOCK();
            UNLOCK();
            iVar13 = AllocTempVector()::s_nIndex * 0xc;
            bVar16 = AllocTempVector()::s_vecTemp == '\0';
            *(float *)(AllocTempVector()::s_vecTemp + iVar13) =
                 *(float *)(this + 0x1a8) - *(float *)(this + 0x19c);
            fVar4 = *(float *)(this + 0x1ac);
            fVar5 = *(float *)(this + 0x1a0);
            *(float *)(AllocTempVector()::s_vecTemp + iVar13 + 4) = fVar4 - fVar5;
            *(float *)(AllocTempVector()::s_vecTemp + iVar13 + 8) =
                 *(float *)(this + 0x1b0) - *(float *)(this + 0x1a4);
            if ((bVar16) &&
               (iVar13 = __cxa_guard_acquire(&AllocTempVector()::s_vecTemp), iVar13 != 0)) {
              __cxa_guard_release(&AllocTempVector()::s_vecTemp);
            }
            if ((AllocTempVector()::s_nIndex == '\0') &&
               (iVar13 = __cxa_guard_acquire(&AllocTempVector()::s_nIndex), iVar13 != 0)) {
              AllocTempVector()::s_nIndex = 0;
              __cxa_guard_release(&AllocTempVector()::s_nIndex);
            }
            AllocTempVector()::s_nIndex = AllocTempVector()::s_nIndex + 0x10001 & 0x7f;
            LOCK();
            UNLOCK();
            iVar13 = AllocTempVector()::s_nIndex * 0xc;
            *(float *)(AllocTempVector()::s_vecTemp + iVar13) =
                 *(float *)(this + 0x1a8) - *(float *)(this + 0x19c);
            *(float *)(AllocTempVector()::s_vecTemp + iVar13 + 4) =
                 *(float *)(this + 0x1ac) - *(float *)(this + 0x1a0);
            fVar6 = *(float *)(this + 0x1b0);
            fVar7 = *(float *)(this + 0x1a4);
            *(float *)(AllocTempVector()::s_vecTemp + iVar13 + 8) = fVar6 - fVar7;
            local_20 = fVar1 * 5.0 *
                       (73728.0 / ((fVar6 - fVar7) * (fVar2 - fVar3) * (fVar4 - fVar5)));
            if (1000.0 <= local_20) {
              local_20 = 1000.0;
            }
            local_28 = local_34 * local_20;
            local_24 = local_30 * local_20;
            local_20 = local_20 * local_2c;
            ApplyAbsVelocityImpulse(this,(Vector *)&local_28);
          }
        }
      }
    }
    if (this[0x105] != (CBaseEntity)0x1) {
      iVar13 = *(int *)(this + 0x100);
      iVar15 = iVar13 - (int)*(float *)(param_1 + 0x3c);
      if (iVar13 != iVar15) {
        (**(code **)(*(int *)this + 0x214))(this,this + 0x100);
        *(int *)(this + 0x100) = iVar15;
        iVar13 = iVar15;
      }
      if (iVar13 < 1) {
        (**(code **)(*(int *)this + 0x130))(this,param_1);
        return 0;
      }
    }
    uVar9 = 1;
  }
  return uVar9;
}

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)