L L4D2node

CTerrorMeleeWeapon::PrimaryAttack

0x0056b6a0 · 279 bytes · __thiscall

_ZN18CTerrorMeleeWeapon13PrimaryAttackEv

Decompiled

undefined (1 param)

/* CTerrorMeleeWeapon::PrimaryAttack() */

void __thiscall CTerrorMeleeWeapon::PrimaryAttack(CTerrorMeleeWeapon *this)

{
  float fVar1;
  uint uVar2;
  CBaseEdict *this_00;
  char cVar3;
  CTerrorPlayer *pCVar4;
  int iVar5;
  undefined *puVar6;
  
  pCVar4 = (CTerrorPlayer *)CTerrorWeapon::GetPlayerOwner((CTerrorWeapon *)this);
  if (pCVar4 != (CTerrorPlayer *)0x0) {
    uVar2 = *(uint *)(pCVar4 + 0x33c4);
    if ((((uVar2 != 0xffffffff) &&
         (puVar6 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar6 != (undefined *)0xfffffffc)) &&
        (*(uint *)(puVar6 + 8) == uVar2 >> 0xc)) && (*(int *)(puVar6 + 4) != 0)) {
      return;
    }
    cVar3 = (**(code **)(*(int *)pCVar4 + 0x840))(pCVar4);
    if (cVar3 == '\0') {
      DevMsg("melee attack failed - !player->CanAttack()\n");
      return;
    }
    cVar3 = (**(code **)(*(int *)this + 0x434))(this);
    if (cVar3 == '\0') {
      DevMsg("melee attack failed - !IsWeaponVisible()\n");
      return;
    }
    cVar3 = CTerrorWeapon::HelpingHandPrimaryAttack((CTerrorWeapon *)this);
    if (cVar3 == '\0') {
      StartMeleeSwing(this,pCVar4,true);
      fVar1 = *(float *)(gpGlobals + 0xc);
      if (fVar1 != *(float *)(this + 0x182c)) {
        if (this[0x6c] == (CTerrorMeleeWeapon)0x0) {
          this_00 = *(CBaseEdict **)(this + 0x30);
          if (this_00 != (CBaseEdict *)0x0) {
            *(uint *)this_00 = *(uint *)this_00 | 0x101;
            iVar5 = CBaseEdict::GetChangeAccessor(this_00);
            *(undefined2 *)(iVar5 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CTerrorMeleeWeapon)((byte)this[0x70] | 1);
        }
        *(float *)(this + 0x182c) = fVar1;
      }
    }
  }
  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)