L L4D2node

CTerrorPlayer::SetModelFromClass

0x009c9440 · 1708 bytes · __thiscall

_ZN13CTerrorPlayer17SetModelFromClassEv

Decompiled

undefined (1 param)

/* CTerrorPlayer::SetModelFromClass() */

void __thiscall CTerrorPlayer::SetModelFromClass(CTerrorPlayer *this)

{
  char *pcVar1;
  uint *puVar2;
  code *pcVar3;
  CBaseEdict *pCVar4;
  int *piVar5;
  char cVar6;
  int iVar7;
  int iVar8;
  int *piVar9;
  KeyValues *this_00;
  CTerrorPlayer *pCVar10;
  CTerrorPlayer *pCVar11;
  undefined4 *puVar12;
  undefined4 *puVar13;
  undefined4 uStackY_78;
  int local_44;
  char *local_40;
  char *local_34;
  undefined4 local_30;
  undefined4 local_2c;
  undefined4 local_28;
  undefined4 local_24;
  undefined4 local_20;
  
  piVar5 = mdlcache;
  (**(code **)(*mdlcache + 0x68))();
                    /* try { // try from 009c9461 to 009c96d7 has its CatchHandler @ 009c9b51 */
  iVar7 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
  cVar6 = IsASurvivorTeam(iVar7);
  if (cVar6 == '\0') {
                    /* try { // try from 009c97bb to 009c9b15 has its CatchHandler @ 009c9b51 */
    iVar7 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
    if ((iVar7 != 3) ||
       (iVar7 = (**(code **)(*(int *)this + 0x544))(), puVar13 = (undefined4 *)&stack0xffffff94,
       iVar7 != 0)) {
      iVar7 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
      if (iVar7 == 3) {
        iVar7 = (**(code **)(*(int *)this + 0x544))();
        if (iVar7 == 9) {
          iVar7 = 0;
        }
        RandomInt();
        if ((((iVar7 == 2) &&
             (this_00 = (KeyValues *)CTerrorGameRules::GetMissionInfo(), this_00 != (KeyValues *)0x0
             )) && (iVar8 = KeyValues::GetInt(this_00,"no_female_boomers",0), iVar8 == 0)) &&
           ((g_ZombieReplacementGender != 1 && (g_ZombieReplacementGender != 2)))) {
          RandomInt();
        }
        (**(code **)(*(int *)this + 0x70))();
        if (iVar7 == 3) {
          puVar13 = (undefined4 *)&stack0xffffff94;
          if (*(int *)(this + 0x458) != 0) {
            if (this[0x6c] == (CTerrorPlayer)0x0) {
              pCVar4 = *(CBaseEdict **)(this + 0x30);
              if (pCVar4 != (CBaseEdict *)0x0) {
                *(uint *)pCVar4 = *(uint *)pCVar4 | 0x101;
                iVar7 = CBaseEdict::GetChangeAccessor(pCVar4);
                *(undefined2 *)(iVar7 + 2) = 0;
              }
            }
            else {
              this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
            }
            *(undefined4 *)(this + 0x458) = 0;
            puVar13 = (undefined4 *)&stack0xffffff94;
          }
          goto LAB_009c96d8;
        }
      }
      else {
        (**(code **)(*(int *)this + 0x70))();
      }
      piVar9 = *(int **)(this + 0x13e0);
      if (piVar9 == (int *)0x0) {
        iVar7 = CBaseEntity::GetModel((CBaseEntity *)this);
        if (iVar7 != 0) {
          CBaseAnimating::LockStudioHdr((CBaseAnimating *)this);
        }
        piVar9 = *(int **)(this + 0x13e0);
        puVar13 = (undefined4 *)&stack0xffffff94;
        if (piVar9 == (int *)0x0) goto LAB_009c96d8;
      }
      puVar13 = (undefined4 *)&stack0xffffff94;
      if ((*piVar9 != 0) &&
         (iVar7 = RandomInt(), puVar13 = (undefined4 *)&stack0xffffff94,
         iVar7 != *(int *)(this + 0x458))) {
        if (this[0x6c] == (CTerrorPlayer)0x0) {
          pCVar4 = *(CBaseEdict **)(this + 0x30);
          if (pCVar4 != (CBaseEdict *)0x0) {
            *(uint *)pCVar4 = *(uint *)pCVar4 | 0x101;
            iVar8 = CBaseEdict::GetChangeAccessor(pCVar4);
            *(undefined2 *)(iVar8 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
        }
        *(int *)(this + 0x458) = iVar7;
        puVar13 = (undefined4 *)&stack0xffffff94;
      }
    }
  }
  else {
    (**(code **)(*(int *)this + 0x20))();
    puVar12 = (undefined4 *)&stack0xffffff90;
    if (local_40 == (char *)0x0) {
      local_40 = "";
    }
    if (DAT_01017434 < 1) {
LAB_009c98e8:
      local_44 = ChooseSurvivorCharacter();
      if (local_44 + 1 != *(int *)(this + 0x290c)) {
        if (this[0x6c] == (CTerrorPlayer)0x0) {
          pCVar4 = *(CBaseEdict **)(this + 0x30);
          if (pCVar4 != (CBaseEdict *)0x0) {
            *(uint *)pCVar4 = *(uint *)pCVar4 | 0x101;
            iVar7 = CBaseEdict::GetChangeAccessor(pCVar4);
            *(undefined2 *)(iVar7 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
        }
        *(int *)(this + 0x290c) = local_44 + 1;
      }
      GetSurvivorModelName();
      (**(code **)(*(int *)this + 0x20))();
      puVar12 = (undefined4 *)&stack0xffffff8c;
      (**(code **)(*(int *)this + 0xb8))();
      UTIL_LogPrintf(
                    "SetModelFromClass: Survivor %s changed model from %s to %s via SetModelFromClass\n"
                    );
      (**(code **)(*(int *)this + 0x70))();
    }
    else {
      iVar7 = 0;
      pcVar1 = (char *)*SurvivorModels;
      while ((pcVar1 != local_40 && (iVar8 = _V_stricmp(pcVar1,local_40), iVar8 != 0))) {
        iVar7 = iVar7 + 1;
        if (DAT_01017434 <= iVar7) goto LAB_009c98e8;
        pcVar1 = (char *)SurvivorModels[iVar7];
      }
      local_44 = *(int *)(this + 0x2ba0);
    }
    if (this[0x121] != (CTerrorPlayer)0x1) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c9514;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      this[0x121] = (CTerrorPlayer)0x1;
    }
    if (this[0x120] != (CTerrorPlayer)0x0) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c9549;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      this[0x120] = (CTerrorPlayer)0x0;
    }
    if (this[0x124] != (CTerrorPlayer)0xff) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c957e;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      this[0x124] = (CTerrorPlayer)0xff;
    }
    if (this[0x125] != (CTerrorPlayer)0xff) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c95b3;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      this[0x125] = (CTerrorPlayer)0xff;
    }
    if (this[0x126] != (CTerrorPlayer)0xff) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c95e8;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      this[0x126] = (CTerrorPlayer)0xff;
    }
    if (this[0x127] != (CTerrorPlayer)0xff) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c961d;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      this[0x127] = (CTerrorPlayer)0xff;
    }
    if (*(int *)(this + 0x458) != 0) {
      if (this[0x6c] == (CTerrorPlayer)0x0) {
        puVar2 = *(uint **)(this + 0x30);
        if (puVar2 != (uint *)0x0) {
          *puVar2 = *puVar2 | 0x101;
          *puVar12 = puVar2;
          puVar12[-1] = 0x9c99bb;
          iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
          *(undefined2 *)(iVar7 + 2) = 0;
        }
      }
      else {
        this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
      }
      *(undefined4 *)(this + 0x458) = 0;
    }
    *(undefined4 *)(this + 0x307c) = 0;
    pCVar10 = this + 0x2d14;
    do {
      while( true ) {
        puVar12[2] = 4;
        puVar12[1] = &local_30;
        *puVar12 = pCVar10;
        local_30 = 0;
        puVar12[-1] = 0x9c9683;
        iVar7 = memcmp((void *)*puVar12,(void *)puVar12[1],puVar12[2]);
        if (iVar7 == 0) break;
        if (this[0x6c] == (CTerrorPlayer)0x0) {
          puVar2 = *(uint **)(this + 0x30);
          if (puVar2 != (uint *)0x0) {
            *puVar2 = *puVar2 | 0x101;
            *puVar12 = puVar2;
            puVar12[-1] = 0x9c96a6;
            iVar7 = CBaseEdict::GetChangeAccessor((CBaseEdict *)*puVar12);
            *(undefined2 *)(iVar7 + 2) = 0;
          }
        }
        else {
          this[0x70] = (CTerrorPlayer)((byte)this[0x70] | 1);
        }
        pCVar11 = pCVar10 + 4;
        *(undefined4 *)pCVar10 = 0;
        pCVar10 = pCVar11;
        if (pCVar11 == this + 0x2d38) goto LAB_009c96c6;
      }
      pCVar10 = pCVar10 + 4;
    } while (pCVar10 != this + 0x2d38);
LAB_009c96c6:
    iVar7 = *(int *)this;
    *puVar12 = this;
    puVar12[1] = local_44;
    pcVar3 = *(code **)(iVar7 + 0x920);
    puVar12[-1] = 0x9c96d8;
    (*pcVar3)();
    puVar13 = puVar12;
  }
LAB_009c96d8:
  puVar13[1] = 0;
  puVar13[2] = &local_34;
  *puVar13 = &local_30;
  local_30 = 0;
  local_2c = 0;
  local_28 = 0;
  local_24 = 0;
  local_20 = 0;
  local_34 = "Head";
                    /* try { // try from 009c9714 to 009c9780 has its CatchHandler @ 009c9b66 */
  puVar13[-1] = 0x9c9719;
  CUtlVector<char_const*,CUtlMemory<char_const*,int>>::InsertBefore
            ((CUtlVector<char_const*,CUtlMemory<char_const*,int>> *)*puVar13,puVar13[1],
             (char **)puVar13[2]);
  puVar13[1] = &local_30;
  *puVar13 = this;
  puVar13[-1] = 0x9c9725;
  CBaseAnimating::RandomizeBodygroups((CBaseAnimating *)*puVar13,(CUtlVector *)puVar13[1]);
  puVar13[2] = &local_34;
  puVar13[1] = 0;
  *puVar13 = &local_30;
  local_24 = 0;
  local_34 = "UpperBody";
  puVar13[-1] = 0x9c9747;
  CUtlVector<char_const*,CUtlMemory<char_const*,int>>::InsertBefore
            ((CUtlVector<char_const*,CUtlMemory<char_const*,int>> *)*puVar13,puVar13[1],
             (char **)puVar13[2]);
  puVar13[1] = &local_30;
  *puVar13 = this;
  puVar13[-1] = 0x9c9753;
  CBaseAnimating::RandomizeBodygroups((CBaseAnimating *)*puVar13,(CUtlVector *)puVar13[1]);
  puVar13[2] = &local_34;
  puVar13[1] = 0;
  *puVar13 = &local_30;
  local_24 = 0;
  local_34 = "LowerBody";
  puVar13[-1] = 0x9c9775;
  CUtlVector<char_const*,CUtlMemory<char_const*,int>>::InsertBefore
            ((CUtlVector<char_const*,CUtlMemory<char_const*,int>> *)*puVar13,puVar13[1],
             (char **)puVar13[2]);
  puVar13[1] = &local_30;
  *puVar13 = this;
  puVar13[-1] = 0x9c9781;
  CBaseAnimating::RandomizeBodygroups((CBaseAnimating *)*puVar13,(CUtlVector *)puVar13[1]);
  *puVar13 = &local_30;
  local_24 = 0;
  puVar13[-1] = 0x9c9790;
  CUtlMemory<char_const*,int>::Purge((CUtlMemory<char_const*,int> *)*puVar13);
  *puVar13 = &local_30;
  local_20 = local_30;
  puVar13[-1] = 0x9c979e;
  CUtlMemory<char_const*,int>::Purge((CUtlMemory<char_const*,int> *)*puVar13);
  iVar7 = *piVar5;
  *puVar13 = piVar5;
  pcVar3 = *(code **)(iVar7 + 0x6c);
  puVar13[-1] = 0x9c97a9;
  (*pcVar3)();
  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)