L L4D2node

CTerrorGameRules::GetVersusCompletion

0x00508460 · 979 bytes · __thiscall

_ZN16CTerrorGameRules19GetVersusCompletionEP13CTerrorPlayer

Decompiled

undefined (2 params)

/* CTerrorGameRules::GetVersusCompletion(CTerrorPlayer*) */

int __thiscall CTerrorGameRules::GetVersusCompletion(CTerrorGameRules *this,CTerrorPlayer *param_1)

{
  int *piVar1;
  int iVar2;
  char cVar3;
  int iVar4;
  TerrorNavArea *pTVar5;
  int iVar6;
  int iVar7;
  longdouble lVar8;
  float fVar9;
  float fVar10;
  float fVar11;
  float fVar12;
  
  if (param_1 == (CTerrorPlayer *)0x0) {
    return 0;
  }
  iVar4 = CBaseEntity::GetTeamNumber((CBaseEntity *)param_1);
  if (iVar4 != 2) {
    return 0;
  }
  iVar4 = *(int *)(this + 0xdfc) >> 2;
  if (iVar4 < 0) {
    iVar4 = 0;
  }
  cVar3 = CDirector::IsFinaleWon(TheDirector);
  if (cVar3 != '\0') {
    return iVar4;
  }
  pTVar5 = (TerrorNavArea *)(**(code **)(*(int *)param_1 + 0x52c))(param_1);
  if (pTVar5 != (TerrorNavArea *)0x0) {
    cVar3 = CDirector::IsFinale(TheDirector);
    if (((cVar3 != '\0') && (cVar3 = CDirector::IsFinaleVehicleReady(TheDirector), cVar3 != '\0'))
       && (((byte)pTVar5[0x12d] & 0x80) != 0)) {
      return iVar4;
    }
    cVar3 = TerrorNavMesh::IsInInitialCheckpoint_NoLandmark(TheNavMesh,pTVar5);
    if (cVar3 != '\0') {
      return 0;
    }
    cVar3 = TerrorNavMesh::IsInExitCheckpoint_NoLandmark(TheNavMesh,pTVar5);
    if (cVar3 != '\0') {
      return iVar4;
    }
  }
  if (*(float *)(TheNavMesh + 0x5f8) <= 0.0) {
    return 0;
  }
  lVar8 = (longdouble)CTerrorPlayer::GetFlowDistance(param_1,0);
  if ((float)lVar8 < 0.0) {
    fVar9 = 0.0;
  }
  else {
    lVar8 = (longdouble)CTerrorPlayer::GetFlowDistance(param_1,0);
    fVar9 = (float)lVar8;
  }
  fVar9 = fVar9 / *(float *)(TheNavMesh + 0x5f8);
  if (1.0 <= fVar9) {
    fVar9 = 1.0;
  }
  if (fVar9 <= 0.0) {
    fVar9 = 0.0;
  }
  iVar6 = *(int *)(*(CDirectorVersusMode **)(TheDirector + 0x63c) + 0x40);
  cVar3 = CDirectorVersusMode::InFinaleMap(*(CDirectorVersusMode **)(TheDirector + 0x63c));
  if ((cVar3 == '\0') || ((iVar6 != 2 && (iVar6 != 4)))) {
    iVar6 = (int)((float)iVar4 * fVar9);
    if ((float)iVar6 < (float)iVar4 * fVar9) {
      iVar6 = iVar6 + 1;
    }
    goto joined_r0x00508731;
  }
  lVar8 = (longdouble)
          CDirectorVersusMode::GetFinaleTravelCompletionValue
                    (*(CDirectorVersusMode **)(TheDirector + 0x63c));
  fVar11 = (float)lVar8;
  piVar1 = *(int **)(TheDirector + 0x638);
  if (*piVar1 == 5) {
    fVar11 = (float)iVar4 * fVar9 * fVar11;
    iVar6 = (int)fVar11;
    if ((float)iVar6 < fVar11) {
      iVar6 = iVar6 + 1;
    }
    goto joined_r0x00508731;
  }
  fVar9 = fVar11 * (float)iVar4;
  iVar7 = (int)fVar9;
  if ((float)iVar7 < fVar9) {
    iVar7 = iVar7 + 1;
  }
  if (iVar6 == 2) {
    iVar6 = piVar1[0x39];
    iVar2 = piVar1[0x3a];
    if ((iVar6 + 2 < 1) || (iVar2 < 1)) goto LAB_0050870a;
    fVar9 = 99999.9;
    if (0.0 < (float)piVar1[0x30]) {
      lVar8 = (longdouble)IntervalTimer::Now();
      fVar9 = (float)lVar8 - (float)piVar1[0x30];
    }
    fVar12 = 1.0 / (float)(iVar6 + 2);
    fVar9 = (float)(int)(fVar9 * 0.2) * 0.1;
    if (*(int *)(*(CDirectorScriptedEventManager **)(TheDirector + 0x638) + 4) == 9) {
      lVar8 = (longdouble)
              CDirectorScriptedEventManager::GetCustomScriptedStageProgress
                        (*(CDirectorScriptedEventManager **)(TheDirector + 0x638),fVar9);
      fVar9 = (float)lVar8;
    }
    fVar9 = fVar9 * fVar12;
    fVar10 = 0.0;
    if ((0.0 <= fVar9) && (fVar10 = fVar12, fVar9 <= fVar12)) {
      fVar10 = fVar9;
    }
    fVar10 = fVar10 + (float)(iVar2 + -1) * fVar12;
LAB_0050867f:
    fVar10 = (1.0 - fVar11) * (float)iVar4 * fVar10;
    iVar6 = (int)fVar10;
    if ((float)iVar6 < fVar10) {
      iVar6 = iVar6 + 1;
    }
  }
  else {
    if (iVar6 == 4) {
      iVar6 = GetScavengeTeamScore(this,2,-1);
      if (0 < *(int *)(this + 0x47c)) {
        fVar10 = (float)iVar6 / (float)*(int *)(this + 0x47c);
        goto LAB_0050867f;
      }
    }
LAB_0050870a:
    iVar6 = 0;
  }
  iVar6 = iVar6 + iVar7;
joined_r0x00508731:
  if (iVar6 < 0) {
    return 0;
  }
  if (iVar4 < iVar6) {
    return iVar4;
  }
  return iVar6;
}

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)