L L4D2node

CGib::SpawnHeadGib

0x006d5db0 · 846 bytes · __cdecl

_ZN4CGib12SpawnHeadGibEP11CBaseEntity

Decompiled

undefined (1 param)

/* CGib::SpawnHeadGib(CBaseEntity*) */

void CGib::SpawnHeadGib(CBaseEntity *param_1)

{
  code *pcVar1;
  CBaseEdict *this;
  CGib *this_00;
  int iVar2;
  int iVar3;
  int *piVar4;
  undefined4 uVar5;
  undefined4 *puVar6;
  longdouble lVar7;
  longdouble lVar8;
  longdouble lVar9;
  undefined4 uStackY_68;
  CGib *in_stack_ffffffa4;
  char *in_stack_ffffffa8;
  float local_34;
  float local_30;
  float local_2c;
  float local_28;
  float local_24;
  float local_20;
  
  this_00 = _CreateEntity<CGib>(in_stack_ffffffa4,in_stack_ffffffa8);
  if (*(int *)(g_Language._28_4_ + 0x30) == 1) {
    Spawn(this_00,"models/germangibs.mdl");
    iVar2 = *(int *)(this_00 + 0x45c);
  }
  else {
    Spawn(this_00,"models/gibs/hgibs.mdl");
    iVar2 = *(int *)(this_00 + 0x45c);
  }
  if (iVar2 != 0) {
    if (this_00[0x6c] == (CGib)0x0) {
      this = *(CBaseEdict **)(this_00 + 0x30);
      if (this != (CBaseEdict *)0x0) {
        *(uint *)this = *(uint *)this | 0x101;
        iVar2 = CBaseEdict::GetChangeAccessor(this);
        *(undefined2 *)(iVar2 + 2) = 0;
      }
    }
    else {
      this_00[0x70] = (CGib)((byte)this_00[0x70] | 1);
    }
    *(undefined4 *)(this_00 + 0x45c) = 0;
  }
  puVar6 = (undefined4 *)&stack0xffffffa4;
  if (param_1 != (CBaseEntity *)0x0) {
    if (((byte)this_00[0x14d] & 0x10) != 0) {
      CBaseEntity::CalcAbsoluteVelocity((CBaseEntity *)this_00);
    }
    local_34 = *(float *)(this_00 + 0x274);
    local_30 = *(float *)(this_00 + 0x278);
    local_2c = *(float *)(this_00 + 0x27c);
    (**(code **)(*(int *)param_1 + 0x234))();
    CBaseEntity::SetLocalOrigin((CBaseEntity *)this_00,(Vector *)&local_28);
    iVar2 = UTIL_FindClientInPVS(*(edict_t **)(this_00 + 0x30));
    iVar3 = (**(code **)(*random_valve + 8))();
    if ((iVar3 < 6) && (iVar2 != 0)) {
      puVar6 = (undefined4 *)&stack0xffffffa0;
      if ((*(int **)(iVar2 + 0xc) != (int *)0x0) &&
         (piVar4 = (int *)(**(code **)(**(int **)(iVar2 + 0xc) + 0x18))(),
         puVar6 = (undefined4 *)&stack0xffffffa0, piVar4 != (int *)0x0)) {
        if (((byte)this_00[0x14d] & 8) != 0) {
          CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this_00);
        }
        (**(code **)(*piVar4 + 0x234))();
        local_30 = local_24 - *(float *)(this_00 + 0x2e4);
        local_2c = local_20 - *(float *)(this_00 + 0x2e8);
        local_34 = local_28 - *(float *)(this_00 + 0x2e0);
        VectorNormalize((Vector *)&local_34);
        local_34 = local_34 * 300.0;
        puVar6 = (undefined4 *)&stack0xffffff9c;
        local_30 = local_30 * 300.0;
        local_2c = local_2c * 300.0 + 100.0;
      }
    }
    else {
      lVar9 = (longdouble)(**(code **)(*random_valve + 4))();
      lVar7 = (longdouble)(**(code **)(*random_valve + 4))();
      lVar8 = (longdouble)(**(code **)(*random_valve + 4))();
      local_34 = (float)lVar8;
      puVar6 = (undefined4 *)&stack0xffffffa0;
      local_30 = (float)lVar7;
      local_2c = (float)lVar9;
    }
    local_28 = *(float *)(this_00 + 0x280);
    local_24 = *(float *)(this_00 + 0x284);
    local_20 = *(float *)(this_00 + 0x288);
    iVar2 = *random_valve;
    *puVar6 = random_valve;
    puVar6[2] = 0x43480000;
    puVar6[1] = 0x42c80000;
    pcVar1 = *(code **)(iVar2 + 4);
    puVar6[-1] = 0x6d5fff;
    lVar9 = (longdouble)(*pcVar1)();
    local_28 = (float)lVar9;
    iVar2 = *random_valve;
    *puVar6 = random_valve;
    puVar6[2] = 0x43960000;
    puVar6[1] = 0x42c80000;
    pcVar1 = *(code **)(iVar2 + 4);
    puVar6[-1] = 0x6d6029;
    lVar9 = (longdouble)(*pcVar1)();
    *puVar6 = this_00;
    local_24 = (float)lVar9;
    puVar6[1] = &local_28;
    puVar6[-1] = 0x6d6045;
    CBaseEntity::SetLocalAngularVelocity((CBaseEntity *)*puVar6,(QAngle *)puVar6[1]);
    iVar2 = *(int *)param_1;
    *puVar6 = param_1;
    pcVar1 = *(code **)(iVar2 + 0x138);
    puVar6[-1] = 0x6d6050;
    uVar5 = (*pcVar1)();
    *(undefined4 *)(this_00 + 0x1410) = uVar5;
    puVar6[2] = &local_34;
    uVar5 = *(undefined4 *)(param_1 + 0x100);
    *puVar6 = this_00;
    puVar6[1] = uVar5;
    puVar6[-1] = 0x6d606c;
    AdjustVelocityBasedOnHealth((CGib *)*puVar6,puVar6[1],(Vector *)puVar6[2]);
    puVar6[1] = &local_34;
    *puVar6 = this_00;
    puVar6[-1] = 0x6d6078;
    CBaseEntity::SetAbsVelocity((CBaseEntity *)*puVar6,(Vector *)puVar6[1]);
  }
  *puVar6 = this_00;
  puVar6[-1] = 0x6d6080;
  LimitVelocity((CGib *)*puVar6);
  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)