L L4D2node

CDirectorScriptedEventManager::GetNextScriptedStage

0x008b8440 · 1345 bytes · __thiscall

_ZN29CDirectorScriptedEventManager20GetNextScriptedStageEv

Decompiled

undefined (1 param)

/* CDirectorScriptedEventManager::GetNextScriptedStage() */

int __thiscall
CDirectorScriptedEventManager::GetNextScriptedStage(CDirectorScriptedEventManager *this)

{
  CDirector *pCVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 uVar4;
  int iVar5;
  CDirectorScriptedEventManager CVar6;
  CDirectorScriptedEventManager *pCVar7;
  CDirectorScriptedEventManager *pCVar8;
  int in_GS_OFFSET;
  longdouble lVar9;
  char *pcVar10;
  CDirector *local_c4 [2];
  undefined2 local_bc;
  ushort local_ba;
  undefined4 local_b8;
  undefined4 local_b4;
  undefined4 local_b0;
  Vector local_ac [12];
  CDirectorScriptedEventManager local_a0 [128];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  pcVar10 = (char *)TheDirector;
  CDirector::OnCustomPanicStageFinished();
  iVar3 = *(int *)(this + 0xe8);
  *(int *)(this + 0xe8) = iVar3 + 1;
  if (this[0xf0] != (CDirectorScriptedEventManager)0x0) {
    V_sprintf_safe<128u>((char *)(this + 8),"%c_CustomFinale%1d",(int)(char)this[0xf0],iVar3 + 1);
    pcVar10 = (char *)TheDirector;
    iVar3 = CDirector::GetScriptValue(TheDirector,(char *)(this + 8),-1);
    if (iVar3 == -1) {
      this[0xf0] = (CDirectorScriptedEventManager)0x0;
    }
  }
  if ((**(char **)(TheDirector + 0x648) == '\0') ||
     (iVar3 = *(int *)(*(char **)(TheDirector + 0x648) + 0x110), iVar3 == 0)) {
    iVar3 = 9;
    if (*(int *)this != 5) {
      this[8] = (CDirectorScriptedEventManager)0x0;
      if (this[0xf0] == (CDirectorScriptedEventManager)0x0) {
        local_a0[0] = (CDirectorScriptedEventManager)0x41;
        CVar6 = (CDirectorScriptedEventManager)0x41;
        local_a0[1] = (CDirectorScriptedEventManager)0x42;
        local_a0[2] = (CDirectorScriptedEventManager)0x43;
        local_a0[3] = (CDirectorScriptedEventManager)0x44;
        local_a0[4] = (CDirectorScriptedEventManager)0x45;
        iVar3 = 0;
        while( true ) {
          iVar5 = RandomInt(iVar3,4);
          local_a0[iVar3] = local_a0[iVar5];
          local_a0[iVar5] = CVar6;
          if (iVar3 + 1 == 4) break;
          CVar6 = local_a0[iVar3 + 1];
          iVar3 = iVar3 + 1;
        }
        pCVar8 = local_a0;
        pCVar7 = this + 8;
        do {
          CVar6 = *pCVar8;
          iVar5 = (int)(char)CVar6;
          V_snprintf((char *)pCVar7,0x80,"%c_CustomFinale1",iVar5);
          iVar3 = CDirector::GetScriptValue(TheDirector,(char *)pCVar7,-1);
          if (iVar3 != -1) {
            UTIL_LogPrintf("IncrementCustomFinaleStage, selecting \'%c\'.\n",iVar5);
            this[0xf0] = CVar6;
            V_snprintf((char *)pCVar7,0x80,"%c_CustomFinale_StageCount",iVar5);
            uVar4 = CDirector::GetScriptValue(TheDirector,(char *)pCVar7,0);
            *(undefined4 *)(this + 0xe4) = uVar4;
            break;
          }
          pCVar8 = pCVar8 + 1;
        } while (pCVar8 != local_a0 + 5);
      }
      pCVar7 = this + 8;
      lVar9 = (longdouble)IntervalTimer::Now();
      if ((float)lVar9 != *(float *)(this + 0xc0)) {
        (**(code **)(*(int *)(this + 0xbc) + 4))(this + 0xbc,this + 0xc0);
        *(float *)(this + 0xc0) = (float)lVar9;
      }
      V_snprintf((char *)pCVar7,0x80,"%c_CustomFinale%1d",(int)(char)this[0xf0],
                 *(undefined4 *)(this + 0xe8));
      iVar3 = CDirector::GetScriptValue(TheDirector,(char *)pCVar7,-1);
      UTIL_LogPrintf("IncrementCustomFinaleStage, moving to %s, result %d\n",pCVar7,iVar3);
      V_snprintf((char *)pCVar7,0x80,"%c_CustomFinaleValue%1d",(int)(char)this[0xf0],
                 *(undefined4 *)(this + 0xe8));
      pcVar10 = (char *)TheDirector;
      if (iVar3 == 3) {
        iVar5 = CDirector::GetScriptValue
                          (TheDirector,(char *)pCVar7,(char *)0x0,(char *)local_a0,0x80);
        if (iVar5 == 0) {
          pcVar10 = "Couldn\'t find a script name for custom scripted stage %s\n";
          Warning("Couldn\'t find a script name for custom scripted stage %s\n",pCVar7);
        }
      }
      else {
        uVar4 = CDirector::GetScriptValue(TheDirector,(char *)pCVar7,-1);
        *(undefined4 *)(this + 0xec) = uVar4;
      }
    }
  }
  else {
    local_bc = 0;
    local_ba = 0;
    local_c4[0] = (CDirector *)0x0;
                    /* try { // try from 008b84d5 to 008b8574 has its CatchHandler @ 008b89af */
    puVar2 = (undefined4 *)CDirector::GetScriptScope(TheDirector,3);
    iVar3 = (**(code **)(*g_pScriptVM + 0x50))(g_pScriptVM,iVar3,0,0,local_c4,*puVar2,1);
    if (iVar3 == 0) {
      uVar4 = CDirector::GetScriptValue(TheDirector,"ScriptedStageValue",1);
      *(undefined4 *)(this + 0xec) = uVar4;
      iVar3 = CDirector::GetScriptValue(TheDirector,"ScriptedStageType",9);
      pcVar10 = (char *)TheDirector;
      uVar4 = CDirector::GetScriptValue(TheDirector,"SpawnSetRule",0);
      pCVar1 = TheDirector;
      *(undefined4 *)(*(int *)(TheDirector + 0x648) + 0x10c) = uVar4;
      if (*(int *)(*(int *)(pCVar1 + 0x648) + 0x10c) == 3) {
        local_b8 = 0;
        local_b4 = 0;
        local_b0 = 0;
                    /* try { // try from 008b8953 to 008b89a4 has its CatchHandler @ 008b89af */
        CDirector::GetScriptValue(local_ac,pCVar1,"SpawnSetPosition",0,0,0);
        lVar9 = (longdouble)CDirector::GetScriptValue(TheDirector,"SpawnSetRadius",1000.0);
        pcVar10 = (char *)TheZombieManager;
        ZombieManager::AddToPositionalSpawnSet(TheZombieManager,true,local_ac,(float)lVar9);
      }
    }
    else {
      pcVar10 = "SCRIPTED MODE: Failed to call GetNextScriptedStage\n";
                    /* try { // try from 008b8837 to 008b883b has its CatchHandler @ 008b89af */
      Msg("SCRIPTED MODE: Failed to call GetNextScriptedStage\n");
      iVar3 = 9;
    }
    if ((local_ba & 1) != 0) {
      pcVar10 = (char *)local_c4[0];
      free(local_c4[0]);
    }
  }
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(pcVar10);
  }
  return iVar3;
}

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)