L L4D2node

CBasePlayer::SetObserverMode

0x007b96f0 · 1719 bytes · __thiscall

_ZN11CBasePlayer15SetObserverModeEi

Decompiled

undefined (2 params)

/* CBasePlayer::SetObserverMode(int) */

undefined4 __thiscall CBasePlayer::SetObserverMode(CBasePlayer *this,int param_1)

{
  CBaseEdict *this_00;
  uint uVar1;
  code *pcVar2;
  char cVar3;
  int iVar4;
  undefined4 *puVar5;
  int iVar6;
  QAngle *pQVar7;
  long lVar8;
  undefined *puVar9;
  int *piVar10;
  int *piVar11;
  IHandleEntity *pIVar12;
  CBasePlayer *local_100;
  float local_fc;
  float local_f8;
  undefined4 local_f4;
  undefined4 local_f0;
  undefined4 local_ec;
  float local_e8;
  float local_e4;
  float local_e0;
  CTraceFilterSimple local_dc [16];
  CBasePlayer *local_cc;
  undefined4 local_c8;
  undefined4 local_c4;
  float local_bc;
  float local_b8;
  float local_b4;
  undefined4 local_ac;
  undefined4 local_a8;
  undefined4 local_a4;
  undefined4 local_9c;
  undefined4 local_98;
  undefined4 local_94;
  undefined4 local_8c;
  undefined1 local_88;
  undefined1 local_87;
  CBasePlayer *local_70;
  undefined4 local_6c;
  undefined4 local_68;
  float local_64;
  float local_60;
  float local_5c;
  
  if (6 < (uint)param_1) {
    return 0;
  }
  if (this[0x104] == (CBasePlayer)0x3) {
    param_1 = 6;
LAB_007b9887:
    cVar3 = (**(code **)(*(int *)this + 0x170))();
    iVar4 = param_1;
    if (cVar3 == '\0') {
      if (param_1 < 4) goto LAB_007b9720;
    }
    else {
      cVar3 = (**(code **)(*(int *)this + 0x680))();
      if (cVar3 == '\0') {
        local_70 = this;
        local_64 = 0.0;
        ForEachPlayer<ValidObserverTargetCounter>((ValidObserverTargetCounter *)&local_70);
        if ((param_1 == 6) && (iVar4 = 4, local_64 == 0.0)) {
          iVar4 = param_1;
        }
      }
    }
    param_1 = iVar4;
    iVar6 = CBaseEntity::GetTeamNumber((CBaseEntity *)this);
    iVar4 = param_1;
    if (1 < iVar6) {
      if (*(int *)(mp_forcecamera._28_4_ + 0x30) == 1) {
        param_1 = 4;
        iVar4 = param_1;
      }
      else {
        iVar4 = 3;
        if (*(int *)(mp_forcecamera._28_4_ + 0x30) != 2) {
          iVar4 = param_1;
        }
      }
    }
  }
  else {
    iVar4 = param_1;
    if (3 < param_1) goto LAB_007b9887;
  }
LAB_007b9720:
  param_1 = iVar4;
  iVar4 = *(int *)(this + 0x1d64);
  if (1 < iVar4) {
    *(int *)(this + 0x1d78) = iVar4;
  }
  if (param_1 != iVar4) {
    if (this[0x6c] == (CBasePlayer)0x0) {
      this_00 = *(CBaseEdict **)(this + 0x30);
      if (this_00 != (CBaseEdict *)0x0) {
        *(uint *)this_00 = *(uint *)this_00 | 0x101;
        iVar4 = CBaseEdict::GetChangeAccessor(this_00);
        *(undefined2 *)(iVar4 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CBasePlayer)((byte)this[0x70] | 1);
    }
    *(int *)(this + 0x1d64) = param_1;
  }
  (**(code **)(*(int *)this + 0x234))();
  piVar10 = (int *)&stack0xfffffed0;
  piVar11 = (int *)&stack0xfffffed0;
  puVar5 = (undefined4 *)(**(code **)(*(int *)this + 0x238))();
  local_f4 = *puVar5;
  local_f0 = puVar5[1];
  local_ec = puVar5[2];
  uVar1 = *(uint *)(this + 0x1d7c);
  if (((uVar1 == 0xffffffff) ||
      (puVar9 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar9 == (undefined *)0xfffffffc)) ||
     (*(uint *)(puVar9 + 8) != uVar1 >> 0xc)) {
    pIVar12 = (IHandleEntity *)0x0;
    piVar10 = (int *)&stack0xfffffed0;
    piVar11 = (int *)&stack0xfffffed0;
  }
  else {
    pIVar12 = *(IHandleEntity **)(puVar9 + 4);
    if (pIVar12 != (IHandleEntity *)0x0) {
      (**(code **)(*(int *)pIVar12 + 0x234))();
      local_100 = local_70;
      local_fc = (float)local_6c;
      local_f8 = (float)local_68;
      pQVar7 = (QAngle *)(**(code **)(*(int *)pIVar12 + 0x238))();
      AngleVectors(pQVar7,(Vector *)&local_e8);
      VectorNormalize((Vector *)&local_e8);
      piVar10 = mdlcache;
      local_8c = 0;
      local_88 = 0;
      local_9c = 0x41000000;
      local_bc = local_e8 * -64.0;
      local_98 = 0x41000000;
      local_94 = 0x41000000;
      local_b8 = local_e4 * -64.0;
      local_b4 = local_e0 * -64.0;
      local_ac = 0;
      local_a8 = 0;
      local_a4 = 0;
      local_87 = local_b8 * local_b8 + local_bc * local_bc + local_b4 * local_b4 != 0.0;
      local_cc = local_100;
      local_c8 = local_fc;
      local_c4 = local_f8;
      (**(code **)(*mdlcache + 0x68))();
                    /* try { // try from 007b9a59 to 007b9b16 has its CatchHandler @ 007b9ddd */
      (**(code **)(*(int *)this + 0x7a0))();
      CTraceFilterSimple::CTraceFilterSimple
                (local_dc,pIVar12,8,(_func_bool_IHandleEntity_ptr_int *)0x0);
      (**(code **)(*enginetrace + 0x14))();
      if (*(int *)(r_visualizetraces._28_4_ + 0x30) != 0) {
                    /* try { // try from 007b9d3d to 007b9d41 has its CatchHandler @ 007b9ddd */
        DebugDrawLine((Vector *)&local_70,(Vector *)&local_64,0xff,0,0,true,-1.0);
      }
      iVar4 = (**(code **)(*g_pGameRules + 0x7c))();
      local_fc = local_60 - *(float *)(iVar4 + 100);
      local_f8 = local_5c - *(float *)(iVar4 + 0x68);
      local_100 = (CBasePlayer *)(local_64 - *(float *)(iVar4 + 0x60));
      puVar5 = (undefined4 *)(**(code **)(*(int *)pIVar12 + 0x238))();
      local_f4 = *puVar5;
      local_f0 = puVar5[1];
      local_ec = puVar5[2];
      (**(code **)(*piVar10 + 0x6c))();
      piVar10 = (int *)&stack0xfffffecc;
      piVar11 = (int *)&stack0xfffffecc;
    }
  }
  uVar1 = 1 << ((byte)param_1 & 0x1f);
  if ((uVar1 & 0xb) != 0) {
    piVar11[4] = 0;
    piVar11[3] = 0;
    piVar11[2] = 0;
    piVar11[1] = (int)this;
    *piVar11 = (int)this;
    piVar11[-1] = 0x7b9b7c;
    SetFOV((CBasePlayer *)*piVar11,(CBaseEntity *)piVar11[1],piVar11[2],(float)piVar11[3],piVar11[4]
          );
    iVar4 = *(int *)this;
    piVar11[1] = (int)&vec3_origin;
    *piVar11 = (int)this;
    pcVar2 = *(code **)(iVar4 + 0x254);
    piVar11[-1] = 0x7b9b8f;
    (*pcVar2)();
    if (pIVar12 != (IHandleEntity *)0x0) {
      iVar4 = *(int *)this;
      *piVar11 = (int)this;
      piVar11[2] = (int)&local_f4;
      piVar11[1] = (int)&local_100;
      pcVar2 = *(code **)(iVar4 + 0x66c);
      piVar11[-1] = 0x7b9bb2;
      (*pcVar2)();
    }
    piVar11[2] = 0;
    piVar11[1] = 0;
    *piVar11 = (int)this;
    piVar11[-1] = 0x7b9bca;
    CBaseEntity::SetMoveType();
    goto LAB_007b9851;
  }
  piVar11 = piVar10;
  if ((uVar1 & 0x40) == 0) {
    if ((uVar1 & 0x30) != 0) {
      iVar4 = 0;
      pcVar2 = *(code **)(*(int *)this + 0x64c);
      uVar1 = *(uint *)(this + 0x1d7c);
      if (((uVar1 != 0xffffffff) &&
          (puVar9 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar9 != (undefined *)0xfffffffc)) &&
         (*(uint *)(puVar9 + 8) == uVar1 >> 0xc)) {
        iVar4 = *(int *)(puVar9 + 4);
      }
      piVar10[1] = iVar4;
      *piVar10 = (int)this;
      piVar10[-1] = 0x7b9839;
      (*pcVar2)();
      piVar10[2] = 0;
      piVar10[1] = 10;
      *piVar10 = (int)this;
      piVar10[-1] = 0x7b9851;
      CBaseEntity::SetMoveType();
    }
    goto LAB_007b9851;
  }
  piVar10[4] = 0;
  piVar10[3] = 0;
  piVar10[2] = 0;
  piVar10[1] = (int)this;
  *piVar10 = (int)this;
  piVar10[-1] = 0x7b9bf4;
  SetFOV((CBasePlayer *)*piVar10,(CBaseEntity *)piVar10[1],piVar10[2],(float)piVar10[3],piVar10[4]);
  iVar4 = *(int *)this;
  *piVar10 = (int)this;
  pcVar2 = *(code **)(iVar4 + 0x5a8);
  piVar10[-1] = 0x7b9bff;
  cVar3 = (*pcVar2)();
  if (cVar3 == '\0') {
    pcVar2 = *(code **)(*engine + 0xe0);
    if (*(int *)(this + 0x30) == 0) {
      iVar4 = 0;
    }
    else {
      iVar4 = *(int *)(this + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
    }
    piVar10[2] = (int)"spec_cinematic";
    piVar10[1] = iVar4;
    *piVar10 = (int)engine;
    piVar10[-1] = 0x7b9c3c;
    iVar4 = (*pcVar2)();
    if (iVar4 != 0) {
      piVar10[2] = 10;
      piVar10[1] = 0;
      *piVar10 = iVar4;
      piVar10[-1] = 0x7b9c58;
      lVar8 = strtol((char *)*piVar10,(char **)piVar10[1],piVar10[2]);
      if (lVar8 != 0) goto LAB_007b9da0;
    }
    iVar4 = 0;
    pcVar2 = *(code **)(*(int *)this + 0x64c);
    uVar1 = *(uint *)(this + 0x1d7c);
    if (((uVar1 != 0xffffffff) &&
        (puVar9 = g_pEntityList + (uVar1 & 0xfff) * 0x10, puVar9 != (undefined *)0xfffffffc)) &&
       (*(uint *)(puVar9 + 8) == uVar1 >> 0xc)) {
      iVar4 = *(int *)(puVar9 + 4);
    }
    piVar10[1] = iVar4;
    *piVar10 = (int)this;
    piVar10[-1] = 0x7b9cb0;
    (*pcVar2)();
  }
  else {
LAB_007b9da0:
    iVar4 = *(int *)this;
    piVar10[1] = 0;
    *piVar10 = (int)this;
    pcVar2 = *(code **)(iVar4 + 0x64c);
    piVar10[-1] = 0x7b9db3;
    (*pcVar2)();
  }
  iVar4 = *(int *)this;
  piVar10[1] = (int)&vec3_origin;
  *piVar10 = (int)this;
  pcVar2 = *(code **)(iVar4 + 0x254);
  piVar10[-1] = 0x7b9cc3;
  (*pcVar2)();
  if (pIVar12 != (IHandleEntity *)0x0) {
    iVar4 = *(int *)this;
    *piVar10 = (int)this;
    piVar10[2] = (int)&local_f4;
    piVar10[1] = (int)&local_100;
    pcVar2 = *(code **)(iVar4 + 0x66c);
    piVar10[-1] = 0x7b9ce6;
    (*pcVar2)();
  }
  piVar10[2] = 0;
  piVar10[1] = 10;
  *piVar10 = (int)this;
  piVar10[-1] = 0x7b9cfe;
  CBaseEntity::SetMoveType();
LAB_007b9851:
  iVar4 = *(int *)this;
  *piVar11 = (int)this;
  pcVar2 = *(code **)(iVar4 + 0x668);
  piVar11[-1] = 0x7b985c;
  (*pcVar2)();
  return 1;
}

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)