
// ========================================================================
// ?GetEntranceAnim@idAI2@@QBA?AW4overrideAnim_t@@XZ
// EA  : 0x829EFC28
// RVA : 0x009EFC28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

overrideAnim_t __fastcall idAI2::GetEntranceAnim(idAI2 *this)
{
  return this->aiEditable.spawnSettings.entranceAnim;
}


// ========================================================================
// ?ApplyDamage@idAI2@@UAAXHHPBVidDeclDamage@@@Z
// EA  : 0x829EFC30
// RVA : 0x009EFC30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ApplyDamage(idAI2 *this, const int physId, const int bodyId, const idDeclDamage *damageDecl)
{
  if ( damageDecl != nullptr )
  {
    idPhysics_StaticMulti::UpdateTime((bfx::BinaryReplayLogOut *)this);
    ((void (__fastcall *)(idAI2 *, _DWORD, _DWORD, const idDeclDamage *, double))this->Damage)(
      a1: this,
      a2: 0,
      a3: 0,
      a4: damageDecl,
      a5: 1.0);
  }
}


// ========================================================================
// ?SetModelByName@idAI2@@UAAXPBD@Z
// EA  : 0x829EFCA8
// RVA : 0x009EFCA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetModelByName(idAI2 *this, const char *modelName)
{
  idRenderModel *v3; // r3

  v3 = clientGame->renderWorld->AllocRenderModel(this: clientGame->renderWorld, a2: modelName, a3: 1, a4: -1);
  this->SetModel(this, a2: v3);
}


// ========================================================================
// ?PerceptionFlagIsSet@idAI2@@QBA_NH@Z
// EA  : 0x829EFD10
// RVA : 0x009EFD10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::PerceptionFlagIsSet(idAI2 *this, const int flags)
{
  return (this->aiVolatile.perception.flags & flags) != 0;
}


// ========================================================================
// ?SaveFSM@idAI2@@QBAXAAVidFile_String@@PBD1@Z
// EA  : 0x829EFD28
// RVA : 0x009EFD28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SaveFSM(idAI2 *this, idFile_String *file, const char *fsmName, const char *indent)
{
  const idFiniteStateMachine *v7; // r3

  v7 = this->aiVolatile.fsms.fsmManager.FindFSM_2(this: &this->aiVolatile.fsms, a2: fsmName);
  if ( v7 != nullptr )
    v7->Save(this: (idFiniteStateMachine *)v7, a2: file, a3: indent);
  else
    idLib::Printf(fmt: "No FSM named '%s' was found.\n", fsmName);
}


// ========================================================================
// ?StartDeathFade@idAI2@@QAAXXZ
// EA  : 0x829EFD98
// RVA : 0x009EFD98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::StartDeathFade(idAI2 *this)
{
  this->aiEditable.death.fadeOutTime = this->aiEditable.death.bodyFadeTime;
}


// ========================================================================
// ?ActivateItemsOnDeath@idAI2@@QAAXXZ
// EA  : 0x829EFDA8
// RVA : 0x009EFDA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ActivateItemsOnDeath(idAI2 *this)
{
  idSmartLootComponent *v2; // r3

  v2 = this->GetSmartLootComponent_2(this);
  if ( v2 != nullptr )
    idSmartLootComponent::Activate(this: v2, owner: this);
}


// ========================================================================
// ?GetValidMeleeTypes@idAI2@@QBAHH@Z
// EA  : 0x829EFDF0
// RVA : 0x009EFDF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetValidMeleeTypes(idAI2 *this, const int mask)
{
  bool IsCrouching; // r3
  int v5; // r10

  IsCrouching = idActor::IsCrouching(this);
  v5 = 34876;
  if ( !IsCrouching )
    v5 = 34872;
  return *(int *)((_BYTE *)&this->__vftable + v5) & mask;
}


// ========================================================================
// ?GetCrosshairIconDistance@idAI2@@UBAMXZ
// EA  : 0x829EFE48
// RVA : 0x009EFE48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::GetCrosshairIconDistance(idAI2 *this)
{
  double v1; // fp1

  v1 = 160.0;
  return *((float *)&v1 + 1);
}


// ========================================================================
// ?CanReceiveAIEvents@idAI2@@UBA_NH@Z
// EA  : 0x829EFE58
// RVA : 0x009EFE58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CanReceiveAIEvents(idAI2 *this, int curTime)
{
  unsigned __int8 v4; // r11

  if ( (unsigned __int8)Get_idCombatStage_useRelaxedChatterVO(ptr: this) != 0 )
    return 0;
  v4 = 1;
  if ( curTime < this->aiVolatile.aiEvents.nextAIEventTime )
    return 0;
  return v4;
}


// ========================================================================
// ?GetEventResponseFlags@idAI2@@UBAHXZ
// EA  : 0x829EFEC0
// RVA : 0x009EFEC0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetEventResponseFlags(idAI2 *this)
{
  return (this->aiVolatile.aiEvents.overloadEnableFlags | this->aiVolatile.aiEvents.flags)
       & ~this->aiVolatile.aiEvents.overloadDisableFlags;
}


// ========================================================================
// ?RespondsToAIEvent@idAI2@@UBA_NPBVidAIEvent@@@Z
// EA  : 0x829EFEF0
// RVA : 0x009EFEF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::RespondsToAIEvent(idAI2 *this, const idAIEvent *event)
{
  int v3; // r30

  v3 = this->GetEventResponseFlags(this);
  return (idAIEvent::GetEventClass(this: event) & v3) != 0;
}


// ========================================================================
// ?DeactivateExtendedClipModel@idAI2@@QAAXXZ
// EA  : 0x829EFF48
// RVA : 0x009EFF48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DeactivateExtendedClipModel(idAI2 *this)
{
  idClipModel *extendedClipModel; // r4

  extendedClipModel = this->aiVolatile.physics.extendedClipModel;
  this->aiVolatile.physics.extendedClipModelStatus = AIEXTENDEDCLIPMODELSTATUS_NONE;
  this->aiVolatile.physics.extendedClipModelEndTime = 0;
  if ( extendedClipModel != nullptr )
  {
    idClip::DeleteClipModel(this: &clientGame->clip, clipModel: extendedClipModel);
    this->aiVolatile.physics.extendedClipModel = nullptr;
  }
}


// ========================================================================
// ?ShouldAimAtEnemyWhileMoving@idAI2@@QAA_NXZ
// EA  : 0x829EFFA8
// RVA : 0x009EFFA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ShouldAimAtEnemyWhileMoving(idAI2 *this)
{
  return this->aiConstants.movement.useMoveFSM;
}


// ========================================================================
// ?BestDiveOrDodge@idAI2@@QBA?AW4aiTransCode_t@idAIStateTransition@@_N000000@Z
// EA  : 0x829EFFB8
// RVA : 0x009EFFB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::BestDiveOrDodge(
        idAI2 *this,
        const bool leftDodge,
        const bool leftDive,
        const bool rightDodge,
        const bool rightDive,
        const bool forwardDive,
        const bool backwardDive,
        const bool preferLeft)
{
  if ( leftDodge )
  {
    if ( rightDodge )
      return ((_cntlzw(preferLeft) & 0x20) != 0) + 300;
  }
  else if ( !rightDodge )
  {
    if ( leftDive )
    {
      if ( rightDive )
        return ((_cntlzw(preferLeft) & 0x20) != 0) + 302;
    }
    else if ( !rightDive )
    {
      if ( forwardDive )
        return 304;
      else
        return !backwardDive ? 0 : 0x131;
    }
    return ((_cntlzw(leftDive) & 0x20) != 0) + 302;
  }
  return ((_cntlzw(leftDodge) & 0x20) != 0) + 300;
}


// ========================================================================
// ?SetMovePushStatus@idAI2@@QAAXW4aiMovePushStatus_t@@H@Z
// EA  : 0x829F0088
// RVA : 0x009F0088
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetMovePushStatus(idAI2 *this, aiMovePushStatus_t newStatus, int frameCount)
{
  idAI2::idAIVolatile *p_aiVolatile; // r30
  idContents *p_clipMask; // r28
  int v7; // r31
  int v8; // r3
  unsigned int v9; // r4
  unsigned int v10; // r31

  this->aiEditable.movement.movePushStatus = newStatus;
  if ( newStatus != AIMOVEPUSHSTATUS_PUSH_NONE )
    this->aiVolatile.physics.movePushEndTime = GetEndTimeByFrames(frameCount);
  else
    this->aiVolatile.physics.movePushEndTime = 0;
  p_aiVolatile = &this->aiVolatile;
  p_clipMask = &this->aiConstants.physics.clipMask;
  v7 = this->aiVolatile.physics.object.GetClipMask(this: (struct idPhysics_AI *)&this->aiVolatile, a2: -1);
  v8 = idContents::ToFlags(this: p_clipMask);
  if ( newStatus == AIMOVEPUSHSTATUS_PUSH_PLAYERS || newStatus == AIMOVEPUSHSTATUS_PUSH_PLAYERS_AND_NPCS )
  {
    v9 = v7 & 0xFFFF7FFF;
    v10 = v8 & 0xFFFF7FFF;
  }
  else
  {
    v9 = v7 | 0x8000;
    v10 = v8 | 0x8000;
  }
  p_aiVolatile->physics.object.SetClipMask(this: &p_aiVolatile->physics.object, a2: v9, a3: 0);
  idContents::FromFlags(this: p_clipMask, flags: v10);
}


// ========================================================================
// ?SetWorldCollision@idAI2@@QAAX_N@Z
// EA  : 0x829F0140
// RVA : 0x009F0140
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetWorldCollision(idAI2 *this, bool collideWithWorld)
{
  idAI2::idAIVolatile *p_aiVolatile; // r31
  int v5; // r3
  int v6; // r3
  idPhysics_AI_vtbl *v7; // r29
  int v8; // r3

  p_aiVolatile = &this->aiVolatile;
  v5 = this->aiVolatile.physics.object.GetNumClipModels(this: (struct idPhysics_AI *)&this->aiVolatile);
  if ( v5 == 1 )
  {
    if ( collideWithWorld )
    {
      v6 = idContents::ToFlags(this: &this->aiConstants.physics.clipMask);
      p_aiVolatile->physics.object.SetClipMask(this: &p_aiVolatile->physics.object, a2: v6, a3: 0);
    }
    else
    {
      p_aiVolatile->physics.object.SetClipMask(this: &p_aiVolatile->physics.object, a2: 0, a3: 0);
    }
  }
  else if ( v5 == 2 )
  {
    if ( collideWithWorld )
    {
      v7 = p_aiVolatile->physics.object.__vftable;
      v8 = idContents::ToFlags(this: &this->aiConstants.physics.clipMask);
      v7->SetClipMask(this: &p_aiVolatile->physics.object, a2: v8, a3: 0);
    }
    else
    {
      p_aiVolatile->physics.object.SetClipMask(this: &p_aiVolatile->physics.object, a2: 0, a3: 0);
    }
    p_aiVolatile->physics.object.SetClipMask(this: &p_aiVolatile->physics.object, a2: 0, a3: 1);
  }
}


// ========================================================================
// ?CalcTurnRadius@idAI2@@QBAMMM@Z
// EA  : 0x829F0258
// RVA : 0x009F0258
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::CalcTurnRadius(idAI2 *this, double speed, double turnRate)
{
  double v3; // fp1

  v3 = (float)((float)((float)((float)360.0 / (float)turnRate) * (float)speed) / (float)((float)3.1415927 * (float)2.0));
  return *((float *)&v3 + 1);
}


// ========================================================================
// ?GetFacialAnimationSet@idAI2@@EAAPBVidDeclFacialAnimationSet@@XZ
// EA  : 0x829F0288
// RVA : 0x009F0288
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

const idDeclFacialAnimationSet *__fastcall idAI2::GetFacialAnimationSet(idAI2 *this)
{
  const idDeclFacialAnimationSet *result; // r3

  result = this->aiVolatile.facialInfo.currentFacialAnimSet;
  if ( result == nullptr )
    return this->aiEditable.facialInfo.defaultFacialAnimSet;
  return result;
}


// ========================================================================
// ?SetInteracting@idAI2@@QAAX_N@Z
// EA  : 0x829F02A0
// RVA : 0x009F02A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetInteracting(idAI2 *this, const bool b)
{
  *((_BYTE *)&this->aiVolatile + 49704) = (32 * b) & 0x20 | *((_BYTE *)&this->aiVolatile + 49704) & 0xDF;
  idGameLocal::ResetSpecifiedInteractAi(this: gameLocal, ai: this);
}


// ========================================================================
// ?Draw@idAI2@@UAA_NPAVidPlayer@@@Z
// EA  : 0x829F02C8
// RVA : 0x009F02C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::Draw(idAI2 *this, idPlayer *player)
{
  idAICamera_Control::Draw(this: &this->aiVolatile.playerControl.camera, player);
  return 1;
}


// ========================================================================
// ?AlertCycleToSubWeb@idAI2@@QBA?AW4aiSubWeb_t@@W4alertCycle_t@@@Z
// EA  : 0x829F02F8
// RVA : 0x009F02F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

aiSubWeb_t __fastcall idAI2::AlertCycleToSubWeb(idAI2 *this, int ac)
{
  if ( ac < 11 )
    return alertCycleToSubWebMap[ac];
  else
    return AISUBWEB_RELAXED;
}


// ========================================================================
// ?GetAlertCycleFSM@idAI2@@QBAPBVidFiniteStateMachine@@XZ
// EA  : 0x829F0320
// RVA : 0x009F0320
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

const idFiniteStateMachine *__fastcall idAI2::GetAlertCycleFSM(idAI2 *this)
{
  return this->aiVolatile.fsms.fsmManager.FindFSM(
           this: (struct idAIFSMManager *)&this->aiVolatile.fsms,
           a2: &idAlertCycleFSM::Type);
}


// ========================================================================
// ?GetAlertCycleFSM@idAI2@@QAAPAVidFiniteStateMachine@@XZ
// EA  : 0x829F0340
// RVA : 0x009F0340
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idFiniteStateMachine *__fastcall idAI2::GetAlertCycleFSM(idAI2 *this)
{
  return this->aiVolatile.fsms.fsmManager.FindFSM_3(
           this: (struct idAIFSMManager *)&this->aiVolatile.fsms,
           a2: &idAlertCycleFSM::Type);
}


// ========================================================================
// ?SetEventOverloadEnableFlags@idAI2@@UAAXW4aiEventClass_t@idAIEvent@@@Z
// EA  : 0x829F0360
// RVA : 0x009F0360
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetEventOverloadEnableFlags(idAI2 *this, int flags)
{
  this->aiVolatile.aiEvents.overloadEnableFlags = flags;
}


// ========================================================================
// ?SetEventOverloadDisableFlags@idAI2@@UAAXW4aiEventClass_t@idAIEvent@@@Z
// EA  : 0x829F0370
// RVA : 0x009F0370
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetEventOverloadDisableFlags(idAI2 *this, int flags)
{
  this->aiVolatile.aiEvents.overloadDisableFlags = flags;
}


// ========================================================================
// ?EnableAIEventResponse@idAI2@@UAAXW4aiEventClass_t@idAIEvent@@@Z
// EA  : 0x829F0380
// RVA : 0x009F0380
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::EnableAIEventResponse(idAI2 *this, const idAIEvent::aiEventClass_t flags)
{
  this->aiVolatile.aiEvents.flags |= flags;
}


// ========================================================================
// ?DisableAIEventResponse@idAI2@@UAAXW4aiEventClass_t@idAIEvent@@@Z
// EA  : 0x829F0398
// RVA : 0x009F0398
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DisableAIEventResponse(idAI2 *this, const idAIEvent::aiEventClass_t flags)
{
  this->aiVolatile.aiEvents.flags &= ~flags;
}


// ========================================================================
// ?IsFSMActive@idAI2@@QBA_NABVidTypeInfo@@@Z
// EA  : 0x829F03B0
// RVA : 0x009F03B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::IsFSMActive(idAI2 *this, const idTypeInfo *fsmType)
{
  idFiniteStateMachine *v3; // r3

  v3 = (idFiniteStateMachine *)this->aiVolatile.fsms.fsmManager.FindFSM(
                                 this: &this->aiVolatile.fsms,
                                 a2: &idAlertCycleFSM::Type);
  return v3 != nullptr && idFiniteStateMachine::IsChildFSMActive(this: v3, type: fsmType);
}


// ========================================================================
// ?GetEnableHeadTracking@idAI2@@QBA_NXZ
// EA  : 0x829F0420
// RVA : 0x009F0420
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::GetEnableHeadTracking(idAI2 *this)
{
  return this->aiVolatile.focus.enableHeadTracking;
}


// ========================================================================
// ?SetCoverAction@idAI2@@QAAXW4coverAction_t@@@Z
// EA  : 0x829F0428
// RVA : 0x009F0428
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetCoverAction(idAI2 *this, coverAction_t action)
{
  this->aiVolatile.cover.coverAction = action;
}


// ========================================================================
// ?RememberCoverActionToAvoid@idAI2@@QAAXW4coverAction_t@@@Z
// EA  : 0x829F0438
// RVA : 0x009F0438
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::RememberCoverActionToAvoid(idAI2 *this, const coverAction_t coverAction)
{
  switch ( coverAction )
  {
    case COVERACTION_BLINDFIRE_LEFT:
    case COVERACTION_FIRE_LEAN_LEFT:
    case COVERACTION_PEEK_LEFT:
    case COVERACTION_FIRE_STEP_LEFT:
      this->aiVolatile.cover.coverActionToAvoid = COVERACTION_FIRE_LEAN_LEFT;
      break;
    case COVERACTION_BLINDFIRE_RIGHT:
    case COVERACTION_FIRE_LEAN_RIGHT:
    case COVERACTION_PEEK_RIGHT:
    case COVERACTION_FIRE_STEP_RIGHT:
      this->aiVolatile.cover.coverActionToAvoid = COVERACTION_FIRE_LEAN_RIGHT;
      break;
    case COVERACTION_BLINDFIRE_OVER:
    case COVERACTION_FIRE_OVER:
    case COVERACTION_PEEK_OVER:
      this->aiVolatile.cover.coverActionToAvoid = COVERACTION_FIRE_OVER;
      break;
    default:
      break;
  }
}


// ========================================================================
// ?SetIsRagdolling@idAI2@@QAAX_N@Z
// EA  : 0x829F04D0
// RVA : 0x009F04D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetIsRagdolling(idAI2 *this, const bool isRagdolling)
{
  if ( isRagdolling )
  {
    if ( (*((_BYTE *)&this->aiVolatile.death + 1760) & 4) == 0 )
      idGameLocal::AddDyingAI(this: gameLocal, ai: this);
  }
  else if ( (*((_BYTE *)&this->aiVolatile.death + 1760) & 4) != 0 )
  {
    idGameLocal::RemoveDyingAI(this: gameLocal, ai: this);
  }
  *((_BYTE *)&this->aiVolatile.death + 1760) = (4 * isRagdolling) & 4
                                             | *((_BYTE *)&this->aiVolatile.death + 1760) & 0xFB;
}


// ========================================================================
// ?CheckForGoreByName@idAI2@@QAA_NABVidAtomicString@@@Z
// EA  : 0x829F0558
// RVA : 0x009F0558
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::CheckForGoreByName(idAI2 *this, const idAtomicString *goreName)
{
  return idGoreComponent::CheckForGoreByName(this: &this->aiVolatile.death.goreComponent, name: goreName);
}


// ========================================================================
// ??0idAI2Patch1@@QAA@XZ
// EA  : 0x829F0C98
// RVA : 0x009F0C98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2Patch1 *__fastcall idAI2Patch1::idAI2Patch1(idAI2Patch1 *this)
{
  unsigned __int64 v1; // r11

  LODWORD(v1) = 0;
  this->bleedOutGroundQuery.index = v1;
  this->bleedOutHipQuery.index = v1;
  idAASPositionMgr::idAASPositionMgr(this: &this->aasPositionMgr);
  this->unclippedOffset.x = 0.0;
  this->unclippedOffset.y = 0.0;
  this->unclippedOffset.z = 0.0;
  idState::idState(this: &this->stateStuck, stateType: &idAlertCycle_Stuck::Type, childFSMType: nullptr, flags: 0);
  this->stateStuck.__vftable = (idAlertCycle_Stuck_vtbl *)&idAlertCycle_Stuck::`vftable';
  return this;
}


// ========================================================================
// ?ApplyWaterEffects@idAI2@@UAAXHH@Z
// EA  : 0x829F0DA0
// RVA : 0x009F0DA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ApplyWaterEffects(idAI2 *this, int physId, int bodyId)
{
  idPhysics *PhysicsForId; // r3
  idPhysics *v7; // r31
  idDynamicWaterEntity *v8; // r30
  idPhysics *Physics; // r3
  int v10; // r3
  float v11; // r7
  float v12; // r6
  int v13; // r28
  idDynamicWaterEntity *v14; // r31
  idPhysics *v15; // r3
  idBounds *v16; // r3
  double v17; // fp31
  idPhysics *v18; // r3
  float *v19; // r3
  idVec3 v22; // [sp+50h] [-60h] BYREF
  char v23; // [sp+60h] [-50h] BYREF

  PhysicsForId = idPhysics::GetPhysicsForId(physicsId_: physId);
  v7 = PhysicsForId;
  if ( PhysicsForId != nullptr )
  {
    v8 = (idDynamicWaterEntity *)idWaterEntity::CastTo(c: (idWaterEntity *)gameLocal->entities.ptr[PhysicsForId->entityNumber]);
    if ( v8 != nullptr )
    {
      idActor::ApplyWaterEffects(this, physId, id: bodyId);
      Physics = idEntity::GetPhysics(this);
      v10 = (int)Physics->GetOrigin(this: Physics, a2: 0);
      v11 = *(float *)(v10 + 4);
      v12 = *(float *)(v10 + 8);
      v22.x = *(float *)v10;
      v22.y = v11;
      v22.z = v12;
      v13 = (int)v7->GetBounds(this: v7, a2: -1);
      v22.z = v7->GetOrigin(this: v7, a2: 0)->z + *(float *)(v13 + 20);
      v14 = idDynamicWaterEntity::CastTo(c: v8);
      if ( v14 != nullptr )
      {
        v15 = idEntity::GetPhysics(this);
        v16 = (idBounds *)v15->GetBounds(this: v15, a2: -1);
        v17 = (float)(idBounds::GetRadius(this: v16) * (float)0.5);
        v18 = idEntity::GetPhysics(this);
        v19 = (float *)v18->GetLinearVelocity(this: (idPhysics *)&v23, result: (idVec3 *)v18, a3: 0);
        _FP8 = (float)((float)1.0 - (float)__fsqrts((float)((float)(*v19 * *v19) + (float)(v19[1] * v19[1]))));
        __asm { fsel      f7, f8, f0, f9 }
        idDynamicWaterEntity::AddRipple(this: v14, pos: &v22, mag: (float)((float)_FP7 * (float)-0.02), radius: v17);
      }
    }
  }
}


// ========================================================================
// ?InitEncounterGroup@idAI2@@AAAXXZ
// EA  : 0x829F0F40
// RVA : 0x009F0F40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitEncounterGroup(idAI2 *this)
{
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r30
  char *data; // r5
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupManager; // r31
  int value; // r10
  idEncounterGroup *v6; // r3
  char v7; // [sp+50h] [-30h] BYREF

  p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
  {
    if ( this->aiEditable.groupName.len != 0 )
      data = this->aiEditable.groupName.data;
    else
      data = this->name.data;
    p_encounterGroupManager = (idHandle<short,enum invalidEncounterGroup_t,-1> *)&gameLocal->encounterGroupManager;
    value = (unsigned __int16)idEncounterGroupManager::AddGroup(
                                this: (idEncounterGroupManager *)&v7,
                                result: p_encounterGroupManager,
                                groupName: data)->value;
    p_encounterGroupHandle->value = value;
    if ( value != 0xFFFF )
    {
      v6 = idEncounterGroupManager::GroupForHandle(
             this: (idEncounterGroupManager *)p_encounterGroupManager,
             handle: p_encounterGroupHandle);
      if ( v6 != nullptr )
        idEncounterGroup::Add(this: v6, ai: this);
    }
  }
}


// ========================================================================
// ?UsesScenePoints@idAI2@@QBA_NXZ
// EA  : 0x829F0FD0
// RVA : 0x009F0FD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::UsesScenePoints(idAI2 *this)
{
  int result; // r3
  const idDeclAIBehavior *decl; // r11

  if ( this->aiEditable.usesScenePoints )
    return 1;
  decl = this->aiEditable.behaviors.decl;
  if ( decl == nullptr )
    return 0;
  result = 1;
  if ( (*((_BYTE *)decl + 196) & 0x40) == 0 )
    return 0;
  return result;
}


// ========================================================================
// ?Dropped@idAI2@@UAAXPAVidEntity@@PBVidDeclInventory@@@Z
// EA  : 0x829F1010
// RVA : 0x009F1010
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Dropped(idAI2 *this, idEntity *user, const idDeclInventory *idecl)
{
  idAIGameState *p_aiGameState; // r29
  const idSpawnId *v6; // r30
  const idAILogic *v7; // r3
  idSpawnId v8; // [sp+50h] [-60h] BYREF
  idSpawnId v9; // [sp+54h] [-5Ch] BYREF
  idAILogic v10[2]; // [sp+60h] [-50h] BYREF

  this->inventoryDecl = idecl;
  p_aiGameState = &gameLocal->aiGameState;
  idSpawnId::idSpawnId(this: &v8, ent: user);
  v6 = idSpawnId::idSpawnId(this: &v9, ent: user);
  v7 = idAILogic::idAILogic(this: v10, ai: this);
  idAIWorldState::AddEntityState(
    this: &this->aiVolatile.world.worldState,
    gameState: p_aiGameState,
    owner: v7,
    entId: v6,
    stimulusType: AISTIMULUS_TRIGGER,
    stimulusAmount: 1.0,
    sourceId: (const idSpawnId *)0x82000000);
}


// ========================================================================
// ?GetModifiedSkill@idAI2@@QBA?AW4aiSkill_t@@XZ
// EA  : 0x829F1098
// RVA : 0x009F1098
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

aiSkill_t __fastcall idAI2::GetModifiedSkill(idAI2 *this)
{
  aiSkill_t result; // r3

  result = gameLocal->GetGameDifficulty(this: gameLocal) + this->aiEditable.skill.skill - 1;
  if ( result < AISKILL_INCOMPETENT )
    return AISKILL_INCOMPETENT;
  if ( result > AISKILL_LETHAL )
    return AISKILL_LETHAL;
  return result;
}


// ========================================================================
// ?SetWalkState@idAI2@@UAAXW4walkState_t@@@Z
// EA  : 0x829F1110
// RVA : 0x009F1110
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetWalkState(idAI2 *this, walkState_t state)
{
  walkState_t maxWalkState; // r11

  maxWalkState = this->aiEditable.movement.maxWalkState;
  if ( state > maxWalkState || (maxWalkState = this->aiEditable.movement.minWalkState, state < maxWalkState) )
    this->actorVolatile.walkState = maxWalkState;
  else
    this->actorVolatile.walkState = state;
}


// ========================================================================
// ?IsWeaponEquipped@idAI2@@QBA_NXZ
// EA  : 0x829F1138
// RVA : 0x009F1138
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsWeaponEquipped(idAI2 *this)
{
  idInventoryItem *v2; // r3
  int v3; // r11
  char v4; // r11
  bool v5; // zf
  int result; // r3
  idInventoryItem *v7; // r3

  if ( this->GetEquipped(this, a2: 2) != nullptr )
  {
    v2 = this->GetEquipped(this, a2: 2);
    v3 = *(_DWORD *)(v2->GetType(this: v2) + 36);
    if ( v3 < idWeapon::Type.typeNum || (v5 = v3 <= idWeapon::Type.lastChild, v4 = 1, !v5) )
      v4 = 0;
    if ( v4 != 0 )
      return 1;
  }
  if ( this->GetEquipped(this, a2: 1) == nullptr )
    return 0;
  v7 = this->GetEquipped(this, a2: 1);
  v5 = (unsigned __int8)idClass::IsType(this: v7, superclass: &idWeapon::Type) != 0;
  result = 1;
  if ( !v5 )
    return 0;
  return result;
}


// ========================================================================
// ?FindWeaponToDraw@idAI2@@QBAPBVidWeapon@@XZ
// EA  : 0x829F1240
// RVA : 0x009F1240
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

const idWeapon *__fastcall idAI2::FindWeaponToDraw(idAI2 *this)
{
  equipSlot_t v2; // r31
  const idWeapon *result; // r3

  v2 = EQUIP_VEHICLE_RAM;
  while ( 1 )
  {
    result = idActor::GetEquippedWeapon(this, slot: v2);
    if ( result != nullptr && result->decl->holsterSlot == v2 )
      break;
    if ( --v2 < EQUIP_NONE )
      return nullptr;
  }
  return result;
}


// ========================================================================
// ?GetEffectiveAccuracy@idAI2@@QBA?AW4aiAccuracy_t@@XZ
// EA  : 0x829F12A8
// RVA : 0x009F12A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

aiAccuracy_t __fastcall idAI2::GetEffectiveAccuracy(idAI2 *this)
{
  if ( (this->aiVolatile.groupStatus.condition & 0x2000) != 0 )
    return ACCURACY_PERFECT;
  if ( this->aiEditable.skill.aimAccuracy != ACCURACY_FROMSKILL )
    return this->aiEditable.skill.aimAccuracy;
  return skillSettings[idAI2::GetModifiedSkill(this)].aimAccuracy;
}


// ========================================================================
// ?SetModel@idAI2@@UAAXPAVidRenderModel@@@Z
// EA  : 0x829F1330
// RVA : 0x009F1330
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetModel(idAI2 *this, idRenderModel *model)
{
  idTreeAnimator *TreeAnimatorFromPresentable; // r27
  idPresentable *presentable; // r3
  char v6; // r9
  idDeclMD6 *decl; // r28
  char v8; // r11
  char v9; // r10
  char v10; // r11
  char v11; // r11
  char v12; // r10
  char v13; // r11
  char v14; // r11
  char v15; // r10
  char v16; // r11
  idTreeAnimator *v17; // r3
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r30
  idFocusInfo *v19; // r31
  const idVarArgs<6> *UserProp; // r3
  const idVarArgs<6> *v21; // r3
  bool v22; // [sp+Bh] [-D5h]
  bool v23; // [sp+Fh] [-D1h]
  bool v24; // [sp+13h] [-CDh]
  bool v25; // [sp+17h] [-C9h]
  __int128 v26; // [sp+70h] [-70h]
  idRotationTrackerRange v27; // [sp+80h] [-60h] BYREF
  idRotationTrackerRange v28; // [sp+90h] [-50h] BYREF
  idRotationTrackerRange v29; // [sp+A0h] [-40h] BYREF

  TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
  presentable = this->presentable;
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
  }
  idPresentable::UpdateModelTransform(this: presentable);
  idFaceMgr::Shutdown(this: &this->aiVolatile.faceMgr, owner: this, ta: TreeAnimatorFromPresentable);
  idActor::SetModel(this, model);
  v6 = *((_BYTE *)&this->aiConstants.animation + 92);
  decl = TreeAnimatorFromPresentable->decl;
  if ( (v6 & 0x80) == 0 || (v8 = 1, (decl->modelCaps & 4) == 0) )
    v8 = 0;
  v9 = (v8 << 6) & 0x40 | *((_BYTE *)&this->aiConstants.animation + 93) & 0xBF;
  *((_BYTE *)&this->aiConstants.animation + 93) = v9;
  if ( (v6 & 0x40) == 0 || (v10 = 1, (decl->modelCaps & 1) == 0) )
    v10 = 0;
  v11 = (32 * v10) & 0x20 | v9 & 0xDF;
  *((_BYTE *)&this->aiConstants.animation + 93) = v11;
  if ( (v6 & 0x20) == 0 || (v12 = 1, (decl->modelCaps & 8) == 0) )
    v12 = 0;
  v13 = (16 * v12) & 0x10 | v11 & 0xEF;
  *((_BYTE *)&this->aiConstants.animation + 93) = v13;
  if ( (v13 & 0x80) == 0 || (v14 = 1, (decl->modelCaps & 2) == 0) )
    v14 = 0;
  v15 = (8 * v14) & 8 | *((_BYTE *)&this->aiConstants.animation + 93) & 0xF7;
  *((_BYTE *)&this->aiConstants.animation + 93) = v15;
  if ( (v6 & 8) == 0 || (v16 = 1, (decl->modelCaps & 2) == 0) )
    v16 = 0;
  *((_BYTE *)&this->aiConstants.animation + 93) = (4 * v16) & 4 | v15 & 0xFB;
  if ( (v6 & 1) != 0 )
  {
    v17 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    idFaceMgr::Init(
      this: &this->aiVolatile.faceMgr,
      owner: this,
      ta: v17,
      mood: MOOD_NONE,
      voiceChannel: SND_CHANNEL_VOICE,
      enableMoodAnimation: (*((_BYTE *)&this->aiConstants.animation + 93) & 0x40) != 0,
      enableLipSyncAnimation: (*((_BYTE *)&this->aiConstants.animation + 93) & 0x20) != 0,
      enableGestureAnimation: (*((_BYTE *)&this->aiConstants.animation + 93) & 0x10) != 0,
      enableEyeTracking: v22,
      useFaceSetupEyeTracking_: v23,
      enableBlinking: v24,
      enableLidDeformation: v25);
  }
  p_focus = &this->aiVolatile.focus;
  v27.minYaw = -90.0;
  v27.maxYaw = 90.0;
  v27.minPitch = -80.0;
  v27.maxPitch = 80.0;
  idFocusInfo::SetConstraints(this: this->aiVolatile.focus.foci.ptr, constraints: &v27);
  v19 = &this->aiVolatile.focus.foci.ptr[1];
  idFocusInfo::SetConstraints(this: v19, constraints: &v27);
  UserProp = idDeclMD6::FindUserProp(this: decl, name: "lookLimits");
  if ( UserProp != nullptr )
  {
    if ( UserProp->numArgs > 1u && UserProp->argTypes[1] == 12 )
      v26 = *(_OWORD *)&UserProp->args[UserProp->argOffsets[1]];
    v28.minYaw = *(float *)&v26;
    v28.maxYaw = *((float *)&v26 + 1);
    v28.minPitch = *((float *)&v26 + 2);
    v28.maxPitch = *((float *)&v26 + 3);
    idFocusInfo::SetConstraints(this: v19, constraints: &v28);
  }
  v21 = idDeclMD6::FindUserProp(this: decl, name: "aimLimits");
  if ( v21 != nullptr )
  {
    if ( v21->numArgs > 1u && v21->argTypes[1] == 12 )
      v26 = *(_OWORD *)&v21->args[v21->argOffsets[1]];
    v29.minYaw = *(float *)&v26;
    v29.maxYaw = *((float *)&v26 + 1);
    v29.minPitch = *((float *)&v26 + 2);
    v29.maxPitch = *((float *)&v26 + 3);
    idFocusInfo::SetConstraints(this: p_focus->foci.ptr, constraints: &v29);
  }
  *((_BYTE *)TreeAnimatorFromPresentable + 2164) |= 0x10u;
}


// ========================================================================
// ?InitNav@idAI2@@AAAXXZ
// EA  : 0x829F1678
// RVA : 0x009F1678
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitNav(idAI2 *this)
{
  const idAINavPowerMoverParms *v2; // r3

  if ( np_enable.valueInteger != 0 && !common->IsMultiplayer(this: common) )
  {
    v2 = this->GetNavParms(this);
    if ( v2 != nullptr && v2->mover.navDecl != nullptr )
      idGameLocal::LoadNavigation(this: gameLocal, navigation: v2->mover.navDecl);
  }
}


// ========================================================================
// ?InitMovement@idAI2@@AAAXXZ
// EA  : 0x829F1710
// RVA : 0x009F1710
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitMovement(idAI2 *this)
{
  idAIMoveState *p_moveState; // r30
  aiMovementMode_t defaultMovementMode; // r4
  double accelRate; // fp13
  double decelRate; // fp12

  p_moveState = &this->aiVolatile.physics.moveState;
  idAIMoveState::Init(this: &this->aiVolatile.physics.moveState, ai: this);
  idAIMoveState::Stop(this: p_moveState, newStatus: AIMOVESTATUS_DONE);
  defaultMovementMode = this->aiConstants.movement.defaultMovementMode;
  this->aiVolatile.physics.moveState.velocityType = AIVELOCITY_ANIMSPEED;
  idAIMoveState::SetMovementModeForReal(this: p_moveState, mode: defaultMovementMode);
  accelRate = this->aiConstants.movement.accelRate;
  decelRate = this->aiConstants.movement.decelRate;
  this->aiVolatile.physics.moveState.maxMoveSpeed = this->aiConstants.movement.moveSpeed.maxRange;
  this->aiVolatile.physics.moveState.accelRate = accelRate;
  this->aiVolatile.physics.moveState.decelRate = decelRate;
}


// ========================================================================
// ?SetPerceptionFlags@idAI2@@QAAXH_N@Z
// EA  : 0x829F1788
// RVA : 0x009F1788
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetPerceptionFlags(idAI2 *this, const int flags, bool setFlag)
{
  idAIFireControl *fireControl; // r3

  if ( setFlag )
  {
    this->aiVolatile.perception.flags |= flags;
    fireControl = this->aiVolatile.fireControl;
    if ( fireControl != nullptr )
      idAIFireControl::SetFireMode(this: fireControl, owner: this, mode: FIREMODE_HOLDFIRE);
  }
  else
  {
    this->aiVolatile.perception.flags &= ~flags;
  }
}


// ========================================================================
// ?IsInAvoidFSM@idAI2@@QBA_NXZ
// EA  : 0x829F17E0
// RVA : 0x009F17E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsInAvoidFSM(idAI2 *this)
{
  idFiniteStateMachine *v1; // r3
  bool IsChildFSMActive; // r3
  unsigned __int8 v3; // r11

  v1 = (idFiniteStateMachine *)this->aiVolatile.fsms.fsmManager.FindFSM(
                                 this: &this->aiVolatile.fsms,
                                 a2: &idAlertCycleFSM::Type);
  if ( v1 == nullptr )
    return 0;
  IsChildFSMActive = idFiniteStateMachine::IsChildFSMActive(this: v1, type: &idAvoidFSM::Type);
  v3 = 1;
  if ( !IsChildFSMActive )
    return 0;
  return v3;
}


// ========================================================================
// ?IsInPlayerInteractFSM@idAI2@@QBA_NXZ
// EA  : 0x829F1848
// RVA : 0x009F1848
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsInPlayerInteractFSM(idAI2 *this)
{
  idFiniteStateMachine *v1; // r3
  bool IsChildFSMActive; // r3
  unsigned __int8 v3; // r11

  v1 = (idFiniteStateMachine *)this->aiVolatile.fsms.fsmManager.FindFSM(
                                 this: &this->aiVolatile.fsms,
                                 a2: &idAlertCycleFSM::Type);
  if ( v1 == nullptr )
    return 0;
  IsChildFSMActive = idFiniteStateMachine::IsChildFSMActive(this: v1, type: &idPlayerInteractFSM::Type);
  v3 = 1;
  if ( !IsChildFSMActive )
    return 0;
  return v3;
}


// ========================================================================
// ?JobSync@idAI2@@UAAXXZ
// EA  : 0x829F18B0
// RVA : 0x009F18B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::JobSync(idAI2 *this)
{
  int v2; // r31
  idArray<idTrajectory_Parabolic,4> *p_trajectories; // r30

  v2 = 4;
  p_trajectories = &this->aiVolatile.trajectories;
  idAnimatedEntity::JobSync(this);
  do
  {
    idTrajectory_Parabolic::UpdateDeferredQueries(this: p_trajectories->ptr, draw: g_showTrajectories.valueInteger != 0);
    --v2;
    p_trajectories = (idArray<idTrajectory_Parabolic,4> *)((char *)p_trajectories + 380);
  }
  while ( v2 != 0 );
  this->aiVolatile.animation.animFSM.JobSync(this: &this->aiVolatile.animation.animFSM);
}


// ========================================================================
// ?ShouldLeaveDormancy@idAI2@@UAA_NXZ
// EA  : 0x829F1918
// RVA : 0x009F1918
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ShouldLeaveDormancy(idAI2 *this)
{
  return ai_enableDormancy.valueInteger == 0 || idEntity::ShouldLeaveDormancy(this);
}


// ========================================================================
// ?InternalCallEvent@idAI2@@MAA?AVidEventArg@@ABVidEventDef@@PBV2@@Z
// EA  : 0x829F1938
// RVA : 0x009F1938
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::InternalCallEvent(
        idAI2 *this,
        idEventArg *result,
        const idEventDef *event,
        const idEventArg *args)
{
  eventType_t type; // r5
  idEventArg *v8; // r3
  const char *EnumName; // r3

  type = event->type;
  if ( type == EVENT_FSMEVENT )
  {
    v8 = (idEventArg *)(*(int (__fastcall **)(float *))(LODWORD(result[1071].value.v[1]) + 56))(a1: &result[1071].value.v[1]);
    idEventReceiver::ProcessEventArgPtr(this, result: v8, ev: event, args);
    return this;
  }
  else
  {
    EnumName = idTypeInfoTools::GetEnumName(
                 this: typeInfoTools,
                 enumTypeName: "eventType_t",
                 enumValue: type,
                 defaultValue: "<unknown>");
    idLib::Warning(fmt: "idAI2::InternalCallEvent() doesn't handle %s event type.", EnumName);
    HIBYTE(this->__vftable) = 0;
    this->listenerList = nullptr;
    return this;
  }
}


// ========================================================================
// ?InternalRespondsTo@idAI2@@MBA_NABVidEventDef@@@Z
// EA  : 0x829F19D8
// RVA : 0x009F19D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::InternalRespondsTo(idAI2 *this, const idEventDef *event)
{
  const idFiniteStateMachine *v3; // r3

  if ( event->type != EVENT_FSMEVENT )
    return false;
  v3 = this->aiVolatile.fsms.fsmManager.GetControllingFSM(this: &this->aiVolatile.fsms);
  return v3->RespondsTo(this: (struct idFiniteStateMachine *)v3, a2: event);
}


// ========================================================================
// ?CheckForOneShotKill@idAI2@@QAA_NPAVidEntity@@@Z
// EA  : 0x829F1A50
// RVA : 0x009F1A50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::CheckForOneShotKill(idAI2 *this, idPlayer *attacker)
{
  __int16 dropState; // r9
  __int64 v6; // r9
  unsigned int v7; // r4

  dropState = this->aiVolatile.dropState;
  if ( dropState != 1 && dropState != 2
    || this->GetEquipped(this, a2: 4) == nullptr
    || this->aiEditable.ignoreDamageWhileDropping )
  {
    return false;
  }
  if ( idPlayer::CastTo(c: attacker) != nullptr )
    return true;
  HIDWORD(v6) = 1664525;
  v7 = 1664525 * clientGame->random.seed;
  clientGame->random.seed = v7 + 1013904223;
  LODWORD(v6) = ((v7 + 1013904223) >> 10) & 0x7FFF;
  return (float)((float)v6 * (float)0.000030518509) < (double)ai_NonPlayerOneShotChance.valueFloat;
}


// ========================================================================
// ?GetJointIndexFromTrace@idAI2@@UAA?AV?$idIndex@FW4invalidJointIndex_t@@@@Utrace_t@@@Z
// EA  : 0x829F1B58
// RVA : 0x009F1B58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::GetJointIndexFromTrace(
        idAI2 *this,
        idIndex<short,enum invalidJointIndex_t> *result,
        trace_t *trace,
        int a4,
        int a5,
        int a6,
        int a7,
        int a8,
        int a9,
        int a10,
        int a11,
        int a12,
        int a13,
        int a14,
        int a15,
        int a16,
        int a17,
        int a18,
        int a19,
        int a20,
        int a21,
        int a22,
        int a23,
        int a24,
        int a25,
        int a26,
        int a27,
        int a28,
        int a29,
        int a30,
        int a31,
        int a32,
        int a33,
        int a34,
        int a35,
        int a36,
        int a37,
        int a38,
        int a39,
        int a40,
        __int16 a41)
{
  if ( a28 != 4 )
    a41 = -1;
  HIWORD(this->__vftable) = a41;
  return this;
}


// ========================================================================
// ?ApplyFakeDamageImpulse@idAI2@@QAAXABVidVec3@@@Z
// EA  : 0x829F1B90
// RVA : 0x009F1B90
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ApplyFakeDamageImpulse(idAI2 *this, const idVec3 *impulse)
{
  idPhysics *Physics; // r3
  int v4; // r3
  float v5; // r29
  const idVec3 *v6; // r9
  bool v7; // [sp+Bh] [-B5h]
  bool v8; // [sp+Fh] [-B1h]
  bool v9; // [sp+13h] [-ADh]
  idVec3 v10; // [sp+90h] [-30h] BYREF

  Physics = idEntity::GetPhysics(this);
  v4 = (int)Physics->GetOrigin(this: Physics, a2: 0);
  v5 = *(float *)(v4 + 8);
  v6 = *(const idVec3 **)v4;
  v10.y = *(float *)(v4 + 4);
  LODWORD(v10.x) = v6;
  v10.z = v5;
  idAIDamageInfo::Update(
    this: &this->aiVolatile.pain.damageInfo,
    ai: this,
    inflictor: nullptr,
    attacker: nullptr,
    damageDecl: nullptr,
    damage: 0.0,
    unscaledDamage: 0.0,
    damageScale: 0.0,
    armorDamage: 0.0,
    impactPoint: &v10,
    impactDir: v6,
    impactJoint: (const idIndex<short,enum invalidJointIndex_t> *)0xFFFFFFFF,
    killed: v7,
    armorPoppedOff: v8,
    forceInjured: v9);
}


// ========================================================================
// ?CheckPain@idAI2@@IAAXPAVidEntity@@0PBVidDeclDamage@@MABVidVec3@@2V?$idIndex@FW4invalidJointIndex_t@@@@@Z
// EA  : 0x829F1C30
// RVA : 0x009F1C30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::CheckPain(
        idAI2 *this,
        idEntity *inflictor,
        idEntity *attacker,
        const idDeclDamage *damageDecl,
        double damage,
        const idVec3 *impactPoint,
        const idVec3 *impactDir,
        idIndex<short,enum invalidJointIndex_t> *jointIndex,
        const idIndex<short,enum invalidJointIndex_t> *a9)
{
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  idPresentable *presentable; // r11
  idTreeAnimator *v14; // r30
  const char *JointName; // r5
  idAIGameState *p_aiGameState; // r30
  const idSpawnId *v17; // r28
  const idAILogic *v18; // r3
  const idSpawnId *v19; // r8
  idSpawnId v20; // [sp+50h] [-60h] BYREF
  idSpawnId v21; // [sp+54h] [-5Ch] BYREF
  idAILogic v22[2]; // [sp+60h] [-50h] BYREF

  if ( !idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
    && (*((_BYTE *)&this->aiEditable.death + 84) & 0x80) != 0 )
  {
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    presentable = this->presentable;
    v14 = TreeAnimatorFromPresentable;
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
    }
    idPresentable::UpdateModelTransform(this: presentable);
    if ( g_debugDamage.valueInteger != 0 )
    {
      if ( v14 != nullptr )
        JointName = idTreeAnimator::GetJointName(this: v14, jointIndex: a9);
      else
        JointName = &byte_8200D768;
      idLib::Printf(fmt: "CheckPain - hit location %d, joint '%s'.\n", (__int16)a9, JointName);
    }
    if ( attacker != nullptr )
    {
      p_aiGameState = &gameLocal->aiGameState;
      idSpawnId::idSpawnId(this: &v20, ent: this);
      v17 = idSpawnId::idSpawnId(this: &v21, ent: attacker);
      v18 = idAILogic::idAILogic(this: v22, ai: this);
      idAIWorldState::AddEntityState(
        this: &this->aiVolatile.world.worldState,
        gameState: p_aiGameState,
        owner: v18,
        entId: v17,
        stimulusType: AISTIMULUS_DAMAGE,
        stimulusAmount: 1.0,
        sourceId: v19);
    }
  }
}


// ========================================================================
// ?DisableAnimatorsOnDeath@idAI2@@QAAXXZ
// EA  : 0x829F1D58
// RVA : 0x009F1D58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DisableAnimatorsOnDeath(idAI2 *this)
{
  idFaceMgr *p_faceMgr; // r30
  idAnimStack *v3; // r3
  idAnimStack *v4; // r3
  idAnimStack *v5; // r3
  idAnimStack *v6; // r3

  p_faceMgr = &this->aiVolatile.faceMgr;
  idFaceMgr::SetEnableAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
  idFaceMgr::SetEnableEyeTracking(this: p_faceMgr, owner: this, enable: false);
  v3 = this->GetAnimStack_2(this);
  idAnimator_Base::SetEnabled(this: &this->aiVolatile.animation.painAnimator, animStack: v3, enabled: false);
  v4 = this->GetAnimStack_2(this);
  idAnimator_Base::SetEnabled(this: &this->aiVolatile.animation.turretAnimator, animStack: v4, enabled: false);
  v5 = this->GetAnimStack_2(this);
  idAnimator_Base::SetEnabled(this: (idAnimator_Base *)&this->aiVolatile.animation, animStack: v5, enabled: false);
  v6 = this->GetAnimStack_2(this);
  idAnimator_Base::SetEnabled(this: &this->walkIK, animStack: v6, enabled: false);
}


// ========================================================================
// ?DoMeleeDamage@idAI2@@QAA_NV?$idIndex@FW4invalidJointIndex_t@@@@ABVidBounds@@PBVidDeclDamage@@PBVidDeclProjectileImpactEffect@@@Z
// EA  : 0x829F1E50
// RVA : 0x009F1E50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::DoMeleeDamage(
        idAI2 *this,
        idIndex<short,enum invalidJointIndex_t> *jointIndex,
        const idBounds *bounds,
        const idDeclDamage *damageDecl,
        const idDeclProjectileImpactEffect *impactEffect)
{
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  char *v11; // r10
  _DWORD *p_z; // r11
  int i; // ctr
  int EntitiesTouchingBounds; // r31
  idPhysics *Physics; // r3
  float *v16; // r3
  double v17; // fp8
  double v18; // fp6
  double v21; // fp12
  double v22; // fp2
  double v23; // fp13
  idPhysics *v24; // r3
  const idVec3 *v25; // r3
  int *v26; // r21
  int j; // r18
  int v28; // r9
  idDoor_Parametric *v29; // r30
  idPhysics *v30; // r3
  idDoor_Parametric *v31; // r31
  idEventArg *v32; // r3
  int v33; // r4
  const idDeclProjectileImpactEffect::projectileImpactEffect_t *ImpactEffectForMaterial; // r3
  const idPresentable *v36; // [sp+8h] [-1C8h]
  idPresentable *v37; // [sp+Ch] [-1C4h]
  idIndex<short,enum invalidJointIndex_t> *v38; // [sp+10h] [-1C0h]
  idVec3 v39; // [sp+70h] [-160h] BYREF
  idVec3 v40; // [sp+80h] [-150h] BYREF
  char v41; // [sp+8Ch] [-144h] BYREF
  idBounds v42; // [sp+90h] [-140h] BYREF
  idVec3 v43; // [sp+A8h] [-128h] BYREF
  char v44; // [sp+B8h] [-118h] BYREF
  int v45[8]; // [sp+D0h] [-100h] BYREF
  idEventArg v46; // [sp+F0h] [-E0h] BYREF
  idMat3 v47; // [sp+110h] [-C0h] BYREF

  TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
  idTreeAnimator::GetWorldSpaceJointTransform(
    this: TreeAnimatorFromPresentable,
    pose: DRIVER_MODEL,
    jointIndex,
    origin: &v40,
    axis: &v47);
  v11 = &v41;
  p_z = (_DWORD *)&bounds[-1].b[1].z;
  for ( i = 6; i != 0; --i )
  {
    ++p_z;
    v11 += 4;
    *(_DWORD *)v11 = *p_z;
  }
  v42.b[0].x = v40.x + v42.b[0].x;
  v42.b[0].y = v42.b[0].y + v40.y;
  v42.b[0].z = v40.z + v42.b[0].z;
  v42.b[1].x = v42.b[1].x + v40.x;
  v42.b[1].y = v42.b[1].y + v40.y;
  v42.b[1].z = v42.b[1].z + v40.z;
  EntitiesTouchingBounds = idClip::GetEntitiesTouchingBounds(
                             this: &clientGame->clip,
                             bounds: &v42,
                             clipMask: 33792,
                             entityList: v45,
                             maxCount: 8);
  if ( EntitiesTouchingBounds <= 0 )
    return 0;
  Physics = idEntity::GetPhysics(this);
  v16 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v17 = (float)(v40.x - *v16);
  v18 = (float)(v40.z - v16[2]);
  _FP2 = (float)((float)((float)((float)(v40.z - v16[2]) * (float)(v40.z - v16[2]))
                       + (float)((float)((float)(v40.x - *v16) * (float)(v40.x - *v16))
                               + (float)((float)(v40.y - v16[1]) * (float)(v40.y - v16[1]))))
               - idMath::FLT_SMALLEST_NON_DENORMAL);
  __asm { fsel      f13, f2, f3, f13 }
  v21 = __frsqrte(_FP13);
  v22 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21
                                                                                      * (float)((float)((float)((float)(v40.z - v16[2]) * (float)(v40.z - v16[2])) + (float)((float)((float)(v40.x - *v16) * (float)(v40.x - *v16)) + (float)((float)(v40.y - v16[1]) * (float)(v40.y - v16[1]))))
                                                                                              * (float)0.5))
                                                                              * (float)v21)
                                                                      - (float)1.5)
                                                      * (float)v21)
                                              * (float)((float)((float)((float)(v40.z - v16[2]) * (float)(v40.z - v16[2]))
                                                              + (float)((float)((float)(v40.x - *v16)
                                                                              * (float)(v40.x - *v16))
                                                                      + (float)((float)(v40.y - v16[1])
                                                                              * (float)(v40.y - v16[1]))))
                                                      * (float)0.5))
                                      * (float)((float)-(float)((float)((float)((float)v21
                                                                              * (float)((float)((float)((float)(v40.z - v16[2]) * (float)(v40.z - v16[2]))
                                                                                              + (float)((float)((float)(v40.x - *v16) * (float)(v40.x - *v16)) + (float)((float)(v40.y - v16[1]) * (float)(v40.y - v16[1]))))
                                                                                      * (float)0.5))
                                                                      * (float)v21)
                                                              - (float)1.5)
                                              * (float)v21))
                              - (float)1.5)
              * (float)((float)-(float)((float)((float)((float)v21
                                                      * (float)((float)((float)((float)(v40.z - v16[2])
                                                                              * (float)(v40.z - v16[2]))
                                                                      + (float)((float)((float)(v40.x - *v16)
                                                                                      * (float)(v40.x - *v16))
                                                                              + (float)((float)(v40.y - v16[1])
                                                                                      * (float)(v40.y - v16[1]))))
                                                              * (float)0.5))
                                              * (float)v21)
                                      - (float)1.5)
                      * (float)v21));
  v23 = (float)((float)-(float)((float)((float)((float)v22
                                              * (float)((float)((float)((float)(v40.z - v16[2]) * (float)(v40.z - v16[2]))
                                                              + (float)((float)((float)(v40.x - *v16)
                                                                              * (float)(v40.x - *v16))
                                                                      + (float)((float)(v40.y - v16[1])
                                                                              * (float)(v40.y - v16[1]))))
                                                      * (float)0.5))
                                      * (float)v22)
                              - (float)1.5)
              * (float)v22);
  v39.y = (float)(v40.y - v16[1])
        * (float)((float)-(float)((float)((float)((float)v22
                                                * (float)((float)((float)((float)(v40.z - v16[2])
                                                                        * (float)(v40.z - v16[2]))
                                                                + (float)((float)((float)(v40.x - *v16)
                                                                                * (float)(v40.x - *v16))
                                                                        + (float)((float)(v40.y - v16[1])
                                                                                * (float)(v40.y - v16[1]))))
                                                        * (float)0.5))
                                        * (float)v22)
                                - (float)1.5)
                * (float)v22);
  v39.x = (float)v17 * (float)v23;
  v39.z = (float)v18 * (float)v23;
  v24 = idEntity::GetPhysics(this);
  v25 = v24->GetGravityNormal(this: v24);
  idVec3::ProjectOntoPlane(this: &v39, normal: v25, overBounce: 1.0);
  v26 = v45;
  for ( j = EntitiesTouchingBounds; j != 0; --j )
  {
    v28 = *v26 + 21563;
    v29 = *((idDoor_Parametric **)&gameLocal->__vftable + v28);
    if ( v29 != (idDoor_Parametric *)this
      && (idActor::CastTo(c: *((idActor **)&gameLocal->__vftable + v28)) == nullptr || !v29->IsDead(this: v29)) )
    {
      v30 = idEntity::GetPhysics(this: v29);
      v30->GetLinearVelocity(this: (idPhysics *)&v44, result: (idVec3 *)v30, a3: 0);
      if ( ai_debugmelee.valueInteger != 0 )
        idLib::Printf(fmt: "%s melee hit on %s\n", this->name.data, v29->name.data);
      v31 = idDoor_Parametric::CastTo(c: v29);
      if ( v31 != nullptr )
      {
        v32 = idEventArg::idEventArg(this: &v46, data: this);
        idEventReceiver::PostEventMS(
          this: v31,
          ev: &EV_KickOpen,
          time: *(_DWORD *)&v32->type,
          arg1: (const idEventArg *)LODWORD(v32->value.v[1]));
      }
      else
      {
        if ( impactEffect != nullptr )
        {
          v33 = 27;
          if ( this->actorConstants.actorClass != ACTORCLASS_MUTANT )
            v33 = 3;
          ImpactEffectForMaterial = idDeclProjectileImpactEffect::GetImpactEffectForMaterial(
                                      this: impactEffect,
                                      materialID: v33);
          v43.x = v39.x * (float)-1.0;
          v43.y = v39.y * (float)-1.0;
          v43.z = v39.z * (float)-1.0;
          idClientGame::ImpactEffect(
            this: clientGame,
            point: &v40,
            normal: &v43,
            color: &idColor::colorWhite,
            effect: ImpactEffectForMaterial,
            skipParticle: false,
            noDecals: false,
            noSounds: false,
            owner: v36,
            entity: v37,
            jointId: v38);
        }
        ((void (__fastcall *)(idDoor_Parametric *, _DWORD, idAI2 *, const idDeclDamage *, double))v29->Damage)(
          a1: v29,
          a2: 0,
          a3: this,
          a4: damageDecl,
          a5: 1.0);
      }
    }
    ++v26;
  }
  return 1;
}


// ========================================================================
// ?CanMelee@idAI2@@QBA_NXZ
// EA  : 0x829F2228
// RVA : 0x009F2228
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::CanMelee(idAI2 *this)
{
  bool IsCrouching; // r3
  int v3; // r10
  idWeapon *v4; // r3
  BOOL result; // r3

  IsCrouching = idActor::IsCrouching(this);
  v3 = 34876;
  if ( !IsCrouching )
    v3 = 34872;
  result = false;
  if ( *(idAI2_vtbl **)((char *)&this->__vftable + v3) != nullptr
    && (*((_BYTE *)this->aiEditable.behaviors.decl + 196) & 4) != 0 )
  {
    v4 = this->GetEquippedWeapon(this);
    if ( v4 == nullptr || v4->fireState == FIRESTATE_IDLE )
      return true;
  }
  return result;
}


// ========================================================================
// ?ExtrapolateMeleeTarget@idAI2@@QBAXABVidVec3@@0AAV2@@Z
// EA  : 0x829F22D0
// RVA : 0x009F22D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ExtrapolateMeleeTarget(
        idAI2 *this,
        const idVec3 *targetPos,
        const idVec3 *targetVel,
        idVec3 *outAttackTo)
{
  const idDeclAIBehavior *decl; // r11
  double y; // fp10
  double z; // fp7
  double v7; // fp6
  double v8; // fp5

  decl = this->aiEditable.behaviors.decl;
  y = targetPos->y;
  z = targetPos->z;
  v7 = (float)(targetVel->y * decl->meleeExtrapolate);
  v8 = (float)(targetVel->z * decl->meleeExtrapolate);
  outAttackTo->x = targetPos->x + (float)(targetVel->x * decl->meleeExtrapolate);
  outAttackTo->y = (float)y + (float)v7;
  outAttackTo->z = (float)z + (float)v8;
}


// ========================================================================
// ?IsTargetInMeleeRange@idAI2@@QBA_NABVidVec3@@W4aiMelee_t@@@Z
// EA  : 0x829F2318
// RVA : 0x009F2318
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsTargetInMeleeRange(idAI2 *this, const idVec3 *targetPos, const aiMelee_t meleeType)
{
  const idDeclAIBehavior *decl; // r11
  double closeMeleeDist; // fp29
  idPhysics *Physics; // r3
  float *v13; // r3
  double v15; // fp7
  double v16; // fp30
  idPhysics *v18; // r3
  int v19; // r3
  unsigned __int8 v20; // r11

  decl = this->aiEditable.behaviors.decl;
  _FP31 = decl->closeMeleeDist;
  if ( (*((_BYTE *)decl + 196) & 4) == 0 )
    return 0;
  if ( (meleeType & 0x100) != 0 )
  {
    _FP13 = (float)(this->aiEditable.behaviors.decl->longMeleeDist - decl->closeMeleeDist);
    __asm { fsel      f31, f13, f0, f31 }
  }
  if ( (meleeType & 0x80) != 0 )
  {
    _FP13 = (float)(this->aiEditable.behaviors.decl->mediumMeleeDist - (float)_FP31);
    __asm { fsel      f31, f13, f0, f31 }
  }
  if ( (meleeType & 0x4000) != 0 && (this->aiVolatile.groupStatus.condition & 8) == 0 )
  {
    _FP13 = (float)(this->aiEditable.behaviors.decl->movingMeleeDist - (float)_FP31);
    __asm { fsel      f31, f13, f0, f31 }
  }
  closeMeleeDist = this->aiEditable.behaviors.decl->closeMeleeDist;
  Physics = idEntity::GetPhysics(this);
  v13 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  _FP12 = (float)((float)closeMeleeDist - (float)_FP31);
  v15 = (float)(targetPos->y - v13[1]);
  v16 = (float)(targetPos->z - v13[2]);
  __asm { fsel      f5, f12, f29, f31 }
  if ( __fsqrts((float)((float)((float)v15 * (float)v15)
                      + (float)((float)(targetPos->x - *v13) * (float)(targetPos->x - *v13)))) > _FP5 )
    return 0;
  v18 = idEntity::GetPhysics(this);
  v19 = (int)v18->GetBounds(this: v18, a2: -1);
  v20 = 1;
  if ( __fabs(v16) >= (float)((float)(*(float *)(v19 + 20) - *(float *)(v19 + 8)) * (float)0.75) )
    return 0;
  return v20;
}


// ========================================================================
// ?IsTargetInLeapAttackZone@idAI2@@QBA_NABVidVec3@@@Z
// EA  : 0x829F24A0
// RVA : 0x009F24A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsTargetInLeapAttackZone(idAI2 *this, const idVec3 *targetPos)
{
  idPhysics *Physics; // r3
  float *v5; // r3
  const idDeclAIBehavior *decl; // r11
  double v7; // fp13
  double maxLeapAttackDistance; // fp8
  double v9; // fp0
  double z; // fp31
  idPhysics *v11; // r31
  idRenderWorld *v12; // r30
  idPhysics *v13; // r3
  idRenderWorld_vtbl *v14; // r31
  const idVec3 *(__fastcall *v15)(idPhysics *, int); // ctr
  int v16; // r3
  idPresentable *presentable; // r11
  idPhysics *v18; // r31
  idRenderWorld *v19; // r30
  idPhysics *v20; // r3
  idRenderWorld_vtbl *v21; // r31
  const idVec3 *(__fastcall *v22)(idPhysics *, int); // ctr
  int v23; // r3
  idPhysics *v25; // r31
  idRenderWorld *v26; // r30
  idPhysics *v27; // r3
  idRenderWorld_vtbl *v28; // r31
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  int v30; // r3
  idVec3 v31; // [sp+60h] [-40h] BYREF
  idVec3 v32; // [sp+70h] [-30h]

  Physics = idEntity::GetPhysics(this);
  v5 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  decl = this->aiEditable.behaviors.decl;
  v7 = (float)(targetPos->y - v5[1]);
  v32.x = targetPos->x - *v5;
  maxLeapAttackDistance = decl->maxLeapAttackDistance;
  v32.z = targetPos->z - v5[2];
  v32.y = v7;
  v9 = __fsqrts((float)((float)((float)v7 * (float)v7) + (float)(v32.x * v32.x)));
  if ( v9 > maxLeapAttackDistance || v9 < decl->minLeapAttackDistance )
  {
    if ( ai_debugLeapAttack.valueInteger != 0 && ai_debugLevel.valueInteger > 0 )
    {
      v25 = idEntity::GetPhysics(this);
      v26 = common->RW(this: common);
      v27 = v25;
      GetOrigin = v25->GetOrigin;
      v28 = v26->__vftable;
      v30 = (int)GetOrigin(this: v27, a2: 0);
      ((void (__fastcall *)(idRenderWorld *, const char *, int, _DWORD, idColor *, int, int, _DWORD, double))v28->DebugText)(
        a1: v26,
        a2: "RANGE",
        a3: v30,
        a4: 0,
        a5: &idColor::colorMagenta,
        a6: 1,
        a7: 16,
        a8: 0,
        a9: 0.2);
    }
  }
  else
  {
    v31 = v32;
    idVec3::NormalizeFast(this: &v31);
    z = v31.z;
    if ( __fabs(v31.z) <= 0.050000001 )
    {
      presentable = this->presentable;
      if ( presentable == nullptr )
      {
        idEntity::InitPresentableInternal(this);
        presentable = this->presentable;
      }
      if ( (float)((float)(presentable->axis.mat[0].x * v31.x)
                 + (float)((float)(presentable->axis.mat[0].y * v31.y) + (float)(presentable->axis.mat[0].z * (float)z))) >= 0.94999999 )
        return 1;
      if ( ai_debugLeapAttack.valueInteger != 0 && ai_debugLevel.valueInteger > 0 )
      {
        v18 = idEntity::GetPhysics(this);
        v19 = common->RW(this: common);
        v20 = v18;
        v22 = v18->GetOrigin;
        v21 = v19->__vftable;
        v23 = (int)v22(this: v20, a2: 0);
        ((void (__fastcall *)(idRenderWorld *, const char *, int, enum idAIStateTransition::aiTransCode_t (__fastcall **)(COMBAT_AtPlugAnim *__hidden, struct idAI2 *, struct idAIFSM *, struct idAIState *, int), idColor *, int, int, _DWORD, double))v21->DebugText)(
          a1: v19,
          a2: "FACING",
          a3: v23,
          a4: &off_82040000,
          a5: &idColor::colorMagenta,
          a6: 1,
          a7: 16,
          a8: 0,
          a9: 0.2);
      }
    }
    else if ( ai_debugLeapAttack.valueInteger != 0 && ai_debugLevel.valueInteger > 0 )
    {
      v11 = idEntity::GetPhysics(this);
      v12 = common->RW(this: common);
      v13 = v11;
      v15 = v11->GetOrigin;
      v14 = v12->__vftable;
      v16 = (int)v15(this: v13, a2: 0);
      ((void (__fastcall *)(idRenderWorld *, const char *, int, enum idAIStateTransition::aiTransCode_t (__fastcall **)(COMBAT_AtPlugAnim *__hidden, struct idAI2 *, struct idAIFSM *, struct idAIState *, int), idColor *, int, int, _DWORD, double))v14->DebugText)(
        a1: v12,
        a2: "HEIGHT",
        a3: v16,
        a4: &off_82040000,
        a5: &idColor::colorMagenta,
        a6: 1,
        a7: 16,
        a8: 0,
        a9: 0.2);
    }
  }
  return 0;
}


// ========================================================================
// ?MeleePreference@idAI2@@QBAHPBVidEntity@@@Z
// EA  : 0x829F27E8
// RVA : 0x009F27E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::MeleePreference(idAI2 *this, idTurret *target)
{
  int result; // r3
  actorClass_t actorClass; // r11

  if ( idTurret::CastTo(c: target) != nullptr )
    return 32;
  if ( idActor::CastTo(c: (idActor *)target) == nullptr )
    return 1;
  actorClass = idActor::CastTo(c: (idActor *)target)->actorConstants.actorClass;
  result = 32;
  if ( actorClass != ACTORCLASS_ROBOT )
    return 1;
  return result;
}


// ========================================================================
// ?GetDesiredWalkStateForDistance@idAI2@@QBA?AW4walkState_t@@MW42@_N@Z
// EA  : 0x829F2868
// RVA : 0x009F2868
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

walkState_t __fastcall idAI2::GetDesiredWalkStateForDistance(
        idAI2 *this,
        double distance,
        const walkState_t maxWalkState,
        walkState_t firedAt,
        char a5)
{
  const idDeclAIBehavior *decl; // r30
  idAI2::aiCondition_t *p_condition; // r29
  int v10; // r31
  double injuredCrouchMoveMax; // fp31
  walkState_t result; // r3

  decl = this->aiEditable.behaviors.decl;
  p_condition = &this->aiVolatile.groupStatus.condition;
  v10 = 1;
  if ( (this->aiVolatile.groupStatus.condition & 8) != 0 )
    injuredCrouchMoveMax = decl->movementBehaviors.injuredCrouchMoveMax;
  else
    injuredCrouchMoveMax = decl->movementBehaviors.crouchMoveMax;
  if ( (*((_BYTE *)decl + 428) & 4) != 0 && distance > decl->movementBehaviors.sprintMoveMin )
  {
    v10 = 3;
  }
  else if ( this->GetPosture(this) == POSTURE_CROUCHED && distance < injuredCrouchMoveMax )
  {
    v10 = 1;
  }
  else if ( distance > decl->movementBehaviors.runMoveMin )
  {
    v10 = 2;
  }
  if ( a5 != 0 && v10 < 2 && (*((_BYTE *)&decl->movementBehaviors + 40) & 0x80) != 0 )
    v10 = 2;
  if ( (*p_condition & 8) != 0 )
    v10 = 2;
  result = firedAt;
  if ( firedAt >= v10 )
    return v10;
  return result;
}


// ========================================================================
// ?HasTauntRage@idAI2@@QBA_NXZ
// EA  : 0x829F2970
// RVA : 0x009F2970
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::HasTauntRage(idAI2 *this)
{
  const idDeclAIBehavior *decl; // r11
  unsigned __int8 v2; // r11
  bool v3; // zf

  decl = this->aiEditable.behaviors.decl;
  if ( decl->rageBehaviors.tauntRageAfterHitEnemyChance > 0 )
    return 1;
  if ( decl->rageBehaviors.tauntRageBehindEnemyChance > 0 )
    return 1;
  if ( decl->rageBehaviors.tauntRageFleeingEnemyChance > 0 )
    return 1;
  v3 = decl->rageBehaviors.tauntRageAfterKillingEnemyChance <= 0;
  v2 = 0;
  if ( !v3 )
    return 1;
  return v2;
}


// ========================================================================
// ?HasAngryRage@idAI2@@QBA_NXZ
// EA  : 0x829F29B8
// RVA : 0x009F29B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::HasAngryRage(idAI2 *this)
{
  const idDeclAIBehavior *decl; // r11
  double angryRageWhenCloseDistance; // fp13
  unsigned __int8 v3; // r11

  decl = this->aiEditable.behaviors.decl;
  if ( decl->rageBehaviors.angryRageAfterHurtChance > 0 )
    return 1;
  if ( decl->rageBehaviors.angryRageAfterMissingChance > 0 )
    return 1;
  if ( decl->rageBehaviors.angryRageAfterAttractChance > 0 )
    return 1;
  angryRageWhenCloseDistance = decl->rageBehaviors.angryRageWhenCloseDistance;
  v3 = 0;
  if ( angryRageWhenCloseDistance > 0.0 )
    return 1;
  return v3;
}


// ========================================================================
// ?ProvidesFormationCover@idAI2@@QBA_NXZ
// EA  : 0x829F2A08
// RVA : 0x009F2A08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ProvidesFormationCover(idAI2 *this)
{
  return (*(_BYTE *)&this->aiEditable.behaviors.decl->dynamicCoverCaps & 0x20) != 0;
}


// ========================================================================
// ?GetUsableDistance@idAI2@@UBAMXZ
// EA  : 0x829F2A18
// RVA : 0x009F2A18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::GetUsableDistance(idAI2 *this)
{
  const idDeclAIPlayerInteraction *decl; // r11
  double approachRadius; // fp1

  decl = this->aiVolatile.aiPlayerInteraction.decl;
  if ( decl != nullptr )
    approachRadius = decl->approachRadius;
  else
    approachRadius = 160.0;
  return *((float *)&approachRadius + 1);
}


// ========================================================================
// ?TakedownWindoIsOpen@idAI2@@QBA_NXZ
// EA  : 0x829F2A40
// RVA : 0x009F2A40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::TakedownWindoIsOpen(idAI2 *this)
{
  idWeapon *v2; // r3
  int *p_takedownWindowClosed; // r31
  BOOL result; // r3

  v2 = this->GetEquippedWeapon(this);
  result = true;
  if ( (v2 == nullptr || v2->fireState != FIRESTATE_RELOADING) && takedownWindoMaxTime.valueInteger != -1 )
  {
    p_takedownWindowClosed = &this->takedownWindowClosed;
    if ( *p_takedownWindowClosed == -1
      || idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) > *p_takedownWindowClosed )
    {
      return false;
    }
  }
  return result;
}


// ========================================================================
// ?SetTakeDownWindow@idAI2@@QAAX_N@Z
// EA  : 0x829F2AF8
// RVA : 0x009F2AF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetTakeDownWindow(idAI2 *this, bool setOpen)
{
  if ( setOpen )
    this->takedownWindowClosed = takedownWindoMaxTime.valueInteger
                               + idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  else
    this->takedownWindowClosed = -1;
}


// ========================================================================
// ?PassMerchantTestCondition@idAI2@@QBA_NABVmerchantCondition_t@idConditionalMerchantInventoryDef@idAIEditable@@PBVidPlayer@@@Z
// EA  : 0x829F2B88
// RVA : 0x009F2B88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::PassMerchantTestCondition(
        idAI2 *this,
        const idAIEditable::idConditionalMerchantInventoryDef::merchantCondition_t *merchcondition,
        const idPlayer *player)
{
  idAIEditable::idConditionalMerchantInventoryDef::merchantConditionType_t condition; // r11
  const idDeclInventory *testInventory; // r31
  idJobManager *v6; // r3
  idJob *JobByDecl; // r3
  BOOL result; // r3
  const idDeclInventory *v9; // r31
  idJobManager *v10; // r3
  idJob *v11; // r3
  idJob *InventoryItemByDeclName; // r3
  idAIEditable::idConditionalMerchantInventoryDef::merchantConditionType_t v13; // r11
  int status; // r11

  condition = merchcondition->condition;
  if ( merchcondition->condition == MERCHANTCONDITION_AVAILABLE )
    return true;
  if ( condition == MERCHANTCONDITION_NOTININVENTORY )
  {
    testInventory = merchcondition->testInventory;
    if ( testInventory != nullptr )
    {
      v6 = (idJobManager *)player->GetInventory(this: player);
      JobByDecl = idJobManager::FindJobByDecl(this: v6, jobDecl: (const idDeclJob *)testInventory);
      if ( JobByDecl != nullptr && ((int (__fastcall *)(idJob *))JobByDecl->__vftable[2].dtr_idClass)(a1: JobByDecl) > 0 )
        return false;
    }
    return true;
  }
  if ( condition == MERCHANTCONDITION_PLAYERINVENTORY )
  {
    v9 = merchcondition->testInventory;
    if ( v9 != nullptr )
    {
      v10 = (idJobManager *)((int (*)(void))player->GetInventory)();
      v11 = idJobManager::FindJobByDecl(this: v10, jobDecl: (const idDeclJob *)v9);
      return v11 != nullptr && ((int (__fastcall *)(idJob *))v11->__vftable[2].dtr_idClass)(a1: v11) >= 1;
    }
    return false;
  }
  InventoryItemByDeclName = idInventoryCollection::FindInventoryItemByDeclName(
                              this: &player->jobManager,
                              jobName: merchcondition->jobDecl.data);
  if ( InventoryItemByDeclName == nullptr )
    return false;
  v13 = merchcondition->condition;
  if ( merchcondition->condition == MERCHANTCONDITION_JOB_ACCEPTED )
    return InventoryItemByDeclName->status >= JOBSTATUS_ACCEPTED;
  if ( v13 == MERCHANTCONDITION_JOB_READY )
    return InventoryItemByDeclName->status >= JOBSTATUS_READYTOTURNIN;
  if ( v13 != MERCHANTCONDITION_JOB_COMPLETE )
    return true;
  status = InventoryItemByDeclName->status;
  result = false;
  if ( status >= 5 )
    return true;
  return result;
}


// ========================================================================
// ?AddConditionalGoodList@idAI2@@QAAXH@Z
// EA  : 0x829F2D18
// RVA : 0x009F2D18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::AddConditionalGoodList(idAI2 *this, int index)
{
  idAIEditable::idConditionalMerchantInventoryDef *v2; // r29
  int v4; // r26
  int num; // r11
  int v6; // r27
  const idDeclInventory **list; // r28
  idPresentable *presentable; // r30
  const idDeclInventory *v9; // r28
  idInventoryCollection *v10; // r3
  idInventoryItem *v11; // r3

  v2 = &this->aiEditable.interactions.conditionalMerchantInventory.list[index];
  v4 = 0;
  num = v2->merchantInventoryList.num;
  v2->listGiven = true;
  if ( num > 0 )
  {
    v6 = 0;
    do
    {
      list = v2->merchantInventoryList.list;
      if ( this->presentable == nullptr )
        idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
      v9 = list[v6];
      v10 = this->GetInventory_2(this);
      v11 = idInventoryCollection::GiveItem(
              this: v10,
              owner: presentable,
              decl: v9,
              count: 1,
              forceCount: false,
              canIntro: false);
      if ( v11 != nullptr )
        v11->forSale = true;
      ++v4;
      ++v6;
    }
    while ( v4 < v2->merchantInventoryList.num );
  }
}


// ========================================================================
// ?ShouldAddDynamicGood@idAI2@@QBA_NPBVidPlayer@@H@Z
// EA  : 0x829F2DD0
// RVA : 0x009F2DD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::ShouldAddDynamicGood(idAI2 *this, const idPlayer *player, int index)
{
  idAIEditable::idDynamicMerchantInventoryDef *v3; // r31
  const idDeclInventory *inventoryDecl; // r30
  int result; // r3
  idJobManager *v7; // r3
  idJob *InventoryItemByDeclName; // r3
  idJob *v9; // r3
  int status; // r11

  v3 = &this->aiEditable.interactions.dynamicMerchantInventory.list[index];
  inventoryDecl = v3->inventoryDecl;
  if ( inventoryDecl == nullptr || v3->itemGiven && v3->giveOnce )
    return 0;
  if ( inventoryDecl->singular )
  {
    v7 = (idJobManager *)player->GetInventory(this: player);
    if ( idJobManager::FindJobByDecl(this: v7, jobDecl: (const idDeclJob *)inventoryDecl) != nullptr )
      return 0;
  }
  if ( v3->jobDecl.len != 0 )
  {
    InventoryItemByDeclName = idInventoryCollection::FindInventoryItemByDeclName(
                                this: &player->jobManager,
                                jobName: v3->jobDecl.data);
    if ( InventoryItemByDeclName == nullptr || InventoryItemByDeclName->status != JOBSTATUS_COMPLETED )
      return 0;
  }
  if ( v3->expiredJobDecl.len == 0 )
    return 1;
  v9 = idInventoryCollection::FindInventoryItemByDeclName(this: &player->jobManager, jobName: v3->expiredJobDecl.data);
  if ( v9 == nullptr )
    return 1;
  status = v9->status;
  result = 0;
  if ( status < 3 )
    return 1;
  return result;
}


// ========================================================================
// ?EverHasGoodsToSell@idAI2@@QBA_NPBVidPlayer@@@Z
// EA  : 0x829F2EB8
// RVA : 0x009F2EB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

unsigned int __fastcall idAI2::EverHasGoodsToSell(idAI2 *this, const idPlayer *player)
{
  idInventoryCollection *v3; // r3
  int InventoryForSale; // r3

  if ( this->aiEditable.interactions.conditionalMerchantInventory.num > 0
    || this->aiEditable.interactions.dynamicMerchantInventory.num > 0
    || this->aiEditable.interactions.specialDynamicMerchantInventory.itemList.num > 0 )
  {
    return 1;
  }
  v3 = (idInventoryCollection *)((int (__fastcall *)(idAI2 *, const idPlayer *))this->GetInventory)(
                                  a1: this,
                                  a2: player);
  InventoryForSale = idInventoryCollection::GetInventoryForSale(this: v3);
  return (-InventoryForSale & (unsigned int)~InventoryForSale) >> 31;
}


// ========================================================================
// ?HasGoodsToSellPlayerNeeds@idAI2@@QBA_NPBVidPlayer@@@Z
// EA  : 0x829F2F30
// RVA : 0x009F2F30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::HasGoodsToSellPlayerNeeds(idAI2 *this, const idPlayer *player)
{
  idPresentable *presentable; // r3
  const idPresentablePlayer *v4; // r31
  idInventoryCollection *v5; // r3
  bool HasInventoryForSalePlayerNeeds; // r3
  unsigned __int8 v7; // r11

  if ( player == nullptr )
    return 0;
  presentable = player->presentable;
  v4 = presentable != nullptr ? presentable->GetPlayerInterface_2(this: presentable) : nullptr;
  v5 = (idInventoryCollection *)this->GetInventory(this);
  HasInventoryForSalePlayerNeeds = idInventoryCollection::HasInventoryForSalePlayerNeeds(this: v5, player: v4);
  v7 = 1;
  if ( !HasInventoryForSalePlayerNeeds )
    return 0;
  return v7;
}


// ========================================================================
// ?SetupFakePosition@idAI2@@QAAXPBVidEntity@@ABVidVec3@@@Z
// EA  : 0x829F2FD8
// RVA : 0x009F2FD8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetupFakePosition(idAI2 *this, const idEntity *_pInstigator, const idVec3 *_fakePos)
{
  idAIGameState *p_aiGameState; // r28
  const idVec3 *v6; // r27
  const idSpawnId *v7; // r30
  const idAILogic *v8; // r3
  const idSpawnId *v9; // r8
  idSpawnId v10; // [sp+50h] [-60h] BYREF
  idSpawnId v11; // [sp+54h] [-5Ch] BYREF
  idAILogic v12[2]; // [sp+60h] [-50h] BYREF

  p_aiGameState = &gameLocal->aiGameState;
  v6 = (const idVec3 *)idSpawnId::idSpawnId(this: &v10, ent: _pInstigator);
  v7 = idSpawnId::idSpawnId(this: &v11, ent: _pInstigator);
  v8 = idAILogic::idAILogic(this: v12, ai: this);
  idAIWorldState::AddEntityStateFakePosition(
    this: &this->aiVolatile.world.worldState,
    gameState: p_aiGameState,
    owner: v8,
    entId: v7,
    stimulusType: AISTIMULUS_HEARING,
    stimulusAmount: 1.0,
    sourceId: v9,
    fakePosition: v6);
}


// ========================================================================
// ?OnAIEvent_VehicleSound@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x829F3058
// RVA : 0x009F3058
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_VehicleSound(idAI2 *this, idAIEventSound *ev)
{
  double v4; // fp31
  idAIGameState *p_aiGameState; // r29
  const idAILogic *v6; // r3
  const idSpawnId *v7; // r8
  idSpawnId v8; // [sp+50h] [-60h] BYREF
  idAILogic v9; // [sp+60h] [-50h] BYREF

  gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED);
  if ( (unsigned __int8)idAIEventSound::IsTypeOf(c: ev) != 0 )
    v4 = (float)(idInfoNavFlightVolume::Spawn(this: ev, ent: this) * this->aiEditable.perception.hearingStimulus);
  else
    v4 = 0.0;
  p_aiGameState = &gameLocal->aiGameState;
  idSpawnId::idSpawnId(this: &v8, ent: this);
  v6 = idAILogic::idAILogic(this: &v9, ai: this);
  idAIWorldState::AddEntityStateFromEvent(
    this: &this->aiVolatile.world.worldState,
    gameState: p_aiGameState,
    owner: v6,
    event: ev,
    stimType: AISTIMULUS_HEARING,
    stimAmount: v4,
    sourceId: v7);
}


// ========================================================================
// ?OnAIEvent_Body@idAI2@@AAAXPBVidAIEventSphere@@@Z
// EA  : 0x829F3118
// RVA : 0x009F3118
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Body(idAI2 *this, idAIEventSphere *ev)
{
  idFiniteStateMachine *v3; // r30
  int GameMs; // r29
  idAIEvent::aiEventClass_t EventClass; // r3

  v3 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  EventClass = idAIEvent::GetEventClass(this: ev);
  idFiniteStateMachine::PostEvent(this: v3, _eventId: EventClass, _eventData: ev, curTime: GameMs);
}


// ========================================================================
// ?OnAIEvent_PlayerInteraction@idAI2@@AAAXPBVidAIEventSphere@@@Z
// EA  : 0x829F3188
// RVA : 0x009F3188
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_PlayerInteraction(idAI2 *this, idAIEventSphere *ev)
{
  idFiniteStateMachine *v4; // r31
  int GameMs; // r30
  idAIEvent::aiEventClass_t EventClass; // r3

  if ( gameLocal->GetGameFrame(this: gameLocal) > 10 )
  {
    if ( this->actorConstants.actorClass != ACTORCLASS_MUTANT )
    {
      if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x40) != 0 )
        idFaceMgr::SetEnableMoodAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x20) != 0 )
        idFaceMgr::SetEnableLipSyncAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x10) != 0 )
        idFaceMgr::SetEnableGestureAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 0x10) != 0 )
        idFaceMgr::SetEnableEyeTracking(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 4) != 0 )
        idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 2) != 0 )
        idFaceMgr::SetEnableLidDeformation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    }
    idEntity::Signal(this, signalnum: SIG_PLAYER_INTERACTING);
    v4 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    EventClass = idAIEvent::GetEventClass(this: ev);
    idFiniteStateMachine::PostEvent(this: v4, _eventId: EventClass, _eventData: ev, curTime: GameMs);
  }
}


// ========================================================================
// ?ActivateExtendedClipModel@idAI2@@QAAPAVidClipModel@@W4aiExtendedClipModelStatus_t@@H@Z
// EA  : 0x829F3308
// RVA : 0x009F3308
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idClipModel *__fastcall idAI2::ActivateExtendedClipModel(
        idAI2 *this,
        aiExtendedClipModelStatus_t status,
        int frameCount)
{
  idClipModel *v5; // r4
  idClipModel *extendedClipModel; // r11
  idPhysics *Physics; // r3
  const idClipModel *v8; // r29
  idClipModel *v9; // r3
  idClipModel *v10; // r3

  if ( status != AIEXTENDEDCLIPMODELSTATUS_NONE )
  {
    extendedClipModel = this->aiVolatile.physics.extendedClipModel;
    this->aiVolatile.physics.extendedClipModelStatus = status;
    if ( extendedClipModel == nullptr )
    {
      Physics = idEntity::GetPhysics(this);
      v8 = Physics->GetClipModel(this: Physics, a2: 0);
      v9 = (idClipModel *)idMem::AllocWithLocation(
                            this: &mem,
                            location: "w:\\tech5\\shared\\idlib\\Heap.h(64) : tag",
                            size: 0xD8u,
                            tag: TAG_CLIPMODEL,
                            zeroBuffer: false,
                            align: ALIGN_16,
                            heap: HEAP_DEFAULTHEAP);
      if ( v9 != nullptr )
        v10 = idClipModel::idClipModel(this: v9, clip: &clientGame->clip, model: v8);
      else
        v10 = nullptr;
      this->aiVolatile.physics.extendedClipModel = v10;
      idClipModel::SetContents(this: v10, newContents: 131096);
      this->aiVolatile.physics.extendedClipModel->enabled = true;
      idClipModel::Link(this: this->aiVolatile.physics.extendedClipModel);
    }
    this->aiVolatile.physics.extendedClipModelEndTime = GetEndTimeByFrames(frameCount);
  }
  else
  {
    v5 = this->aiVolatile.physics.extendedClipModel;
    this->aiVolatile.physics.extendedClipModelStatus = AIEXTENDEDCLIPMODELSTATUS_NONE;
    this->aiVolatile.physics.extendedClipModelEndTime = 0;
    if ( v5 != nullptr )
    {
      idClip::DeleteClipModel(this: &clientGame->clip, clipModel: v5);
      this->aiVolatile.physics.extendedClipModel = nullptr;
    }
  }
  return this->aiVolatile.physics.extendedClipModel;
}


// ========================================================================
// __unwind$517518
// EA  : 0x829F3418
// RVA : 0x009F3418
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_517518()
{
  int v0; // r12

  operator delete(p: *(void **)(v0 - 128 + 80), tag: TAG_CLIPMODEL);
}


// ========================================================================
// ?AimDebug@idAI2@@QBAXPBDH@Z
// EA  : 0x829F3448
// RVA : 0x009F3448
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::AimDebug(idAI2 *this, const char *text, int level)
{
  idPhysics *Physics; // r29
  idRenderWorld *v6; // r28
  const idVec3 *v7; // r31
  float *v8; // r3
  double v9; // fp9
  double v10; // fp7
  float v11[4]; // [sp+60h] [-50h] BYREF
  char v12; // [sp+70h] [-40h] BYREF

  if ( ai_debugAim.valueInteger >= level && idAI2::GetDebugLevel() > 0 )
  {
    Physics = idEntity::GetPhysics(this);
    v6 = common->RW(this: common);
    v7 = this->GetEyeOffset(this: &v12, result: this);
    v8 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v9 = (float)(v7->z + v8[2]);
    v10 = (float)(v7->y + v8[1]);
    v11[0] = *v8 + v7->x;
    v11[2] = v9;
    v11[1] = v10;
    ((void (__fastcall *)(idRenderWorld *, const char *, float *, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, int, _DWORD, double))v6->DebugText)(
      a1: v6,
      a2: text,
      a3: v11,
      a4: v6->DebugText,
      a5: &idColor::colorOrange,
      a6: 1,
      a7: 1,
      a8: 0,
      a9: 0.25);
  }
}


// ========================================================================
// ?LookDebug@idAI2@@QBAXPBDHH@Z
// EA  : 0x829F3550
// RVA : 0x009F3550
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::LookDebug(idAI2 *this, const char *text, int level, int duration)
{
  idPhysics *Physics; // r26
  idRenderWorld *v9; // r25
  const idVec3 *v10; // r24
  float *v11; // r3
  double v12; // fp9
  double v13; // fp7
  int entityNumber; // r31
  int GameMs; // r3
  __int64 v16; // r10
  __int64 v17; // r8
  va *v18; // r3
  int v19; // [sp+8h] [-10C8h]
  int v20; // [sp+Ch] [-10C4h]
  int v21; // [sp+10h] [-10C0h]
  int v22; // [sp+14h] [-10BCh]
  int v23; // [sp+18h] [-10B8h]
  int v24; // [sp+1Ch] [-10B4h]
  float v25[4]; // [sp+60h] [-1070h] BYREF
  _BYTE v26[16]; // [sp+70h] [-1060h] BYREF
  va v27; // [sp+80h] [-1050h] BYREF

  if ( ai_debugLook.valueInteger >= level && idAI2::GetDebugLevel() > 0 )
  {
    Physics = idEntity::GetPhysics(this);
    v9 = common->RW(this: common);
    v10 = this->GetEyeOffset(this: v26, result: this);
    v11 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v12 = (float)(v10->z + v11[2]);
    v13 = (float)(v10->y + v11[1]);
    v25[0] = v10->x + *v11;
    v25[2] = v12;
    v25[1] = v13;
    ((void (__fastcall *)(idRenderWorld *, const char *, float *, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, int, _DWORD, double))v9->DebugText)(
      a1: v9,
      a2: text,
      a3: v25,
      a4: v9->DebugText,
      a5: &idColor::colorMagenta,
      a6: 1,
      a7: duration,
      a8: 0,
      a9: 0.25);
    if ( ai_debugLook.valueInteger > level )
    {
      entityNumber = this->entityNumber;
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      LODWORD(v16) = &unk_82270000;
      HIDWORD(v17) = text;
      v18 = va::va(
              this: &v27,
              fmt: "[%d] %d %s\n",
              a3: __SPAIR64__(GameMs, entityNumber),
              a4: v17,
              a5: v16,
              a6: v19,
              a7: v20,
              a8: v21,
              a9: v22,
              a10: v23,
              a11: v24);
      idLib::Printf(fmt: v18->buffer);
    }
  }
}


// ========================================================================
// ?GetDestination@idVisibilityObscurity@idAI2@@QBA?AVidVec3@@PBV2@W4obscurityTest_t@12@@Z
// EA  : 0x829F36B0
// RVA : 0x009F36B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2::idVisibilityObscurity *__fastcall idAI2::idVisibilityObscurity::GetDestination(
        idAI2::idVisibilityObscurity *this,
        idVec3 *result,
        idVec3 *ai,
        const idAI2::idVisibilityObscurity::obscurityTest_t obscurityTest)
{
  const idDeclAIBehavior *x_low; // r29
  double sidestepDistance; // fp30
  double diveDistance; // fp31
  float y; // r7
  float z; // r5
  idPhysics *v11; // r28
  const idVec3 *v12; // r3
  double v13; // fp31
  double v14; // fp30
  double v15; // fp29
  float *v16; // r3
  idWeapon *(__fastcall *v17)(struct idAI2 *); // r11
  double v18; // fp6
  double v19; // fp5
  idWeapon *v20; // r4
  aiItemSelect_t v21; // r11
  double v22; // fp11
  double v23; // fp10
  idPhysics *Physics; // r3
  idPresentable *z_low; // r11
  idPhysics *v26; // r29
  double v27; // fp31
  double v28; // fp29
  double v29; // fp30
  float *v30; // r3
  double v31; // fp9
  double v32; // fp7
  double v33; // fp6
  idPhysics *v34; // r3
  idPresentable *v35; // r11
  idPhysics *v36; // r29
  double v37; // fp31
  double v38; // fp29
  double v39; // fp30
  float *v40; // r3
  idPhysics *v41; // r3
  idPresentable *v42; // r11
  idPhysics *v43; // r29
  double v44; // fp30
  double v45; // fp29
  double v46; // fp31
  float *v47; // r3
  idPhysics *v48; // r3
  idPresentable *v49; // r11
  idPhysics *v50; // r29
  double v51; // fp13
  double v52; // fp30
  double v53; // fp12
  idPhysics *v54; // r3
  idPresentable *v55; // r11
  idPhysics *v56; // r29
  double v57; // fp30
  double v58; // fp29
  double v59; // fp31
  float *v60; // r3
  idPhysics *v61; // r3
  idPresentable *v62; // r11
  double v63; // fp31
  idVec3 v65; // [sp+50h] [-90h] BYREF
  char v66[16]; // [sp+60h] [-80h] BYREF
  idMat3 v67; // [sp+70h] [-70h] BYREF

  x_low = (const idDeclAIBehavior *)LODWORD(ai[950].x);
  sidestepDistance = x_low->dodging.sidestepDistance;
  diveDistance = x_low->dodging.diveDistance;
  y = vec3_origin.y;
  z = vec3_origin.z;
  *(float *)&this->clipQuery[0].index = vec3_origin.x;
  *((float *)&this->clipQuery[0].index + 1) = y;
  *(float *)&this->clipQuery[1].index = z;
  if ( obscurityTest != OBSCURITYTEST_MUZZLE_POS )
  {
    if ( obscurityTest == OBSCURITYTEST_HALF_HEIGHT_NEAR_LEFT )
    {
      Physics = idEntity::GetPhysics(this: (idEntity *)ai);
      z_low = (idPresentable *)LODWORD(ai[40].z);
      v26 = Physics;
      if ( z_low == nullptr )
      {
        idEntity::InitPresentableInternal(this: (idEntity *)ai);
        z_low = (idPresentable *)LODWORD(ai[40].z);
      }
      v27 = (float)(z_low->axis.mat[1].x * (float)sidestepDistance);
      v28 = (float)(z_low->axis.mat[1].y * (float)sidestepDistance);
      v29 = (float)(z_low->axis.mat[1].z * (float)sidestepDistance);
      v30 = (float *)v26->GetOrigin(this: v26, a2: 0);
      v31 = (float)(*v30 + (float)v27);
      v32 = (float)(v30[1] + (float)v28);
      v33 = (float)(v30[2] + (float)v29);
    }
    else
    {
      if ( obscurityTest == OBSCURITYTEST_HALF_HEIGHT_NEAR_RIGHT )
      {
        v34 = idEntity::GetPhysics(this: (idEntity *)ai);
        v35 = (idPresentable *)LODWORD(ai[40].z);
        v36 = v34;
        if ( v35 == nullptr )
        {
          idEntity::InitPresentableInternal(this: (idEntity *)ai);
          v35 = (idPresentable *)LODWORD(ai[40].z);
        }
        v37 = (float)(v35->axis.mat[1].x * (float)sidestepDistance);
        v38 = (float)(v35->axis.mat[1].y * (float)sidestepDistance);
        v39 = (float)(v35->axis.mat[1].z * (float)sidestepDistance);
        v40 = (float *)v36->GetOrigin(this: v36, a2: 0);
        v31 = (float)(*v40 - (float)v37);
        v33 = (float)(v40[2] - (float)v39);
      }
      else
      {
        switch ( obscurityTest )
        {
          case OBSCURITYTEST_HALF_HEIGHT_FAR_LEFT:
            v41 = idEntity::GetPhysics(this: (idEntity *)ai);
            v42 = (idPresentable *)LODWORD(ai[40].z);
            v43 = v41;
            if ( v42 == nullptr )
            {
              idEntity::InitPresentableInternal(this: (idEntity *)ai);
              v42 = (idPresentable *)LODWORD(ai[40].z);
            }
            v44 = (float)(v42->axis.mat[1].x * (float)diveDistance);
            v45 = (float)(v42->axis.mat[1].y * (float)diveDistance);
            v46 = (float)(v42->axis.mat[1].z * (float)diveDistance);
            v47 = (float *)v43->GetOrigin(this: v43, a2: 0);
            v31 = (float)((float)v44 + *v47);
            v32 = (float)(v47[1] + (float)v45);
            v33 = (float)(v47[2] + (float)v46);
            goto LABEL_33;
          case OBSCURITYTEST_HALF_HEIGHT_FAR_RIGHT:
            v48 = idEntity::GetPhysics(this: (idEntity *)ai);
            v49 = (idPresentable *)LODWORD(ai[40].z);
            v50 = v48;
            if ( v49 == nullptr )
            {
              idEntity::InitPresentableInternal(this: (idEntity *)ai);
              v49 = (idPresentable *)LODWORD(ai[40].z);
            }
            v51 = v49->axis.mat[1].y;
            v52 = (float)(v49->axis.mat[1].x * (float)diveDistance);
            v53 = v49->axis.mat[1].z;
            break;
          case OBSCURITYTEST_FULL_HEIGHT_FORWARD:
            v54 = idEntity::GetPhysics(this: (idEntity *)ai);
            v55 = (idPresentable *)LODWORD(ai[40].z);
            v56 = v54;
            if ( v55 == nullptr )
            {
              idEntity::InitPresentableInternal(this: (idEntity *)ai);
              v55 = (idPresentable *)LODWORD(ai[40].z);
            }
            v57 = (float)(v55->axis.mat[0].x * (float)diveDistance);
            v58 = (float)(v55->axis.mat[0].y * (float)diveDistance);
            v59 = (float)(v55->axis.mat[0].z * (float)diveDistance);
            v60 = (float *)v56->GetOrigin(this: v56, a2: 0);
            v31 = (float)(*v60 + (float)v57);
            v32 = (float)(v60[1] + (float)v58);
            v33 = (float)(v60[2] + (float)v59);
            goto LABEL_33;
          case OBSCURITYTEST_FULL_HEIGHT_BACK:
            v61 = idEntity::GetPhysics(this: (idEntity *)ai);
            v62 = (idPresentable *)LODWORD(ai[40].z);
            v50 = v61;
            if ( v62 == nullptr )
            {
              idEntity::InitPresentableInternal(this: (idEntity *)ai);
              v62 = (idPresentable *)LODWORD(ai[40].z);
            }
            v51 = v62->axis.mat[0].y;
            v52 = (float)((float)diveDistance * v62->axis.mat[0].x);
            v53 = v62->axis.mat[0].z;
            break;
          default:
            return this;
        }
        v38 = (float)((float)v51 * (float)diveDistance);
        v63 = (float)((float)v53 * (float)diveDistance);
        v40 = (float *)v50->GetOrigin(this: v50, a2: 0);
        v33 = (float)(v40[2] - (float)v63);
        v31 = (float)(*v40 - (float)v52);
      }
      v32 = (float)(v40[1] - (float)v38);
    }
LABEL_33:
    *(float *)&this->clipQuery[1].index = v33;
    *((float *)&this->clipQuery[0].index + 1) = v32;
    *(float *)&this->clipQuery[0].index = v31;
    return this;
  }
  v11 = idEntity::GetPhysics(this: (idEntity *)ai);
  v12 = (const idVec3 *)(*(int (__fastcall **)(char *, idVec3 *))(LODWORD(ai->x) + 672))(a1: v66, a2: ai);
  v13 = (float)(v12->x * (float)0.75);
  v14 = (float)(v12->y * (float)0.75);
  v15 = (float)(v12->z * (float)0.75);
  v16 = (float *)v11->GetOrigin(this: v11, a2: 0);
  v17 = *(idWeapon *(__fastcall **)(struct idAI2 *))(LODWORD(ai->x) + 704);
  v18 = (float)(v16[1] + (float)v14);
  v19 = (float)(v16[2] + (float)v15);
  *(float *)&this->clipQuery[0].index = (float)v13 + *v16;
  *((float *)&this->clipQuery[0].index + 1) = v18;
  *(float *)&this->clipQuery[1].index = v19;
  v20 = v17(this: (struct idAI2 *)ai);
  if ( v20 != nullptr )
  {
    v21 = x_low->itemSelect[1];
    if ( v21 != AIITEMSELECT_LARGE_RANGED_MUTANT
      && v21 != AIITEMSELECT_SCOOP_MUTANT
      && idAI2::GetMuzzlePoint(this: (idAI2 *)ai, weapon: v20, muzzlePos: &v65, muzzleAxis: &v67) )
    {
      v22 = (float)(x_low->muzzleTraceClearOffset + v65.z);
      v23 = v65.y;
      *(float *)&this->clipQuery[0].index = v65.x;
      *((float *)&this->clipQuery[0].index + 1) = v23;
      *(float *)&this->clipQuery[1].index = v22;
    }
  }
  return this;
}


// ========================================================================
// ?DebugDodge@@YA?AW4aiTransCode_t@idAIStateTransition@@PBVidAI2@@PADW412@@Z
// EA  : 0x829F3AB8
// RVA : 0x009F3AB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIStateTransition::aiTransCode_t __fastcall DebugDodge(
        const idAI2 *ai,
        char *txt,
        idAIStateTransition::aiTransCode_t trans)
{
  idPhysics *Physics; // r29
  idRenderWorld *v6; // r28
  idPhysics *v7; // r3
  idRenderWorld_vtbl *v8; // r29
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  int v10; // r3
  idPhysics *v12; // r29
  idRenderWorld *v13; // r28
  idPhysics *v14; // r3
  idRenderWorld_vtbl *v15; // r29
  const idVec3 *(__fastcall *v16)(idPhysics *, int); // ctr
  int v17; // r3

  if ( ai_debugLevel.valueInteger > 0 && ai_debugDodge.valueInteger > 0 )
  {
    if ( trans == 0 )
    {
      Physics = idEntity::GetPhysics(this: &ai->idActor);
      v6 = common->RW(this: common);
      v7 = Physics;
      GetOrigin = Physics->GetOrigin;
      v8 = v6->__vftable;
      v10 = (int)GetOrigin(this: v7, a2: 0);
      ((void (__fastcall *)(idRenderWorld *, char *, int, unsigned int, idColor *, int, int, _DWORD, double))v8->DebugText)(
        a1: v6,
        a2: txt,
        a3: v10,
        a4: 0x82000000,
        a5: &idColor::colorWhite,
        a6: 1,
        a7: 500,
        a8: 0,
        a9: 1.0);
      return trans;
    }
    v12 = idEntity::GetPhysics(this: &ai->idActor);
    v13 = common->RW(this: common);
    v14 = v12;
    v16 = v12->GetOrigin;
    v15 = v13->__vftable;
    v17 = (int)v16(this: v14, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, char *, int, unsigned int, idColor *, int, int, _DWORD, double))v15->DebugText)(
      a1: v13,
      a2: txt,
      a3: v17,
      a4: 0x82000000,
      a5: &idColor::colorYellow,
      a6: 1,
      a7: 1000,
      a8: 0,
      a9: 1.0);
    idLib::Printf(fmt: "Dodge: %s\n", txt);
  }
  return trans;
}


// ========================================================================
// ?GetEncounterGroup@idAI2@@QAAPAVidEncounterGroup@@XZ
// EA  : 0x829F3C20
// RVA : 0x009F3C20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idEncounterGroup *__fastcall idAI2::GetEncounterGroup(idAI2 *this)
{
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
    return nullptr;
  else
    return idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
}


// ========================================================================
// ?GetWalkState@idAI2@@UBA?AW4walkState_t@@XZ
// EA  : 0x829F3C50
// RVA : 0x009F3C50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

walkState_t __fastcall idAI2::GetWalkState(idAI2 *this)
{
  if ( ai_forceWalk.valueInteger <= 0 || ai_forceWalk.valueInteger >= 4 )
    return this->actorVolatile.walkState;
  else
    return ai_forceWalk.valueInteger;
}


// ========================================================================
// ?GetWalkModifier@idAI2@@UBA?AW4aiWalkModifier_t@@XZ
// EA  : 0x829F3C80
// RVA : 0x009F3C80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

aiWalkModifier_t __fastcall idAI2::GetWalkModifier(idAI2 *this)
{
  char *data; // r28
  int v3; // r30
  const char **v4; // r31

  data = ai_walkMod.valueString.data;
  if ( *ai_walkMod.valueString.data == 0 )
    return this->aiEditable.movement.walkMod;
  v3 = 0;
  v4 = aiWalkModifierNames;
  while ( idStr::Icmp(s1: data, s2: *v4) != 0 )
  {
    ++v4;
    ++v3;
    if ( (int)v4 >= (int)aiMovePushStatusNames )
      return this->aiEditable.movement.walkMod;
  }
  return v3;
}


// ========================================================================
// ?GetRunModifier@idAI2@@UBA?AW4aiWalkModifier_t@@XZ
// EA  : 0x829F3CF8
// RVA : 0x009F3CF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

aiWalkModifier_t __fastcall idAI2::GetRunModifier(idAI2 *this)
{
  char *data; // r28
  int v3; // r30
  const char **v4; // r31

  data = ai_runMod.valueString.data;
  if ( *ai_runMod.valueString.data == 0 )
    return this->aiEditable.movement.runMod;
  v3 = 0;
  v4 = aiWalkModifierNames;
  while ( idStr::Icmp(s1: data, s2: *v4) != 0 )
  {
    ++v4;
    ++v3;
    if ( (int)v4 >= (int)aiMovePushStatusNames )
      return this->aiEditable.movement.runMod;
  }
  return v3;
}


// ========================================================================
// ?SetSolid@idAI2@@QAAX_N@Z
// EA  : 0x829F3D70
// RVA : 0x009F3D70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetSolid(idAI2 *this, bool isSolid)
{
  idAI2::idAIVolatile *p_aiVolatile; // r31
  int v5; // r29
  int v6; // r3
  int v7; // r30
  bool v8; // zf

  p_aiVolatile = &this->aiVolatile;
  v5 = idContents::ToFlags(this: &this->aiConstants.physics.contents);
  v6 = this->aiVolatile.physics.object.GetNumClipModels(this: (struct idPhysics_AI *)&this->aiVolatile);
  v8 = !isSolid;
  v7 = v6;
  if ( v8 )
  {
    if ( v6 == 1 )
    {
      p_aiVolatile->physics.object.SetContents(this: &this->aiVolatile.physics.object, a2: 0, a3: 0);
    }
    else if ( v6 == 2 )
    {
      p_aiVolatile->physics.object.SetContents(this: &this->aiVolatile.physics.object, a2: 0, a3: 0);
      p_aiVolatile->physics.object.SetContents(this: &this->aiVolatile.physics.object, a2: 0, a3: 1);
    }
    p_aiVolatile->physics.object.UnlinkClip(this: &this->aiVolatile.physics.object);
    *((_BYTE *)&this->aiVolatile + 49705) &= ~0x80u;
  }
  else
  {
    p_aiVolatile->physics.object.EnableClip(this: &this->aiVolatile.physics.object);
    p_aiVolatile->physics.object.LinkClip(this: &this->aiVolatile.physics.object);
    if ( v7 == 1 )
    {
      p_aiVolatile->physics.object.SetContents(this: &this->aiVolatile.physics.object, a2: v5, a3: 0);
    }
    else if ( v7 == 2 )
    {
      p_aiVolatile->physics.object.SetContents(this: &this->aiVolatile.physics.object, a2: v5, a3: 0);
      p_aiVolatile->physics.object.SetContents(this: &this->aiVolatile.physics.object, a2: 8, a3: 1);
    }
    *((_BYTE *)&this->aiVolatile + 49705) |= 0x80u;
  }
}


// ========================================================================
// ?SetAimFocusEntity@idAI2@@QAAXPBVidEntity@@_NW4aimPoint_t@@H@Z
// EA  : 0x829F3EE8
// RVA : 0x009F3EE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetAimFocusEntity(
        idAI2 *this,
        const idEntity *ent,
        bool keepFocusInView,
        aimPoint_t aimPoint,
        int timeout)
{
  idFocusInfo::SetFocusEntity(
    this: this->aiVolatile.focus.foci.ptr,
    owner: this,
    _ent: ent,
    _keepFocusInView: keepFocusInView,
    _aimPoint: aimPoint,
    duration: timeout);
}


// ========================================================================
// ?SetExplicitAimFocusPoint@idAI2@@QAAXABVidVec3@@_NHW4aiFocus_t@@@Z
// EA  : 0x829F3F08
// RVA : 0x009F3F08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetExplicitAimFocusPoint(
        idAI2 *this,
        const idVec3 *point,
        bool keepFocusInView,
        int timeout,
        aiFocus_t focusType)
{
  idFocusInfo::SetExplicitFocusPoint(
    this: this->aiVolatile.focus.foci.ptr,
    owner: this,
    focusPoint: point,
    _keepFocusInView: keepFocusInView,
    duration: timeout,
    _focusType: focusType);
}


// ========================================================================
// ?SetAimFocusAimPoint@idAI2@@QAAXW4aimPoint_t@@@Z
// EA  : 0x829F3F28
// RVA : 0x009F3F28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetAimFocusAimPoint(idAI2 *this, aimPoint_t point)
{
  this->aiVolatile.focus.foci.ptr[0].aimPoint = point;
}


// ========================================================================
// ?ReloadWeapon@idAI2@@QAAXPAVidWeapon@@@Z
// EA  : 0x829F3F30
// RVA : 0x009F3F30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ReloadWeapon(idAI2 *this, idWeapon *weapon)
{
  idWeapon_vtbl *v4; // r29
  int v5; // r28
  idInventoryCollection *v6; // r3

  if ( weapon != nullptr && weapon->fireState == FIRESTATE_RELOADING )
  {
    v4 = weapon->__vftable;
    v5 = ((int (__fastcall *)(idAI2 *))this->GetFXMgrForAttachment)(a1: this);
    v6 = this->GetInventory_2(this);
    v4->Reload(this: weapon, a2: v6, a3: (idFXManager *)v5, a4: false, a5: false, a6: false);
    idLib::Warning(fmt: "idAI2::ReloadWeapon was called - make sure a frame command is not missing on the reload animation!");
  }
}


// ========================================================================
// ?GetRepullTriggerInterval@idAI2@@QBAXPBVidWeapon@@AAH1@Z
// EA  : 0x829F3FC0
// RVA : 0x009F3FC0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetRepullTriggerInterval(idAI2 *this, const idWeapon *weapon, int *min, int *max)
{
  char *v6; // r11

  v6 = (char *)weapon->decl + 24 * idAI2::GetModifiedSkill(this);
  *min = *((_DWORD *)v6 + 227);
  *max = *((_DWORD *)v6 + 228);
}


// ========================================================================
// ?GetBurstDuration@idAI2@@QBAXPBVidWeapon@@AAH1@Z
// EA  : 0x829F4010
// RVA : 0x009F4010
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetBurstDuration(idAI2 *this, const idWeapon *weapon, int *min, int *max)
{
  char *v6; // r11

  v6 = (char *)weapon->decl + 24 * idAI2::GetModifiedSkill(this);
  *min = *((_DWORD *)v6 + 229);
  *max = *((_DWORD *)v6 + 230);
}


// ========================================================================
// ?GetFireAtLastKnownDuration@idAI2@@QAAXPBVidWeapon@@AAH1@Z
// EA  : 0x829F4060
// RVA : 0x009F4060
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetFireAtLastKnownDuration(idAI2 *this, const idWeapon *weapon, int *min, int *max)
{
  aiSkill_t ModifiedSkill; // r3

  ModifiedSkill = idAI2::GetModifiedSkill(this);
  *min = skillSettings[ModifiedSkill].minFireAtLastKnownDuration;
  *max = skillSettings[ModifiedSkill].maxFireAtLastKnownDuration;
}


// ========================================================================
// ?GetEyeOffset@idAI2@@UBA?BVidVec3@@XZ
// EA  : 0x829F40C8
// RVA : 0x009F40C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::GetEyeOffset(idAI2 *this, idAnimatedEntity *result)
{
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  float v5; // r11
  idTreeAnimator *v6; // r31
  int lastBlendTime; // r27
  int v8; // r28
  const idIndex<short,enum invalidJointIndex_t> *v9; // r5
  const idIndex<short,enum invalidJointIndex_t> *eventNum; // r28
  double z; // fp5
  double v13; // fp0
  float x; // r9
  float y; // r8
  idVec3 v16; // [sp+50h] [-B0h] BYREF
  idVec3 v17; // [sp+60h] [-A0h] BYREF
  idMat3 v18; // [sp+70h] [-90h] BYREF
  idMat3 v19[2]; // [sp+A0h] [-60h] BYREF

  TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this: result);
  v5 = *(float *)&result->presentable;
  v6 = TreeAnimatorFromPresentable;
  if ( v5 == 0.0 )
  {
    idEntity::InitPresentableInternal(this: result);
    v5 = *(float *)&result->presentable;
  }
  idPresentable::UpdateModelTransform(this: (idPresentable *)LODWORD(v5));
  if ( v6 != nullptr
    && (lastBlendTime = v6->lastBlendTime,
        (v8 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - lastBlendTime) <= 2
                                                                                           * gameLocal->GetGameMsPerFrame(
                                                                                               this: gameLocal,
                                                                                               a2: GAMETIME_SCALED))
    && (v9 = (const idIndex<short,enum invalidJointIndex_t> *)*(unsigned __int16 *)&result[11].animEventHandler.trackedEvents.staticList[21].initCounter,
        eventNum = (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)result[11].animEventHandler.trackedEvents.staticList[21].eventNum,
        (__int16)v9 >= 0)
    && (__int16)eventNum >= 0 )
  {
    idTreeAnimator::GetWorldSpaceJointTransform(this: v6, pose: DRIVER_MODEL, jointIndex: v9, origin: &v17, axis: &v18);
    idTreeAnimator::GetWorldSpaceJointTransform(
      this: v6,
      pose: DRIVER_MODEL,
      jointIndex: eventNum,
      origin: &v16,
      axis: v19);
    z = v6->g.origin.z;
    v13 = (float)((float)((float)((float)(v17.y - v16.y) * (float)0.5) + v16.y) - v6->g.origin.y);
    v16.x = (float)((float)((float)(v17.x - v16.x) * (float)0.5) + v16.x) - v6->g.origin.x;
    v16.y = v13;
    x = v16.x;
    y = v16.y;
    v16.z = (float)((float)((float)(v17.z - v16.z) * (float)0.5) + v16.z) - (float)z;
    this->listeningToList = (idList<idEventReceiver *,5> *)LODWORD(v16.z);
    *(float *)&this->listenerList = y;
    *(float *)&this->__vftable = x;
    return this;
  }
  else
  {
    idActor::GetEyeOffset(this, (const idVec3 *)result);
    return this;
  }
}


// ========================================================================
// ?OkToFocus@@YA_NABVidVec3@@00@Z
// EA  : 0x829F4260
// RVA : 0x009F4260
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall OkToFocus(const idVec3 *to, const idVec3 *from, const idVec3 *actualPos)
{
  double v3; // fp6
  double v4; // fp4
  double v7; // fp7
  double v8; // fp2
  double v9; // fp3
  double v10; // fp2
  double v11; // fp1
  double v12; // fp7
  double v13; // fp8
  double v14; // fp6
  double v16; // fp4
  double v17; // fp2
  double v19; // fp10
  double v21; // fp5
  double v22; // fp1
  double v23; // fp10

  v3 = (float)(to->y - from->y);
  v4 = (float)(to->z - from->z);
  _FP7 = (float)((float)((float)((float)v4 * (float)v4)
                       + (float)((float)((float)v3 * (float)v3)
                               + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
               - idMath::FLT_SMALLEST_NON_DENORMAL);
  __asm { fsel      f2, f7, f1, f13 }
  v7 = __frsqrte(_FP2);
  v8 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v7
                                                                                     * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                                             * (float)0.5))
                                                                             * (float)v7)
                                                                     - (float)1.5)
                                                     * (float)v7)
                                             * (float)((float)((float)((float)v4 * (float)v4)
                                                             + (float)((float)((float)v3 * (float)v3)
                                                                     + (float)((float)(to->x - from->x)
                                                                             * (float)(to->x - from->x))))
                                                     * (float)0.5))
                                     * (float)((float)-(float)((float)((float)((float)v7
                                                                             * (float)((float)((float)((float)v4 * (float)v4)
                                                                                             + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                                     * (float)0.5))
                                                                     * (float)v7)
                                                             - (float)1.5)
                                             * (float)v7))
                             - (float)1.5)
             * (float)((float)-(float)((float)((float)((float)v7
                                                     * (float)((float)((float)((float)v4 * (float)v4)
                                                                     + (float)((float)((float)v3 * (float)v3)
                                                                             + (float)((float)(to->x - from->x)
                                                                                     * (float)(to->x - from->x))))
                                                             * (float)0.5))
                                             * (float)v7)
                                     - (float)1.5)
                     * (float)v7));
  v9 = (float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v7 * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5)) * (float)v7) - (float)1.5)
                                                                                     * (float)v7)
                                                                             * (float)((float)((float)((float)v4 * (float)v4)
                                                                                             + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                                     * (float)0.5))
                                                                     * (float)((float)-(float)((float)((float)((float)v7 * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5)) * (float)v7)
                                                                                             - (float)1.5)
                                                                             * (float)v7))
                                                             - (float)1.5)
                                             * (float)((float)-(float)((float)((float)((float)v7
                                                                                     * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                                             * (float)0.5))
                                                                             * (float)v7)
                                                                     - (float)1.5)
                                                     * (float)v7))
                                     * (float)((float)((float)((float)v4 * (float)v4)
                                                     + (float)((float)((float)v3 * (float)v3)
                                                             + (float)((float)(to->x - from->x)
                                                                     * (float)(to->x - from->x))))
                                             * (float)0.5))
                             * (float)v8)
                     - (float)1.5);
  v10 = (float)((float)v9
              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v7
                                                                                              * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                      * (float)v7)
                                                                              - (float)1.5)
                                                              * (float)v7)
                                                      * (float)((float)((float)((float)v4 * (float)v4)
                                                                      + (float)((float)((float)v3 * (float)v3)
                                                                              + (float)((float)(to->x - from->x)
                                                                                      * (float)(to->x - from->x))))
                                                              * (float)0.5))
                                              * (float)((float)-(float)((float)((float)((float)v7
                                                                                      * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                                              * (float)0.5))
                                                                              * (float)v7)
                                                                      - (float)1.5)
                                                      * (float)v7))
                                      - (float)1.5)
                      * (float)((float)-(float)((float)((float)((float)v7
                                                              * (float)((float)((float)((float)v4 * (float)v4)
                                                                              + (float)((float)((float)v3 * (float)v3)
                                                                                      + (float)((float)(to->x - from->x)
                                                                                              * (float)(to->x - from->x))))
                                                                      * (float)0.5))
                                                      * (float)v7)
                                              - (float)1.5)
                              * (float)v7)));
  v11 = (float)((float)((float)v9
                      * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v7 * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                              * (float)v7)
                                                                                      - (float)1.5)
                                                                      * (float)v7)
                                                              * (float)((float)((float)((float)v4 * (float)v4)
                                                                              + (float)((float)((float)v3 * (float)v3)
                                                                                      + (float)((float)(to->x - from->x)
                                                                                              * (float)(to->x - from->x))))
                                                                      * (float)0.5))
                                                      * (float)((float)-(float)((float)((float)((float)v7
                                                                                              * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                      * (float)v7)
                                                                              - (float)1.5)
                                                              * (float)v7))
                                              - (float)1.5)
                              * (float)((float)-(float)((float)((float)((float)v7
                                                                      * (float)((float)((float)((float)v4 * (float)v4)
                                                                                      + (float)((float)((float)v3 * (float)v3)
                                                                                              + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                              * (float)0.5))
                                                              * (float)v7)
                                                      - (float)1.5)
                                      * (float)v7)))
              * (float)((float)((float)v4 * (float)v4)
                      + (float)((float)((float)v3 * (float)v3)
                              + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))));
  v13 = (float)((float)(to->x - from->x)
              * (float)((float)v9
                      * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v7 * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                              * (float)v7)
                                                                                      - (float)1.5)
                                                                      * (float)v7)
                                                              * (float)((float)((float)((float)v4 * (float)v4)
                                                                              + (float)((float)((float)v3 * (float)v3)
                                                                                      + (float)((float)(to->x - from->x)
                                                                                              * (float)(to->x - from->x))))
                                                                      * (float)0.5))
                                                      * (float)((float)-(float)((float)((float)((float)v7
                                                                                              * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                      * (float)v7)
                                                                              - (float)1.5)
                                                              * (float)v7))
                                              - (float)1.5)
                              * (float)((float)-(float)((float)((float)((float)v7
                                                                      * (float)((float)((float)((float)v4 * (float)v4)
                                                                                      + (float)((float)((float)v3 * (float)v3)
                                                                                              + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                              * (float)0.5))
                                                              * (float)v7)
                                                      - (float)1.5)
                                      * (float)v7))));
  v12 = (float)((float)v3
              * (float)((float)v9
                      * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v7 * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                              * (float)v7)
                                                                                      - (float)1.5)
                                                                      * (float)v7)
                                                              * (float)((float)((float)((float)v4 * (float)v4)
                                                                              + (float)((float)((float)v3 * (float)v3)
                                                                                      + (float)((float)(to->x - from->x)
                                                                                              * (float)(to->x - from->x))))
                                                                      * (float)0.5))
                                                      * (float)((float)-(float)((float)((float)((float)v7
                                                                                              * (float)((float)((float)((float)v4 * (float)v4) + (float)((float)((float)v3 * (float)v3) + (float)((float)(to->x - from->x) * (float)(to->x - from->x)))) * (float)0.5))
                                                                                      * (float)v7)
                                                                              - (float)1.5)
                                                              * (float)v7))
                                              - (float)1.5)
                              * (float)((float)-(float)((float)((float)((float)v7
                                                                      * (float)((float)((float)((float)v4 * (float)v4)
                                                                                      + (float)((float)((float)v3 * (float)v3)
                                                                                              + (float)((float)(to->x - from->x) * (float)(to->x - from->x))))
                                                                              * (float)0.5))
                                                              * (float)v7)
                                                      - (float)1.5)
                                      * (float)v7))));
  v14 = (float)((float)(to->z - from->z) * (float)v10);
  if ( v11 <= 16.0 )
    return false;
  v16 = (float)(actualPos->y - from->y);
  v17 = (float)(actualPos->z - from->z);
  _FP1 = (float)((float)((float)((float)(actualPos->x - from->x) * (float)(actualPos->x - from->x))
                       + (float)((float)((float)v17 * (float)v17) + (float)((float)v16 * (float)v16)))
               - idMath::FLT_SMALLEST_NON_DENORMAL);
  v19 = (float)((float)((float)((float)(actualPos->x - from->x) * (float)(actualPos->x - from->x))
                      + (float)((float)((float)v17 * (float)v17) + (float)((float)v16 * (float)v16)))
              * (float)0.5);
  __asm { fsel      f9, f1, f3, f13 }
  v21 = __frsqrte(_FP9);
  v22 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21 * (float)v19)
                                                                              * (float)v21)
                                                                      - (float)1.5)
                                                      * (float)v21)
                                              * (float)v19)
                                      * (float)((float)-(float)((float)((float)((float)v21 * (float)v19) * (float)v21)
                                                              - (float)1.5)
                                              * (float)v21))
                              - (float)1.5)
              * (float)((float)-(float)((float)((float)((float)v21 * (float)v19) * (float)v21) - (float)1.5) * (float)v21));
  v23 = (float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21 * (float)v19) * (float)v21) - (float)1.5)
                                                                                      * (float)v21)
                                                                              * (float)v19)
                                                                      * (float)((float)-(float)((float)((float)((float)v21 * (float)v19) * (float)v21)
                                                                                              - (float)1.5)
                                                                              * (float)v21))
                                                              - (float)1.5)
                                              * (float)((float)-(float)((float)((float)((float)v21 * (float)v19)
                                                                              * (float)v21)
                                                                      - (float)1.5)
                                                      * (float)v21))
                                      * (float)v19)
                              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21 * (float)v19) * (float)v21)
                                                                                              - (float)1.5)
                                                                              * (float)v21)
                                                                      * (float)v19)
                                                              * (float)((float)-(float)((float)((float)((float)v21 * (float)v19)
                                                                                              * (float)v21)
                                                                                      - (float)1.5)
                                                                      * (float)v21))
                                                      - (float)1.5)
                                      * (float)((float)-(float)((float)((float)((float)v21 * (float)v19) * (float)v21)
                                                              - (float)1.5)
                                              * (float)v21)))
                      - (float)1.5);
  return (float)((float)((float)((float)(actualPos->z - from->z) * (float)((float)v23 * (float)v22)) * (float)v14)
               + (float)((float)((float)((float)(actualPos->y - from->y) * (float)((float)v23 * (float)v22)) * (float)v12)
                       + (float)((float)((float)(actualPos->x - from->x) * (float)((float)v23 * (float)v22)) * (float)v13))) > -0.000000050005699;
}


// ========================================================================
// ?SetEnableAutoFocus@idAI2@@QAAX_N@Z
// EA  : 0x829F43A0
// RVA : 0x009F43A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetEnableAutoFocus(idAI2 *this, bool enable)
{
  if ( enable && !this->aiVolatile.focus.enableAutoFocus )
    this->aiVolatile.focus.foci.ptr[1].focusTimeout = idGameTimeManager::GetGameMs(
                                                        this: &clientGame->gameTimeManager,
                                                        type: GAMETIME_SCALED);
  this->aiVolatile.focus.enableAutoFocus = enable;
}


// ========================================================================
// ?DistanceExponentToDistance@idCheckSurroundingsState@@ABAMH@Z
// EA  : 0x829F4410
// RVA : 0x009F4410
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idCheckSurroundingsState::DistanceExponentToDistance(
        idCheckSurroundingsState *this,
        unsigned int distanceExponent,
        double a3,
        double a4,
        long double a5)
{
  long double v5; // fp2
  long double v6; // fp2
  double v7; // fp1

  *(double *)&v5 = __fsqrts(2.0);
  *((double *)&v5 + 1) = (float)__SPAIR64__(0x82000000, distanceExponent);
  v6 = pow(x: v5, y: a5);
  v7 = (float)((float)((float)((float)*(double *)&v6 * (float)10.0) * UNITS_PER_INCH_2) * (float)12.0);
  return *((float *)&v7 + 1);
}


// ========================================================================
// ?FindNetDirectionInterest@idCheckSurroundingsState@@ABAMPBVidAI2@@ABVidVec3@@@Z
// EA  : 0x829F4478
// RVA : 0x009F4478
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idCheckSurroundingsState::FindNetDirectionInterest(
        idCheckSurroundingsState *this,
        const idAI2 *ai,
        const idVec3 *testDirection)
{
  double v5; // fp30
  idPhysics *Physics; // r3
  double v7; // fp29
  float *v8; // r3
  float *v9; // r10
  int v10; // ctr
  float *p_y; // r11
  double v12; // fp0
  double v15; // fp0
  double v18; // fp0
  double v21; // fp0
  double v24; // fp1
  char v26; // [sp+50h] [-40h] BYREF

  v5 = 0.0;
  Physics = idEntity::GetPhysics(this: &ai->idActor);
  v7 = VELOCITY_SCALE;
  v8 = (float *)Physics->GetLinearVelocity(this: (idPhysics *)&v26, result: (idVec3 *)Physics, a3: 0);
  v9 = &this->lookInterest.ptr[1];
  v10 = 2;
  p_y = &gameLocal->directionVector[0].y;
  do
  {
    v12 = (float)((float)(testDirection->z * p_y[1])
                + (float)((float)(*p_y * testDirection->y) + (float)(testDirection->x * *(p_y - 1))));
    if ( v12 > 0.0 )
    {
      _FP1 = -(float)((float)v12 * (float)v12);
      __asm { fsel      f13, f1, f31, f3 }
      v5 = (float)((float)((float)((float)((float)((float)(v8[2] * (float)v7) * p_y[1])
                                         + (float)((float)(*p_y * (float)(v8[1] * (float)v7))
                                                 + (float)(*(p_y - 1) * (float)(*v8 * (float)v7))))
                                 + *(v9 - 1))
                         * (float)_FP13)
                 + (float)v5);
    }
    v15 = (float)((float)(testDirection->z * p_y[4])
                + (float)((float)(testDirection->x * p_y[2]) + (float)(testDirection->y * p_y[3])));
    if ( v15 > 0.0 )
    {
      _FP1 = -(float)((float)v15 * (float)v15);
      __asm { fsel      f13, f1, f31, f3 }
      v5 = (float)((float)((float)((float)((float)(p_y[3] * (float)(v8[1] * (float)v7))
                                         + (float)((float)(p_y[2] * (float)(*v8 * (float)v7))
                                                 + (float)(p_y[4] * (float)(v8[2] * (float)v7))))
                                 + *v9)
                         * (float)_FP13)
                 + (float)v5);
    }
    v18 = (float)((float)(testDirection->z * p_y[7])
                + (float)((float)(testDirection->x * p_y[5]) + (float)(testDirection->y * p_y[6])));
    if ( v18 > 0.0 )
    {
      _FP1 = -(float)((float)v18 * (float)v18);
      __asm { fsel      f13, f1, f31, f3 }
      v5 = (float)((float)((float)((float)((float)(p_y[6] * (float)(v8[1] * (float)v7))
                                         + (float)((float)(p_y[5] * (float)(*v8 * (float)v7))
                                                 + (float)(p_y[7] * (float)(v8[2] * (float)v7))))
                                 + v9[1])
                         * (float)_FP13)
                 + (float)v5);
    }
    v21 = (float)((float)(testDirection->z * p_y[10])
                + (float)((float)(testDirection->x * p_y[8]) + (float)(testDirection->y * p_y[9])));
    if ( v21 > 0.0 )
    {
      _FP1 = -(float)((float)v21 * (float)v21);
      __asm { fsel      f13, f1, f31, f3 }
      v5 = (float)((float)((float)((float)((float)(p_y[9] * (float)(v8[1] * (float)v7))
                                         + (float)((float)(p_y[8] * (float)(*v8 * (float)v7))
                                                 + (float)(p_y[10] * (float)(v8[2] * (float)v7))))
                                 + v9[2])
                         * (float)_FP13)
                 + (float)v5);
    }
    v9 += 4;
    p_y += 12;
    --v10;
  }
  while ( v10 != 0 );
  v24 = v5;
  return *((float *)&v24 + 1);
}


// ========================================================================
// ?GetLookedAtElapsedTime@idCheckSurroundingsState@@QBAHPBVidEntity@@@Z
// EA  : 0x829F4660
// RVA : 0x009F4660
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idCheckSurroundingsState::GetLookedAtElapsedTime(idCheckSurroundingsState *this, const idEntity *entity)
{
  int v3; // r31
  idArray<idSpawnId,4> *i; // r11
  int result; // r3
  idSpawnId v6; // [sp+50h] [-20h] BYREF

  idSpawnId::idSpawnId(this: &v6, ent: entity);
  v3 = 0;
  for ( i = &this->lookedAtEntitySpawnIDs; i->ptr[0].value != v6.value; i = (idArray<idSpawnId,4> *)((char *)i + 4) )
  {
    if ( ++v3 >= 4 )
      return 10000;
  }
  result = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - this->lookedAtEntitiesTime.ptr[v3];
  if ( result <= 10000 )
    return result;
  return 10000;
}


// ========================================================================
// ?SetLastLookedAtTime@idCheckSurroundingsState@@QAAXPBVidEntity@@H@Z
// EA  : 0x829F4700
// RVA : 0x009F4700
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idCheckSurroundingsState::SetLastLookedAtTime(
        idCheckSurroundingsState *this,
        const idEntity *entity,
        int setTime)
{
  int v5; // r10
  idArray<idSpawnId,4> *p_lookedAtEntitySpawnIDs; // r11
  int v7; // r7
  int v8; // r8
  int v9; // r10
  int *v10; // r9
  idSpawnId v11; // [sp+50h] [-20h] BYREF

  idSpawnId::idSpawnId(this: &v11, ent: entity);
  v5 = 0;
  p_lookedAtEntitySpawnIDs = &this->lookedAtEntitySpawnIDs;
  do
  {
    if ( p_lookedAtEntitySpawnIDs->ptr[0].value == v11.value )
    {
      this->lookedAtEntitiesTime.ptr[v5] = setTime;
      return;
    }
    ++v5;
    p_lookedAtEntitySpawnIDs = (idArray<idSpawnId,4> *)((char *)p_lookedAtEntitySpawnIDs + 4);
  }
  while ( v5 < 4 );
  v7 = 0;
  v8 = this->lookedAtEntitiesTime.ptr[0];
  if ( this->lookedAtEntitySpawnIDs.ptr[0].value != 0x1FFF )
  {
    v9 = 1;
    v10 = &this->lookedAtEntitiesTime.ptr[1];
    while ( *(v10 - 4) != 0x1FFF )
    {
      if ( *v10 < v8 )
      {
        v7 = v9;
        v8 = *v10;
      }
      ++v9;
      ++v10;
      if ( v9 >= 4 )
        goto LABEL_13;
    }
    v7 = v9;
  }
LABEL_13:
  this->lookedAtEntitySpawnIDs.ptr[v7] = v11;
  this->lookedAtEntitiesTime.ptr[v7] = setTime;
}


// ========================================================================
// `idAI2::FindClosestFocus'::`2'::idLookDebug::~idLookDebug
// EA  : 0x829F47E8
// RVA : 0x009F47E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall _idAI2::FindClosestFocus_::_2_::idLookDebug::~idLookDebug(int a1)
{
  const char *v1; // r4

  v1 = *(const char **)(a1 + 4);
  if ( v1 != nullptr )
    idAI2::LookDebug(this: *(idAI2 **)a1, text: v1, level: 1, duration: *(_DWORD *)(a1 + 8));
}


// ========================================================================
// ?SetSpeakingVO@idAI2@@QAAXXZ
// EA  : 0x829F4808
// RVA : 0x009F4808
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetSpeakingVO(idAI2 *this)
{
  if ( this->actorConstants.actorClass != ACTORCLASS_MUTANT )
  {
    if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x40) != 0 )
      idFaceMgr::SetEnableMoodAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x20) != 0 )
      idFaceMgr::SetEnableLipSyncAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x10) != 0 )
      idFaceMgr::SetEnableGestureAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 0x10) != 0 )
      idFaceMgr::SetEnableEyeTracking(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 4) != 0 )
      idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 2) != 0 )
      idFaceMgr::SetEnableLidDeformation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
  }
}


// ========================================================================
// ?SetActionScript@idAI2@@QAAXABV?$idList@VidScriptAction@@$04@@PAVidEntity@@1@Z
// EA  : 0x829F4910
// RVA : 0x009F4910
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetActionScript(
        idAI2 *this,
        const idList<idScriptAction,5> *script,
        idEntity *scriptExecutor,
        idEntity *activator)
{
  if ( !this->IsDead(this) )
    idComponentActionScript::SetActionScript(
      this: &this->actionScript,
      entity: this,
      script,
      scriptExecutor,
      activator,
      tool: false);
}


// ========================================================================
// ?EndActionScript@idAI2@@QAAXXZ
// EA  : 0x829F4970
// RVA : 0x009F4970
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::EndActionScript(idAI2 *this)
{
  idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
}


// ========================================================================
// ?OnActionScriptFinished@idAI2@@QAAXH@Z
// EA  : 0x829F4980
// RVA : 0x009F4980
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnActionScriptFinished(idAI2 *this, const int curTime)
{
  *((_BYTE *)&this->aiEditable.death + 84) = *((_BYTE *)&this->aiEditable.death + 84) & 0x7F
                                           | *((_BYTE *)&this->aiEditable.behaviors.decl->damageBehaviors + 84) & 0x80;
}


// ========================================================================
// ?SetActionScriptFlag@idAI2@@QAAXH_N@Z
// EA  : 0x829F4998
// RVA : 0x009F4998
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetActionScriptFlag(idAI2 *this, const int flags, bool setFlag)
{
  int v3; // r10
  int v4; // r9

  v3 = this->aiVolatile.script.flags;
  v4 = v3 | flags;
  if ( !setFlag )
    v4 = v3 & ~flags;
  this->aiVolatile.script.flags = v4;
}


// ========================================================================
// ?ActionScriptFlagIsSet@idAI2@@QBA_NH@Z
// EA  : 0x829F49C0
// RVA : 0x009F49C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ActionScriptFlagIsSet(idAI2 *this, const int flags)
{
  return idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
      && (this->aiVolatile.script.flags & flags) != 0;
}


// ========================================================================
// ?GetActionFSM@idAI2@@QAAPAVidAIActionFSM@@XZ
// EA  : 0x829F4A30
// RVA : 0x009F4A30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idLegsFSM *__fastcall idAI2::GetActionFSM(idAI2 *this)
{
  return &this->aiVolatile.fsms.actionManager.legsFSM;
}


// ========================================================================
// ?GetCurrentAction@idAI2@@QBAPAVidAIAction@@XZ
// EA  : 0x829F4A38
// RVA : 0x009F4A38
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIAction *__fastcall idAI2::GetCurrentAction(idAI2 *this)
{
  idLegsFSM *p_legsFSM; // r3

  p_legsFSM = &this->aiVolatile.fsms.actionManager.legsFSM;
  if ( p_legsFSM != nullptr )
    return idAIActionFSM::GetCurrentAction(this: p_legsFSM);
  else
    return nullptr;
}


// ========================================================================
// ?GetActionStatus@idAI2@@QBA?AW4fsmStatus_t@idFiniteStateMachine@@XZ
// EA  : 0x829F4A50
// RVA : 0x009F4A50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idFiniteStateMachine::fsmStatus_t __fastcall idAI2::GetActionStatus(idAI2 *this)
{
  return idFiniteStateMachine::GetStatus(this: &this->aiVolatile.fsms.actionManager.legsFSM);
}


// ========================================================================
// ?IsIdling@idAI2@@QBA_NXZ
// EA  : 0x829F4A58
// RVA : 0x009F4A58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsIdling(idAI2 *this)
{
  idLegsFSM *p_legsFSM; // r3
  idAIAction *CurrentAction; // r3
  char IsTypeOf; // r3
  unsigned __int8 v4; // r11

  p_legsFSM = &this->aiVolatile.fsms.actionManager.legsFSM;
  if ( p_legsFSM == nullptr )
    return 0;
  CurrentAction = idAIActionFSM::GetCurrentAction(this: p_legsFSM);
  if ( CurrentAction == nullptr )
    return 0;
  IsTypeOf = idAction_Idle::IsTypeOf(c: CurrentAction);
  v4 = 1;
  if ( IsTypeOf == 0 )
    return 0;
  return v4;
}


// ========================================================================
// ?SetAlertCycle@idAI2@@QAAXW4alertCycle_t@@@Z
// EA  : 0x829F4AA8
// RVA : 0x009F4AA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetAlertCycle(idAI2 *this, alertCycle_t ac)
{
  alertCycle_t v3; // r30
  alertCycle_t alertCycle; // r11
  alertCycle_t previousAlertCycle; // r10
  aiSubWeb_t v6; // r4
  alertCycle_t highestAlertCycle; // r11

  if ( !this->aiEditable.spawnSettings.alwaysInCombat
    || ac == ALERTCYCLE_DYING
    || (v3 = ALERTCYCLE_COMBAT, ac == ALERTCYCLE_DEAD) )
  {
    v3 = ac;
  }
  alertCycle = this->aiVolatile.fsms.alertCycle;
  if ( alertCycle != v3 )
    this->aiVolatile.fsms.previousAlertCycle = alertCycle;
  this->aiVolatile.fsms.alertCycle = v3;
  if ( v3 == ALERTCYCLE_COMBAT )
  {
    previousAlertCycle = this->aiVolatile.fsms.previousAlertCycle;
    this->aiVolatile.memory.highestAlertCycle = ALERTCYCLE_COMBAT;
    if ( previousAlertCycle != ALERTCYCLE_COMBAT )
      this->aiVolatile.memory.lastSurprisedTime = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
  }
  else if ( v3 == ALERTCYCLE_SEARCH )
  {
    highestAlertCycle = this->aiVolatile.memory.highestAlertCycle;
    if ( highestAlertCycle <= ALERTCYCLE_SEARCH )
      highestAlertCycle = ALERTCYCLE_SEARCH;
    this->aiVolatile.memory.highestAlertCycle = highestAlertCycle;
  }
  else if ( v3 >= ALERTCYCLE_MAX )
  {
    v6 = AISUBWEB_RELAXED;
    goto LABEL_11;
  }
  v6 = alertCycleToSubWebMap[v3];
LABEL_11:
  idAI2::SetSubWeb(this, sw: v6);
}


// ========================================================================
// ??0idAIFSMCallback@@QAA@XZ
// EA  : 0x829F4BC8
// RVA : 0x009F4BC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIFSMCallback *__fastcall idAIFSMCallback::idAIFSMCallback(idAIFSMCallback *this)
{
  this->__vftable = (idAIFSMCallback_vtbl *)&idAIFSMCallback::`vftable';
  idFSMLog::idFSMLog(this: &this->log, maxSize: 64);
  return this;
}


// ========================================================================
// __unwind$518995
// EA  : 0x829F4C1C
// RVA : 0x009F4C1C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_518995()
{
  int v0; // r12

  idFSMCallback::~idFSMCallback(this: *(idFSMCallback **)(v0 - 112 + 132));
}


// ========================================================================
// ?OnTransition@idAIFSMCallback@@UAAXPBVidFiniteStateMachine@@PBVidTypeInfo@@11H@Z
// EA  : 0x829F4C48
// RVA : 0x009F4C48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIFSMCallback::OnTransition(
        idAIFSMCallback *this,
        const idFiniteStateMachine *fsm,
        const idTypeInfo *fromStateType,
        const idTypeInfo *toStateType,
        const idTypeInfo *transType,
        int transCode)
{
  idFSMLogEntry *v11; // r3
  idFSMLogEntry *v12; // r26

  v11 = idFSMLog::Alloc(this: &this->log);
  v11->type = LOGENTRY_TRANSITION;
  v12 = v11;
  v11->time = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v12->fsm = fsm;
  v12->curStateType = fromStateType;
  v12->nextStateType = toStateType;
  v12->transitionType = transType;
  v12->transCode = transCode;
}


// ========================================================================
// ?OnRestart@idAIFSMCallback@@UAAXPBVidFiniteStateMachine@@PBVidTypeInfo@@@Z
// EA  : 0x829F4CB8
// RVA : 0x009F4CB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIFSMCallback::OnRestart(
        idAIFSMCallback *this,
        const idFiniteStateMachine *fsm,
        const idTypeInfo *curStateType)
{
  idFSMLogEntry *v4; // r3
  idFSMLogEntry *v5; // r30

  v4 = idFSMLog::Alloc(this: &this->log);
  v4->type = LOGENTRY_RESTART;
  v5 = v4;
  v4->time = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v5->fsm = fsm;
  v5->curStateType = nullptr;
  v5->nextStateType = nullptr;
  v5->transitionType = nullptr;
  v5->transCode = 0;
}


// ========================================================================
// ?OnError@idAIFSMCallback@@UAAXPBVidFiniteStateMachine@@PBVidTypeInfo@@1H@Z
// EA  : 0x829F4D30
// RVA : 0x009F4D30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIFSMCallback::OnError(
        idAIFSMCallback *this,
        const idFiniteStateMachine *fsm,
        const idTypeInfo *curStateType,
        const idTypeInfo *transType,
        int transCode)
{
  idFSMLogEntry *v8; // r3
  idFSMLogEntry *v9; // r28

  v8 = idFSMLog::Alloc(this: &this->log);
  v8->type = LOGENTRY_ERROR;
  v9 = v8;
  v8->time = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v9->fsm = fsm;
  v9->curStateType = nullptr;
  v9->nextStateType = nullptr;
  v9->transitionType = transType;
  v9->transCode = transCode;
}


// ========================================================================
// ?SetIdealAimFocusPoint@idAI2@@QAAXABVidVec3@@HW4aiFocus_t@@@Z
// EA  : 0x829F4D98
// RVA : 0x009F4D98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetIdealAimFocusPoint(idAI2 *this, const idVec3 *point, int timeout, aiFocus_t focusType)
{
  idFocusInfo::SetExplicitFocusPoint(
    this: this->aiVolatile.focus.foci.ptr,
    owner: this,
    focusPoint: point,
    _keepFocusInView: false,
    duration: timeout,
    _focusType: focusType);
}


// ========================================================================
// ?SetIdealLookFocusPoint@idAI2@@QAAXABVidVec3@@HW4aiFocus_t@@@Z
// EA  : 0x829F4DB8
// RVA : 0x009F4DB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetIdealLookFocusPoint(idAI2 *this, const idVec3 *point, int timeout, aiFocus_t focusType)
{
  idFocusInfo::SetExplicitFocusPoint(
    this: &this->aiVolatile.focus.foci.ptr[1],
    owner: this,
    focusPoint: point,
    _keepFocusInView: false,
    duration: timeout,
    _focusType: focusType);
}


// ========================================================================
// ?ClearAimFocus@idAI2@@QAAXXZ
// EA  : 0x829F4DD8
// RVA : 0x009F4DD8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearAimFocus(idAI2 *this)
{
  idFocusInfo::Clear(this: this->aiVolatile.focus.foci.ptr, owner: this);
}


// ========================================================================
// ?ClearLookFocus@idAI2@@QAAXXZ
// EA  : 0x829F4DE8
// RVA : 0x009F4DE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearLookFocus(idAI2 *this)
{
  idFocusInfo::Clear(this: &this->aiVolatile.focus.foci.ptr[1], owner: this);
}


// ========================================================================
// ?SetEnableHeadTracking@idAI2@@QAAX_N@Z
// EA  : 0x829F4DF8
// RVA : 0x009F4DF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetEnableHeadTracking(idAI2 *this, const bool enable)
{
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r30
  int i; // r31

  this->aiVolatile.focus.enableHeadTracking = enable;
  p_focus = &this->aiVolatile.focus;
  for ( i = 2; i != 0; --i )
  {
    idFocusInfo::SetEnableTracking(this: p_focus->foci.ptr, owner: this, enable);
    p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)p_focus + 272);
  }
}


// ========================================================================
// ?SetSuppressHeadTracking@idAI2@@QAAX_N@Z
// EA  : 0x829F4E40
// RVA : 0x009F4E40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetSuppressHeadTracking(idAI2 *this, bool suppress)
{
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r30
  int i; // r31

  p_focus = &this->aiVolatile.focus;
  for ( i = 2; i != 0; --i )
  {
    idFocusInfo::SetSuppressTracking(this: p_focus->foci.ptr, owner: this, suppress);
    p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)p_focus + 272);
  }
}


// ========================================================================
// ?CoverApproachForDirection@@YA?AW4coverApproach_t@idAI2@@ABVidVec3@@_N1@Z
// EA  : 0x829F4E80
// RVA : 0x009F4E80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2::coverApproach_t __fastcall CoverApproachForDirection(
        const idVec3 *relativePosition,
        const bool allowTurnAroundLeft,
        const bool allowTurnAroundRight)
{
  double y; // fp13
  idAI2::coverApproach_t result; // r3
  double x; // fp0

  y = relativePosition->y;
  x = relativePosition->x;
  result = COVER_APPROACH_MAX;
  if ( y > 0.0 )
  {
    if ( x > 0.0 )
    {
      if ( x > y )
        return COVER_APPROACH_RIGHT;
      if ( allowTurnAroundRight )
        return COVER_APPROACH_TURN_AROUND_RIGHT;
      if ( allowTurnAroundLeft )
        return COVER_APPROACH_WRAP_AROUND_LEFT;
      return result;
    }
    if ( -x <= y )
    {
      if ( allowTurnAroundLeft )
        return COVER_APPROACH_TURN_AROUND_LEFT;
      if ( allowTurnAroundRight )
        return COVER_APPROACH_WRAP_AROUND_RIGHT;
      return result;
    }
    return COVER_APPROACH_LEFT;
  }
  if ( __fabs(x) < -y )
    return COVER_APPROACH_FORWARD;
  result = COVER_APPROACH_RIGHT;
  if ( x <= 0.0 )
    return COVER_APPROACH_LEFT;
  return result;
}


// ========================================================================
// ?GetRunCycleIndexForType@idAI2@@QBAHW4runIndexType_t@@@Z
// EA  : 0x829F4F40
// RVA : 0x009F4F40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetRunCycleIndexForType(idAI2 *this, unsigned int t)
{
  const idDeclAIBehavior *decl; // r11

  decl = this->aiEditable.behaviors.decl;
  if ( t > 8 )
    return -1;
  switch ( t )
  {
    case 0u:
      return 0;
    case 1u:
      idLib::Warning(fmt: "idAI2::GetRunCycleIndexForType run index type ANIMWEBAI_RUNINDEXTYPE_INJURED cannot be selected this way");
      return -1;
    case 2u:
      return decl->runTypeBehaviors.scrambleRunIndex;
    case 3u:
      return decl->runTypeBehaviors.farRunIndex;
    case 4u:
      return decl->runTypeBehaviors.gunDownIndex;
    case 5u:
      return decl->runTypeBehaviors.narrowIndex;
    case 6u:
      return decl->runTypeBehaviors.upStairsIndex;
    case 7u:
      return decl->runTypeBehaviors.downStairsIndex;
    default:
      break;
  }
  return decl->runTypeBehaviors.duckIndex;
}


// ========================================================================
// ?GetIdleIndexForType@idAI2@@QBAHW4runIndexType_t@@@Z
// EA  : 0x829F5048
// RVA : 0x009F5048
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetIdleIndexForType(idAI2 *this, unsigned int t)
{
  const idDeclAIBehavior *decl; // r11

  decl = this->aiEditable.behaviors.decl;
  if ( t <= 8 && t != 0 )
  {
    if ( t == 1 )
    {
      idLib::Warning(fmt: "idAI2::GetIdleIndexForType idle index type ANIMWEBAI_RUNINDEXTYPE_INJURED cannot be selected this way");
      return -1;
    }
    if ( t != 2 && t != 3 )
    {
      if ( t == 4 )
        return decl->idleBehaviors.gunDownIndex;
      if ( t == 5 )
        return decl->idleBehaviors.narrowIndex;
      if ( t - 6 >= 2 )
        return decl->idleBehaviors.duckIndex;
    }
  }
  return 0;
}


// ========================================================================
// ?PlayAnimWebPathPerfect@idAI2@@QAAXABVidAnimWebPath@@ABVidVec3@@ABVidMat3@@_N3@Z
// EA  : 0x829F5108
// RVA : 0x009F5108
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::PlayAnimWebPathPerfect(
        idAI2 *this,
        const idAnimWebPath *animPath,
        const idVec3 *pos,
        idQuat *axis,
        const bool forcedTransition,
        const bool perfectDestination)
{
  idQuat *v11; // r3
  double y; // fp13
  double z; // fp12
  double v14; // fp11
  double v15; // fp10
  double v16; // fp9
  double w; // fp8
  idEventArg *v18; // r28
  const idEventArg *v19; // [sp+8h] [-2A8h]
  const idEventArg *v20; // [sp+Ch] [-2A4h]
  _BYTE v21[20]; // [sp+70h] [-240h] BYREF
  _BYTE v22[20]; // [sp+90h] [-220h] BYREF
  _BYTE v23[20]; // [sp+B0h] [-200h] BYREF
  _BYTE v24[20]; // [sp+D0h] [-1E0h] BYREF
  _BYTE v25[20]; // [sp+F0h] [-1C0h] BYREF
  float v26[5]; // [sp+110h] [-1A0h] BYREF
  int v27; // [sp+130h] [-180h]
  float x; // [sp+134h] [-17Ch]
  float v29; // [sp+138h] [-178h]
  float v30; // [sp+13Ch] [-174h]
  idStr v31; // [sp+150h] [-160h] BYREF
  idStr v32; // [sp+170h] [-140h] BYREF
  _DWORD v33[5]; // [sp+190h] [-120h] BYREF
  _DWORD v34[5]; // [sp+1B0h] [-100h] BYREF
  _DWORD v35[5]; // [sp+1D0h] [-E0h] BYREF
  _DWORD v36[5]; // [sp+1F0h] [-C0h] BYREF
  idMat3 v37; // [sp+210h] [-A0h] BYREF
  idEventReceiver v38[9]; // [sp+240h] [-70h] BYREF

  v31.len = 0;
  v31.allocedAndFlag = 20;
  v31.data = v31.baseBuffer;
  v31.baseBuffer[0] = 0;
  v32.allocedAndFlag = 20;
  v32.data = v32.baseBuffer;
  v32.len = 0;
  v32.baseBuffer[0] = 0;
  idAI2::GetSubWebAndStateFromAnimWebPath(this, animWebPath: animPath->data, subWebName: &v31, stateName: &v32);
  HIBYTE(v35[0]) = 105;
  HIBYTE(v36[0]) = 105;
  HIBYTE(v33[0]) = 115;
  HIBYTE(v34[0]) = 115;
  this->scriptProxy.blocking = false;
  v35[1] = perfectDestination;
  v36[1] = forcedTransition;
  v33[1] = v32.data;
  v34[1] = v31.data;
  v11 = idMat3::ToQuat(this: &v37, result: axis);
  y = pos->y;
  z = pos->z;
  x = pos->x;
  v14 = v11->x;
  HIBYTE(v26[0]) = 113;
  v15 = v11->y;
  HIBYTE(v27) = 118;
  v16 = v11->z;
  w = v11->w;
  v29 = y;
  v30 = z;
  v26[1] = v14;
  v26[2] = v15;
  v26[3] = v16;
  v26[4] = w;
  v18 = idEventArg::idEventArg(this: (idEventArg *)&v37.mat[1].y, data: this);
  memcpy(Dst: v25, Src: v35, Size: sizeof(v25));
  memcpy(Dst: v24, Src: v36, Size: sizeof(v24));
  memcpy(Dst: v23, Src: v33, Size: sizeof(v23));
  memcpy(Dst: v22, Src: v34, Size: sizeof(v22));
  memcpy(Dst: v21, Src: v26, Size: sizeof(v21));
  idEventReceiver::ProcessEvent(
    this: v38,
    result: (idEventArg *)&this->scriptProxy,
    ev: *(const idEventDef **)&v18->type,
    arg1: (const idEventArg *)LODWORD(v18->value.v[1]),
    arg2: (const idEventArg *)LODWORD(v18->value.v[2]),
    arg3: (const idEventArg *)__ROL4__(v27, 32),
    arg4: (const idEventArg *)LODWORD(v29),
    arg5: (const idEventArg *)LODWORD(v30),
    arg6: v19,
    arg7: v20);
  idStr::FreeData(this: &v32);
  idStr::FreeData(this: &v31);
}


// ========================================================================
// __unwind$519179
// EA  : 0x829F52D0
// RVA : 0x009F52D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_519179()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 688 + 336));
}


// ========================================================================
// __unwind$519180
// EA  : 0x829F52F8
// RVA : 0x009F52F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_519180()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 688 + 368));
}


// ========================================================================
// ?AllocPresentable@idAI2@@UAAPAVidPresentable@@PAVidRenderModel@@@Z
// EA  : 0x829F5328
// RVA : 0x009F5328
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idPresentableAI *__fastcall idAI2::AllocPresentable(idAI2 *this, idRenderModel *renderModel_)
{
  idPresentableAI *v4; // r29
  int entityNumber; // r27
  const idDeclFX *v6; // r26
  idAnimStack *v7; // r3
  bool v9; // [sp+Bh] [-A5h]

  v4 = (idPresentableAI *)idMem::AllocWithLocation(
                            this: &mem,
                            location: "w:\\tech5\\shared\\idlib\\Heap.h(64) : tag",
                            size: 0x3DB8u,
                            tag: TAG_PRESENTABLE,
                            zeroBuffer: false,
                            align: ALIGN_16,
                            heap: HEAP_DEFAULTHEAP);
  if ( v4 == nullptr )
    return nullptr;
  entityNumber = this->entityNumber;
  v6 = this->GetFXDecl(this);
  v7 = this->GetAnimStack_2(this);
  return idPresentableAI::idPresentableAI(
           this: v4,
           ent: this,
           renderModel_,
           animStack_: v7,
           animPain_: &this->aiVolatile.animation.painAnimator,
           inf: &this->aiConstants.movement.influence,
           entityNumber_: entityNumber,
           fxDecl_: v6,
           useSphereModel_: v9);
}


// ========================================================================
// __unwind$519304
// EA  : 0x829F53F0
// RVA : 0x009F53F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_519304()
{
  int v0; // r12

  operator delete(p: *(void **)(v0 - 176 + 96), tag: TAG_PRESENTABLE);
}


// ========================================================================
// ?UpdateInfluenceTrail@idAI2@@AAAXXZ
// EA  : 0x829F5420
// RVA : 0x009F5420
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateInfluenceTrail(idAI2 *this)
{
  idPhysics *Physics; // r29
  int GameMs; // r28
  idPresentable *presentable; // r31
  idInfluenceTrailManager *p_influenceTrailManager; // r30
  const idVec3 *v6; // r3

  if ( ai_enableInfluenceTrails.valueInteger != 0 )
  {
    Physics = idEntity::GetPhysics(this);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    if ( this->presentable == nullptr )
      idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
    p_influenceTrailManager = &clientGame->influenceTrailManager;
    v6 = Physics->GetOrigin(this: Physics, a2: 0);
    idInfluenceTrailManager::UpdatePosition(
      this: p_influenceTrailManager,
      trail: &presentable->influenceHandle,
      position: v6,
      time: GameMs);
  }
}


// ========================================================================
// ?IsOnElevator@idAI2@@QAA_NXZ
// EA  : 0x829F54C8
// RVA : 0x009F54C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsOnElevator(idAI2 *this)
{
  float *Physics; // r30
  int v3; // r28
  idPhysics *v4; // r3
  idPhysics *v5; // r3
  int v6; // r3
  int v7; // r11
  int v8; // r31
  idPhysics *PhysicsForId; // r3
  bool IsPusher; // r31
  float *v11; // r3
  idPhysics *v12; // r3
  _BYTE v14[16]; // [sp+50h] [-50h] BYREF

  if ( idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this) )
    return 0;
  if ( idEntity::GetPhysics(this) == nullptr )
    return 0;
  if ( idEntity::GetPhysics(this)->type != PHYSICS_AI )
    return 0;
  if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 86) & 1) == 0 )
    return 0;
  Physics = (float *)idEntity::GetPhysics(this);
  v3 = 0;
  v4 = idEntity::GetPhysics(this);
  if ( v4->GetNumContacts(this: v4) <= 0 )
    return 0;
  while ( 1 )
  {
    v5 = idEntity::GetPhysics(this);
    v6 = (int)v5->GetContact(this: v5, a2: v3);
    v7 = *(_DWORD *)(v6 + 56);
    v8 = v6;
    if ( v7 > 0
      && v7 < 0x2000
      && idMover::CastTo(c: (idMover *)gameLocal->entities.ptr[v7]) != nullptr
      && (float)((float)(Physics[16] * *(float *)(v8 + 16))
               + (float)((float)(Physics[18] * *(float *)(v8 + 24)) + (float)(Physics[17] * *(float *)(v8 + 20)))) < -0.1 )
    {
      PhysicsForId = idPhysics::GetPhysicsForId(physicsId_: *(_DWORD *)(v8 + 60));
      if ( PhysicsForId != nullptr && PhysicsForId->type == PHYSICS_PARAMETRIC )
      {
        IsPusher = idPhysics_Parametric::IsPusher(this: (idPhysics_Parametric *)PhysicsForId);
        v11 = (float *)(*(int (__fastcall **)(_BYTE *, float *, _DWORD))(*(_DWORD *)Physics + 264))(
                         a1: v14,
                         a2: Physics,
                         a3: 0);
        if ( IsPusher
          && (float)((float)(v11[2] * v11[2]) + (float)((float)(*v11 * *v11) + (float)(v11[1] * v11[1]))) > (double)(float)(ai_pushVelocityTolerance.valueFloat * ai_pushVelocityTolerance.valueFloat) )
        {
          break;
        }
      }
    }
    ++v3;
    v12 = idEntity::GetPhysics(this);
    if ( v3 >= v12->GetNumContacts(this: v12) )
      return 0;
  }
  return 1;
}


// ========================================================================
// ?StartRagdoll@idAI2@@UAA?AW4testSolidResult_t@idAnimator_AF@@ABVidRagdollInfo@@@Z
// EA  : 0x829F56D0
// RVA : 0x009F56D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAnimator_AF::testSolidResult_t __fastcall idAI2::StartRagdoll(idAI2 *this, const idRagdollInfo *info)
{
  if ( (*((_BYTE *)&this->aiVolatile.death + 1760) & 2) != 0 )
    return TESTSOLID_IN_SOLID;
  idAI2::SetIsRagdolling(this, isRagdolling: true);
  return idActor::StartRagdoll(this, info);
}


// ========================================================================
// ?StopRagdoll@idAI2@@UAAXXZ
// EA  : 0x829F5738
// RVA : 0x009F5738
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::StopRagdoll(idAI2 *this)
{
  idAI2::SetIsRagdolling(this, isRagdolling: false);
  idActor::StopRagdoll(this);
}


// ========================================================================
// ?GetMoveOrientation@idAI2@@QAAAAVidAIOrientation@@XZ
// EA  : 0x829F5770
// RVA : 0x009F5770
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIOrientation *__fastcall idAI2::GetMoveOrientation(idAI2 *this)
{
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    return &this->aiVolatile.animation.animFSM.orientMove;
  else
    return &this->aiVolatile.physics.moveState.moveOrientation;
}


// ========================================================================
// ?GetBodyOrientation@idAI2@@QAAAAVidAIOrientation@@XZ
// EA  : 0x829F57C8
// RVA : 0x009F57C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIOrientation *__fastcall idAI2::GetBodyOrientation(idAI2 *this)
{
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    return &this->aiVolatile.animation.animFSM.orientBody;
  else
    return &this->aiVolatile.focus.bodyOrientation;
}


// ========================================================================
// ?SetAxis@idAI2@@UAAXABVidMat3@@@Z
// EA  : 0x829F5820
// RVA : 0x009F5820
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetAxis(idAI2 *this, const idMat3 *axis)
{
  idAIOrientation *p_orientBody; // r3

  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    p_orientBody = &this->aiVolatile.animation.animFSM.orientBody;
  else
    p_orientBody = &this->aiVolatile.focus.bodyOrientation;
  idAIOrientation::Init(this: p_orientBody, axis);
}


// ========================================================================
// ?IsMoveDone@idAI2@@QAA_N_N@Z
// EA  : 0x829F5880
// RVA : 0x009F5880
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::IsMoveDone(idAI2 *this, bool checkAlignment)
{
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    return this->aiVolatile.animation.animFSM.IsMoveDone(this: &this->aiVolatile.animation.animFSM);
  else
    return (_cntlzw(this->aiVolatile.physics.moveState.GetMoveStatus(this: &this->aiVolatile.physics.moveState)) & 0x20) != 0;
}


// ========================================================================
// ?GetMoveInterface@idAI2@@QAAAAVidAIMoveInterface@@XZ
// EA  : 0x829F5900
// RVA : 0x009F5900
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIMoveState *__fastcall idAI2::GetMoveInterface(idAI2 *this)
{
  idAIMoveState *result; // r3

  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) == 0 )
    return &this->aiVolatile.physics.moveState;
  result = (idAIMoveState *)&this->aiVolatile.animation.animFSM.idAIMoveInterface;
  if ( this == (idAI2 *)-34880 )
    return nullptr;
  return result;
}


// ========================================================================
// ?PauseFiberTillActionCompletes@idAIScriptProxy@@AAAXV?$idHandle@HW4invalidFiberId_t@@$0A@@@@Z
// EA  : 0x829F5968
// RVA : 0x009F5968
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIScriptProxy::PauseFiberTillActionCompletes(
        idAIScriptProxy *this,
        idHandle<int,enum invalidFiberId_t,0> *fiberHandle)
{
  idLegsFSM *p_legsFSM; // r11
  idHandle<int,enum invalidFiberId_t,0> *value; // r4

  if ( idSuperScriptSystem::IsThreadHandleValid(this: &gameLocal->superScript, threadHandle: fiberHandle) )
  {
    p_legsFSM = &this->owner->aiVolatile.fsms.actionManager.legsFSM;
    if ( this->owner != (idAI2 *)-32672 )
    {
      value = (idHandle<int,enum invalidFiberId_t,0> *)this->owner->aiVolatile.fsms.actionManager.legsFSM.waitFiberHandle.value;
      if ( value != nullptr )
      {
        if ( idSuperScriptSystem::IsThreadHandleValid(this: &gameLocal->superScript, threadHandle: value) )
          idLib::Error(fmt: "Fiber tried to wait on action FSM, but the actionFSM is already waiting on another fiber");
        idLib::Error(fmt: "Fiber tried to wait on action FSM, but the actionFSM is already waiting on a dead fiber");
      }
      p_legsFSM->waitFiberHandle.value = (int)fiberHandle;
    }
    idSuperScriptSystem::WaitForFSM(this: &gameLocal->superScript);
  }
}


// ========================================================================
// ?PauseThreadTillActionCompletes@idAIScriptProxy@@AAAXPAVidThread@@@Z
// EA  : 0x829F5A00
// RVA : 0x009F5A00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIScriptProxy::PauseThreadTillActionCompletes(idAIScriptProxy *this, idThread *thread)
{
  idLegsFSM *p_legsFSM; // r11
  const idHandle<int,enum invalidThreadHandle_t,0> *value; // r4
  idThread *v5; // r3
  char *data; // r4

  if ( thread != nullptr )
  {
    p_legsFSM = &this->owner->aiVolatile.fsms.actionManager.legsFSM;
    if ( this->owner != (idAI2 *)-32672 )
    {
      value = (const idHandle<int,enum invalidThreadHandle_t,0> *)this->owner->aiVolatile.fsms.actionManager.legsFSM.waitThreadHandle.value;
      if ( value != nullptr )
      {
        v5 = idThreadManager::GetThread(this: &gameLocal->program.threadManager, threadHandle: value);
        data = thread->threadName.data;
        if ( v5 != nullptr )
          idLib::Error(
            fmt: "Thread '%s' tried to wait on action FSM, but the action FSM is already waiting on thread '%s'",
            data,
            v5->threadName.data);
        idLib::Error(
          fmt: "Thread '%s' tried to wait on action FSM, but the actionFSM is already waiting on a dead thread",
          data);
      }
      p_legsFSM->waitThreadHandle.value = thread->threadHandle.value;
    }
    idThread::WaitForFSM(this: thread, waiting: true);
  }
}


// ========================================================================
// ?GetEntranceAnimWebPath@idAI2@@QBA?AVidAnimWebPath@@XZ
// EA  : 0x829F66F8
// RVA : 0x009F66F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::GetEntranceAnimWebPath(idAI2 *this, idAnimWebPath *result)
{
  idStr::idStr((idStr *)this, text: (idAnimWebPath *)((char *)result + 11332));
  return this;
}


// ========================================================================
// ?CanFireRobot@idAI2@@QAA_NH@Z
// EA  : 0x829F6730
// RVA : 0x009F6730
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CanFireRobot(idAI2 *this, int _curTime, int a3, __int64 a4, __int64 a5)
{
  int lastShootTime; // r11
  double stageHealth; // fp12
  double chargeHealthFract; // fp10
  double v9; // fp4
  idEntityPtr<idEntity> *p_triggerOnPowerOut; // r30
  __int64 v11; // r9
  __int64 v12; // r7
  idEventArg *v13; // r3
  char *v14; // r10
  _DWORD *v15; // r11
  int i; // ctr
  idEntity *v17; // r3
  double v18; // fp0
  double v19; // fp12
  int v20; // r11
  double v22; // fp12
  int v23; // r11
  char v24; // [sp+5Ch] [-54h] BYREF
  __int64 v25; // [sp+68h] [-48h]
  idEventArg v26; // [sp+80h] [-30h] BYREF

  if ( !this->aiEditable.actionSettings.customRobot.usesRobot )
    return 1;
  if ( this->aiEditable.actionSettings.customRobot.isCharging
    || this->aiEditable.actionSettings.customRobot.noFireTime >= _curTime )
  {
    this->aiEditable.actionSettings.customRobot.lastShootTime = -1;
    return 0;
  }
  if ( this->aiEditable.actionSettings.customRobot.shootHealthDrain <= 0.0 )
    return 1;
  lastShootTime = this->aiEditable.actionSettings.customRobot.lastShootTime;
  if ( lastShootTime <= 0
    || (stageHealth = this->aiEditable.actionSettings.customRobot.stageHealth,
        LODWORD(a5) = _curTime - lastShootTime,
        chargeHealthFract = this->aiEditable.actionSettings.customRobot.chargeHealthFract,
        v9 = (float)-(float)((float)((float)((float)((float)a5 * this->aiEditable.actionSettings.customRobot.stageHealth)
                                           * this->aiEditable.actionSettings.customRobot.shootHealthDrain)
                                   * (float)0.001)
                           - this->aiEditable.actionSettings.customRobot.curStageHealth),
        this->aiEditable.actionSettings.customRobot.curStageHealth = -(float)((float)((float)((float)((float)a5 * this->aiEditable.actionSettings.customRobot.stageHealth)
                                                                                            * this->aiEditable.actionSettings.customRobot.shootHealthDrain)
                                                                                    * (float)0.001)
                                                                            - this->aiEditable.actionSettings.customRobot.curStageHealth),
        (float)((float)v9 / (float)stageHealth) > chargeHealthFract) )
  {
    LODWORD(a5) = this->aiEditable.actionSettings.customRobot.numStages;
    v22 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth
                / this->aiEditable.actionSettings.customRobot.stageHealth);
    v23 = a5 - this->aiEditable.actionSettings.customRobot.curStage;
    this->aiEditable.actionSettings.customRobot.lastShootTime = _curTime;
    LODWORD(a4) = v23 - 1;
    this->aiEditable.actionSettings.customRobot.bossHealth = (float)((float)v22 + (float)a4) / (float)a5;
    return 1;
  }
  p_triggerOnPowerOut = &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut;
  if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut) != nullptr )
  {
    v13 = idEventArg::idEventArg(this: &v26, data: this);
    v14 = &v24;
    v15 = (_DWORD *)&v13[-1].value.q[3];
    for ( i = 5; i != 0; --i )
    {
      ++v15;
      v14 += 4;
      *(_DWORD *)v14 = *v15;
    }
    v17 = idEntityPtr<idEntity const>::operator->(this: p_triggerOnPowerOut);
    idEventReceiver::PostEventMS(this: v17, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)HIDWORD(v25));
  }
  v18 = this->aiEditable.actionSettings.customRobot.stageHealth;
  LODWORD(v11) = this->aiEditable.actionSettings.customRobot.numStages;
  v19 = (float)(this->aiEditable.actionSettings.customRobot.stageHealth
              * this->aiEditable.actionSettings.customRobot.chargeHealthFract);
  v20 = v11 - this->aiEditable.actionSettings.customRobot.curStage;
  this->aiEditable.actionSettings.customRobot.curStageHealth = this->aiEditable.actionSettings.customRobot.stageHealth
                                                             * this->aiEditable.actionSettings.customRobot.chargeHealthFract;
  LODWORD(v12) = v20 - 1;
  this->aiEditable.actionSettings.customRobot.chargeDoneTime = -1;
  this->aiEditable.actionSettings.customRobot.isCharging = true;
  this->aiEditable.actionSettings.customRobot.lastShootTime = -1;
  this->aiEditable.actionSettings.customRobot.bossHealth = (float)((float)v12 + (float)((float)v19 / (float)v18))
                                                         / (float)v11;
  return 0;
}


// ========================================================================
// ?StopFireRobot@idAI2@@QAAXH@Z
// EA  : 0x829F6930
// RVA : 0x009F6930
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::StopFireRobot(idAI2 *this, const int _curTime, int a3, __int64 a4, __int64 a5)
{
  int lastShootTime; // r11
  double stageHealth; // fp0
  double chargeHealthFract; // fp10
  double v9; // fp4
  idEntityPtr<idEntity> *p_triggerOnPowerOut; // r30
  idEventArg *v11; // r3
  char *v12; // r10
  _DWORD *v13; // r11
  int i; // ctr
  idEntity *v15; // r3
  double v16; // fp13
  char v17; // [sp+5Ch] [-64h] BYREF
  __int64 v18; // [sp+68h] [-58h]
  idEventArg v19[3]; // [sp+80h] [-40h] BYREF

  if ( this->aiEditable.actionSettings.customRobot.usesRobot )
  {
    lastShootTime = this->aiEditable.actionSettings.customRobot.lastShootTime;
    if ( lastShootTime > 0
      && !this->aiEditable.actionSettings.customRobot.isCharging
      && this->aiEditable.actionSettings.customRobot.shootHealthDrain > 0.0 )
    {
      stageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
      LODWORD(a5) = _curTime - lastShootTime;
      chargeHealthFract = this->aiEditable.actionSettings.customRobot.chargeHealthFract;
      v9 = (float)-(float)((float)((float)((float)((float)a5 * this->aiEditable.actionSettings.customRobot.stageHealth)
                                         * this->aiEditable.actionSettings.customRobot.shootHealthDrain)
                                 * (float)0.001)
                         - this->aiEditable.actionSettings.customRobot.curStageHealth);
      this->aiEditable.actionSettings.customRobot.curStageHealth = -(float)((float)((float)((float)((float)a5
                                                                                                  * this->aiEditable.actionSettings.customRobot.stageHealth)
                                                                                          * this->aiEditable.actionSettings.customRobot.shootHealthDrain)
                                                                                  * (float)0.001)
                                                                          - this->aiEditable.actionSettings.customRobot.curStageHealth);
      if ( (float)((float)v9 / (float)stageHealth) <= chargeHealthFract )
      {
        p_triggerOnPowerOut = &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut;
        if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut) != nullptr )
        {
          v11 = idEventArg::idEventArg(this: v19, data: this);
          v12 = &v17;
          v13 = (_DWORD *)&v11[-1].value.q[3];
          for ( i = 5; i != 0; --i )
          {
            ++v13;
            v12 += 4;
            *(_DWORD *)v12 = *v13;
          }
          v15 = idEntityPtr<idEntity const>::operator->(this: p_triggerOnPowerOut);
          idEventReceiver::PostEventMS(this: v15, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)HIDWORD(v18));
        }
        stageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
        v16 = this->aiEditable.actionSettings.customRobot.chargeHealthFract;
        this->aiEditable.actionSettings.customRobot.chargeDoneTime = -1;
        this->aiEditable.actionSettings.customRobot.curStageHealth = (float)stageHealth * (float)v16;
        this->aiEditable.actionSettings.customRobot.isCharging = true;
      }
      LODWORD(a5) = this->aiEditable.actionSettings.customRobot.numStages;
      LODWORD(a4) = a5 - this->aiEditable.actionSettings.customRobot.curStage - 1;
      this->aiEditable.actionSettings.customRobot.bossHealth = (float)((float)a4
                                                                     + (float)(this->aiEditable.actionSettings.customRobot.curStageHealth
                                                                             / (float)stageHealth))
                                                             / (float)a5;
    }
    this->aiEditable.actionSettings.customRobot.lastShootTime = -1;
  }
}


// ========================================================================
// ?GetBossHudInfo@idAI2@@QAA?AVidHudBossInfo@@XZ
// EA  : 0x829F6AA0
// RVA : 0x009F6AA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::GetBossHudInfo(idAI2 *this, idHudBossInfo *result)
{
  float amount; // r11
  int numBars; // r10

  amount = result[905].amount;
  numBars = result[908].numBars;
  this->listeningToList = (idList<idEventReceiver *,5> *)result[903].visibleBars;
  *(float *)&this->__vftable = amount;
  this->listenerList = (idList<idEventReceiver *,5> *)(LODWORD(amount) - numBars);
  return this;
}


// ========================================================================
// ?SetAccuracy@idAI2@@QAAXW4aiAccuracy_t@@@Z
// EA  : 0x829F6AC0
// RVA : 0x009F6AC0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetAccuracy(idAI2 *this, aiAccuracy_t a)
{
  aiAccuracy_t EffectiveAccuracy; // r3

  this->aiEditable.skill.aimAccuracy = a;
  EffectiveAccuracy = idAI2::GetEffectiveAccuracy(this);
  idFocusInfo::SetTrackingParmsIndex(this: this->aiVolatile.focus.foci.ptr, idx: EffectiveAccuracy);
}


// ========================================================================
// ?GetModelTransform@idAI2@@UBAXAAVidVec3@@AAVidMat3@@@Z
// EA  : 0x829F6B00
// RVA : 0x009F6B00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetModelTransform(idAI2 *this, idVec3 *modelOrigin, idMat3 *modelAxis)
{
  const idAnimator_AF *v6; // r3
  char v7; // r11
  const idVec3 *v8; // r27
  const idMat3 *v9; // r28
  idAIOrientation *BodyOrientation; // r3
  double x; // fp9
  double y; // fp8
  double v13; // fp2
  double v14; // fp1
  idAnimator_AF *v15; // r3
  idMat3 v16; // [sp+50h] [-60h] BYREF

  v6 = this->GetAF(this);
  if ( v6->isActive || (v7 = 0, v6->isClientAuthoritativeActive) )
    v7 = 1;
  if ( v7 != 0 || this->GetAF(this)->isSyncing )
  {
    v15 = (idAnimator_AF *)this->GetAF(this);
    idAnimator_AF::GetModelTransform(this: v15, modelOrigin, modelAxis);
  }
  else
  {
    v8 = this->aiVolatile.physics.object.GetOrigin(this: &this->aiVolatile, a2: 0);
    v9 = this->aiVolatile.physics.object.GetAxis(this: &this->aiVolatile, a2: 0);
    BodyOrientation = idAI2::GetBodyOrientation(this);
    *modelAxis = *idMat3::operator*(this: &v16, result: &BodyOrientation->axis, a: v9);
    x = v8->x;
    y = v8->y;
    v13 = (float)((float)(this->actorConstants.modelInfo.modelOffset.x * modelAxis->mat[0].y)
                + (float)((float)(modelAxis->mat[1].y * this->actorConstants.modelInfo.modelOffset.y)
                        + (float)(modelAxis->mat[2].y * this->actorConstants.modelInfo.modelOffset.z)));
    v14 = (float)((float)(modelAxis->mat[2].x * this->actorConstants.modelInfo.modelOffset.z)
                + (float)((float)(this->actorConstants.modelInfo.modelOffset.x * modelAxis->mat[0].x)
                        + (float)(this->actorConstants.modelInfo.modelOffset.y * modelAxis->mat[1].x)));
    modelOrigin->z = v8->z
                   + (float)((float)(modelAxis->mat[0].z * this->actorConstants.modelInfo.modelOffset.x)
                           + (float)((float)(modelAxis->mat[1].z * this->actorConstants.modelInfo.modelOffset.y)
                                   + (float)(modelAxis->mat[2].z * this->actorConstants.modelInfo.modelOffset.z)));
    modelOrigin->y = (float)y + (float)v13;
    modelOrigin->x = (float)x + (float)v14;
  }
}


// ========================================================================
// ?UpdateDrop@idAI2@@QAAXXZ
// EA  : 0x829F6CD0
// RVA : 0x009F6CD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateDrop(idAI2 *this)
{
  __int16 *p_dropState; // r26
  idClipQuery *p_dropToGroundQuery; // r31
  idClientGame *v4; // r30
  unsigned __int64 v5; // r28
  unsigned __int64 index; // r11
  int entityNumber; // r30
  idPhysics *Physics; // r3
  float *v9; // r3
  double v10; // fp12
  double v11; // fp11
  idPhysics *v12; // r3
  const idVec3 *v13; // r3
  int v14; // [sp+8h] [-148h]
  bool v15; // [sp+Fh] [-141h]
  const char *v16; // [sp+10h] [-140h]
  int v17; // [sp+14h] [-13Ch]
  int v18; // [sp+18h] [-138h]
  int v19; // [sp+1Ch] [-134h]
  int v20; // [sp+20h] [-130h]
  int v21; // [sp+24h] [-12Ch]
  int v22; // [sp+28h] [-128h]
  int v23; // [sp+2Ch] [-124h]
  int v24; // [sp+30h] [-120h]
  int v25; // [sp+34h] [-11Ch]
  int v26; // [sp+38h] [-118h]
  int v27; // [sp+3Ch] [-114h]
  int v28; // [sp+40h] [-110h]
  int v29; // [sp+44h] [-10Ch]
  int v30; // [sp+48h] [-108h]
  int v31; // [sp+4Ch] [-104h]
  int v32; // [sp+50h] [-100h]
  int v33; // [sp+58h] [-F8h]
  int v34; // [sp+60h] [-F0h]
  idVec3 v35; // [sp+70h] [-E0h] BYREF
  char v36; // [sp+80h] [-D0h] BYREF
  trace_t v37; // [sp+90h] [-C0h] BYREF

  p_dropState = &this->aiVolatile.dropState;
  if ( this->aiVolatile.dropState == 1 )
  {
    HIDWORD(v5) = &ai_useTurnTransitions.valueString.baseBuffer[12];
    p_dropToGroundQuery = &this->aiVolatile.dropToGroundQuery;
    v4 = clientGame;
    LODWORD(v5) = 0;
    if ( (unsigned __int8)idClip::QueryIsValid(this: &clientGame->clip, clipQuery: &this->aiVolatile.dropToGroundQuery) != 0 )
    {
      index = p_dropToGroundQuery->index;
      p_dropToGroundQuery->index = v5;
      idCollisionModelManager::GetContentsResult(
        this: collisionModelManager,
        result: &v37,
        query: &v4->clip.collisionQueries[index & 0xFFF].query,
        peek: false);
      if ( v37.fraction < 1.0 )
        *p_dropState = 2;
    }
    if ( *p_dropState != 2 )
    {
      entityNumber = this->entityNumber;
      Physics = idEntity::GetPhysics(this);
      v9 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
      v10 = v9[1];
      v11 = (float)(v9[2] - (float)290.0);
      v35.x = *v9;
      v35.y = v10;
      v35.z = v11;
      v12 = idEntity::GetPhysics(this);
      v13 = v12->GetOrigin(this: v12, a2: 0);
      p_dropToGroundQuery->index = *(unsigned __int64 *)&idClip::Translation(
                                                           this: (idClip *)&v36,
                                                           result: &clientGame->clip,
                                                           a3: nullptr,
                                                           start: v13,
                                                           end: &v35,
                                                           clipModel: nullptr,
                                                           startAxis: &mat3_identity,
                                                           clipMask: 106513,
                                                           passEntityNumber: v14,
                                                           moveClipModel: v15,
                                                           userName: v16,
                                                           a12: v17,
                                                           a13: v18,
                                                           a14: v19,
                                                           a15: v20,
                                                           a16: v21,
                                                           a17: v22,
                                                           a18: v23,
                                                           a19: v24,
                                                           a20: v25,
                                                           a21: v26,
                                                           a22: v27,
                                                           a23: v28,
                                                           a24: v29,
                                                           a25: v30,
                                                           a26: v31,
                                                           a27: v32,
                                                           a28: entityNumber,
                                                           a29: v33,
                                                           a30: false,
                                                           a31: v34,
                                                           a32: (int)"w:\\tech5\\tungsten\\game\\ai\\AI2.cpp(4527) : DroppingGuy")->world;
    }
  }
}


// ========================================================================
// ?PlayAdditivePain@idAI2@@IAA_NPAVidEntity@@0PBVidDeclDamage@@MABVidVec3@@2V?$idIndex@FW4invalidJointIndex_t@@@@@Z
// EA  : 0x829F6E48
// RVA : 0x009F6E48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::PlayAdditivePain(
        idAI2 *this,
        idEntity *inflictor,
        idPlayer *attacker,
        const idDeclDamage *damageDecl,
        double damage,
        const idVec3 *impactPoint,
        const idVec3 *impactDir,
        const idVec3 *joint,
        __int16 a9,
        int a10,
        int a11,
        int a12,
        int a13,
        int a14,
        int a15,
        int a16,
        int a17,
        int a18,
        int a19,
        int a20,
        int a21,
        int a22,
        int a23,
        int a24,
        int a25,
        int a26,
        idIndex<short,enum invalidJointIndex_t> a27)
{
  int index; // r28
  bool v32; // r11
  double v33; // fp31
  char v34; // r6
  char v35; // r11
  const idDeclAIBehavior *decl; // r11
  bool v37; // zf
  idPresentable *presentable; // r3
  idPlayer *v40; // r3
  idPlayer *v41; // r29
  idPresentable *v42; // r11
  idPresentable *v43; // r3
  idIndex<short,enum invalidJointIndex_t> *value; // r30
  idPresentableAI *v45; // r3
  idTreeAnimator *TreeAnimatorFromPresentable; // r27
  idPresentable *v47; // r3
  damageDirection_t DamageDirection; // r29
  const idWeapon *v49; // r3
  int GameMs; // r29
  const idAnimStack *v51; // r3
  const blendParms_t *v52; // r7
  const idDeclMD6 *v53; // r11
  idJointGroupCollection *p_jointGroupCollection; // r29
  const idJointGroup *JointGroup; // r29
  const char *v56; // r3
  const char *v57; // r28
  const char *str; // r29
  idTreeAnimator *v59; // r3
  const char *JointName; // r3
  idDeclTwitchPain v61; // [sp+50h] [-A0h] BYREF

  a27.value = a9;
  index = 0;
  v32 = idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
     && (this->aiVolatile.script.flags & 0x80) != 0;
  if ( v32 || (*((_BYTE *)&this->aiEditable.death + 84) & 0x40) == 0 )
    return 0;
  v33 = (float)((float)damage / this->aiHealth.GetMaxBaseHealth_Impl(this: &this->aiHealth));
  v34 = _cntlzw(this->aiVolatile.physics.moveState.GetMoveStatus(this: &this->aiVolatile.physics.moveState) - 1);
  if ( (v34 & 0x20) == 0 || (v35 = 1, this->actorVolatile.walkState < WALKSTATE_RUNNING) )
    v35 = 0;
  v37 = v35 == 0;
  decl = this->aiEditable.behaviors.decl;
  if ( v37 )
  {
    if ( (v34 & 0x20) != 0 )
    {
      if ( v33 < decl->damageBehaviors.twitchThresholdWalking )
        return 0;
    }
    else if ( v33 < decl->damageBehaviors.twitchThresholdStanding )
    {
      return 0;
    }
  }
  else if ( v33 < decl->damageBehaviors.twitchThresholdRunning )
  {
    return 0;
  }
  if ( !common->IsMultiplayer(this: common) )
    goto LABEL_29;
  presentable = this->presentable;
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
  }
  if ( presentable->GetAIInterface(this: presentable) != nullptr )
  {
    if ( (unsigned __int8)idPlayer::IsTypeOf(c: attacker) != 0 )
    {
      v40 = idPlayer::CastTo(c: attacker);
      v41 = v40;
      if ( v40 != nullptr )
      {
        v42 = v40->presentable;
        if ( v42 == nullptr )
        {
          idEntity::InitPresentableInternal(this: v40);
          v42 = v41->presentable;
        }
        index = v42->index;
      }
    }
    v43 = this->presentable;
    if ( v43 == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      v43 = this->presentable;
    }
    value = (idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)a27.value;
    v45 = v43->GetAIInterface(this: v43);
    idPresentableAI::PlayAdditivePain(this: v45, projDir: joint, joint: value, playerIndex: index);
  }
  else
  {
LABEL_29:
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    v47 = this->presentable;
    if ( v47 == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      v47 = this->presentable;
    }
    idPresentable::UpdateModelTransform(this: v47);
    DamageDirection = idActor::GetDamageDirection(
                        axis: &this->actorVolatile.modelInfo.modelAxis,
                        dir: joint,
                        numDirs: 2);
    if ( this->aiEditable.death.declTwitchPain == nullptr )
      return 0;
    *(_DWORD *)&v61.programaticallyDefined = 0;
    v61.hasBeenParsedAtLeastOnce = false;
    v61.parent = (idDeclTypeInfo *)20;
    v61.declSource = (idDeclSource *)&v61.hasBeenParsedAtLeastOnce;
    v49 = this->GetEquippedWeapon(this);
    idAI2::GetWeaponPrefix(this, weapon: v49, subWebPrefix: (idStr *)&v61.programaticallyDefined);
    idDeclTwitchPain::GetTwitchPainAliasHandle(
      this: &v61,
      result: (idHandle<unsigned short,enum invalidAliasHandle_t,65535> *)this->aiEditable.death.declTwitchPain,
      forModelDef: TreeAnimatorFromPresentable->decl,
      weaponPrefix: (const char *)v61.declSource,
      damageDir: DamageDirection,
      jointIndex: &a27);
    if ( HIWORD(v61.__vftable) != 0xFFFF )
    {
      blendParms_t::blendParms_t(this: (blendParms_t *)&v61.resourceListPtr);
      blendParms_t::SetDurationMS(this: (blendParms_t *)&v61.resourceListPtr, ms: 0x96u);
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      v51 = this->GetAnimStack_2(this);
      idAnimator_Channel::PlayAnim(
        this: &this->aiVolatile.animation.painAnimator,
        stack: v51,
        ah: (const idHandle<unsigned short,enum invalidAliasHandle_t,65535> *)&v61,
        curTime: GameMs,
        rateScale: 1.0,
        blendParms: v52,
        blendOutDurationMS_: (blendParms_t *)&v61.resourceListPtr,
        leafStarted: (idMD6LeafPlay **)0x12C,
        a9: nullptr);
    }
    if ( ai_debugPain.valueInteger != 0 && ai_debugLevel.valueInteger != 0 )
    {
      v53 = TreeAnimatorFromPresentable->decl;
      p_jointGroupCollection = &v53->jointGroupCollection;
      if ( v53 == nullptr )
        p_jointGroupCollection = nullptr;
      idJointGroupCollection::GetJointGroupHandle(
        this: (idJointGroupCollection *)&v61.trackedMemory,
        result: p_jointGroupCollection,
        type: 2,
        jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)a27.value);
      if ( p_jointGroupCollection != nullptr )
        JointGroup = idJointGroupCollection::GetJointGroup(
                       this: p_jointGroupCollection,
                       handle: (const idHandle<int,enum invalidJointGroupHandle,0> *)&v61.trackedMemory);
      else
        JointGroup = nullptr;
      v56 = animation->FindAliasName(this: animation, a2: &v61);
      if ( v56 != nullptr )
        v57 = v56;
      else
        v57 = "<INVALID ALIAS>";
      if ( JointGroup != nullptr )
        str = JointGroup->groupName.str;
      else
        str = &byte_8200D768;
      v59 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      JointName = idTreeAnimator::GetJointName(
                    this: v59,
                    jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)a27.value);
      idLib::Printf(
        fmt: "^2Twitch: joint: '%s', joint group: '%s', alias: '%s' damage: %.0f (%.0f%%)\n",
        JointName,
        str,
        v57,
        damage,
        (float)((float)v33 * (float)100.0));
    }
    idStr::FreeData(this: (idStr *)&v61.programaticallyDefined);
  }
  return 1;
}


// ========================================================================
// __unwind$523606
// EA  : 0x829F7288
// RVA : 0x009F7288
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_523606()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 240 + 128));
}


// ========================================================================
// ?UpdateDeathCollision@idAI2@@IAAXXZ
// EA  : 0x829F72B0
// RVA : 0x009F72B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateDeathCollision(idAI2 *this)
{
  idClipQuery *p_deathCollisionQuery; // r29
  idClientGame *v3; // r30
  __int128 v4; // r11
  idIndex<short,enum invalidJointIndex_t> *TreeAnimatorFromPresentable; // r28
  const char **v6; // r30
  idTreeAnimator *JointIndex; // r3
  idPhysics *Physics; // r3
  idMat3 *v21; // r30
  idPhysics *v22; // r3
  float *v23; // r3
  double v24; // fp13
  double v25; // fp12
  const idMat3 *v26; // r3
  idPhysics *v27; // r3
  const idMat3 *v28; // r28
  idPhysics *v29; // r3
  const idVec3 *v30; // r3
  const char *v31; // [sp+8h] [-B18h]
  int v32; // [sp+Ch] [-B14h]
  int v33; // [sp+10h] [-B10h]
  int v34; // [sp+14h] [-B0Ch]
  int v35; // [sp+18h] [-B08h]
  int v36; // [sp+1Ch] [-B04h]
  int v37; // [sp+20h] [-B00h]
  int v38; // [sp+24h] [-AFCh]
  int v39; // [sp+28h] [-AF8h]
  int v40; // [sp+2Ch] [-AF4h]
  int v41; // [sp+30h] [-AF0h]
  int v42; // [sp+34h] [-AECh]
  int v43; // [sp+38h] [-AE8h]
  int v44; // [sp+3Ch] [-AE4h]
  int v45; // [sp+40h] [-AE0h]
  int v46; // [sp+44h] [-ADCh]
  int v47; // [sp+48h] [-AD8h]
  int v48; // [sp+4Ch] [-AD4h]
  int v49; // [sp+50h] [-AD0h]
  idBounds v50; // [sp+60h] [-AC0h] BYREF
  idBounds v51; // [sp+80h] [-AA0h] BYREF
  idTreeAnimator v52; // [sp+98h] [-A88h] BYREF

  if ( this->IsDying(this)
    && (*((_BYTE *)&this->aiVolatile.death + 1760) & 2) == 0
    && (this->aiVolatile.death.deathInfo.deathFlags & 0x20) != 0 )
  {
    p_deathCollisionQuery = &this->aiVolatile.death.deathInfo.deathCollisionQuery;
    v3 = clientGame;
    if ( (unsigned __int8)idClip::QueryIsValid(
                            this: &clientGame->clip,
                            clipQuery: &this->aiVolatile.death.deathInfo.deathCollisionQuery) != 0
      && (*((idClipQuery *)&v4 + 1) = (idClipQuery)p_deathCollisionQuery->index,
          DWORD1(v4) = &consoleFont[21088],
          p_deathCollisionQuery->index = *(unsigned __int64 *)((char *)&v4 + 4),
          idCollisionModelManager::GetClipResult(
            this: collisionModelManager,
            result: (clipResult_t *)&v52.g.axis.mat[2],
            query: &v3->clip.collisionQueries[v4 & 0xFFF].query,
            peek: false),
          SLODWORD(v52.g.axis.mat[2].y) > 0) )
    {
      this->aiVolatile.death.deathInfo.deathFlags &= ~0x20u;
      this->StartRagdoll(this, a2: &this->ragdollInfo);
    }
    else
    {
      TreeAnimatorFromPresentable = (idIndex<short,enum invalidJointIndex_t> *)idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      v6 = deathJointNames;
      v50.b[0].z = 1.0e30;
      v50.b[0].y = 1.0e30;
      v50.b[0].x = 1.0e30;
      v50.b[1].z = -1.0e30;
      v50.b[1].y = v50.b[1].z;
      v50.b[1].x = v50.b[1].z;
      do
      {
        JointIndex = idTreeAnimator::GetJointIndex(this: &v52, result: TreeAnimatorFromPresentable, jointName: *v6);
        idTreeAnimator::GetWorldSpaceJointTransform(
          this: (idTreeAnimator *)TreeAnimatorFromPresentable,
          pose: (animationPose_t)0,
          jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(JointIndex->__vftable),
          origin: &v52.deferredOrigin,
          axis: (idMat3 *)&v52.referenceBounds.b[1]);
        ++v6;
        _FP5 = (float)(v50.b[0].x - v52.deferredOrigin.x);
        _FP4 = (float)(v50.b[0].y - v52.deferredOrigin.y);
        _FP3 = (float)(v50.b[0].z - v52.deferredOrigin.z);
        _FP2 = (float)(v52.deferredOrigin.x - v50.b[1].x);
        _FP1 = (float)(v52.deferredOrigin.y - v50.b[1].y);
        _FP31 = (float)(v52.deferredOrigin.z - v50.b[1].z);
        __asm { fsel      f11, f5, f0, f11 }
        v50.b[0].x = _FP11;
        __asm { fsel      f10, f4, f13, f10 }
        v50.b[0].y = _FP10;
        __asm { fsel      f9, f3, f12, f9 }
        v50.b[0].z = _FP9;
        __asm { fsel      f8, f2, f0, f8 }
        v50.b[1].x = _FP8;
        __asm { fsel      f7, f1, f13, f7 }
        v50.b[1].y = _FP7;
        __asm { fsel      f6, f31, f12, f6 }
        v50.b[1].z = _FP6;
      }
      while ( (int)v6 < (int)&idClassFactory<idStateData,256,112> `RTTI Type Descriptor' );
      Physics = idEntity::GetPhysics(this);
      v21 = (idMat3 *)Physics->GetAxis(this: Physics, a2: 0);
      v22 = idEntity::GetPhysics(this);
      v23 = (float *)v22->GetOrigin(this: v22, a2: 0);
      v24 = v23[1];
      v25 = -v23[2];
      *((float *)&v52.__vftable + 2) = -*v23;
      *(float *)&v52.name.str = v25;
      *((float *)&v52.__vftable + 3) = -v24;
      v26 = idMat3::Inverse(this: (idMat3 *)&v52.deferredAxis.mat[1].z, result: v21);
      idBounds::FromTransformedBounds(this: &v51, bounds: &v50, origin: (const idVec3 *)(&v52.__vftable + 2), axis: v26);
      v51.b[0].x = v51.b[0].x - (float)10.0;
      v51.b[0].y = v51.b[0].y - (float)10.0;
      v51.b[1].x = v51.b[1].x + (float)10.0;
      v51.b[1].y = v51.b[1].y + (float)10.0;
      v51.b[0].z = (float)(v51.b[0].z - (float)10.0) + (float)15.0;
      v51.b[1].z = (float)(v51.b[1].z + (float)10.0) + (float)15.0;
      idTraceModel::InitBox(this: (idTraceModel *)&v52.gameParmBlock.staticConstants[30].swizzle[2]);
      idTraceModel::SetupBox(this: (idTraceModel *)&v52.gameParmBlock.staticConstants[30].swizzle[2], boxBounds: &v51);
      idTraceModel::operator=(
        this: &this->aiVolatile.death.deathInfo.deathBox,
        __that: (const idTraceModel *)&v52.gameParmBlock.staticConstants[30].swizzle[2]);
      v27 = idEntity::GetPhysics(this);
      v28 = v27->GetAxis(this: v27, a2: 0);
      v29 = idEntity::GetPhysics(this);
      v30 = v29->GetOrigin(this: v29, a2: 0);
      p_deathCollisionQuery->index = *(unsigned __int64 *)&idClip::Clip(
                                                             this: (idClip *)&v52.deferredAxis.mat[0].y,
                                                             result: &clientGame->clip,
                                                             a3: nullptr,
                                                             start: v30,
                                                             trm: &this->aiVolatile.death.deathInfo.deathBox,
                                                             startAxis: v28,
                                                             clipMask: 1,
                                                             passEntityNumber: 0x2000,
                                                             userName: v31,
                                                             a10: v32,
                                                             a11: v33,
                                                             a12: v34,
                                                             a13: v35,
                                                             a14: v36,
                                                             a15: v37,
                                                             a16: v38,
                                                             a17: v39,
                                                             a18: v40,
                                                             a19: v41,
                                                             a20: v42,
                                                             a21: v43,
                                                             a22: v44,
                                                             a23: v45,
                                                             a24: v46,
                                                             a25: v47,
                                                             a26: v48,
                                                             a27: v49,
                                                             a28: (int)"w:\\tech5\\tungsten\\game\\ai\\AI2.cpp(5840) : Clip")->world;
      if ( ai_debugLevel.valueInteger > 0 )
      {
        v50.b[0].x = v50.b[0].x - (float)10.0;
        v50.b[1].x = v50.b[1].x + (float)10.0;
        v50.b[0].y = v50.b[0].y - (float)10.0;
        v50.b[1].y = v50.b[1].y + (float)10.0;
        v50.b[0].z = (float)(v50.b[0].z - (float)10.0) + (float)15.0;
        v50.b[1].z = (float)(v50.b[1].z + (float)10.0) + (float)15.0;
        clientGame->renderWorld->DebugBounds(
          this: clientGame->renderWorld,
          a2: (const idVec4 *)&idColor::colorPurple,
          a3: &v50,
          a4: &vec3_origin,
          a5: 0,
          a6: false);
      }
    }
  }
}


// ========================================================================
// ?GetMeleeDirection@idAI2@@QBA?AW4aiDirection_t@@ABVidVec3@@0AA_N_N@Z
// EA  : 0x829F76B0
// RVA : 0x009F76B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetMeleeDirection(
        idAI2 *this,
        const idVec3 *target,
        const idVec3 *vel,
        bool *outNarrowFront,
        const bool debug)
{
  const idDeclAIBehavior *decl; // r10
  double v10; // fp31
  double v11; // fp30
  double v12; // fp27
  idPhysics *Physics; // r3
  float *v14; // r3
  double v15; // fp29
  double v16; // fp28
  double v17; // fp22
  double v18; // fp24
  double v21; // fp9
  double v22; // fp2
  double v23; // fp27
  double v24; // fp26
  idPhysics *v25; // r3
  float *v26; // r3
  float v27; // r7
  float v28; // r9
  double v30; // fp12
  double v32; // fp9
  double v33; // fp13
  double v34; // fp12
  double v35; // fp31
  double v36; // fp30
  double v37; // fp23
  idAIOrientation *p_orientBody; // r11
  char *v40; // r10
  _DWORD *p_z; // r11
  int i; // ctr
  double v43; // fp0
  double v44; // fp12
  int v45; // r27
  idPhysics *v46; // r31
  idPhysics *v47; // r3
  idPresentable *presentable; // r11
  idPhysics *v49; // r29
  double v50; // fp25
  double v51; // fp21
  double v52; // fp20
  float *v53; // r3
  idPhysics *v54; // r3
  double v55; // fp6
  double v56; // fp5
  idRenderWorld_vtbl *v57; // r29
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  int v59; // r3
  char v60; // r11
  idPhysics *v61; // r29
  idPhysics *v62; // r26
  float *v63; // r3
  double v64; // fp10
  double v65; // fp9
  idRenderWorld_vtbl *v66; // r29
  int v67; // r3
  idColor *v68; // r4
  float *v69; // r6
  idPhysics *v70; // r29
  idPhysics *v71; // r26
  float *v72; // r3
  double v73; // fp10
  double v74; // fp9
  idPhysics *v75; // r3
  float *v76; // r3
  double v77; // fp10
  double v78; // fp9
  float v79[4]; // [sp+60h] [-100h] BYREF
  float v80[4]; // [sp+70h] [-F0h] BYREF
  float v81[4]; // [sp+80h] [-E0h] BYREF
  float v82[3]; // [sp+90h] [-D0h] BYREF
  char v83; // [sp+9Ch] [-C4h] BYREF
  float v84; // [sp+A0h] [-C0h]
  float v85; // [sp+A4h] [-BCh]
  float v86; // [sp+A8h] [-B8h]
  float v87; // [sp+ACh] [-B4h]
  float v88; // [sp+B0h] [-B0h]
  float v89; // [sp+B4h] [-ACh]

  *outNarrowFront = false;
  decl = this->aiEditable.behaviors.decl;
  v10 = (float)(target->x + (float)(vel->x * decl->meleeExtrapolate));
  v11 = (float)(target->y + (float)(vel->y * decl->meleeExtrapolate));
  v12 = (float)(target->z + (float)(vel->z * decl->meleeExtrapolate));
  Physics = idEntity::GetPhysics(this);
  v14 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v15 = (float)((float)v10 - *v14);
  v16 = (float)((float)v11 - v14[1]);
  v17 = (float)((float)v12 - v14[2]);
  v18 = 0.0;
  _FP12 = (float)((float)((float)((float)v16 * (float)v16)
                        + (float)((float)((float)v10 - *v14) * (float)((float)v10 - *v14)))
                - idMath::FLT_SMALLEST_NON_DENORMAL);
  __asm { fsel      f10, f12, f13, f0 }
  v21 = __frsqrte(_FP10);
  v22 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21
                                                                                      * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15))
                                                                                              * (float)0.5))
                                                                              * (float)v21)
                                                                      - (float)1.5)
                                                      * (float)v21)
                                              * (float)((float)((float)((float)v16 * (float)v16)
                                                              + (float)((float)v15 * (float)v15))
                                                      * (float)0.5))
                                      * (float)((float)-(float)((float)((float)((float)v21
                                                                              * (float)((float)((float)((float)v16 * (float)v16)
                                                                                              + (float)((float)v15 * (float)v15))
                                                                                      * (float)0.5))
                                                                      * (float)v21)
                                                              - (float)1.5)
                                              * (float)v21))
                              - (float)1.5)
              * (float)((float)-(float)((float)((float)((float)v21
                                                      * (float)((float)((float)((float)v16 * (float)v16)
                                                                      + (float)((float)v15 * (float)v15))
                                                              * (float)0.5))
                                              * (float)v21)
                                      - (float)1.5)
                      * (float)v21));
  v23 = (float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21 * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5)) * (float)v21) - (float)1.5) * (float)v21)
                                                                                              * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5))
                                                                                      * (float)((float)-(float)((float)((float)((float)v21 * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5)) * (float)v21) - (float)1.5)
                                                                                              * (float)v21))
                                                                              - (float)1.5)
                                                              * (float)((float)-(float)((float)((float)((float)v21 * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5))
                                                                                              * (float)v21)
                                                                                      - (float)1.5)
                                                                      * (float)v21))
                                                      * (float)((float)((float)((float)v16 * (float)v16)
                                                                      + (float)((float)v15 * (float)v15))
                                                              * (float)0.5))
                                              * (float)v22)
                                      - (float)1.5)
                      * (float)v22)
              * (float)v15);
  v24 = (float)((float)v16
              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v21 * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5)) * (float)v21) - (float)1.5) * (float)v21)
                                                                                              * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5))
                                                                                      * (float)((float)-(float)((float)((float)((float)v21 * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5)) * (float)v21) - (float)1.5)
                                                                                              * (float)v21))
                                                                              - (float)1.5)
                                                              * (float)((float)-(float)((float)((float)((float)v21 * (float)((float)((float)((float)v16 * (float)v16) + (float)((float)v15 * (float)v15)) * (float)0.5))
                                                                                              * (float)v21)
                                                                                      - (float)1.5)
                                                                      * (float)v21))
                                                      * (float)((float)((float)((float)v16 * (float)v16)
                                                                      + (float)((float)v15 * (float)v15))
                                                              * (float)0.5))
                                              * (float)v22)
                                      - (float)1.5)
                      * (float)v22));
  v25 = idEntity::GetPhysics(this);
  v26 = (float *)v25->GetOrigin(this: v25, a2: 0);
  v27 = target->y - v26[1];
  v28 = target->z - v26[2];
  _FP1 = (float)((float)((float)((float)(target->x - *v26) * (float)(target->x - *v26))
                       + (float)((float)(v28 * v28) + (float)(v27 * v27)))
               - idMath::FLT_SMALLEST_NON_DENORMAL);
  v30 = (float)((float)((float)((float)(target->x - *v26) * (float)(target->x - *v26))
                      + (float)((float)(v28 * v28) + (float)(v27 * v27)))
              * (float)0.5);
  __asm { fsel      f10, f1, f2, f13 }
  v32 = __frsqrte(_FP10);
  v33 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v32 * (float)v30)
                                                                              * (float)v32)
                                                                      - (float)1.5)
                                                      * (float)v32)
                                              * (float)v30)
                                      * (float)((float)-(float)((float)((float)((float)v32 * (float)v30) * (float)v32)
                                                              - (float)1.5)
                                              * (float)v32))
                              - (float)1.5)
              * (float)((float)-(float)((float)((float)((float)v32 * (float)v30) * (float)v32) - (float)1.5) * (float)v32));
  v34 = (float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v32 * (float)v30)
                                                                                      * (float)v32)
                                                                              - (float)1.5)
                                                              * (float)v32)
                                                      * (float)v30)
                                              * (float)((float)-(float)((float)((float)((float)v32 * (float)v30)
                                                                              * (float)v32)
                                                                      - (float)1.5)
                                                      * (float)v32))
                                      - (float)1.5)
                      * (float)((float)-(float)((float)((float)((float)v32 * (float)v30) * (float)v32) - (float)1.5)
                              * (float)v32))
              * (float)v30);
  v36 = (float)(v27 * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33));
  v37 = (float)(v28 * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33));
  v35 = (float)((float)(target->x - *v26)
              * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33));
  if ( (float)((float)((float)v36 * (float)v36) + (float)((float)v35 * (float)v35)) < 0.89999998 )
    return 0;
  if ( (float)((float)((float)(v28 * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33))
                     * (float)0.0)
             + (float)((float)((float)(v27
                                     * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5)
                                             * (float)v33))
                             * (float)v24)
                     + (float)((float)((float)(target->x - *v26)
                                     * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5)
                                             * (float)v33))
                             * (float)v23))) < -0.5 )
  {
    v23 = (float)((float)(target->x - *v26)
                * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33));
    v24 = (float)(v27 * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33));
    v18 = (float)(v28 * (float)((float)-(float)((float)((float)v34 * (float)v33) - (float)1.5) * (float)v33));
  }
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    p_orientBody = &this->aiVolatile.animation.animFSM.orientBody;
  else
    p_orientBody = &this->aiVolatile.focus.bodyOrientation;
  v40 = &v83;
  p_z = (_DWORD *)&p_orientBody->idealDir.z;
  for ( i = 9; i != 0; --i )
  {
    ++p_z;
    v40 += 4;
    *(_DWORD *)v40 = *p_z;
  }
  v43 = (float)((float)(v88 * (float)v24) + (float)((float)(v87 * (float)v23) + (float)(v89 * (float)v18)));
  v44 = (float)((float)(v84 * (float)v23) + (float)((float)(v86 * (float)v18) + (float)(v85 * (float)v24)));
  if ( v43 < 0.70710677 )
  {
    if ( v43 >= -0.70710677 )
    {
      if ( v44 <= 0.0 )
      {
        v45 = 4;
      }
      else
      {
        v45 = 0;
        if ( v44 > 0.9238795 )
          *outNarrowFront = true;
      }
    }
    else
    {
      v45 = 6;
    }
  }
  else
  {
    v45 = 2;
  }
  if ( debug )
  {
    v46 = idEntity::GetPhysics(this);
    v47 = idEntity::GetPhysics(this);
    presentable = this->presentable;
    v49 = v47;
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
    }
    v50 = (float)(presentable->axis.mat[0].x * (float)200.0);
    v51 = (float)(presentable->axis.mat[0].y * (float)200.0);
    v52 = (float)(presentable->axis.mat[0].z * (float)200.0);
    v53 = (float *)v46->GetOrigin(this: v46, a2: 0);
    v55 = (float)(v53[1] + (float)v51);
    v56 = (float)(*v53 + (float)v50);
    v79[2] = v53[2] + (float)v52;
    v54 = v49;
    v79[0] = v56;
    v79[1] = v55;
    GetOrigin = v49->GetOrigin;
    v57 = clientGame->renderWorld->__vftable;
    v59 = (int)GetOrigin(this: v54, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, idColor *, int, float *, double))v57->DebugArrow)(
      a1: clientGame->renderWorld,
      a2: &idColor::colorGreen,
      a3: v59,
      a4: v79,
      a5: 2.0);
    if ( v23 != v35 || v24 != v36 || (v60 = 1, v18 != v37) )
      v60 = 0;
    if ( v60 != 0 )
    {
      v61 = idEntity::GetPhysics(this);
      v62 = idEntity::GetPhysics(this);
      v63 = (float *)v61->GetOrigin(this: v61, a2: 0);
      v64 = (float)(v63[1] + (float)v16);
      v65 = (float)(*v63 + (float)v15);
      v80[2] = v63[2] + (float)v17;
      v80[1] = v64;
      v80[0] = v65;
      v66 = clientGame->renderWorld->__vftable;
      v67 = (int)v62->GetOrigin(this: v62, a2: 0);
      v68 = &idColor::colorMagenta;
      v69 = v80;
    }
    else
    {
      v70 = idEntity::GetPhysics(this);
      v71 = idEntity::GetPhysics(this);
      v72 = (float *)v70->GetOrigin(this: v70, a2: 0);
      v73 = (float)(v72[2] + (float)v17);
      v74 = (float)(v72[1] + (float)v16);
      v81[0] = *v72 + (float)v15;
      v81[2] = v73;
      v81[1] = v74;
      v66 = clientGame->renderWorld->__vftable;
      v67 = (int)v71->GetOrigin(this: v71, a2: 0);
      v68 = &idColor::colorRed;
      v69 = v81;
    }
    ((void (__fastcall *)(idRenderWorld *, idColor *, int, float *, double))v66->DebugArrow)(
      a1: clientGame->renderWorld,
      a2: v68,
      a3: v67,
      a4: v69,
      a5: 2.0);
    v75 = idEntity::GetPhysics(this);
    v76 = (float *)v75->GetOrigin(this: v75, a2: 0);
    v77 = (float)(v76[1] + (float)v16);
    v78 = (float)((float)v15 + *v76);
    v82[2] = v76[2] + (float)v17;
    v82[1] = v77;
    v82[0] = v78;
    ((void (__fastcall *)(idRenderWorld *, idColor *, const idVec3 *, float *, double))clientGame->renderWorld->DebugArrow)(
      a1: clientGame->renderWorld,
      a2: &idColor::colorOrange,
      a3: target,
      a4: v82,
      a5: 2.0);
  }
  return v45;
}


// ========================================================================
// ?GetMeleeTypeForTarget@idAI2@@QBA?AW4aiMelee_t@@ABVidVec3@@0HH@Z
// EA  : 0x829F7C70
// RVA : 0x009F7C70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetMeleeTypeForTarget(
        idAI2 *this,
        const idVec3 *targetPos,
        const idVec3 *targetVel,
        const int meleeMask,
        const int preferredMask)
{
  int MeleeDirection; // r24
  idPhysics *Physics; // r3
  float *v13; // r3
  bool v14; // r25
  const idDeclAIBehavior *decl; // r31
  double v16; // fp9
  int v17; // r29
  bool v18; // r28
  double v19; // fp31
  idPhysics *v20; // r3
  double movingPainSpeed; // fp30
  float *v22; // r3
  float y; // r10
  float z; // r9
  idPhysics *v25; // r3
  int v26; // r11
  int v27; // r31
  int v28; // r11
  int v29; // r29
  int v30; // r28
  int v31; // r31
  bool v32; // [sp+50h] [-C0h] BYREF
  idVec3 v33; // [sp+58h] [-B8h] BYREF
  idVec3 v34[2]; // [sp+68h] [-A8h] BYREF
  _DWORD v35[8]; // [sp+80h] [-90h] BYREF

  MeleeDirection = idAI2::GetMeleeDirection(this, target: targetPos, vel: targetVel, outNarrowFront: &v32, debug: false);
  if ( MeleeDirection < 8 )
  {
    Physics = idEntity::GetPhysics(this);
    v13 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v14 = v32;
    v16 = (float)(targetPos->y - v13[1]);
    v17 = 0;
    v18 = false;
    v19 = __fsqrts((float)((float)((float)v16 * (float)v16)
                         + (float)((float)(targetPos->x - *v13) * (float)(targetPos->x - *v13))));
    decl = this->aiEditable.behaviors.decl;
    if ( v19 < decl->movingMeleeDist && v19 > (float)(decl->movingMeleeDist * (float)0.5) && v32 )
    {
      v20 = idEntity::GetPhysics(this);
      movingPainSpeed = decl->damageBehaviors.movingPainSpeed;
      v22 = (float *)v20->GetLinearVelocity(this: (idPhysics *)&v33, result: (idVec3 *)v20, a3: 0);
      if ( (float)((float)(*v22 * *v22) + (float)(v22[1] * v22[1])) >= (double)(float)((float)movingPainSpeed
                                                                                     * (float)movingPainSpeed)
        && (float)((float)(targetVel->x * targetVel->x) + (float)(targetVel->y * targetVel->y)) >= (double)(float)(decl->damageBehaviors.movingPainSpeed * decl->damageBehaviors.movingPainSpeed) )
      {
        y = targetVel->y;
        z = targetVel->z;
        v33.x = targetVel->x;
        v33.y = y;
        v33.z = z;
        idVec3::NormalizeFast(this: &v33);
        v25 = idEntity::GetPhysics(this);
        v25->GetLinearVelocity(this: (idPhysics *)v34, result: (idVec3 *)v25, a3: 0);
        idVec3::NormalizeFast(this: v34);
        v18 = (float)((float)(v33.x * v34[0].x) + (float)((float)(v34[0].y * v33.y) + (float)(v34[0].z * v33.z))) > 0.70700002;
      }
    }
    v26 = idActor::IsCrouching(this)
        ? this->aiVolatile.animation.crouchMeleeFlags
        : this->aiVolatile.animation.meleeFlags;
    if ( (v26 & 0x4000) != 0 && v18 && (this->aiVolatile.groupStatus.condition & 8) == 0 )
    {
      v17 = 0x4000;
    }
    else if ( v19 < decl->closeMeleeDist )
    {
      if ( v14 )
        v17 = 32;
      v17 |= 0x2042u;
    }
    if ( v19 < decl->mediumMeleeDist )
      v17 |= 0x80u;
    if ( v19 < decl->longMeleeDist )
      v17 |= 0x100u;
    v35[0] = v17;
    v35[1] = 0;
    v35[3] = 0;
    v35[5] = 0;
    v35[2] = 8;
    v35[4] = 4;
    v35[6] = 16;
    v35[7] = 0;
    v27 = v35[MeleeDirection];
    v28 = idActor::IsCrouching(this)
        ? this->aiVolatile.animation.crouchMeleeFlags
        : this->aiVolatile.animation.meleeFlags;
    v29 = v28 & v27 & meleeMask;
    if ( v29 != 0 )
    {
      if ( (v29 & preferredMask) != 0 )
        v29 &= preferredMask;
      v30 = 1;
      if ( (v29 & 0x62) != 0 )
      {
        v31 = 0;
        if ( (v29 & 0x20) != 0 )
        {
          v30 = 32;
          v31 = 1;
        }
        if ( (v29 & 0x40) != 0 && idRandom2::RandomInt(this: &clientGame->random, max: v31 + 1) == 0 )
        {
          v30 = 64;
          ++v31;
        }
        if ( (v29 & 2) != 0 && idRandom2::RandomInt(this: &clientGame->random, max: v31 + 1) == 0 )
        {
          v30 = 2;
LABEL_45:
          if ( (v29 & 0x2000) != 0
            && ((double (__fastcall *)(idAIHealth *))this->aiHealth.GetBaseHealthRatio_Impl)(a1: &this->aiHealth) < 1.0
            && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
             - this->aiVolatile.memory.lastDamageTime < 2000 )
          {
            return 0x2000;
          }
          return v30;
        }
      }
      else
      {
        if ( (v29 & 0x80) != 0 )
          return 128;
        if ( (v29 & 0x100) != 0 )
          return 256;
        v30 = v29;
      }
      if ( v30 == 2 )
        goto LABEL_45;
      return v30;
    }
  }
  return 1;
}


// ========================================================================
// ?GetDirectionTo@idAI2@@QBA?AW4aiDirection_t@@ABVidVec3@@@Z
// EA  : 0x829F80A8
// RVA : 0x009F80A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

aiDirection_t __fastcall idAI2::GetDirectionTo(idAI2 *this, const idVec3 *pos)
{
  idPhysics *Physics; // r3
  float *v5; // r3
  double v6; // fp7
  double v9; // fp12
  double v10; // fp2
  double v11; // fp30
  double v12; // fp29
  double v13; // fp28
  idAIOrientation *p_orientBody; // r11
  float y; // r8
  float z; // r7
  float x; // r6
  float v18; // r5
  float v19; // r4
  idPhysics *v20; // r3
  const idVec3 *v21; // r3
  idPhysics *v22; // r3
  const idVec3 *v23; // r3
  double v24; // fp0
  double v25; // fp12
  aiDirection_t result; // r3
  double v27; // fp13
  idVec3 v28; // [sp+50h] [-60h] BYREF
  idVec3 v29; // [sp+60h] [-50h] BYREF

  Physics = idEntity::GetPhysics(this);
  v5 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v6 = (float)(pos->y - v5[1]);
  _FP2 = (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5)))
               - idMath::FLT_SMALLEST_NON_DENORMAL);
  __asm { fsel      f13, f2, f3, f13 }
  v9 = __frsqrte(_FP13);
  v10 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v9
                                                                                      * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5)))
                                                                                              * (float)0.5))
                                                                              * (float)v9)
                                                                      - (float)1.5)
                                                      * (float)v9)
                                              * (float)((float)((float)((float)v6 * (float)v6)
                                                              + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5)))
                                                      * (float)0.5))
                                      * (float)((float)-(float)((float)((float)((float)v9
                                                                              * (float)((float)((float)((float)v6 * (float)v6)
                                                                                              + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5)))
                                                                                      * (float)0.5))
                                                                      * (float)v9)
                                                              - (float)1.5)
                                              * (float)v9))
                              - (float)1.5)
              * (float)((float)-(float)((float)((float)((float)v9
                                                      * (float)((float)((float)((float)v6 * (float)v6)
                                                                      + (float)((float)(pos->x - *v5)
                                                                              * (float)(pos->x - *v5)))
                                                              * (float)0.5))
                                              * (float)v9)
                                      - (float)1.5)
                      * (float)v9));
  v11 = (float)((float)(pos->x - *v5)
              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5)) * (float)v9) - (float)1.5) * (float)v9)
                                                                                              * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5))
                                                                                      * (float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5)) * (float)v9) - (float)1.5)
                                                                                              * (float)v9))
                                                                              - (float)1.5)
                                                              * (float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5))
                                                                                              * (float)v9)
                                                                                      - (float)1.5)
                                                                      * (float)v9))
                                                      * (float)((float)((float)((float)v6 * (float)v6)
                                                                      + (float)((float)(pos->x - *v5)
                                                                              * (float)(pos->x - *v5)))
                                                              * (float)0.5))
                                              * (float)v10)
                                      - (float)1.5)
                      * (float)v10));
  v12 = (float)((float)v6
              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5)) * (float)v9) - (float)1.5) * (float)v9)
                                                                                              * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5))
                                                                                      * (float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5)) * (float)v9) - (float)1.5)
                                                                                              * (float)v9))
                                                                              - (float)1.5)
                                                              * (float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5))
                                                                                              * (float)v9)
                                                                                      - (float)1.5)
                                                                      * (float)v9))
                                                      * (float)((float)((float)((float)v6 * (float)v6)
                                                                      + (float)((float)(pos->x - *v5)
                                                                              * (float)(pos->x - *v5)))
                                                              * (float)0.5))
                                              * (float)v10)
                                      - (float)1.5)
                      * (float)v10));
  v13 = (float)((float)(pos->z - v5[2])
              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5)) * (float)v9) - (float)1.5) * (float)v9)
                                                                                              * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5))
                                                                                      * (float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5)) * (float)v9) - (float)1.5)
                                                                                              * (float)v9))
                                                                              - (float)1.5)
                                                              * (float)((float)-(float)((float)((float)((float)v9 * (float)((float)((float)((float)v6 * (float)v6) + (float)((float)(pos->x - *v5) * (float)(pos->x - *v5))) * (float)0.5))
                                                                                              * (float)v9)
                                                                                      - (float)1.5)
                                                                      * (float)v9))
                                                      * (float)((float)((float)((float)v6 * (float)v6)
                                                                      + (float)((float)(pos->x - *v5)
                                                                              * (float)(pos->x - *v5)))
                                                              * (float)0.5))
                                              * (float)v10)
                                      - (float)1.5)
                      * (float)v10));
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    p_orientBody = &this->aiVolatile.animation.animFSM.orientBody;
  else
    p_orientBody = &this->aiVolatile.focus.bodyOrientation;
  y = p_orientBody->axis.mat[0].y;
  z = p_orientBody->axis.mat[0].z;
  x = p_orientBody->axis.mat[1].x;
  v18 = p_orientBody->axis.mat[1].y;
  v19 = p_orientBody->axis.mat[1].z;
  v28.x = p_orientBody->axis.mat[0].x;
  v28.y = y;
  v28.z = z;
  v29.x = x;
  v29.y = v18;
  v29.z = v19;
  v20 = idEntity::GetPhysics(this);
  v21 = v20->GetGravityNormal(this: v20);
  idVec3::ProjectOntoPlane(this: &v28, normal: v21, overBounce: 1.0);
  v22 = idEntity::GetPhysics(this);
  v23 = v22->GetGravityNormal(this: v22);
  idVec3::ProjectOntoPlane(this: &v29, normal: v23, overBounce: 1.0);
  v24 = (float)((float)((float)v11 * v28.x) + (float)((float)(v28.z * (float)v13) + (float)(v28.y * (float)v12)));
  v25 = (float)((float)(v29.x * (float)v11) + (float)((float)(v29.y * (float)v12) + (float)(v29.z * (float)v13)));
  if ( v24 >= 0.0 )
  {
    if ( v24 > 0.9238795 )
      return AIDIR_FRONT;
    if ( v25 > 0.0 )
    {
      if ( v24 > 0.3826834 )
        return AIDIR_FRONT_LEFT;
      return AIDIR_LEFT;
    }
    if ( v24 > 0.3826834 )
      return AIDIR_FRONT_RIGHT;
    return AIDIR_RIGHT;
  }
  if ( v24 < -0.9238795 )
    return AIDIR_BEHIND;
  v27 = -0.3826834;
  if ( v25 <= 0.0 )
  {
    result = AIDIR_BEHIND_RIGHT;
    if ( v24 > v27 )
      return result;
    return AIDIR_RIGHT;
  }
  if ( v24 >= v27 )
    return AIDIR_LEFT;
  return AIDIR_BEHIND_LEFT;
}


// ========================================================================
// ?IsFacingMe@idAI2@@QBA_NPBVidEntity@@M@Z
// EA  : 0x829F8318
// RVA : 0x009F8318
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::IsFacingMe(idAI2 *this, const idEntity *entity, double dotThreshold)
{
  idAIEntityState *v6; // r3
  aiSenseState_t *v7; // r31
  idPhysics *Physics; // r30
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r29
  float *v10; // r3
  double v11; // fp7
  double v12; // fp6
  const aiPhysicalState_t *v13; // r3
  double x; // fp4
  float z; // r6
  float y; // r5
  double v17; // fp11
  idVec3 v19; // [sp+50h] [-40h] BYREF

  v6 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: entity);
  if ( entity == nullptr )
    return false;
  if ( v6 == nullptr )
    return false;
  v7 = v6->senses.ptr[1];
  if ( v7->lastUnconfirmedStimTime < 0 )
    return false;
  Physics = idEntity::GetPhysics(this);
  ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: v7);
  v10 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v11 = (float)(v10[1] - ConfirmedPhysicalSafe->origin.y);
  v12 = (float)(v10[2] - ConfirmedPhysicalSafe->origin.z);
  v19.x = *v10 - ConfirmedPhysicalSafe->origin.x;
  v19.y = v11;
  v19.z = v12;
  idVec3::NormalizeFast(this: &v19);
  v13 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v7);
  x = v19.x;
  z = v13->viewfwd.z;
  y = v13->viewfwd.y;
  v19.x = v13->viewfwd.x;
  v17 = (float)((float)(z * v19.z) + (float)((float)(v19.x * (float)x) + (float)(y * v19.y)));
  v19.z = z;
  v19.y = y;
  return v17 > dotThreshold;
}


// ========================================================================
// ?AmIToEntitysLeft@idAI2@@QBA_NPBVidEntity@@@Z
// EA  : 0x829F8440
// RVA : 0x009F8440
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::AmIToEntitysLeft(idAI2 *this, const idEntity *entity)
{
  idAIEntityState *v4; // r3
  idAIEntityState *v5; // r11
  int lastSense; // r10
  idAI2 *v7; // r3
  aiSenseState_t *v8; // r31
  idPhysics *Physics; // r30
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r29
  float *v11; // r3
  double v12; // fp31
  double v13; // fp30
  const aiPhysicalState_t *v14; // r3

  v4 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: entity);
  v5 = v4;
  if ( entity == nullptr || v4 == nullptr )
    return false;
  lastSense = v4->lastSense;
  v7 = this;
  v8 = v5->senses.ptr[lastSense];
  Physics = idEntity::GetPhysics(this: v7);
  ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: v8);
  v11 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v12 = (float)(*v11 - ConfirmedPhysicalSafe->origin.x);
  v13 = (float)(v11[1] - ConfirmedPhysicalSafe->origin.y);
  v14 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v8);
  return (float)((float)(v14->viewfwd.y * (float)v12) - (float)(v14->viewfwd.x * (float)v13)) > 0.0;
}


// ========================================================================
// ?StartReloading@idAI2@@QAA_NPAVidAIFSM@@PAVidAIState@@HW4equipSlot_t@@@Z
// EA  : 0x829F8548
// RVA : 0x009F8548
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::StartReloading(
        idAI2 *this,
        idEventArg *fsm,
        idAIState *state,
        const int curTime,
        equipSlot_t reloadSlot)
{
  idInventoryCollection *v9; // r25
  const idDeclAmmo *NextLoadableAmmo; // r28
  equipSlot_t v11; // r27
  double v12; // fp31
  idWeapon *v13; // r3
  idWeapon *v14; // r30
  const idAmmoItem *v15; // r29
  const idDeclAmmo *v16; // r31
  __int64 v17; // r11
  double v18; // fp30
  __int64 v19; // r9
  idWeapon *EquippedWeapon; // r3
  idWeapon *v22; // r31
  const idAmmoItem *ammoClip; // r30
  const idDeclAmmo *decl; // r11
  idEventArg *v25; // r29
  _BYTE v26[20]; // [sp+70h] [-110h] BYREF
  __int64 v27; // [sp+90h] [-F0h]
  __int64 v28; // [sp+98h] [-E8h]
  _DWORD v29[5]; // [sp+A0h] [-E0h] BYREF
  int v30; // [sp+C0h] [-C0h]
  equipSlot_t v31; // [sp+C4h] [-BCh]
  idEventArg v32; // [sp+E0h] [-A0h] BYREF
  idEventReceiver v33[2]; // [sp+100h] [-80h] BYREF

  v9 = this->GetInventory_2(this);
  NextLoadableAmmo = nullptr;
  if ( reloadSlot != EQUIP_NONE )
  {
    EquippedWeapon = idActor::GetEquippedWeapon(this, slot: reloadSlot);
    v22 = EquippedWeapon;
    if ( EquippedWeapon == nullptr )
    {
      idLib::Warning(
        fmt: "idAI2::StartReloading - slot '%s' has not weapon",
        idDeclInventory::equipSlotTagNames[reloadSlot]);
      return 0;
    }
    ammoClip = EquippedWeapon->ammoClip;
    if ( ammoClip != nullptr )
      decl = (const idDeclAmmo *)ammoClip->decl;
    else
      decl = nullptr;
    NextLoadableAmmo = decl;
    if ( decl == nullptr
      || !idWeapon::CanReload(this: EquippedWeapon, inventory: v9, ammoDecl: decl, secondaryAmmo: false) )
    {
      NextLoadableAmmo = idWeapon::FindNextLoadableAmmo(
                           this: v22,
                           inventory: v9,
                           curAmmo: ammoClip,
                           secondaryAmmo: false);
      if ( NextLoadableAmmo == nullptr )
      {
        idLib::Warning(
          fmt: "idAI2::StartReloading - slot '%s', weapon '%s' can't reload",
          idDeclInventory::equipSlotTagNames[reloadSlot],
          v22->decl->name.str);
        return 0;
      }
    }
  }
  else
  {
    v11 = EQUIP_NONE;
    v12 = 3.4028235e38;
    do
    {
      v13 = idActor::GetEquippedWeapon(this, slot: v11);
      v14 = v13;
      if ( v13 != nullptr )
      {
        v15 = v13->ammoClip;
        v16 = v15 != nullptr ? (const idDeclAmmo *)v15->decl : nullptr;
        if ( v16 != nullptr && idWeapon::CanReload(this: v13, inventory: v9, ammoDecl: v16, secondaryAmmo: false)
          || (v16 = idWeapon::FindNextLoadableAmmo(this: v14, inventory: v9, curAmmo: v15, secondaryAmmo: false)) != nullptr )
        {
          LODWORD(v17) = idWeapon::AmmoInClip(this: v14, secondaryAmmo: false);
          HIDWORD(v17) = *((unsigned __int8 *)v14 + 452);
          v27 = v17;
          v18 = (float)v17;
          LODWORD(v19) = idDeclWeapon::GetClipSize(
                           this: (idDeclWeapon *)v14->decl,
                           ammoDecl: v16,
                           weaponUpgraded: (v17 & 0x400000000LL) != 0,
                           secondary: false);
          v28 = v19;
          if ( (float)((float)v18 / (float)v19) < v12 )
          {
            v12 = (float)((float)v18 / (float)v19);
            reloadSlot = v11;
            NextLoadableAmmo = v16;
          }
        }
      }
      ++v11;
    }
    while ( v11 < EQUIP_MAX );
    if ( reloadSlot == EQUIP_NONE )
    {
      idLib::Warning(fmt: "idAI2::StartReloading - no weapons need reloading");
      return 0;
    }
  }
  idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
  LODWORD(fsm[1].value.v[2]) = state;
  v29[1] = NextLoadableAmmo;
  v31 = reloadSlot;
  HIBYTE(v29[0]) = 100;
  HIBYTE(v30) = 105;
  v25 = idEventArg::idEventArg(this: &v32, data: this);
  memcpy(Dst: v26, Src: v29, Size: sizeof(v26));
  idEventReceiver::ProcessEvent(
    this: v33,
    result: fsm,
    ev: *(const idEventDef **)&v25->type,
    arg1: (const idEventArg *)LODWORD(v25->value.v[1]),
    arg2: (const idEventArg *)LODWORD(v25->value.v[2]),
    arg3: (const idEventArg *)__ROL4__(v30, 32));
  return 1;
}


// ========================================================================
// ?GetTalkState@idAI2@@QBA?AW4talkState_t@@PBVidEntity@@@Z
// EA  : 0x829F8828
// RVA : 0x009F8828
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetTalkState(idAI2 *this, idPlayer *activator)
{
  idPlayer *v5; // r30

  if ( (unsigned __int8)Get_idCombatStage_useRelaxedChatterVO(ptr: this) == 0
    && idAI2::GetCurrentPlayerInteraction(this) != nullptr
    && (idAI2::GetCurrentPlayerInteraction(this)->interactionJob != nullptr
     || idAI2::GetCurrentPlayerInteraction(this)->messageVO != nullptr
     || idAI2::GetCurrentPlayerInteraction(this)->messageTriggerEnt.len != 0
     || (v5 = idPlayer::CastTo(c: activator), (unsigned __int8)idAI2::EverHasGoodsToSell(this, player: v5) != 0)
     || v5 != nullptr && idJobManager::FindCompletedJob(this: &v5->jobManager, completionNPC: this) != nullptr) )
  {
    return 2;
  }
  else
  {
    return 0;
  }
}


// ========================================================================
// ?GetTakedownName@idAI2@@QAAXABV?$idList@VidStr@@$04@@AAVidStr@@@Z
// EA  : 0x829F8908
// RVA : 0x009F8908
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetTakedownName(idAI2 *this, const idList<idStr,5> *tdList, idStr *takedownName)
{
  int num; // r11
  char v5; // r28
  int valueInteger; // r10
  int v7; // r11
  char v8; // r6
  idStr *v9; // r29
  size_t len; // r30
  idStr *v11; // r29

  num = tdList->num;
  v5 = 0;
  if ( num > 0 )
  {
    valueInteger = takedownID.valueInteger;
    if ( takedownID.valueInteger <= -1 )
    {
      v5 = 1;
      v11 = &tdList->list[idRandom2::RandomInt(this: &clientGame->random, max: num - 1)];
      len = v11->len;
      idStr::EnsureAlloced(this: takedownName, amount: v11->len + 1, keepold: false, geometricGrowth: false);
      memcpy(Dst: takedownName->data, Src: v11->data, Size: len);
      takedownName->data[len] = 0;
    }
    else
    {
      v8 = ((num ^ takedownID.valueInteger) >= 0) + (takedownID.valueInteger >= (unsigned int)num);
      v7 = num - 1;
      v5 = v8 & 1;
      if ( takedownID.valueInteger >= v7 )
        valueInteger = v7;
      v9 = &tdList->list[valueInteger];
      len = v9->len;
      idStr::EnsureAlloced(this: takedownName, amount: v9->len + 1, keepold: false, geometricGrowth: false);
      memcpy(Dst: takedownName->data, Src: v9->data, Size: len);
      takedownName->data[len] = 0;
    }
    takedownName->len = len;
  }
  if ( v5 == 0 )
    idLib::Printf(fmt: " invalid takedown ID \n");
}


// ========================================================================
// ?GetUsableState@idAI2@@UBA?AW4usableState_t@@PBVidEntity@@ABVidFocusTrace@@@Z
// EA  : 0x829F8A20
// RVA : 0x009F8A20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::GetUsableState(idAI2 *this, idPlayer *activator, const idFocusTrace *ft)
{
  const idAlertCycle_Passified *curState; // r29
  idInventoryCollection *v8; // r3
  idFaction *v9; // r29
  const idFaction *v10; // r3

  curState = (const idAlertCycle_Passified *)this->aiVolatile.fsms.fsmManager.FindFSM(
                                               this: &this->aiVolatile.fsms,
                                               a2: &idAlertCycleFSM::Type)->curState;
  if ( this->disassembleLoot.lootBoxes.num > 0 )
    return 12;
  if ( this->IsDead(this) && !this->IsDying(this) || (*((_BYTE *)&this->aiVolatile.death + 1761) & 0x40) != 0 )
  {
    if ( idActor::IsLootable(this) && (!this->looted || idActor::HasLootableItems(this)) )
      return 2;
    return 0;
  }
  if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 87) & 0x80) != 0
    && idAlertCycle_Passified::CastTo(c: curState) != nullptr )
  {
    v8 = (idInventoryCollection *)this->GetInventory(this);
    if ( idInventoryCollection::FindInventoryItemByName(this: v8, internalName: "mutant_tag") == nullptr )
      return 6;
    return 0;
  }
  v9 = (idFaction *)this->GetFaction_2(this);
  v10 = activator->GetFaction_2(this: activator);
  if ( idFaction::GetAttitudeTowards(this: v9, otherFaction: v10) < ATTITUDE_NEUTRAL
    || this->aiVolatile.aiPlayerInteraction.decl == nullptr )
  {
    return 0;
  }
  if ( ft->distance <= ((double (__fastcall *)(idAI2 *))this->GetUsableDistance)(a1: this)
    && this->aiVolatile.memory.interactionIsUsable
    && idAI2::GetTalkState(this, activator) >= 2 )
  {
    return 4;
  }
  else
  {
    return 5;
  }
}


// ========================================================================
// ?GetOnlineUsableState@idAI2@@UBA?AW4usableState_t@@XZ
// EA  : 0x829F8C18
// RVA : 0x009F8C18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

usableState_t __fastcall idAI2::GetOnlineUsableState(idAI2 *this)
{
  const idAlertCycle_Passified *curState; // r30
  usableState_t result; // r3
  int deathTime; // r31
  int v5; // r30
  idInventoryCollection *v6; // r3
  bool v7; // zf

  curState = (const idAlertCycle_Passified *)this->aiVolatile.fsms.fsmManager.FindFSM(
                                               this: &this->aiVolatile.fsms,
                                               a2: &idAlertCycleFSM::Type)->curState;
  if ( this->disassembleLoot.lootBoxes.num > 0 )
    return USABLE_DISASSEMBLE;
  if ( this->IsDead(this) )
  {
    if ( idActor::IsLootable(this) && (!this->looted || idActor::HasLootableItems(this)) )
    {
      deathTime = this->aiVolatile.death.deathTime;
      v5 = (int)(float)(ai_lootDelay.valueFloat * (float)1000.0);
      if ( gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) > v5 + deathTime )
        return USABLE_LOOT;
    }
  }
  else if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 87) & 0x80) != 0
         && idAlertCycle_Passified::CastTo(c: curState) != nullptr )
  {
    v6 = (idInventoryCollection *)this->GetInventory(this);
    v7 = idInventoryCollection::FindInventoryItemByName(this: v6, internalName: "mutant_tag") == nullptr;
    result = USABLE_AI_TAGGABLE;
    if ( v7 )
      return result;
  }
  return USABLE_NOT_USABLE;
}


// ========================================================================
// ?IsCrosshairSubdued@idAI2@@UBA_NPBVidEntity@@ABVidFocusTrace@@W4usableState_t@@@Z
// EA  : 0x829F8D80
// RVA : 0x009F8D80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsCrosshairSubdued(
        idAI2 *this,
        idPlayer *activator,
        const idFocusTrace *ft,
        const usableState_t usable)
{
  int result; // r3
  double v7; // fp1

  if ( usable != USABLE_AI_TALK && usable != USABLE_AI_TOWN )
    return 0;
  if ( idAI2::GetTalkState(this, activator) < 2 )
    return 1;
  v7 = ((double (__fastcall *)(idAI2 *))this->GetUsableDistance)(a1: this);
  result = 1;
  if ( ft->distance <= v7 )
    return 0;
  return result;
}


// ========================================================================
// ?ShouldAddConditionalGoodList@idAI2@@QBA_NPBVidPlayer@@H@Z
// EA  : 0x829F8E08
// RVA : 0x009F8E08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ShouldAddConditionalGoodList(idAI2 *this, const idPlayer *player, int index)
{
  idAIEditable::idConditionalMerchantInventoryDef *v3; // r30
  BOOL result; // r3
  int v7; // r31
  int v8; // r29

  v3 = &this->aiEditable.interactions.conditionalMerchantInventory.list[index];
  if ( v3->listGiven )
    return false;
  result = idAI2::PassMerchantTestCondition(this, merchcondition: &v3->merchantTestCondition, player);
  v7 = 0;
  if ( v3->additionalMerchantConditions.num > 0 )
  {
    v8 = 0;
    do
    {
      if ( !result )
        break;
      result = idAI2::PassMerchantTestCondition(
                 this,
                 merchcondition: &v3->additionalMerchantConditions.list[v8],
                 player);
      ++v7;
      ++v8;
    }
    while ( v7 < v3->additionalMerchantConditions.num );
  }
  return result;
}


// ========================================================================
// ?IsMerchant@idAI2@@QBA_NPBVidPlayer@@@Z
// EA  : 0x829F8EA0
// RVA : 0x009F8EA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsMerchant(idAI2 *this, idPlayer *player)
{
  const idFaction *v4; // r29
  idFaction *v5; // r3
  const aiPlayerInteraction_t *CurrentPlayerInteraction; // r3
  int result; // r3
  bool v8; // zf

  v4 = player->GetFaction_2(this: player);
  v5 = (idFaction *)this->GetFaction_2(this);
  if ( idFaction::GetAttitudeTowards(this: v5, otherFaction: v4) < ATTITUDE_NEUTRAL )
    return 0;
  CurrentPlayerInteraction = idAI2::GetCurrentPlayerInteraction(this);
  if ( CurrentPlayerInteraction != nullptr && CurrentPlayerInteraction->forceNoMerchant )
    return 0;
  if ( idAI2::GetTalkState(this, activator: player) < 2 )
    return 0;
  v8 = (unsigned __int8)idAI2::EverHasGoodsToSell(this, player) != 0;
  result = 1;
  if ( !v8 )
    return 0;
  return result;
}


// ========================================================================
// ?SetAnimWebEvent@idAI2@@QAAXW4aiAnimWeb_t@@W4priority_t@idAnimWebEvent@@V?$idIndex@FW4invalidSubWebIndex_t@idDeclAnimWeb@@@@V?$idIndex@FW4invalidStateIndex_t@idDeclAnimWeb@@@@W4animWebEvent_t@@ABVidEventDef@@@Z
// EA  : 0x829F8F48
// RVA : 0x009F8F48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetAnimWebEvent(
        idAI2 *this,
        const aiAnimWeb_t web,
        idAnimWebEvent::priority_t priority,
        const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *swi,
        const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *si,
        animWebEvent_t eventType,
        const idEventDef *eventDef)
{
  idAnimator_AnimWeb::SetEvent(
    this: &this->aiVolatile.animation.animWebAnimator.ptr[web],
    eventType,
    subWebIndex: swi,
    stateIndex: si,
    eventDef,
    priority);
}


// ========================================================================
// ?ClearAnimWebEvent@idAI2@@QAAXW4aiAnimWeb_t@@W4priority_t@idAnimWebEvent@@W4animWebEvent_t@@@Z
// EA  : 0x829F8FA0
// RVA : 0x009F8FA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearAnimWebEvent(
        idAI2 *this,
        const aiAnimWeb_t web,
        const idAnimWebEvent::priority_t priority,
        animWebEvent_t eventType)
{
  idAnimator_AnimWeb::ClearEvent(this: &this->aiVolatile.animation.animWebAnimator.ptr[web], eventType);
}


// ========================================================================
// ?ClearAllAnimWebEvents@idAI2@@QAAXW4aiAnimWeb_t@@W4priority_t@idAnimWebEvent@@@Z
// EA  : 0x829F8FB8
// RVA : 0x009F8FB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearAllAnimWebEvents(
        idAI2 *this,
        const aiAnimWeb_t web,
        const idAnimWebEvent::priority_t priority)
{
  idAnimator_AnimWeb::ClearEvents(this: &this->aiVolatile.animation.animWebAnimator.ptr[web]);
}


// ========================================================================
// ?ClearWaitForOverrideAnim@idAI2@@QAAXW4priority_t@idAnimWebEvent@@@Z
// EA  : 0x829F8FD0
// RVA : 0x009F8FD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearWaitForOverrideAnim(idAI2 *this, const idAnimWebEvent::priority_t priority)
{
  idAnimator_AnimWeb::ClearEvent(
    this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
    eventType: ANIMWEB_EVENT_START_BLEND_IN);
}


// ========================================================================
// ?AnimEventReceived@idAI2@@QBA_NW4priority_t@idAnimWebEvent@@@Z
// EA  : 0x829F8FE0
// RVA : 0x009F8FE0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::AnimEventReceived(idAI2 *this, const idAnimWebEvent::priority_t priority)
{
  return (_cntlzw(idAnimator_AnimWeb::IsAnyEventPending(this: (idAnimator_AnimWeb *)&this->aiVolatile.animation)) & 0x20) != 0;
}


// ========================================================================
// ?WaitForOverrideAnim@idAI2@@QAA_NW4priority_t@idAnimWebEvent@@W4overrideAnim_t@@W4animWebEvent_t@@_N@Z
// EA  : 0x829F9020
// RVA : 0x009F9020
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::WaitForOverrideAnim(
        idAI2 *this,
        idAnimWebEvent::priority_t priority,
        const overrideAnim_t ot,
        animWebEvent_t ev,
        bool force)
{
  overrideWebInfo_t *v9; // r27
  idAIAnimWebState_Current *v10; // r3
  idAnimWebState *v11; // r11
  idList<idDeclAnimWeb::idStateInfo,32> *p_states; // r10
  idDeclAnimWeb::idStateInfo **p_debugState; // r11
  int i; // ctr
  aiSubWeb_t destSubWeb; // r10
  const char *destStateName; // r6
  idAIMemory::aiMemoryAnimAfterOverride animAfterOverride; // r11
  idAIAnimWebState *v18; // r3
  idAnimWebState *v19; // r11
  idList<idDeclAnimWeb::idStateInfo,32> *v20; // r10
  idDeclAnimWeb::idStateInfo **v21; // r11
  int k; // ctr
  idAnimWebState *v23; // r3
  idList<idDeclAnimWeb::idStateInfo,32> *v24; // r10
  idAtomicString *v25; // r11
  int j; // ctr
  idAIAnimWebState *v27; // r3
  idAnimWebState *v28; // r11
  idList<idDeclAnimWebEdge,32> *p_edges; // r10
  idDeclAnimWebEdge **v30; // r11
  int m; // ctr
  idAnimWebCmdCtx *v32; // r3
  idAnimWebCmd *v33; // r3
  idAnimWebCmd *v34; // r3
  aiSubWeb_t v36; // r4
  idAIMemory::aiMemoryAnimAfterOverride v37; // r11
  __int16 v38; // r11
  idStr *p_num; // r3
  awPathResult_t v40; // r3
  idDeclAnimWebNode *v41; // r3
  const idDeclAnimWebNode::idModelInfo *v42; // r3
  __int64 v43; // r10
  unsigned __int16 v44; // [sp+50h] [-220h] BYREF
  unsigned __int16 v45; // [sp+52h] [-21Eh] BYREF
  idDeclAnimWeb v46; // [sp+54h] [-21Ch] BYREF
  idAnimWebCmd v47; // [sp+170h] [-100h] BYREF

  v9 = &overrideWebInfo[ot];
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
  {
    v10 = idAIAnimWebState_Current::idAIAnimWebState_Current(
            this: (idAIAnimWebState_Current *)&v46.edgeIndexCacheSize,
            ai: this);
    v11 = &v10->idAnimWebState;
    if ( v10 == nullptr )
      v11 = nullptr;
    p_states = &v46.states;
    p_debugState = (idDeclAnimWeb::idStateInfo **)&v11[-1].debugState;
    for ( i = 5; i != 0; --i )
    {
      ++p_debugState;
      p_states = (idList<idDeclAnimWeb::idStateInfo,32> *)((char *)p_states + 4);
      p_states->list = *p_debugState;
    }
    destSubWeb = v9->destSubWeb;
    v46.edgeIndexCacheSize = (unsigned int)&idAIAnimWebState::`vftable';
    if ( destSubWeb == AISUBWEB_MAX )
    {
      v23 = idAnimWebState::AsState(
              this: (idAnimWebState *)&v46.settings.showAbbreviatedNodeProps,
              result: (idAnimWebState *)&v46.states.num,
              state: v9->destStateName);
      v24 = &v46.states;
      v25 = &v23[-1].debugState;
      for ( j = 5; j != 0; --j )
      {
        ++v25;
        v24 = (idList<idDeclAnimWeb::idStateInfo,32> *)((char *)v24 + 4);
        v24->list = (idDeclAnimWeb::idStateInfo *)v25->str;
      }
    }
    else
    {
      destStateName = v9->destStateName;
      animAfterOverride = this->aiVolatile.memory.animAfterOverride;
      if ( animAfterOverride != AIMEMORY_ANIMAFTER_OVERRIDE_DEFAULT )
      {
        if ( animAfterOverride == AIMEMORY_ANIMAFTER_OVERRIDE_IDLE )
        {
          destStateName = "idle";
        }
        else if ( (unsigned int)animAfterOverride < (AIMEMORY_ANIMAFTER_OVERRIDE_RUN|AIMEMORY_ANIMAFTER_OVERRIDE_IDLE) )
        {
          destStateName = "run";
        }
      }
      this->aiVolatile.memory.animAfterOverride = AIMEMORY_ANIMAFTER_OVERRIDE_DEFAULT;
      v18 = idAIAnimWebState::idAIAnimWebState(
              this: (idAIAnimWebState *)&v46.editorModels.num,
              ai: this,
              subweb: v9->destSubWeb,
              stateName: destStateName);
      v19 = &v18->idAnimWebState;
      if ( v18 == nullptr )
        v19 = nullptr;
      v20 = &v46.states;
      v21 = (idDeclAnimWeb::idStateInfo **)&v19[-1].debugState;
      for ( k = 5; k != 0; --k )
      {
        ++v21;
        v20 = (idList<idDeclAnimWeb::idStateInfo,32> *)((char *)v20 + 4);
        v20->list = *v21;
      }
      v46.editorModels.num = (int)&idAIAnimWebState::`vftable';
    }
    v27 = idAIAnimWebState::idAIAnimWebState(
            this: (idAIAnimWebState *)&v46.nodeCache.num,
            ai: this,
            subweb: v9->subWeb,
            stateName: v9->stateName);
    v28 = &v27->idAnimWebState;
    if ( v27 == nullptr )
      v28 = nullptr;
    p_edges = &v46.edges;
    v30 = (idDeclAnimWebEdge **)&v28[-1].debugState;
    for ( m = 5; m != 0; --m )
    {
      ++v30;
      p_edges = (idList<idDeclAnimWebEdge,32> *)((char *)p_edges + 4);
      p_edges->list = *v30;
    }
    v46.nodeCache.num = (int)&idAIAnimWebState::`vftable';
    v32 = this->GetAnimWebCmdCtx(this);
    idAnimWebCmd::idAnimWebCmd(
      this: &v47,
      _owner: v32,
      userName: "w:\\tech5\\tungsten\\game\\ai\\AI2.cpp(9863) : WaitForOverrideAnim");
    v33 = idAnimWebCmd::ChangeState(this: &v47, _dst: (const idAnimWebState *)&v46.states.num);
    v34 = idAnimWebCmd::Via(this: v33, _via: (const idAnimWebState *)&v46.edges.num, optional: false);
    v34->groupFilter = 8193;
    v34->groups = 0x80000000;
    if ( force )
      idAnimWebCmd::Force(this: &v47, blendFrames: 3, originBlend: ORIGINBLEND_BRANCH);
    return (_cntlzw(idAnimWebCmd::Commit(this: &v47, priority: AWCMD_PRIORITY_HIGH, ev: AWCMD_EVENT_DEST_BLEND_END))
          & 0x20) != 0;
  }
  idAnimator_AnimWeb::GetCurSubWebIndex(
    this: (idAnimator_AnimWeb *)&v45,
    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)&this->aiVolatile.animation);
  idAnimator_AnimWeb::GetCurStateIndex(
    this: (idAnimator_AnimWeb *)&v44,
    result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)&this->aiVolatile.animation);
  v36 = v9->destSubWeb;
  if ( v36 != AISUBWEB_MAX )
  {
    *(_DWORD *)&v46.nodes.granularity = 20;
    v46.nodes.num = 0;
    v46.nodes.size = (int)&v46.subWebs;
    HIBYTE(v46.subWebs.list) = 0;
    idAI2::GetSubWebPrefix(this, swt: v36, subWebPrefix: (idStr *)&v46.nodes.num);
    v45 = HIWORD(idDeclAnimWeb::GetSubWebIndexForName(
                   this: (idDeclAnimWeb *)((char *)&v46.trackedMemory + 2),
                   result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                   subWebName: (const char *)v46.nodes.size)->__vftable);
    v37 = this->aiVolatile.memory.animAfterOverride;
    if ( v37 != AIMEMORY_ANIMAFTER_OVERRIDE_DEFAULT )
    {
      if ( v37 == AIMEMORY_ANIMAFTER_OVERRIDE_IDLE )
      {
        v44 = HIWORD(idDeclAnimWeb::GetStateIndexForName(
                       this: (idDeclAnimWeb *)&v46.resourceError,
                       result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                       name: "idle")->__vftable);
      }
      else if ( (unsigned int)v37 < (AIMEMORY_ANIMAFTER_OVERRIDE_RUN|AIMEMORY_ANIMAFTER_OVERRIDE_IDLE) )
      {
        v44 = HIWORD(idDeclAnimWeb::GetStateIndexForName(
                       this: (idDeclAnimWeb *)((char *)&v46.trackedMemory + 2),
                       result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                       name: "run")->__vftable);
      }
    }
    else
    {
      v44 = HIWORD(idDeclAnimWeb::GetStateIndexForName(
                     this: (idDeclAnimWeb *)&v46.nextOnHashChain,
                     result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                     name: v9->destStateName)->__vftable);
    }
    v38 = v45;
    this->aiVolatile.memory.animAfterOverride = AIMEMORY_ANIMAFTER_OVERRIDE_DEFAULT;
    if ( v38 < 0 )
    {
      idLib::Warning(
        fmt: "idAI2::WaitForOverrideAnim - subweb '%s' not found in animWeb '%s'",
        (const char *)v46.nodes.size,
        this->aiVolatile.animation.animWebAnimator.ptr[0].decl->name.str);
      p_num = (idStr *)&v46.nodes.num;
LABEL_50:
      idStr::FreeData(this: p_num);
      return false;
    }
    if ( (v44 & 0x8000u) != 0 )
    {
      idLib::Warning(
        fmt: "idAI2::WaitForOverrideAnim - state '%s' not found in animWeb '%s'",
        v9->destStateName,
        this->aiVolatile.animation.animWebAnimator.ptr[0].decl->name.str);
      p_num = (idStr *)&v46.nodes.num;
      goto LABEL_50;
    }
    idStr::FreeData(this: (idStr *)&v46.nodes.num);
  }
  v46.textSource = (char *)20;
  v46.staleCount = 0;
  *((_DWORD *)&v46.idResource + 8) = &v46.textLength;
  HIBYTE(v46.textLength) = 0;
  idAI2::GetSubWebPrefix(this, swt: (const aiSubWeb_t)v9->subWeb, subWebPrefix: (idStr *)&v46.staleCount);
  idDeclAnimWeb::GetSubWebIndexForName(
    this: (idDeclAnimWeb *)((char *)&v46.__vftable + 2),
    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
    subWebName: *((const char **)&v46.idResource + 8));
  idDeclAnimWeb::GetStateIndexForName(
    this: &v46,
    result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
    name: v9->stateName);
  if ( SLOWORD(v46.__vftable) < 0 )
  {
    idLib::Warning(
      fmt: "idAI2::WaitForOverrideAnim - subweb '%s' not found in animWeb '%s'",
      *((const char **)&v46.idResource + 8),
      this->aiVolatile.animation.animWebAnimator.ptr[0].decl->name.str);
    p_num = (idStr *)&v46.staleCount;
    goto LABEL_50;
  }
  if ( SHIWORD(v46.__vftable) < 0 )
  {
    idLib::Warning(
      fmt: "idAI2::WaitForOverrideAnim - state '%s' not found in animWeb '%s'",
      v9->stateName,
      this->aiVolatile.animation.animWebAnimator.ptr[0].decl->name.str);
    p_num = (idStr *)&v46.staleCount;
    goto LABEL_50;
  }
  v40 = idAI2::ChangeAnimStateVia(
          this,
          web: AIANIMWEB_BODY,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v45,
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v44,
          viaSubWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)LOWORD(v46.__vftable),
          viaStateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)HIWORD(v46.__vftable),
          interruptPath: INTR_PATH_YES,
          interruptBlend: INTR_BLEND_NO);
  if ( v40 < AWPATH_OK )
  {
    p_num = (idStr *)&v46.staleCount;
    goto LABEL_50;
  }
  if ( v40 == AWPATH_OK )
  {
    idDeclAnimWeb::FindNodeIndex(
      this: (idDeclAnimWeb *)&v46.trackedMemory,
      result: (idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
      subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v45,
      stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v44);
    if ( v46.trackedMemory >= 0 )
    {
      v41 = this->aiVolatile.animation.animWebAnimator.ptr[0].decl->nodes.list[SHIWORD(v46.trackedMemory)];
      if ( v41 != nullptr )
      {
        v42 = idDeclAnimWebNode::NumAnims(this: v41, modelIndex: nullptr);
        LODWORD(v43) = idRandom2::RandomInt(this: &clientGame->random, max: (int)&v42[-1].tagGroups + 3);
        *(_QWORD *)&v46.nextOnHashChain = v43;
        this->aiVolatile.animation.animWebAnimator.ptr[0].select01 = (float)v43;
      }
    }
    LOWORD(v46.nextOnHashChain) = (_WORD)this - 32576;
    HIWORD(v46.nextOnHashChain) = v46.__vftable;
    idAnimator_AnimWeb::SetEvent(
      this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
      eventType: ev,
      subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)LOWORD(v46.__vftable),
      stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)HIWORD(v46.__vftable),
      eventDef: &EV_AnimWeb_Wait,
      priority);
  }
  idStr::FreeData(this: (idStr *)&v46.staleCount);
  return true;
}


// ========================================================================
// __unwind$525212
// EA  : 0x829F950C
// RVA : 0x009F950C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_525212()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 624 + 144));
}


// ========================================================================
// __unwind$525213
// EA  : 0x829F9534
// RVA : 0x009F9534
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_525213()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 624 + 112));
}


// ========================================================================
// ?WaitForAnimToEnd@idAI2@@QAA_NW4priority_t@idAnimWebEvent@@PBD1W4animWebEvent_t@@@Z
// EA  : 0x829F9560
// RVA : 0x009F9560
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WaitForAnimToEnd(
        idAI2 *this,
        idAnimWebEvent::priority_t priority,
        const char *subWebName,
        const char *stateName,
        animWebEvent_t ev)
{
  idAI2::idAIVolatile::idAIAnimationInfo *p_animation; // r31
  awPathResult_t v12; // r3
  unsigned __int16 v13; // [sp+50h] [-40h] BYREF
  unsigned __int16 v14; // [sp+52h] [-3Eh] BYREF
  unsigned __int16 v15; // [sp+54h] [-3Ch] BYREF
  unsigned __int16 v16; // [sp+56h] [-3Ah] BYREF

  p_animation = &this->aiVolatile.animation;
  idAnimator_AnimWeb::GetCurSubWebIndex(
    this: (idAnimator_AnimWeb *)&v16,
    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)&this->aiVolatile.animation);
  idAnimator_AnimWeb::GetCurStateIndex(
    this: (idAnimator_AnimWeb *)&v15,
    result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation);
  idDeclAnimWeb::GetSubWebIndexForName(
    this: (idDeclAnimWeb *)&v14,
    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
    subWebName);
  idDeclAnimWeb::GetStateIndexForName(
    this: (idDeclAnimWeb *)&v13,
    result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
    name: stateName);
  if ( (v14 & 0x8000u) != 0 )
  {
    idLib::Warning(
      fmt: "idAI2::WaitForAnimToEnd - subweb '%s' not found in animWeb '%s'",
      subWebName,
      p_animation->animWebAnimator.ptr[0].decl->name.str);
    return 0;
  }
  if ( (v13 & 0x8000u) == 0 )
  {
    v12 = idAI2::ChangeAnimStateVia(
            this,
            web: AIANIMWEB_BODY,
            subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v16,
            stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v15,
            viaSubWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v14,
            viaStateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v13,
            interruptPath: INTR_PATH_YES,
            interruptBlend: INTR_BLEND_NO);
    if ( v12 < AWPATH_OK )
      return 0;
    if ( v12 == AWPATH_OK )
      idAnimator_AnimWeb::SetEvent(
        this: (idAnimator_AnimWeb *)p_animation,
        eventType: ev,
        subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v14,
        stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v13,
        eventDef: &EV_AnimWeb_Wait,
        priority);
    return 1;
  }
  else
  {
    idLib::Warning(
      fmt: "idAI2::WaitForAnimToEnd - state '%s' not found in animWeb '%s'",
      stateName,
      p_animation->animWebAnimator.ptr[0].decl->name.str);
    return 0;
  }
}


// ========================================================================
// ?WaitForAnimToStart@idAI2@@QAA_NW4aiAnimWeb_t@@W4priority_t@idAnimWebEvent@@PBD2W4animWebEvent_t@@@Z
// EA  : 0x829F9680
// RVA : 0x009F9680
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WaitForAnimToStart(
        idAI2 *this,
        const aiAnimWeb_t awt,
        idAnimWebEvent::priority_t priority,
        const char *subWebName,
        const char *stateName,
        animWebEvent_t ev)
{
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> **v6; // r9
  char *v8; // r26
  awPathResult_t v12; // r3
  unsigned __int16 v14; // [sp+50h] [-40h] BYREF
  unsigned __int16 v15; // [sp+52h] [-3Eh] BYREF

  v6 = (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> **)((char *)this + 820 * awt);
  v8 = (char *)(v6 + 8240);
  idDeclAnimWeb::GetSubWebIndexForName(this: (idDeclAnimWeb *)&v15, result: v6[8250], subWebName);
  idDeclAnimWeb::GetStateIndexForName(
    this: (idDeclAnimWeb *)&v14,
    result: *((idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> **)v8 + 10),
    name: stateName);
  v12 = idAI2::ChangeAnimState(
          this,
          web: AIANIMWEB_BODY,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v15,
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v14,
          interruptPath: INTR_PATH_YES,
          interruptBlend: INTR_BLEND_NO);
  if ( v12 < AWPATH_OK )
    return 0;
  if ( v12 == AWPATH_OK )
    idAnimator_AnimWeb::SetEvent(
      this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
      eventType: ev,
      subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v15,
      stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v14,
      eventDef: &EV_AnimWeb_Wait,
      priority);
  return 1;
}


// ========================================================================
// ?WaitForAnimToStartVia@idAI2@@QAA_NW4aiAnimWeb_t@@W4priority_t@idAnimWebEvent@@V?$idIndex@FW4invalidSubWebIndex_t@idDeclAnimWeb@@@@V?$idIndex@FW4invalidStateIndex_t@idDeclAnimWeb@@@@23W4animWebEvent_t@@@Z
// EA  : 0x829F9730
// RVA : 0x009F9730
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WaitForAnimToStartVia(
        idAI2 *this,
        aiAnimWeb_t awt,
        idAnimWebEvent::priority_t priority,
        const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *dswi,
        const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *dsi,
        const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *vswi,
        const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *vsi,
        animWebEvent_t ev)
{
  awPathResult_t v13; // r3

  v13 = idAI2::ChangeAnimStateVia(
          this,
          web: awt,
          subWebIndex: dswi,
          stateIndex: dsi,
          viaSubWebIndex: vswi,
          viaStateIndex: vsi,
          interruptPath: INTR_PATH_YES,
          interruptBlend: INTR_BLEND_NO);
  if ( v13 < AWPATH_OK )
    return 0;
  if ( v13 == AWPATH_OK )
    idAnimator_AnimWeb::SetEvent(
      this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
      eventType: ev,
      subWebIndex: dswi,
      stateIndex: dsi,
      eventDef: &EV_AnimWeb_Wait,
      priority);
  return 1;
}


// ========================================================================
// ?WaitForAnimToStartVia@idAI2@@QAA_NW4aiAnimWeb_t@@W4priority_t@idAnimWebEvent@@PBD222W4animWebEvent_t@@@Z
// EA  : 0x829F97B8
// RVA : 0x009F97B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WaitForAnimToStartVia(
        idAI2 *this,
        aiAnimWeb_t awt,
        idAnimWebEvent::priority_t priority,
        const char *subWebName,
        const char *stateName,
        const char *viaSubWebName,
        const char *viaStateName,
        const animWebEvent_t ev)
{
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> **v9; // r9
  char *v11; // r24
  aiAnimWeb_t v16; // r4
  const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *v17; // r28
  const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *v18; // r27
  awPathResult_t v19; // r3
  unsigned __int16 v21; // [sp+50h] [-50h] BYREF
  unsigned __int16 v22; // [sp+52h] [-4Eh] BYREF
  unsigned __int16 v23; // [sp+54h] [-4Ch] BYREF
  unsigned __int16 v24; // [sp+56h] [-4Ah] BYREF

  v9 = (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> **)((char *)this + 820 * awt);
  v11 = (char *)(v9 + 8240);
  idDeclAnimWeb::GetSubWebIndexForName(this: (idDeclAnimWeb *)&v24, result: v9[8250], subWebName: viaSubWebName);
  idDeclAnimWeb::GetStateIndexForName(
    this: (idDeclAnimWeb *)&v23,
    result: *((idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> **)v11 + 10),
    name: viaStateName);
  idDeclAnimWeb::GetSubWebIndexForName(
    this: (idDeclAnimWeb *)&v22,
    result: *((idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> **)v11 + 10),
    subWebName);
  idDeclAnimWeb::GetStateIndexForName(
    this: (idDeclAnimWeb *)&v21,
    result: *((idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> **)v11 + 10),
    name: stateName);
  v16 = awt;
  v17 = (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v21;
  v18 = (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v22;
  v19 = idAI2::ChangeAnimStateVia(
          this,
          web: v16,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v22,
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v21,
          viaSubWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v24,
          viaStateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v23,
          interruptPath: INTR_PATH_YES,
          interruptBlend: INTR_BLEND_NO);
  if ( v19 < AWPATH_OK )
    return 0;
  if ( v19 == AWPATH_OK )
    idAnimator_AnimWeb::SetEvent(
      this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
      eventType: ANIMWEB_EVENT_START_BLEND_IN,
      subWebIndex: v18,
      stateIndex: v17,
      eventDef: &EV_AnimWeb_Wait,
      priority);
  return 1;
}


// ========================================================================
// ?UpdateAttachments@idAI2@@UAAXXZ
// EA  : 0x829F98A8
// RVA : 0x009F98A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateAttachments(idAI2 *this)
{
  idWeapon *v2; // r27
  idPresentable *presentable; // r3
  idPresentable *v4; // r11
  idPresentableAI *v5; // r3
  const idDeclInventory *decl; // r11
  int entityNumber; // r6
  double v8; // fp6
  double v9; // fp5
  idRenderWorld *v10; // r3
  idHandle<int,enum invalidAttachment_t,-1> *v11; // r3
  idAttachmentCollection *v12; // r3
  const idAttachment *v13; // r3
  idIndex<short,enum invalidJointIndex_t> *v14; // r30
  idRenderWorld *v15; // r3
  idRenderWorld *v16; // r3
  idRenderWorld *v17; // r3
  idVec3 v18; // [sp+50h] [-130h] BYREF
  unsigned __int16 v19; // [sp+5Ch] [-124h] BYREF
  idAttachmentCollection v20; // [sp+60h] [-120h] BYREF
  float v21[4]; // [sp+78h] [-108h] BYREF
  float v22[4]; // [sp+88h] [-F8h] BYREF
  float v23[4]; // [sp+98h] [-E8h] BYREF
  float v24[6]; // [sp+A8h] [-D8h] BYREF
  idMat3 v25; // [sp+C0h] [-C0h] BYREF
  idStr v26; // [sp+F0h] [-90h] BYREF
  idMat3 v27; // [sp+110h] [-70h] BYREF

  idActor::UpdateAttachments(this);
  v2 = this->GetEquippedWeapon(this);
  if ( common->IsMultiplayer(this: common) )
  {
    presentable = this->presentable;
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
    }
    if ( presentable->GetAIInterface(this: presentable) != nullptr )
    {
      v26.len = 0;
      v26.allocedAndFlag = 20;
      v26.data = v26.baseBuffer;
      v26.baseBuffer[0] = 0;
      idAI2::GetWeaponPrefix(this, weapon: v2, subWebPrefix: &v26);
      v4 = this->presentable;
      if ( v4 == nullptr )
      {
        idEntity::InitPresentableInternal(this);
        v4 = this->presentable;
      }
      v5 = v4->GetAIInterface(this: v4);
      idPresentableAI::SetWeaponPrefix(this: v5, strWeaponPrefix: &v26);
      idStr::FreeData(this: &v26);
    }
  }
  if ( v2 != nullptr
    && (*((_BYTE *)v2 + 452) & 2) != 0
    && idAI2::GetLaserSightPoint(this, weapon: v2, laserPos: (idVec3 *)&v20.attachments.size, laserAxis: &v27) )
  {
    decl = v2->decl;
    entityNumber = this->entityNumber;
    v8 = (float)(v27.mat[0].y * *(float *)&decl[1].inventoryClass.allocedAndFlag);
    v9 = (float)(v27.mat[0].z * *(float *)&decl[1].inventoryClass.allocedAndFlag);
    v21[0] = *(float *)&v20.attachments.size + (float)(v27.mat[0].x * *(float *)&decl[1].inventoryClass.allocedAndFlag);
    v21[1] = *(float *)&v20.attachments.granularity + (float)v8;
    v21[2] = *(float *)&v20.parent + (float)v9;
    v2->UpdateLaserSight(
      this: v2,
      a2: (const idVec3 *)&v20.attachments.size,
      a3: (const idVec3 *)v21,
      a4: entityNumber,
      a5: nullptr);
    if ( g_debugLaserSight.valueInteger != 0 )
    {
      v10 = gameLocal->GetRenderWorld(this: gameLocal);
      v10->DebugLine(
        this: v10,
        a2: (const idVec4 *)&idColor::colorRed,
        a3: (const idVec3 *)&v20.attachments.size,
        a4: (const idVec3 *)v21,
        a5: 0,
        a6: true);
      v11 = (idHandle<int,enum invalidAttachment_t,-1> *)this->GetAttachments_2(this);
      idAttachmentCollection::FindAttachment(this: &v20, result: v11, item: v2);
      if ( v20.attachments.list != (idAttachment *)-1 )
      {
        v12 = this->GetAttachments_2(this);
        v13 = idAttachmentCollection::Get(this: v12, handle: (const idHandle<int,enum invalidAttachment_t,-1> *)&v20);
        if ( v13 != nullptr && v13->handle.value != -1 && (*((_BYTE *)v13 + 104) & 0x80) != 0 )
        {
          v14 = (idIndex<short,enum invalidJointIndex_t> *)_RTDynamicCast(
                                                             inptr: v13->presentable->model,
                                                             VfDelta: 0,
                                                             SrcType: &idRenderModel `RTTI Type Descriptor',
                                                             TargetType: &idTreeAnimator `RTTI Type Descriptor',
                                                             isReference: 0);
          idTreeAnimator::GetJointIndex(this: (idTreeAnimator *)&v19, result: v14, jointName: "origin");
          idTreeAnimator::GetWorldSpaceJointTransform(
            this: (idTreeAnimator *)v14,
            pose: DRIVER_MODEL,
            jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)v19,
            origin: &v18,
            axis: &v25);
          v15 = gameLocal->GetRenderWorld(this: gameLocal);
          v22[0] = v18.x + (float)(v25.mat[0].x * (float)96.0);
          v22[1] = v18.y + (float)(v25.mat[0].y * (float)96.0);
          v22[2] = v18.z + (float)(v25.mat[0].z * (float)96.0);
          ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, float *, double))v15->DebugArrow)(
            a1: v15,
            a2: &idColor::colorGreen,
            a3: &v18,
            a4: v22,
            a5: 4.0);
          v16 = gameLocal->GetRenderWorld(this: gameLocal);
          v24[0] = (float)(v25.mat[1].x * (float)96.0) + v18.x;
          v24[1] = (float)(v25.mat[1].y * (float)96.0) + v18.y;
          v24[2] = (float)(v25.mat[1].z * (float)96.0) + v18.z;
          ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, float *, double))v16->DebugArrow)(
            a1: v16,
            a2: &idColor::colorRed,
            a3: &v18,
            a4: v24,
            a5: 4.0);
          v17 = gameLocal->GetRenderWorld(this: gameLocal);
          v23[0] = (float)(v25.mat[2].x * (float)96.0) + v18.x;
          v23[1] = (float)(v25.mat[2].y * (float)96.0) + v18.y;
          v23[2] = (float)(v25.mat[2].z * (float)96.0) + v18.z;
          ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, float *, double))v17->DebugArrow)(
            a1: v17,
            a2: &idColor::colorBlue,
            a3: &v18,
            a4: v23,
            a5: 4.0);
        }
      }
    }
  }
}


// ========================================================================
// __unwind$525752
// EA  : 0x829F9CE8
// RVA : 0x009F9CE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_525752()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 384 + 240));
}


// ========================================================================
// ?GetTravelSpeeds@idAI2@@QBA?AVidAAS2TravelSpeeds@@XZ
// EA  : 0x829F9D10
// RVA : 0x009F9D10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::GetTravelSpeeds(idAI2 *this, idAAS2TravelSpeeds *result)
{
  double flySpeed; // fp13

  if ( (*(int (__fastcall **)(idAAS2TravelSpeeds *))(LODWORD(result->defaultSpeed) + 800))(a1: result) == 1 )
    flySpeed = result[649].flySpeed;
  else
    flySpeed = result[649].crouchSpeed;
  *(float *)&this->__vftable = flySpeed;
  *(float *)&this->listenerList = 0.0;
  *(float *)&this->listeningToList = 0.0;
  *(float *)&this->name.len = (float)flySpeed * (float)0.5;
  return this;
}


// ========================================================================
// ?UpdateExtendedClipModel@idAI2@@QAA_NXZ
// EA  : 0x829F9D98
// RVA : 0x009F9D98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::UpdateExtendedClipModel(idAI2 *this)
{
  idTreeAnimator *TreeAnimatorFromPresentable; // r30
  idPresentable *presentable; // r3
  idDeclMD6 *JointIndex; // r3
  idPhysics *Physics; // r3
  int v7; // r3
  idClipModel *extendedClipModel; // r11
  float y; // r3
  float z; // r30
  int v11; // [sp+8h] [-168h]
  bool v12; // [sp+Fh] [-161h]
  const char *v13; // [sp+10h] [-160h]
  int v14; // [sp+14h] [-15Ch]
  int v15; // [sp+18h] [-158h]
  int v16; // [sp+1Ch] [-154h]
  int v17; // [sp+20h] [-150h]
  int v18; // [sp+24h] [-14Ch]
  int v19; // [sp+28h] [-148h]
  int v20; // [sp+2Ch] [-144h]
  int v21; // [sp+30h] [-140h]
  int v22; // [sp+34h] [-13Ch]
  int v23; // [sp+38h] [-138h]
  int v24; // [sp+3Ch] [-134h]
  int v25; // [sp+40h] [-130h]
  int v26; // [sp+44h] [-12Ch]
  int v27; // [sp+48h] [-128h]
  int v28; // [sp+4Ch] [-124h]
  int v29; // [sp+50h] [-120h]
  int entityNumber; // [sp+54h] [-11Ch]
  int v31; // [sp+58h] [-118h]
  int v32; // [sp+60h] [-110h]
  char v33; // [sp+70h] [-100h] BYREF
  idVec3 v34; // [sp+78h] [-F8h] BYREF
  idVec3 v35; // [sp+88h] [-E8h] BYREF
  char v36; // [sp+98h] [-D8h] BYREF
  idMat3 v37; // [sp+A0h] [-D0h] BYREF
  trace_t v38; // [sp+D0h] [-A0h] BYREF

  if ( this->aiVolatile.physics.extendedClipModel != nullptr )
  {
    if ( this->aiVolatile.physics.extendedClipModelEndTime != 0
      && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.physics.extendedClipModelEndTime )
    {
      idAI2::DeactivateExtendedClipModel(this);
      return 1;
    }
    if ( this->aiVolatile.physics.extendedClipModelStatus == AIEXTENDEDCLIPMODELSTATUS_HIPS )
    {
      TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      presentable = this->presentable;
      if ( presentable == nullptr )
      {
        idEntity::InitPresentableInternal(this);
        presentable = this->presentable;
      }
      idPresentable::UpdateModelTransform(this: presentable);
      JointIndex = idDeclMD6::GetJointIndex(
                     this: (idDeclMD6 *)&v33,
                     result: (idIndex<short,enum invalidJointIndex_t> *)TreeAnimatorFromPresentable->decl,
                     jointName: "hips");
      idTreeAnimator::GetWorldSpaceJointTransform(
        this: TreeAnimatorFromPresentable,
        pose: DRIVER_MODEL,
        jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(JointIndex->__vftable),
        origin: &v35,
        axis: &v37);
      Physics = idEntity::GetPhysics(this);
      v7 = (int)Physics->GetOrigin(this: Physics, a2: 0);
      extendedClipModel = this->aiVolatile.physics.extendedClipModel;
      v35.z = *(float *)(v7 + 8);
      entityNumber = this->entityNumber;
      y = extendedClipModel->origin.y;
      z = extendedClipModel->origin.z;
      v34.x = extendedClipModel->origin.x;
      v34.y = y;
      v34.z = z;
      idClip::Translation(
        this: (idClip *)&v36,
        result: &clientGame->clip,
        a3: &v38,
        start: &v34,
        end: &v35,
        clipModel: extendedClipModel,
        startAxis: &extendedClipModel->axis,
        clipMask: 33792,
        passEntityNumber: v11,
        moveClipModel: v12,
        userName: v13,
        a12: v14,
        a13: v15,
        a14: v16,
        a15: v17,
        a16: v18,
        a17: v19,
        a18: v20,
        a19: v21,
        a20: v22,
        a21: v23,
        a22: v24,
        a23: v25,
        a24: v26,
        a25: v27,
        a26: v28,
        a27: v29,
        a28: entityNumber,
        a29: v31,
        a30: false,
        a31: v32,
        a32: 0);
      idClipModel::SetLinkedPosition(
        this: this->aiVolatile.physics.extendedClipModel,
        newOrigin: &v38.endpos,
        newAxis: &mat3_identity);
    }
  }
  return 1;
}


// ========================================================================
// ?ReleaseCover@idAI2@@QAAXXZ
// EA  : 0x829F9F00
// RVA : 0x009F9F00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ReleaseCover(idAI2 *this)
{
  idAICover *p_currentCover; // r30
  idAIMemory *p_memory; // r31

  p_currentCover = &this->aiVolatile.memory.currentCover;
  if ( idAICover::IsValid(this: &this->aiVolatile.memory.currentCover) )
  {
    p_memory = &this->aiVolatile.memory;
    idAIMemory::SetLastCover(this: p_memory, cover: p_currentCover);
    idAICover::Unreserve(this: p_currentCover);
    idAICover::idAICover(this: &p_memory->currentCover);
    p_memory->flags &= ~1u;
  }
}


// ========================================================================
// ?Debug_ScenePoints@idAI2@@QAAXXZ
// EA  : 0x829F9F80
// RVA : 0x009F9F80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Debug_ScenePoints(idAI2 *this)
{
  char v2; // r11
  const idDeclAIBehavior *decl; // r11
  int v4; // r10
  idScenePoint *curScenePoint; // r31
  scenePointType_t type; // r11
  idColor *v7; // r11
  float g; // r8
  float b; // r7
  float a; // r6
  idPhysics *Physics; // r3
  float *v12; // r3
  float *ScenePointPos; // r3
  float *presentable; // r11
  double v15; // fp8
  double v16; // fp4
  idScenePoint_Look *v17; // r3
  idScenePoint_Look *v18; // r31
  int GameMs; // r3
  char v20; // r11
  scenePointLookFlags_t lookFlags; // r11
  float r; // r10
  float v23; // r9
  float v24; // r8
  float v25; // r7
  idPhysics *v26; // r3
  float *v27; // r3
  float *v28; // r3
  float *v29; // r11
  double v30; // fp12
  double v31; // fp3
  idScenePoint *overrideScenePoint; // r31
  int v33; // r3
  char v34; // r11
  idPhysics *v35; // r3
  float *v36; // r3
  float *v37; // r3
  idVec3 v38; // [sp+50h] [-130h] BYREF
  idVec3 v39; // [sp+60h] [-120h] BYREF
  float x; // [sp+70h] [-110h] BYREF
  float y; // [sp+74h] [-10Ch]
  float v42; // [sp+78h] [-108h]
  float v43; // [sp+80h] [-100h] BYREF
  float v44; // [sp+84h] [-FCh]
  float v45; // [sp+88h] [-F8h]
  idColor v46; // [sp+90h] [-F0h] BYREF
  idColor v47; // [sp+A0h] [-E0h] BYREF
  float v48[4]; // [sp+B0h] [-D0h] BYREF
  float v49[4]; // [sp+C0h] [-C0h] BYREF
  float v50[4]; // [sp+D0h] [-B0h] BYREF
  float v51[4]; // [sp+E0h] [-A0h] BYREF
  float v52[4]; // [sp+F0h] [-90h] BYREF
  _BYTE v53[56]; // [sp+100h] [-80h] BYREF

  if ( this->aiEditable.usesScenePoints )
  {
    v2 = 1;
  }
  else
  {
    decl = this->aiEditable.behaviors.decl;
    if ( decl == nullptr || (v4 = *((_BYTE *)decl + 196) & 0x40, v2 = 1, v4 == 0) )
      v2 = 0;
  }
  if ( v2 != 0 )
  {
    curScenePoint = this->aiVolatile.memory.curScenePoint;
    v39 = vec3_origin;
    v38 = vec3_origin;
    if ( curScenePoint == nullptr )
      goto LABEL_19;
    if ( (*(_BYTE *)&curScenePoint->flags & 8) == 0 )
      goto LABEL_19;
    idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    if ( curScenePoint->currentUser != this )
      goto LABEL_19;
    v47 = idColor::colorRed;
    type = curScenePoint->type;
    if ( type == (ROAM|LOOK) )
    {
      v7 = &idColor::colorBlue;
    }
    else
    {
      if ( type != ROAM )
        goto LABEL_15;
      v7 = &idColor::colorGreen;
    }
    g = v7->g;
    b = v7->b;
    a = v7->a;
    v47.r = v7->r;
    v47.g = g;
    v47.b = b;
    v47.a = a;
LABEL_15:
    Physics = idEntity::GetPhysics(this);
    v12 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v39.x = *v12;
    v39.y = v12[1];
    v39.z = v12[2] + (float)10.0;
    ScenePointPos = (float *)idScenePoint::GetScenePointPos(this: (idScenePoint *)v53, result: curScenePoint);
    v38.x = *ScenePointPos;
    v38.y = ScenePointPos[1];
    v38.z = ScenePointPos[2] + (float)10.0;
    ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, idVec3 *, double))clientGame->renderWorld->DebugArrow3)(
      a1: clientGame->renderWorld,
      a2: &v47,
      a3: &v39,
      a4: &v38,
      a5: 3.0);
    v52[0] = v38.x;
    v52[1] = v38.y;
    v52[2] = v38.z + (float)80.0;
    ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, float *, double))clientGame->renderWorld->DebugArrow3)(
      a1: clientGame->renderWorld,
      a2: &v47,
      a3: &v38,
      a4: v52,
      a5: 3.0);
    if ( ai_debugScenePoints.valueInteger >= 2 )
    {
      x = v38.x;
      v42 = v38.z + (float)80.0;
      y = v38.y;
      presentable = (float *)curScenePoint->presentable;
      if ( presentable == nullptr )
      {
        idEntity::InitPresentableInternal(this: curScenePoint);
        presentable = (float *)curScenePoint->presentable;
      }
      v15 = (float)(presentable[35] * (float)40.0);
      v16 = (float)((float)(presentable[34] * (float)40.0) + y);
      v48[0] = (float)(presentable[33] * (float)40.0) + x;
      v48[1] = v16;
      v48[2] = (float)v15 + v42;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))clientGame->renderWorld->DebugArrow3)(
        a1: clientGame->renderWorld,
        a2: &v47,
        a3: &x,
        a4: v48,
        a5: 3.0);
    }
LABEL_19:
    v17 = idScenePoint_Look::CastTo(c: (idScenePoint_Look *)this->aiVolatile.memory.curLookScenePoint);
    v18 = v17;
    if ( v17 == nullptr || (*(_BYTE *)&v17->flags & 8) == 0 )
      goto LABEL_34;
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    if ( v18->currentUser == nullptr || (v20 = 1, GameMs >= v18->requestTime) )
      v20 = 0;
    if ( v20 == 0 )
      goto LABEL_34;
    v46 = idColor::colorRed;
    lookFlags = v18->lookFlags;
    if ( (lookFlags & 2) != 0 )
    {
      r = idColor::colorBlue.r;
      v23 = idColor::colorBlue.g;
      v24 = idColor::colorBlue.b;
      v25 = idColor::colorBlue.a;
    }
    else
    {
      if ( (lookFlags & 1) == 0 )
        goto LABEL_30;
      r = idColor::colorGreen.r;
      v23 = idColor::colorGreen.g;
      v24 = idColor::colorGreen.b;
      v25 = idColor::colorGreen.a;
    }
    v46.r = r;
    v46.g = v23;
    v46.b = v24;
    v46.a = v25;
LABEL_30:
    v26 = idEntity::GetPhysics(this);
    v27 = (float *)v26->GetOrigin(this: v26, a2: 0);
    v39.x = *v27;
    v39.y = v27[1];
    v39.z = v27[2] + (float)10.0;
    v28 = (float *)idScenePoint::GetScenePointPos(this: (idScenePoint *)v53, result: v18);
    v38.x = *v28;
    v38.y = v28[1];
    v38.z = v28[2] + (float)10.0;
    ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, idVec3 *, double))clientGame->renderWorld->DebugArrow3)(
      a1: clientGame->renderWorld,
      a2: &v46,
      a3: &v39,
      a4: &v38,
      a5: 3.0);
    v51[2] = v38.z + (float)40.0;
    v51[0] = v38.x;
    v51[1] = v38.y;
    ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, float *, double))clientGame->renderWorld->DebugArrow3)(
      a1: clientGame->renderWorld,
      a2: &v46,
      a3: &v38,
      a4: v51,
      a5: 3.0);
    if ( ai_debugScenePoints.valueInteger >= 2 )
    {
      v43 = v38.x;
      v45 = v38.z + (float)40.0;
      v44 = v38.y;
      v29 = (float *)v18->presentable;
      if ( v29 == nullptr )
      {
        idEntity::InitPresentableInternal(this: v18);
        v29 = (float *)v18->presentable;
      }
      v30 = (float)(v29[34] * (float)40.0);
      v31 = (float)((float)(v29[33] * (float)40.0) + v43);
      v50[2] = (float)(v29[35] * (float)40.0) + v45;
      v50[0] = v31;
      v50[1] = (float)v30 + v44;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))clientGame->renderWorld->DebugArrow3)(
        a1: clientGame->renderWorld,
        a2: &v46,
        a3: &v43,
        a4: v50,
        a5: 3.0);
    }
LABEL_34:
    overrideScenePoint = this->aiVolatile.memory.overrideScenePoint;
    if ( overrideScenePoint != nullptr && (*(_BYTE *)&overrideScenePoint->flags & 8) != 0 )
    {
      v33 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      if ( overrideScenePoint->currentUser == nullptr || (v34 = 1, v33 >= overrideScenePoint->requestTime) )
        v34 = 0;
      if ( v34 != 0 )
      {
        v35 = idEntity::GetPhysics(this);
        v36 = (float *)v35->GetOrigin(this: v35, a2: 0);
        v39.x = *v36;
        v39.y = v36[1];
        v39.z = v36[2] + (float)10.0;
        v37 = (float *)idScenePoint::GetScenePointPos(this: (idScenePoint *)v53, result: overrideScenePoint);
        v38.x = *v37;
        v38.y = v37[1];
        v38.z = v37[2] + (float)10.0;
        ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, idVec3 *, double))clientGame->renderWorld->DebugArrow3)(
          a1: clientGame->renderWorld,
          a2: &idColor::colorWhite,
          a3: &v39,
          a4: &v38,
          a5: 3.0);
        v49[0] = v38.x;
        v49[1] = v38.y;
        v49[2] = v38.z + (float)80.0;
        ((void (__fastcall *)(idRenderWorld *, idColor *, idVec3 *, float *, double))clientGame->renderWorld->DebugArrow3)(
          a1: clientGame->renderWorld,
          a2: &idColor::colorWhite,
          a3: &v38,
          a4: v49,
          a5: 3.0);
      }
    }
  }
}


// ========================================================================
// ?CoverAvoidanceOptions@idAI2@@QAA_NAA_N000000000000@Z
// EA  : 0x829FA668
// RVA : 0x009FA668
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CoverAvoidanceOptions(
        idAI2 *this,
        bool *outDodgeRoomToLeft,
        bool *outDiveRoomToLeft,
        bool *outDodgeCoverToLeft,
        bool *outDiveCoverToLeft,
        bool *outDodgeRoomToRight,
        bool *outDiveRoomToRight,
        bool *outDodgeCoverToRight,
        bool *outDiveCoverToRight,
        bool *outDiveRoomForward,
        bool *outDiveCoverForward,
        bool *outDiveRoomBack,
        bool *outDiveCoverBack,
        bool *outCoverByCrouching,
        int a15,
        int a16,
        int a17,
        int a18,
        int a19,
        int a20,
        int a21,
        int a22,
        int a23,
        int a24,
        int a25,
        int a26,
        int a27,
        bool *a28,
        int a29,
        _BYTE *a30,
        int a31,
        bool *a32,
        int a33,
        _BYTE *a34,
        int a35,
        bool *outDiveCoverToRighta,
        int a37,
        bool *outDiveRoomForwarda)
{
  bool v39; // r3
  unsigned __int8 v40; // r11

  if ( !this->aiVolatile.visibilityObscurity.valid )
    return 0;
  *outDodgeRoomToLeft = ((this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[3] >= OBSCURITY_UNKNOWN)
                       + (this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[3] <= (unsigned int)OBSCURITY_PATH_BLOCKED))
                      & 1;
  *outDodgeRoomToRight = ((this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[4] >= OBSCURITY_UNKNOWN)
                        + (this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[4] <= (unsigned int)OBSCURITY_PATH_BLOCKED))
                       & 1;
  *outDiveRoomToLeft = ((this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[1] >= OBSCURITY_UNKNOWN)
                      + (this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[1] <= (unsigned int)OBSCURITY_PATH_BLOCKED))
                     & 1;
  *outDiveRoomToRight = ((this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[2] >= OBSCURITY_UNKNOWN)
                       + (this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[2] <= (unsigned int)OBSCURITY_PATH_BLOCKED))
                      & 1;
  *outDodgeCoverToLeft = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[3] - 3) & 0x20) != 0;
  *outDodgeCoverToRight = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[4] - 3) & 0x20) != 0;
  *outDiveCoverToLeft = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[1] - 3) & 0x20) != 0;
  *a28 = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[2] - 3) & 0x20) != 0;
  *a30 = ((this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[5] >= OBSCURITY_UNKNOWN)
        + (this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[5] <= (unsigned int)OBSCURITY_PATH_BLOCKED))
       & 1;
  *a32 = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[5] - 3) & 0x20) != 0;
  *a34 = ((this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[6] >= OBSCURITY_UNKNOWN)
        + (this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[6] <= (unsigned int)OBSCURITY_PATH_BLOCKED))
       & 1;
  *outDiveCoverToRighta = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[6] - 3) & 0x20) != 0;
  *outDiveRoomForwarda = (_cntlzw(this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[0] - 3) & 0x20) != 0;
  *outDodgeRoomToLeft = *outDodgeRoomToLeft;
  *outDodgeRoomToRight = *outDodgeRoomToRight;
  *outDiveRoomToLeft = *outDiveRoomToLeft;
  *outDiveRoomToRight = *outDiveRoomToRight;
  *outDodgeCoverToLeft = *outDodgeCoverToLeft;
  *outDodgeCoverToRight = *outDodgeCoverToRight;
  *outDiveCoverToLeft = *outDiveCoverToLeft;
  *a28 = *a28;
  v39 = *outDiveRoomForwarda;
  *outDiveRoomForwarda = v39;
  if ( *outDodgeRoomToLeft )
    return 1;
  if ( *outDodgeRoomToRight )
    return 1;
  if ( *outDiveRoomToLeft )
    return 1;
  if ( *outDiveRoomToRight )
    return 1;
  if ( *outDodgeCoverToLeft )
    return 1;
  if ( *outDodgeCoverToRight )
    return 1;
  if ( *outDiveCoverToLeft )
    return 1;
  if ( *a28 )
    return 1;
  v40 = 0;
  if ( v39 )
    return 1;
  return v40;
}


// ========================================================================
// ?SetupDiveDodgeOrFlinchAction@idAI2@@QAAXW4aiMoveReason_t@@PAVidAIState@@PAVidAIFSM@@@Z
// EA  : 0x829FA930
// RVA : 0x009FA930
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetupDiveDodgeOrFlinchAction(idAI2 *this, int moveReason, idAIState *state, idEventArg *fsm)
{
  const idDeclAIBehavior *decl; // r11
  int minAimDodgeInterval; // r25
  int maxAimDodgeInterval; // r24
  idAIStateTransition::aiTransCode_t transCode; // r30
  int v12; // r23
  unsigned int v13; // r3
  float v14; // r29
  idEventArg *v15; // r3
  idPresentable *presentable; // r11
  double v17; // fp1
  double v18; // fp31
  double v19; // fp30
  double v20; // fp0
  idEventArg *v21; // r27
  _BYTE v22[20]; // [sp+70h] [-140h] BYREF
  _BYTE v23[20]; // [sp+90h] [-120h] BYREF
  float v24[5]; // [sp+B0h] [-100h] BYREF
  idEventReceiver v25[2]; // [sp+D0h] [-E0h] BYREF
  idEventArg v26; // [sp+F0h] [-C0h] BYREF
  idEventArg v27; // [sp+110h] [-A0h] BYREF
  idEventReceiver v28[2]; // [sp+130h] [-80h] BYREF

  decl = this->aiEditable.behaviors.decl;
  minAimDodgeInterval = decl->dodging.minAimDodgeInterval;
  maxAimDodgeInterval = decl->dodging.maxAimDodgeInterval;
  transCode = this->aiVolatile.memory.transCode;
  v12 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
  this->aiVolatile.memory.nextDodgeTime = v12 + GetRandomInterval(_min: minAimDodgeInterval, _max: maxAimDodgeInterval);
  switch ( transCode )
  {
    case TRANSCODE_OC_DIVE_LEFT:
    case TRANSCODE_OC_DIVE_RIGHT:
    case TRANSCODE_OC_DIVE_FORWARD:
    case TRANSCODE_OC_DIVE_BACKWARD:
      presentable = this->presentable;
      if ( presentable == nullptr )
      {
        idEntity::InitPresentableInternal(this);
        presentable = this->presentable;
      }
      v17 = idVec3::ToYaw(this: presentable->axis.mat);
      v18 = v17;
      v19 = v17;
      switch ( transCode )
      {
        case TRANSCODE_OC_DIVE_LEFT:
          v19 = (float)((float)v17 + (float)90.0);
LABEL_26:
          idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
          LODWORD(fsm[1].value.v[2]) = state;
          v24[1] = v18;
          *(float *)&v25[0].listenerList = v19;
          HIBYTE(v24[0]) = 102;
          HIBYTE(v25[0].__vftable) = 102;
          v26.type = 105;
          v26.value.i = moveReason;
          v21 = idEventArg::idEventArg(this: &v27, data: this);
          memcpy(Dst: v23, Src: v24, Size: sizeof(v23));
          memcpy(Dst: v22, Src: v25, Size: sizeof(v22));
          idEventReceiver::ProcessEvent(
            this: v28,
            result: fsm,
            ev: *(const idEventDef **)&v21->type,
            arg1: (const idEventArg *)LODWORD(v21->value.v[1]),
            arg2: (const idEventArg *)LODWORD(v21->value.v[2]),
            arg3: (const idEventArg *)__ROL4__(*(_DWORD *)&v26.type, 32),
            arg4: (const idEventArg *)LODWORD(v26.value.v[1]));
          return;
        case TRANSCODE_OC_DIVE_RIGHT:
          v20 = 90.0;
          break;
        case TRANSCODE_OC_DIVE_BACKWARD:
          v20 = 180.0;
          break;
        default:
          goto LABEL_26;
      }
      v19 = (float)((float)v17 - (float)v20);
      goto LABEL_26;
    case TRANSCODE_OC_DODGE_LEFT:
    case TRANSCODE_OC_DODGE_RIGHT:
      LODWORD(v14) = 3;
      if ( transCode == TRANSCODE_OC_DODGE_RIGHT )
        LODWORD(v14) = 2;
      goto LABEL_13;
    case TRANSCODE_OC_CROUCH:
      v13 = 1664525 * clientGame->random.seed + 1013904223;
      clientGame->random.seed = v13;
      this->aiVolatile.memory.nextMoveTime = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED)
                                           + ((v13 >> 10) & 0x7FFF) % 0x7D0
                                           + 3000;
      return;
    case TRANSCODE_OC_FLINCH_LEFT:
    case TRANSCODE_OC_FLINCH_RIGHT:
      LODWORD(v14) = 25;
      if ( transCode == TRANSCODE_OC_FLINCH_RIGHT )
        LODWORD(v14) = 26;
LABEL_13:
      idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
      LODWORD(fsm[1].value.v[2]) = state;
      v24[1] = v14;
      HIBYTE(v24[0]) = 105;
      v15 = idEventArg::idEventArg(this: &v26, data: this);
      idEventReceiver::ProcessEvent(
        this: v25,
        result: fsm,
        ev: *(const idEventDef **)&v15->type,
        arg1: (const idEventArg *)LODWORD(v15->value.v[1]),
        arg2: (const idEventArg *)LODWORD(v15->value.v[2]));
      break;
    default:
      break;
  }
}


// ========================================================================
// ?CanHideHelmetGroupTest@idAI2@@QAA_NXZ
// EA  : 0x829FACA8
// RVA : 0x009FACA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CanHideHelmetGroupTest(idAI2 *this)
{
  idDamageGroup *DamageGroup; // r3
  int result; // r3
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r30
  idEncounterGroup *v5; // r3
  bool v6; // zf

  if ( !this->aiEditable.behaviors.decl->dodging.onlyCoverHideNoHelmet )
    return 1;
  DamageGroup = idActor::GetDamageGroup(this, name: "head");
  if ( DamageGroup != nullptr && DamageGroup->locationArmor > 0.0 )
    return 0;
  p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
    || idEncounterGroupManager::GroupForHandle(
         this: &gameLocal->encounterGroupManager,
         handle: &this->aiVolatile.encounterGroupHandle) == nullptr )
  {
    return 1;
  }
  v5 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
     ? nullptr
     : idEncounterGroupManager::GroupForHandle(this: &gameLocal->encounterGroupManager, handle: p_encounterGroupHandle);
  v6 = idEncounterGroup::NumLivingMembers(this: v5) == 1;
  result = 0;
  if ( !v6 )
    return 1;
  return result;
}


// ========================================================================
// ?GetVoiceController@idAI2@@QAAPAVidAIVoiceController@@W4voiceController_t@@@Z
// EA  : 0x829FAD78
// RVA : 0x009FAD78
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIVoiceController *__fastcall idAI2::GetVoiceController(idAI2 *this, unsigned int vc)
{
  idEncounterGroup *v3; // r3

  if ( vc == 0 )
    return &this->aiVolatile.voiceController;
  if ( vc == 1 )
  {
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF )
    {
      v3 = idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      if ( v3 != nullptr )
        return &v3->voiceController;
    }
  }
  else if ( vc < 3 )
  {
    return &gameLocal->globalVoiceController;
  }
  return nullptr;
}


// ========================================================================
// ?GetDefaultSpeedByCurrentWalkState@idAI2@@QBAMXZ
// EA  : 0x829FAE28
// RVA : 0x009FAE28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::GetDefaultSpeedByCurrentWalkState(idAI2 *this)
{
  double maxRange; // fp1

  if ( this->GetWalkState(this) == WALKSTATE_RUNNING )
    maxRange = this->aiConstants.movement.moveSpeed.maxRange;
  else
    maxRange = this->aiConstants.movement.moveSpeed.minRange;
  return *((float *)&maxRange + 1);
}


// ========================================================================
// ?GetViewTransform@idAI2@@UBAXAAVidVec3@@AAVidMat3@@@Z
// EA  : 0x829FAE88
// RVA : 0x009FAE88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetViewTransform(idAI2 *this, idVec3 *origin, idMat3 *axis)
{
  tagData_t *p_viewTagData; // r31
  idTreeAnimator *v6; // r3
  const idIndex<short,enum invalidJointIndex_t> *value; // r31
  idTreeAnimator *TreeAnimatorFromPresentable; // r3

  if ( this->aiVolatile.animation.viewTagData.parentJoint.value == 0xFFFF )
  {
    value = (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)this->aiVolatile.faceMgr.eyeJointIndex[1].value;
    if ( value == (const idIndex<short,enum invalidJointIndex_t> *)0xFFFF )
    {
      idActor::GetViewTransform(this, origin, axis);
    }
    else
    {
      TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      idTreeAnimator::GetWorldSpaceJointTransform(
        this: TreeAnimatorFromPresentable,
        pose: DRIVER_MODEL,
        jointIndex: value,
        origin,
        axis);
    }
  }
  else
  {
    p_viewTagData = &this->aiVolatile.animation.viewTagData;
    v6 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    idTreeAnimator::GetWorldSpaceTagTransform(this: v6, tagData: p_viewTagData, origin, axis);
  }
}


// ========================================================================
// ?CalcMovementTurnRate@idAI2@@QBAMABVidVec3@@0@Z
// EA  : 0x829FAF20
// RVA : 0x009FAF20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::CalcMovementTurnRate(idAI2 *this, const idVec3 *idealDir, const idVec3 *curDir)
{
  double valueFloat; // fp0
  idPhysics *Physics; // r3
  double v10; // fp1
  float v12; // [sp+50h] [-30h] BYREF
  float v13; // [sp+54h] [-2Ch]
  float v14; // [sp+58h] [-28h]

  if ( ((double (__fastcall *)(idCVarSystem *, const char *, const idVec3 *, double))cvarSystem->GetCVarFloat)(
         a1: cvarSystem,
         a2: "ai_forceMoveSpeed",
         a3: curDir,
         a4: 0.0) == 0.0 )
  {
    Physics = idEntity::GetPhysics(this);
    Physics->GetLinearVelocity(this: (idPhysics *)&v12, result: (idVec3 *)Physics, a3: 0);
    valueFloat = __fsqrts((float)((float)(v12 * v12) + (float)((float)(v13 * v13) + (float)(v14 * v14))));
  }
  else
  {
    valueFloat = ai_forceMoveSpeed.valueFloat;
  }
  if ( (float)(this->aiConstants.movement.moveSpeed.maxRange - this->aiConstants.movement.moveSpeed.minRange) == 0.0 )
  {
    _FP0 = 0.0;
  }
  else
  {
    _FP11 = -(float)((float)valueFloat - this->aiConstants.movement.moveSpeed.minRange);
    __asm { fsel      f10, f11, f31, f13 }
    _FP8 = (float)((float)1.0
                 - (float)((float)_FP10
                         / (float)(this->aiConstants.movement.moveSpeed.maxRange
                                 - this->aiConstants.movement.moveSpeed.minRange)));
    __asm { fsel      f0, f8, f9, f0 }
  }
  if ( ai_forceTurnRate.valueInteger != 0 )
    v10 = (float)((float)((float)(ai_maxTurnRate.valueFloat - ai_minTurnRate.valueFloat) * (float)_FP0)
                + ai_minTurnRate.valueFloat);
  else
    v10 = (float)((float)((float)(this->aiConstants.movement.moveTurnRate.maxRange
                                - this->aiConstants.movement.moveTurnRate.minRange)
                        * (float)_FP0)
                + this->aiConstants.movement.moveTurnRate.minRange);
  return *((float *)&v10 + 1);
}


// ========================================================================
// ?Teleport@idAI2@@UAAXABVidVec3@@ABVidAngles@@@Z
// EA  : 0x829FB060
// RVA : 0x009FB060
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Teleport(idAI2 *this, const idVec3 *origin, idAngles *angles)
{
  idAIOrientation *p_orientBody; // r29
  const idMat3 *v7; // r3
  const idAAS2 *v8; // r3
  idAnimFSMHumanoid *p_animFSM; // r29
  idAnimFSMHumanoid_vtbl *v10; // r31
  idMat3 *v11; // r3
  idAngles v12[6]; // [sp+50h] [-50h] BYREF

  idActor::Teleport(this, origin, angles);
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    p_orientBody = &this->aiVolatile.animation.animFSM.orientBody;
  else
    p_orientBody = &this->aiVolatile.focus.bodyOrientation;
  v7 = idAngles::ToMat3(this: v12, result: (idMat3 *)angles);
  idAIOrientation::SetAxis(this: p_orientBody, axis: v7);
  v8 = this->GetAAS(this);
  idActor::GetAASPosition(this, aas: v8);
  p_animFSM = &this->aiVolatile.animation.animFSM;
  v10 = this->aiVolatile.animation.animFSM.__vftable;
  v11 = idAngles::ToMat3(this: v12, result: (idMat3 *)angles);
  v10->InitTransform(this: p_animFSM, a2: origin, a3: v11);
}


// ========================================================================
// ?RoleHintNodeScore@idAI2@@QBAMABVidVec3@@W4combatHintClass_t@idAICombatHint@@@Z
// EA  : 0x829FB110
// RVA : 0x009FB110
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::RoleHintNodeScore(
        idAI2 *this,
        const idVec3 *point,
        idAICombatHint::combatHintClass_t hintClass)
{
  idCombatStage *CurrentCombatStage; // r3
  double RolePositionWeight; // fp1

  CurrentCombatStage = idAI2::GetCurrentCombatStage(this);
  if ( CurrentCombatStage != nullptr )
    RolePositionWeight = idCombatStage::GetRolePositionWeight(
                           this: CurrentCombatStage,
                           role: (const encounterGroupRole_t)this->aiVolatile.groupStatus.currentRole,
                           pos: point,
                           hintClass);
  else
    RolePositionWeight = 0.0;
  return *((float *)&RolePositionWeight + 1);
}


// ========================================================================
// ?GetAnimationDelta@idAI2@@QBAXPBVidMD6Anim@@AAVidVec3@@@Z
// EA  : 0x829FB178
// RVA : 0x009FB178
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetAnimationDelta(idAI2 *this, const idMD6Anim *anim, idVec3 *outDelta)
{
  idMD6AnimData *animData; // r11
  idQuat *startDelta; // r4
  float *endDelta; // r11
  double v7; // fp7
  double v8; // fp6
  idVec3 *v9; // r3
  idQuat *v10; // r3
  idVec3 v11; // [sp+50h] [-40h] BYREF
  idQuat v12; // [sp+60h] [-30h] BYREF
  idQuat v13; // [sp+70h] [-20h] BYREF

  animData = anim->animData;
  startDelta = nullptr;
  if ( animData != nullptr )
  {
    startDelta = (idQuat *)animData->startDelta;
    endDelta = animData->endDelta;
  }
  else
  {
    endDelta = nullptr;
  }
  v7 = (float)(endDelta[9] - startDelta[2].y);
  v8 = (float)(endDelta[10] - startDelta[2].z);
  v11.x = endDelta[8] - startDelta[2].x;
  v11.y = v7;
  v11.z = v8;
  v9 = (idVec3 *)idQuat::Inverse(this: &v13, result: startDelta);
  v10 = idQuat::operator*(this: &v12, result: v9, a: &v11);
  outDelta->x = v10->x;
  outDelta->y = v10->y;
  outDelta->z = v10->z;
}


// ========================================================================
// ?PlayAnimWebPath@idAI2@@QAA?BW4awPathResult_t@@ABVidAnimWebPath@@_N@Z
// EA  : 0x829FB230
// RVA : 0x009FB230
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::PlayAnimWebPath(idAI2 *this, const idAnimWebPath *animPath, const bool forceTransition)
{
  idAI2::idAIVolatile::idAIAnimationInfo *p_animation; // r30
  const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *v5; // r29
  idDeclAnimWeb *StateIndexForName; // r3
  const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *v7; // r28
  int v8; // r3
  int v9; // r27
  int v11; // [sp+50h] [-A0h] BYREF
  idAI2::idAIVolatile::idAIAnimationInfo *v12; // [sp+54h] [-9Ch] BYREF
  blendParms_t v13; // [sp+60h] [-90h] BYREF
  idStr v14; // [sp+80h] [-70h] BYREF
  idStr v15[2]; // [sp+A0h] [-50h] BYREF

  v15[0].len = 0;
  v15[0].allocedAndFlag = 20;
  v15[0].data = v15[0].baseBuffer;
  v15[0].baseBuffer[0] = 0;
  v14.allocedAndFlag = 20;
  v14.data = v14.baseBuffer;
  v14.len = 0;
  v14.baseBuffer[0] = 0;
  p_animation = &this->aiVolatile.animation;
  idAI2::GetSubWebAndStateFromAnimWebPath(this, animWebPath: animPath->data, subWebName: v15, stateName: &v14);
  v5 = (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)HIWORD(idDeclAnimWeb::GetSubWebIndexForName(
                                                                                 this: (idDeclAnimWeb *)&v11,
                                                                                 result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
                                                                                 subWebName: v15[0].data)->__vftable);
  StateIndexForName = idDeclAnimWeb::GetStateIndexForName(
                        this: (idDeclAnimWeb *)&v12,
                        result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
                        name: v14.data);
  v7 = (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)HIWORD(StateIndexForName->__vftable);
  if ( (__int16)v5 < 0 || (__int16)v7 < 0 )
  {
    idStr::FreeData(this: &v14);
    idStr::FreeData(this: v15);
    return 0;
  }
  else
  {
    if ( forceTransition )
    {
      blendParms_t::blendParms_t(this: &v13);
      blendParms_t::SetDurationMS(this: &v13, ms: 0x3E8u);
      v8 = idAnimator_AnimWeb::ForceState(
             this: (idAnimator_AnimWeb *)p_animation,
             subWebIndex_: v5,
             stateIndex_: v7,
             blendParms: &v13,
             blendEventMask_: 0);
    }
    else
    {
      v8 = idAnimator_AnimWeb::ChangeState(
             this: (idAnimator_AnimWeb *)p_animation,
             subWebIndex: v5,
             stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)HIWORD(StateIndexForName->__vftable),
             interruptPath_: INTR_PATH_YES,
             interruptBlend_: INTR_BLEND_NO,
             blendEventMask_: 0);
    }
    v9 = v8;
    if ( v8 == 1 )
    {
      v12 = p_animation;
      idAnimator_AnimWeb::SetEvent(
        this: (idAnimator_AnimWeb *)p_animation,
        eventType: ANIMWEB_EVENT_DEST_CLAMPED,
        subWebIndex: v5,
        stateIndex: v7,
        eventDef: &EV_AnimWeb_Wait,
        priority: PRIORITY_LOW);
    }
    idStr::FreeData(this: &v14);
    idStr::FreeData(this: v15);
    return v9;
  }
}


// ========================================================================
// __unwind$527310
// EA  : 0x829FB398
// RVA : 0x009FB398
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_527310()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 240 + 160));
}


// ========================================================================
// __unwind$527311
// EA  : 0x829FB3C0
// RVA : 0x009FB3C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_527311()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 240 + 128));
}


// ========================================================================
// ?ShouldScramble@idAI2@@QBA_NXZ
// EA  : 0x829FB3E8
// RVA : 0x009FB3E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ShouldScramble(idAI2 *this)
{
  int valueInteger; // r30
  idEncounterGroup *v3; // r3
  int stageChangeTime; // r31
  BOOL result; // r3

  result = false;
  if ( ai_enableScrambles.valueInteger != 0 )
  {
    valueInteger = ai_scrambleTime.valueInteger;
    if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
       - this->aiVolatile.memory.lastFiredAtTime < valueInteger
      || (unsigned __int8)idAI2::IsInAvoidFSM(this) != 0
      || (this->aiVolatile.groupStatus.condition & 0x10) != 0 )
    {
      return true;
    }
    if ( idAI2::GetCurrentCombatStage(this) != nullptr
      && idAI2::GetCurrentCombatStage(this)->stageType == COMBAT_STAGE_RETREAT )
    {
      v3 = (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      stageChangeTime = v3->stageChangeTime;
      if ( stageChangeTime + 8000 > idGameTimeManager::GetGameMs(
                                      this: &clientGame->gameTimeManager,
                                      type: GAMETIME_SCALED) )
        return true;
    }
  }
  return result;
}


// ========================================================================
// ?UpdateGoreLevel@idAI2@@QAA_N_N@Z
// EA  : 0x829FB510
// RVA : 0x009FB510
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::UpdateGoreLevel(idAI2 *this, const bool painTest)
{
  idDamageGroup *DamageGroup; // r31
  idDamageGroup *v5; // r3
  goreLevel_t goreLevel; // r23
  int v7; // r26
  int v8; // r27
  damageGroupGoreLevelInfo_t *list; // r25
  int num; // r24
  int v11; // r29
  damageGroupGoreLevelInfo_t *v12; // r30
  int v13; // r11
  const char *data; // r4
  int v15; // r30
  const char *str; // r6
  const char *v17; // r27
  damageGroupGoreLevelInfo_t *v18; // r29
  char *v19; // r26
  int GameMs; // r3
  double v21; // fp10
  double v22; // fp9
  damageGroupGoreLevelInfo_t *v23; // r29
  bool v24; // r5
  runIndexType_t v25; // r4
  double forwardRunIndex; // fp1
  idAtomicString v28; // [sp+50h] [-70h] BYREF
  idAtomicString v29; // [sp+54h] [-6Ch] BYREF
  idVec3 v30; // [sp+58h] [-68h] BYREF

  if ( ai_enableInjuredRuns.valueInteger == 0
    || this->aiEditable.behaviors.decl->damageBehaviors.injuredRunMode != AIINJUREDRUNMODE_GORE_LEVEL )
  {
    return 0;
  }
  if ( notSupported )
    idLib::Error(
      fmt: "Advanced goring isn't supported, damage behaviours can't use 'AIINJUREDRUNMODE_GORE_LEVEL' untill we fixed it, onl"
      "y 'killshot' goring is allowed!");
  DamageGroup = idActor::GetDamageGroup(
                  this,
                  joint: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)this->aiVolatile.pain.damageInfo.jointIndex.value);
  v5 = idActor::GetDamageGroup(this, name: this->aiVolatile.pain.damageInfo.injuryDamageGroup.str);
  goreLevel = GORELEVEL_NONE;
  if ( v5 != nullptr )
    goreLevel = v5->goreLevelInfo.list[this->aiVolatile.pain.damageInfo.injuryGoreLevelIndex].goreLevel;
  if ( DamageGroup == nullptr )
    return 0;
  v7 = -1;
  v8 = 0;
  if ( DamageGroup->goreLevelInfo.num <= 0 )
    return 0;
  list = DamageGroup->goreLevelInfo.list;
  num = DamageGroup->goreLevelInfo.num;
  v11 = 0;
  do
  {
    v12 = &list[v11];
    if ( !list[v11].requiresPain || painTest )
    {
      v13 = v12->goreLevel;
      if ( v13 > DamageGroup->currentGoreLevel
        && v13 > goreLevel
        && idDamageGroup::HealthRatio(this: DamageGroup) < (double)v12->healthRatio )
      {
        v7 = v8;
      }
    }
    ++v8;
    ++v11;
  }
  while ( v8 < num );
  if ( v7 < 0 )
    return 0;
  data = DamageGroup->groupName.data;
  v15 = v7;
  DamageGroup->currentGoreLevel = list[v7].goreLevel;
  idAtomicString::Set(this: &v28, str_: data);
  str = v28.str;
  this->aiVolatile.pain.damageInfo.injuryGoreLevelIndex = v7;
  this->aiVolatile.pain.damageInfo.injuryDamageGroup.str = str;
  if ( ai_debugGore.valueInteger != 0 && ai_debugLevel.valueInteger != 0 )
  {
    v17 = DamageGroup->groupName.data;
    v18 = &DamageGroup->goreLevelInfo.list[v15];
    v19 = this->name.data;
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idLib::Printf(fmt: "[%6d] ai %s new gore level %d for %s\n", GameMs, v19, v18->goreLevel, v17);
  }
  v21 = -DamageGroup->lastHitAxis.mat[0].y;
  v22 = -DamageGroup->lastHitAxis.mat[0].x;
  v30.z = -DamageGroup->lastHitAxis.mat[0].z;
  v30.x = v22;
  v30.y = v21;
  v23 = &DamageGroup->goreLevelInfo.list[v15];
  idAtomicString::Set(this: &v29, str_: DamageGroup->groupName.data);
  if ( !idGoreComponent::CheckForGoreByDamageGroup(
          this: &this->aiVolatile.death.goreComponent,
          name: &v29,
          level: v23->goreLevel,
          dir: &v30) )
    idLib::Warning(
      fmt: "idAI2::AlertCycle::Pain::Enter - bad gore name %s and/or level %d",
      DamageGroup->groupName.data,
      DamageGroup->goreLevelInfo.list[v15].goreLevel);
  forwardRunIndex = DamageGroup->forwardRunIndex;
  if ( forwardRunIndex != 0.0 )
    idAnimWebAI::SetForwardRunIndex(
      this: this->aiVolatile.animation.animWebAnimator.ptr,
      newRunIndex: forwardRunIndex,
      newIdleIndex: DamageGroup->injuredIdleIndex,
      t: v25,
      blend: v24);
  return 1;
}


// ========================================================================
// ?PauseCurrentThreadTillActionCompletes@idAIScriptProxy@@AAAXXZ
// EA  : 0x829FB788
// RVA : 0x009FB788
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIScriptProxy::PauseCurrentThreadTillActionCompletes(idAIScriptProxy *this)
{
  idThread *currentThread; // r31

  currentThread = gameLocal->program.threadManager.currentThread;
  if ( currentThread != nullptr )
  {
    this->owner->AddThread(
      this: this->owner,
      a2: (const idHandle<int,enum invalidThreadHandle_t,0> *)currentThread->threadHandle.value);
    idAIScriptProxy::PauseThreadTillActionCompletes(this, thread: currentThread);
  }
}


// ========================================================================
// ?PauseCurrentFiberTillActionCompletes@idAIScriptProxy@@AAAXXZ
// EA  : 0x829FB7F8
// RVA : 0x009FB7F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIScriptProxy::PauseCurrentFiberTillActionCompletes(idAIScriptProxy *this)
{
  idHandle<int,enum invalidFiberId_t,0> *v2; // [sp+50h] [-20h] BYREF

  idSuperScriptSystem::GetCurrentFiberHandle(
    this: (idSuperScriptSystem *)&v2,
    result: (idHandle<int,enum invalidFiberId_t,0> *)&gameLocal->superScript);
  if ( v2 != nullptr )
  {
    ((void (__fastcall *)(idAI2 *))this->owner->AddFiber)(a1: this->owner);
    idAIScriptProxy::PauseFiberTillActionCompletes(this, fiberHandle: v2);
  }
}


// ========================================================================
// ?Set@idAIDeathInfo@@QAAXABVidAIDamageInfo@@@Z
// EA  : 0x829FC830
// RVA : 0x009FC830
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAIDeathInfo::Set(idAIDeathInfo *this, idAIDamageInfo *info)
{
  int value; // r10
  idEntity *v5; // r3
  idEntity *v6; // r3
  int v7; // r9
  idGameLocal *v8; // r11
  idEntity *v9; // r3
  idEntity *v10; // r3

  value = info->attacker.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr
    && (v6 = idEntity::CastTo(c: v5)) != nullptr )
  {
    this->attacker.spawnId.value = (gameLocal->spawnIds.ptr[v6->entityNumber] << 13) | v6->entityNumber;
  }
  else
  {
    this->attacker.spawnId.value = 0x1FFF;
  }
  v7 = info->inflictor.spawnId.value;
  v8 = gameLocal;
  if ( gameLocal->spawnIds.ptr[v7 & 0x1FFF] == v7 >> 13 && (v9 = gameLocal->entities.ptr[v7 & 0x1FFF]) != nullptr )
  {
    v10 = idEntity::CastTo(c: v9);
    v8 = gameLocal;
  }
  else
  {
    v10 = nullptr;
  }
  if ( v10 != nullptr )
    this->inflictor.spawnId.value = (v8->spawnIds.ptr[v10->entityNumber] << 13) | v10->entityNumber;
  else
    this->inflictor.spawnId.value = 0x1FFF;
  this->impulse = *idAIDamageInfo::GetDeathImpulse(this: info);
  this->startDeathTime = idGameTimeManager::GetGameMs(
                           this: &gameLocal->clientGame.gameTimeManager,
                           type: GAMETIME_SCALED);
}


// ========================================================================
// ??0idAnimWebDefaults@idAI2@@QAA@XZ
// EA  : 0x829FCB10
// RVA : 0x009FCB10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2::idAnimWebDefaults *__fastcall idAI2::idAnimWebDefaults::idAnimWebDefaults(idAI2::idAnimWebDefaults *this)
{
  this->webPath.len = 0;
  this->webPath.data = this->webPath.baseBuffer;
  this->webPath.allocedAndFlag = 20;
  this->webPath.baseBuffer[0] = 0;
  this->activeLayers.list = nullptr;
  this->activeLayers.granularity = 0;
  this->activeLayers.memTag = 5;
  this->activeLayers.listStatic = 0;
  this->activeLayers.size = 0;
  this->activeLayers.num = 0;
  idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)&this->activeLayers);
  this->enabled = false;
  return this;
}


// ========================================================================
// __unwind$531275
// EA  : 0x829FCB78
// RVA : 0x009FCB78
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_531275()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: *(idStr **)(v0 - 112 + 132));
}


// ========================================================================
// ??0idAnimWebDefaults@idAI2@@QAA@PBD0_N@Z
// EA  : 0x829FCBA8
// RVA : 0x009FCBA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2::idAnimWebDefaults *__fastcall idAI2::idAnimWebDefaults::idAnimWebDefaults(
        idAI2::idAnimWebDefaults *this,
        char *subWebName_,
        char *stateName_,
        bool enabled_)
{
  this->webPath.len = 0;
  this->webPath.data = this->webPath.baseBuffer;
  this->webPath.allocedAndFlag = 20;
  this->webPath.baseBuffer[0] = 0;
  this->activeLayers.list = nullptr;
  this->activeLayers.granularity = 0;
  this->activeLayers.memTag = 5;
  this->activeLayers.listStatic = 0;
  this->activeLayers.size = 0;
  this->activeLayers.num = 0;
  idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)&this->activeLayers);
  this->enabled = enabled_;
  idAnimWebPath::SetPath(this: &this->webPath, webName: &byte_8200D768, subWebName: subWebName_, stateName: stateName_);
  return this;
}


// ========================================================================
// __unwind$531329
// EA  : 0x829FCC34
// RVA : 0x009FCC34
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_531329()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: *(idStr **)(v0 - 128 + 148));
}


// ========================================================================
// __unwind$531330
// EA  : 0x829FCC5C
// RVA : 0x009FCC5C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_531330()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(*(_DWORD *)(v0 - 128 + 148) + 32));
}


// ========================================================================
// ??0idAIFocusInfo@idAIVolatile@idAI2@@QAA@XZ
// EA  : 0x829FCC90
// RVA : 0x009FCC90
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2::idAIVolatile::idAIFocusInfo *__fastcall idAI2::idAIVolatile::idAIFocusInfo::idAIFocusInfo(
        idAI2::idAIVolatile::idAIFocusInfo *this)
{
  `eh vector constructor iterator'(
    ptr: this,
    size: 0x110u,
    count: 2,
    pCtor: (void (__fastcall *)(void *))idFocusInfo::idFocusInfo,
    pDtor: (void (__fastcall *)(void *))idFocusInfo::~idFocusInfo);
  idAIOrientation::idAIOrientation(this: &this->bodyOrientation, minRate: 45.0, maxRate: 540.0);
  this->enableHeadTracking = true;
  this->enableBodyRotation = true;
  *(_WORD *)&this->enableAutoFocus = 1;
  idCheckSurroundingsState::idCheckSurroundingsState(this: &this->checkSurroundingsState);
  return this;
}


// ========================================================================
// __unwind$531389
// EA  : 0x829FCD20
// RVA : 0x009FCD20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_531389()
{
  int v0; // r12

  idArray<idFocusInfo,2>::~idArray<idFocusInfo,2>(this: *(idAI2::idAIVolatile::idAIFocusInfo **)(v0 - 112 + 132));
}


// ========================================================================
// ?RobotBatteryExplodes@idAI2@@QAA_NPAVidEntity@@@Z
// EA  : 0x829FCED8
// RVA : 0x009FCED8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::RobotBatteryExplodes(idAI2 *this, idEntity *_pAttacker)
{
  int curStage; // r10
  idGameLocal *v5; // r11
  int value; // r9
  idEntity *v7; // r3
  const idEntity *v8; // r4
  idEntityPtr<idEntity> *v9; // r30
  idEventArg *v10; // r3
  char *v11; // r10
  _DWORD *v12; // r9
  int i; // ctr
  idEntity *v14; // r3
  int v15; // r9
  idEntity *v16; // r3
  idEventArg *v17; // r3
  char *v18; // r10
  _DWORD *v19; // r11
  int j; // ctr
  idEntity *v21; // r3
  int numStages; // r10
  int v23; // r11
  idPhysics *Physics; // r3
  idPresentable *presentable; // r3
  idEntity *NextTeamEntity; // r30
  idEntity *v27; // r28
  idPresentable *v28; // r3
  int GameMs; // r3
  __int64 v31; // r10
  double v32; // fp9
  __int64 v33; // r8
  bool v34; // [sp+Bh] [-115h]
  bool v35; // [sp+Fh] [-111h]
  bool v36; // [sp+13h] [-10Dh]
  char v37; // [sp+ACh] [-74h] BYREF
  __int64 v38; // [sp+B8h] [-68h]
  idEventArg v39; // [sp+D0h] [-50h] BYREF

  if ( !this->aiEditable.actionSettings.customRobot.usesRobot )
    return 0;
  curStage = this->aiEditable.actionSettings.customRobot.curStage;
  if ( this->aiEditable.actionSettings.customRobot.stageTriggers.num <= curStage )
    goto LABEL_9;
  v5 = gameLocal;
  value = this->aiEditable.actionSettings.customRobot.stageTriggers.list[curStage].spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v7 = gameLocal->entities.ptr[this->aiEditable.actionSettings.customRobot.stageTriggers.list[curStage].spawnId.value
                               & 0x1FFF];
    if ( v7 != nullptr )
    {
      if ( idEntity::CastTo(c: v7) != nullptr )
      {
        v8 = _pAttacker;
        v9 = &this->aiEditable.actionSettings.customRobot.stageTriggers.list[this->aiEditable.actionSettings.customRobot.curStage];
        v10 = idEventArg::idEventArg(this: &v39, data: v8);
        v11 = &v37;
        v12 = (_DWORD *)&v10[-1].value.q[3];
        for ( i = 5; i != 0; --i )
        {
          ++v12;
          v11 += 4;
          *(_DWORD *)v11 = *v12;
        }
        v14 = idEntityPtr<idEntity const>::operator->(this: v9);
        idEventReceiver::PostEventMS(this: v14, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)HIDWORD(v38));
      }
LABEL_9:
      v5 = gameLocal;
    }
  }
  if ( this->aiEditable.actionSettings.customRobot.isCharging )
  {
    v15 = this->aiEditable.actionSettings.customRobot.triggerOnChargingDone.spawnId.value;
    if ( v5->spawnIds.ptr[v15 & 0x1FFF] == v15 >> 13 )
    {
      v16 = v5->entities.ptr[v15 & 0x1FFF];
      if ( v16 != nullptr && idEntity::CastTo(c: v16) != nullptr )
      {
        v17 = idEventArg::idEventArg(this: &v39, data: this);
        v18 = &v37;
        v19 = (_DWORD *)&v17[-1].value.q[3];
        for ( j = 5; j != 0; --j )
        {
          ++v19;
          v18 += 4;
          *(_DWORD *)v18 = *v19;
        }
        v21 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnChargingDone);
        idEventReceiver::PostEventMS(this: v21, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)HIDWORD(v38));
      }
    }
  }
  numStages = this->aiEditable.actionSettings.customRobot.numStages;
  v23 = this->aiEditable.actionSettings.customRobot.curStage + 1;
  this->aiEditable.actionSettings.customRobot.curStage = v23;
  if ( v23 < numStages )
  {
    this->aiEditable.actionSettings.customRobot.curStageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
    this->aiEditable.actionSettings.customRobot.chargeStartTime = -1;
    this->aiEditable.actionSettings.customRobot.isCharging = false;
    this->aiEditable.actionSettings.customRobot.chargeDoneTime = -1;
    this->aiEditable.actionSettings.customRobot.immuneDoneTime = idGameTimeManager::GetGameMs(
                                                                   this: &clientGame->gameTimeManager,
                                                                   type: GAMETIME_SCALED)
                                                               - (int)(float)((float)1000.0 * (float)-2.0);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    LODWORD(v31) = this->aiEditable.actionSettings.customRobot.numStages;
    v32 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth
                / this->aiEditable.actionSettings.customRobot.stageHealth);
    LODWORD(v33) = v31 - this->aiEditable.actionSettings.customRobot.curStage - 1;
    this->aiEditable.actionSettings.customRobot.noFireTime = GameMs - (int)(float)(1000.0 * (float)-2.0);
    this->aiEditable.actionSettings.customRobot.bossHealth = (float)((float)v33 + (float)v32) / (float)v31;
    return 0;
  }
  this->aiHealth.Kill_Impl(this: &this->aiHealth, a2: 1.0);
  this->aiHealth.SetDeadFlag(this: &this->aiHealth);
  Physics = idEntity::GetPhysics(this);
  Physics->GetOrigin(this: Physics, a2: 0);
  idAIDamageInfo::Update(
    this: &this->aiVolatile.pain.damageInfo,
    ai: this,
    inflictor: this,
    attacker: this,
    damageDecl: gameLocal->damageDecl,
    damage: 0.0,
    unscaledDamage: 0.0,
    damageScale: 0.0,
    armorDamage: 0.0,
    impactPoint: (const idVec3 *)0x1AAB50,
    impactDir: (const idVec3 *)1,
    impactJoint: nullptr,
    killed: v34,
    armorPoppedOff: v35,
    forceInjured: v36);
  if ( this->IsDead(this) || this->IsDying(this) )
  {
    presentable = this->presentable;
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
    }
    idPresentable::SetParm(this: presentable, parm: rp->Diversity, scalar: 0.0);
    NextTeamEntity = idEntity::GetNextTeamEntity(this);
    if ( NextTeamEntity != nullptr )
    {
      do
      {
        v27 = idEntity::GetNextTeamEntity(this: NextTeamEntity);
        if ( idEntity::GetBindMaster(this: NextTeamEntity) == this )
        {
          v28 = NextTeamEntity->presentable;
          if ( v28 == nullptr )
          {
            idEntity::InitPresentableInternal(this: NextTeamEntity);
            v28 = NextTeamEntity->presentable;
          }
          idPresentable::SetParm(this: v28, parm: rp->Diversity, scalar: 0.0);
          idEntity::UpdateVisuals(this: NextTeamEntity);
        }
        NextTeamEntity = v27;
      }
      while ( v27 != nullptr );
    }
  }
  return 1;
}


// ========================================================================
// ?OnActivateRobot@idAI2@@QAAXHPAVidEntity@@@Z
// EA  : 0x829FD310
// RVA : 0x009FD310
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnActivateRobot(idAI2 *this, int _curTime, idEntity *_pActivator)
{
  int chargeDoneTime; // r10
  double chargeTime; // fp13

  if ( this->aiEditable.actionSettings.customRobot.usesRobot && this->aiEditable.actionSettings.customRobot.isCharging )
  {
    chargeDoneTime = this->aiEditable.actionSettings.customRobot.chargeDoneTime;
    if ( chargeDoneTime == -1 )
    {
      chargeTime = this->aiEditable.actionSettings.customRobot.chargeTime;
      this->aiEditable.actionSettings.customRobot.chargeStartTime = _curTime;
      this->aiEditable.actionSettings.customRobot.chargeDoneTime = (int)(float)((float)chargeTime * (float)1000.0)
                                                                 + _curTime;
    }
    else if ( chargeDoneTime > 0 )
    {
      idAI2::RobotBatteryExplodes(this, _pAttacker: _pActivator);
    }
  }
}


// ========================================================================
// ?OnActivate@idAI2@@UAAXPAVidEntity@@@Z
// EA  : 0x829FD3A0
// RVA : 0x009FD3A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnActivate(idAI2 *this, idEntity *activator)
{
  int GameMs; // r3

  if ( this->aiEditable.actionSettings.customRobot.usesRobot )
  {
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idAI2::OnActivateRobot(this, _curTime: GameMs, _pActivator: activator);
    if ( !this->IsDead(this) )
      this->IsDying(this);
  }
}


// ========================================================================
// ?UpdateBodyOrientationWhileMoving@idAI2@@QAAXXZ
// EA  : 0x829FD520
// RVA : 0x009FD520
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateBodyOrientationWhileMoving(idAI2 *this)
{
  idAIOrientation *v2; // r28
  aiMovementMode_t movementMode; // r11
  int startMoveFrame; // r29
  idPhysics *Physics; // r30
  const idVec3 *v6; // r29
  double minRange; // fp31
  double v8; // fp1
  double v13; // fp27
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r30
  double v15; // fp7
  double v16; // fp6
  double y; // fp31
  double z; // fp30
  double x; // fp29
  double v20; // fp10
  double v21; // fp6
  double v22; // fp4
  long double v23; // fp2
  double v24; // fp0
  idQuat *v25; // r3
  idAIOrientation *MoveOrientation; // r3
  turnDirection_t v27; // r3
  double turnVelocity; // fp31
  unsigned __int8 v29; // r31
  double v30; // fp0
  int (*GetGameMsPerFrame)(void); // ctr
  int v32; // r3
  turnDirection_t v33; // r5
  __int64 v34; // fp11
  double v35; // fp0
  idQuat v36; // [sp+50h] [-C0h] BYREF
  idVec3 v37; // [sp+60h] [-B0h] BYREF
  idVec3 v38; // [sp+70h] [-A0h] BYREF
  float v39[4]; // [sp+80h] [-90h] BYREF
  idVec3 v40; // [sp+90h] [-80h] BYREF
  idQuat v41[4]; // [sp+A0h] [-70h] BYREF

  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) == 0 )
  {
    v2 = (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0
       ? &this->aiVolatile.animation.animFSM.orientBody
       : &this->aiVolatile.focus.bodyOrientation;
    movementMode = this->aiVolatile.physics.moveState.movementMode;
    if ( movementMode != AIMOVEMODE_ANIM
      && movementMode != AIMOVEMODE_ANIM_GRAVITY
      && movementMode != AIMOVEMODE_ANIM_TURN
      && movementMode != AIMOVEMODE_ANIM_DRIVEN
      && !this->aiVolatile.physics.moveState.IsPlayingTraversalAnim(this: &this->aiVolatile.physics.moveState) )
    {
      startMoveFrame = this->aiVolatile.physics.moveState.startMoveFrame;
      if ( gameLocal->GetGameFrame(this: gameLocal) != startMoveFrame
        && this->aiVolatile.physics.moveState.remainingTransitionFrames <= 0 )
      {
        if ( !this->aiVolatile.focus.enableBodyRotation
          || this->aiEditable.movement.suppressBodyRotation
          || idActor::IsSitting(this) )
        {
          idAIOrientation::UpdateStatic(this: v2);
        }
        else if ( !idAIMoveState::AlignToNextPoint(this: &this->aiVolatile.physics.moveState) )
        {
          Physics = idEntity::GetPhysics(this);
          v6 = Physics->GetGravityNormal(this: Physics);
          Physics->GetLinearVelocity(this: (idPhysics *)&v40, result: (idVec3 *)Physics, a3: 0);
          minRange = this->aiConstants.movement.moveSpeed.minRange;
          v8 = idVec3::NormalizeFast(this: &v40);
          if ( (float)(this->aiConstants.movement.moveSpeed.maxRange - (float)minRange) == 0.0 )
          {
            _FP0 = 0.0;
          }
          else
          {
            _FP12 = -(float)((float)v8 - (float)minRange);
            __asm { fsel      f11, f12, f28, f0 }
            _FP9 = (float)((float)1.0
                         - (float)((float)_FP11
                                 / (float)(this->aiConstants.movement.moveSpeed.maxRange - (float)minRange)));
            __asm { fsel      f0, f9, f10, f30 }
          }
          if ( ai_forceTurnRate.valueInteger != 0 )
            v13 = (float)((float)((float)(ai_maxTurnRate.valueFloat - ai_minTurnRate.valueFloat) * (float)_FP0)
                        + ai_minTurnRate.valueFloat);
          else
            v13 = (float)((float)((float)(this->aiConstants.movement.bodyTurnRate.maxRange
                                        - this->aiConstants.movement.bodyTurnRate.minRange)
                                * (float)_FP0)
                        + this->aiConstants.movement.bodyTurnRate.minRange);
          if ( (*((_BYTE *)&this->aiEditable.behaviors.decl->movementBehaviors + 40) & 8) != 0 )
          {
            idAIOrientation::SetIdealDir(this: v2, ai: this, dir: &v40);
            *(_QWORD *)&v36.x = __PAIR64__(
                                  &unk_82390000,
                                  gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED));
            idAIOrientation::UpdateAxis(
              this: v2,
              normal: v6,
              turnRate: v13,
              timeSeconds: (float)((float)*(__int64 *)&v36.x * (float)0.001));
          }
          else
          {
            p_focus = &this->aiVolatile.focus;
            if ( (unsigned __int8)idFocusInfo::HasFocus(this: this->aiVolatile.focus.foci.ptr) == 0 )
              p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)&this->aiVolatile.focus.foci.ptr[1];
            if ( this->aiConstants.movement.allowStrafing
              && ((unsigned __int8)idAI2::HasFocus(this) != 0 && p_focus->foci.ptr[0].keepFocusInView
               || ai_faceFocus.valueInteger != 0) )
            {
              this->GetEyePos(this, a2: (idVec3 *)v39);
              v15 = (float)(p_focus->foci.ptr[0].idealFocusPoint.y - v39[1]);
              v16 = (float)(p_focus->foci.ptr[0].idealFocusPoint.z - v39[2]);
              if ( p_focus->foci.ptr[0].fociType != AIFOCI_AIM )
              {
                v38.x = p_focus->foci.ptr[0].idealFocusPoint.x - v39[0];
                v38.y = v15;
                v38.z = v16;
                idVec3::ProjectOntoPlane(this: &v38, normal: v6, overBounce: 1.0);
                idVec3::NormalizeFast(this: &v38);
                y = v40.y;
                z = v40.z;
                x = v40.x;
                if ( (float)((float)(v38.x * v40.x) + (float)((float)(v40.z * v38.z) + (float)(v40.y * v38.y))) <= (double)p_focus->foci.ptr[0].aimTracker.maxYawDot )
                {
                  v20 = v6->y;
                  v21 = (float)(v6->x * v38.y);
                  v22 = (float)((float)(v6->z * v38.y) - (float)(v6->y * v38.z));
                  v36.y = (float)(v6->x * v38.z) - (float)(v6->z * v38.x);
                  v36.x = v22;
                  v36.z = (float)((float)v20 * v38.x) - (float)v21;
                  idVec3::NormalizeFast(this: (idVec3 *)&v36);
                  if ( (float)((float)(v36.x * (float)x) + (float)((float)(v36.y * (float)y) + (float)(v36.z * (float)z))) <= 0.0 )
                    v24 = 0.0;
                  else
                    v24 = -1.0;
                  v36.x = p_focus->foci.ptr[0].aimTracker.maxYaw.value * (float)v24;
                  *(double *)&v23 = (float)(v36.z * (float)z);
                  *((double *)&v23 + 1) = v36.z;
                  idQuat::idQuat(
                    this: v41,
                    axis: v6,
                    angle: (const idTypesafeNumber<float,enum RadiansUnique_t> *)&v36,
                    a4: v23);
                  v25 = idQuat::operator*(this: &v36, result: (idVec3 *)v41, a: &v38);
                  v37.x = v25->x;
                  v37.y = v25->y;
                  v37.z = v25->z;
                }
                else
                {
                  v37.x = v40.x;
                  v37.y = v40.y;
                  v37.z = v40.z;
                }
              }
              else
              {
                v37.x = p_focus->foci.ptr[0].idealFocusPoint.x - v39[0];
                v37.y = v15;
                v37.z = v16;
                idVec3::ProjectOntoPlane(this: &v37, normal: v6, overBounce: 1.0);
                idVec3::NormalizeFast(this: &v37);
              }
              idAIOrientation::SetIdealDir(this: v2, ai: this, dir: &v37);
              *(_QWORD *)&v36.x = __PAIR64__(
                                    &unk_82390000,
                                    gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED));
              idAIOrientation::UpdateAxis(
                this: v2,
                normal: v6,
                turnRate: v13,
                timeSeconds: (float)((float)*(__int64 *)&v36.x * (float)0.001));
            }
            else
            {
              MoveOrientation = idAI2::GetMoveOrientation(this);
              idAIOrientation::SetIdealDir(this: v2, ai: this, dir: &MoveOrientation->idealDir);
              v27 = idAIOrientation::CalculateTurnDirection(this: v2, normal: v6);
              turnVelocity = v2->turnVelocity;
              v29 = v27;
              if ( v27 == v2->currentTurnDir || v2->currentTurnDir == 0 )
              {
                if ( v27 == TURN_LEFT )
                {
                  if ( turnVelocity < 1.0 )
                  {
                    if ( turnVelocity >= 0.0 )
                    {
                      if ( turnVelocity >= 0.5 )
                        turnVelocity = (float)(v2->turnVelocity + (float)0.025);
                      else
                        turnVelocity = (float)(v2->turnVelocity + (float)0.1);
                    }
                    else
                    {
                      turnVelocity = (float)(v2->turnVelocity + (float)0.2);
                    }
                  }
                }
                else if ( turnVelocity > -1.0 )
                {
                  if ( turnVelocity <= 0.0 )
                  {
                    if ( turnVelocity <= -0.5 )
                      v30 = 0.025;
                    else
                      v30 = 0.1;
                  }
                  else
                  {
                    v30 = 0.2;
                  }
                  turnVelocity = (float)(v2->turnVelocity - (float)v30);
                }
              }
              v2->turnVelocity = turnVelocity;
              GetGameMsPerFrame = (int (*)(void))gameLocal->GetGameMsPerFrame;
              if ( turnVelocity < 0.0 )
              {
                *(_QWORD *)&v36.x = __PAIR64__(&unk_82200000, GetGameMsPerFrame());
                v33 = TURN_RIGHT;
                v35 = -1.5;
                v34 = *(_QWORD *)&v36.x;
              }
              else
              {
                v32 = GetGameMsPerFrame();
                v33 = TURN_LEFT;
                *(_QWORD *)&v36.x = __PAIR64__(0x82000000, v32);
                v34 = __PAIR64__(0x82000000, v32);
                v35 = 1.5;
              }
              idAIOrientation::UpdateBodyAxis(
                this: v2,
                normal: v6,
                turnDir: v33,
                turnRate: (float)((float)((float)v13 * (float)turnVelocity) * (float)v35),
                timeSeconds: (float)((float)v34 * (float)0.001));
              v2->currentTurnDir = v29;
            }
          }
        }
      }
    }
  }
}


// ========================================================================
// ?UpdateBodyOrientationWhileMovingWithFSM@idAI2@@QAAXXZ
// EA  : 0x829FDB40
// RVA : 0x009FDB40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateBodyOrientationWhileMovingWithFSM(idAI2 *this)
{
  idAIOrientation *p_orientBody; // r29
  idPhysics *Physics; // r30
  const idVec3 *v4; // r28
  double minRange; // fp31
  double v6; // fp1
  double v11; // fp27
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r30
  double v13; // fp7
  double v14; // fp6
  double v15; // fp7
  double v16; // fp6
  double y; // fp31
  double z; // fp30
  double x; // fp29
  double v20; // fp10
  double v21; // fp6
  double v22; // fp4
  long double v23; // fp2
  double v24; // fp0
  idQuat *v25; // r3
  idAIOrientation *MoveOrientation; // r3
  turnDirection_t v27; // r3
  double turnVelocity; // fp31
  unsigned __int8 v29; // r31
  double v30; // fp0
  int (*GetGameMsPerFrame)(void); // ctr
  int v32; // r3
  turnDirection_t v33; // r5
  __int64 v34; // fp11
  double v35; // fp0
  idQuat v36; // [sp+50h] [-B0h] BYREF
  idVec3 v37; // [sp+60h] [-A0h] BYREF
  idVec3 v38; // [sp+70h] [-90h] BYREF
  float v39; // [sp+80h] [-80h] BYREF
  float v40; // [sp+84h] [-7Ch]
  float v41; // [sp+88h] [-78h]
  idVec3 v42; // [sp+90h] [-70h] BYREF
  idQuat v43[3]; // [sp+A0h] [-60h] BYREF

  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    p_orientBody = &this->aiVolatile.animation.animFSM.orientBody;
  else
    p_orientBody = &this->aiVolatile.focus.bodyOrientation;
  if ( !this->aiVolatile.focus.enableBodyRotation
    || this->aiEditable.movement.suppressBodyRotation
    || idActor::IsSitting(this) )
  {
    idAIOrientation::UpdateStatic(this: p_orientBody);
  }
  else
  {
    Physics = idEntity::GetPhysics(this);
    v4 = Physics->GetGravityNormal(this: Physics);
    Physics->GetLinearVelocity(this: (idPhysics *)&v42, result: (idVec3 *)Physics, a3: 0);
    minRange = this->aiConstants.movement.moveSpeed.minRange;
    v6 = idVec3::NormalizeFast(this: &v42);
    if ( (float)(this->aiConstants.movement.moveSpeed.maxRange - (float)minRange) == 0.0 )
    {
      _FP0 = 0.0;
    }
    else
    {
      _FP12 = -(float)((float)v6 - (float)minRange);
      __asm { fsel      f11, f12, f28, f0 }
      _FP9 = (float)((float)1.0
                   - (float)((float)_FP11 / (float)(this->aiConstants.movement.moveSpeed.maxRange - (float)minRange)));
      __asm { fsel      f0, f9, f10, f30 }
    }
    if ( ai_forceTurnRate.valueInteger != 0 )
      v11 = (float)((float)((float)(ai_maxTurnRate.valueFloat - ai_minTurnRate.valueFloat) * (float)_FP0)
                  + ai_minTurnRate.valueFloat);
    else
      v11 = (float)((float)((float)(this->aiConstants.movement.bodyTurnRate.maxRange
                                  - this->aiConstants.movement.bodyTurnRate.minRange)
                          * (float)_FP0)
                  + this->aiConstants.movement.bodyTurnRate.minRange);
    p_focus = &this->aiVolatile.focus;
    if ( (unsigned __int8)idFocusInfo::HasFocus(this: this->aiVolatile.focus.foci.ptr) == 0 )
      p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)&this->aiVolatile.focus.foci.ptr[1];
    if ( (unsigned __int8)idAI2::HasFocus(this) != 0
      && (p_focus->foci.ptr[0].keepFocusInView || ai_faceFocus.valueInteger != 0) )
    {
      this->GetEyePos(this, a2: (idVec3 *)&v39);
      if ( p_focus->foci.ptr[0].fociType != AIFOCI_AIM
        || (*((_BYTE *)&this->aiEditable.behaviors.decl->movementBehaviors + 40) & 4) == 0 )
      {
        v15 = (float)(p_focus->foci.ptr[0].idealFocusPoint.y - v40);
        v16 = (float)(p_focus->foci.ptr[0].idealFocusPoint.z - v41);
        v38.x = p_focus->foci.ptr[0].idealFocusPoint.x - v39;
        v38.y = v15;
        v38.z = v16;
        idVec3::ProjectOntoPlane(this: &v38, normal: v4, overBounce: 1.0);
        idVec3::NormalizeFast(this: &v38);
        y = v42.y;
        z = v42.z;
        x = v42.x;
        if ( (float)((float)(v38.x * v42.x) + (float)((float)(v42.z * v38.z) + (float)(v42.y * v38.y))) <= (double)p_focus->foci.ptr[0].aimTracker.maxYawDot )
        {
          v20 = v4->y;
          v21 = (float)(v4->x * v38.y);
          v22 = (float)((float)(v4->z * v38.y) - (float)(v4->y * v38.z));
          v36.y = (float)(v4->x * v38.z) - (float)(v4->z * v38.x);
          v36.x = v22;
          v36.z = (float)((float)v20 * v38.x) - (float)v21;
          idVec3::NormalizeFast(this: (idVec3 *)&v36);
          if ( (float)((float)(v36.x * (float)x) + (float)((float)(v36.y * (float)y) + (float)(v36.z * (float)z))) <= 0.0 )
            v24 = 0.0;
          else
            v24 = -1.0;
          v36.x = p_focus->foci.ptr[0].aimTracker.maxYaw.value * (float)v24;
          *(double *)&v23 = (float)(v36.z * (float)z);
          *((double *)&v23 + 1) = v36.z;
          idQuat::idQuat(
            this: v43,
            axis: v4,
            angle: (const idTypesafeNumber<float,enum RadiansUnique_t> *)&v36,
            a4: v23);
          v25 = idQuat::operator*(this: &v36, result: (idVec3 *)v43, a: &v38);
          v37.x = v25->x;
          v37.y = v25->y;
          v37.z = v25->z;
        }
        else
        {
          v37.x = v42.x;
          v37.y = v42.y;
          v37.z = v42.z;
        }
      }
      else
      {
        v13 = (float)(p_focus->foci.ptr[0].idealFocusPoint.y - v40);
        v14 = (float)(p_focus->foci.ptr[0].idealFocusPoint.z - v41);
        v37.x = p_focus->foci.ptr[0].idealFocusPoint.x - v39;
        v37.y = v13;
        v37.z = v14;
        idVec3::ProjectOntoPlane(this: &v37, normal: v4, overBounce: 1.0);
        idVec3::NormalizeFast(this: &v37);
      }
      idAIOrientation::SetIdealDir(this: p_orientBody, ai: this, dir: &v37);
      *(_QWORD *)&v36.x = __PAIR64__(&unk_82390000, gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED));
      idAIOrientation::UpdateAxis(
        this: p_orientBody,
        normal: v4,
        turnRate: v11,
        timeSeconds: (float)((float)*(__int64 *)&v36.x * (float)0.001));
    }
    else
    {
      MoveOrientation = idAI2::GetMoveOrientation(this);
      idAIOrientation::SetIdealDir(this: p_orientBody, ai: this, dir: &MoveOrientation->idealDir);
      v27 = idAIOrientation::CalculateTurnDirection(this: p_orientBody, normal: v4);
      turnVelocity = p_orientBody->turnVelocity;
      v29 = v27;
      if ( v27 == p_orientBody->currentTurnDir || p_orientBody->currentTurnDir == 0 )
      {
        if ( v27 == TURN_LEFT )
        {
          if ( turnVelocity < 1.0 )
          {
            if ( turnVelocity >= 0.0 )
            {
              if ( turnVelocity >= 0.5 )
                turnVelocity = (float)(p_orientBody->turnVelocity + (float)0.025);
              else
                turnVelocity = (float)(p_orientBody->turnVelocity + (float)0.1);
            }
            else
            {
              turnVelocity = (float)(p_orientBody->turnVelocity + (float)0.2);
            }
          }
        }
        else if ( turnVelocity > -1.0 )
        {
          if ( turnVelocity <= 0.0 )
          {
            if ( turnVelocity <= -0.5 )
              v30 = 0.025;
            else
              v30 = 0.1;
          }
          else
          {
            v30 = 0.2;
          }
          turnVelocity = (float)(p_orientBody->turnVelocity - (float)v30);
        }
      }
      p_orientBody->turnVelocity = turnVelocity;
      GetGameMsPerFrame = (int (*)(void))gameLocal->GetGameMsPerFrame;
      if ( turnVelocity < 0.0 )
      {
        *(_QWORD *)&v36.x = __PAIR64__(&unk_82200000, GetGameMsPerFrame());
        v33 = TURN_RIGHT;
        v35 = -1.5;
        v34 = *(_QWORD *)&v36.x;
      }
      else
      {
        v32 = GetGameMsPerFrame();
        v33 = TURN_LEFT;
        *(_QWORD *)&v36.x = __PAIR64__(0x82000000, v32);
        v34 = __PAIR64__(0x82000000, v32);
        v35 = 1.5;
      }
      idAIOrientation::UpdateBodyAxis(
        this: p_orientBody,
        normal: v4,
        turnDir: v33,
        turnRate: (float)((float)((float)v11 * (float)turnVelocity) * (float)v35),
        timeSeconds: (float)((float)v34 * (float)0.001));
      p_orientBody->currentTurnDir = v29;
    }
  }
}


// ========================================================================
// ?StartStaggeringPain@idAI2@@IAA_NABVidAIDamageInfo@@@Z
// EA  : 0x829FE080
// RVA : 0x009FE080
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::StartStaggeringPain(idAI2 *this, idVec3 *info)
{
  idComponentActionScript *p_actionScript; // r29
  int v5; // r30
  bool v6; // r11
  idScenePoint_Combat *v7; // r3
  idDamageGroup *DamageGroup; // r3
  int y_low; // r7
  char v10; // r27
  char v11; // r20
  const idDeclDamage *damageDecl; // r23
  int v13; // r8
  idDamageImpulse *x_low; // r6
  int v15; // r9
  idDamageImpulse *v16; // r11
  damageIntensity_t DamageIntensity; // r22
  double x; // fp31
  double v19; // fp29
  double v20; // fp31
  const idDeclAIBehavior *decl; // r26
  idPhysics *Physics; // r3
  BOOL v23; // r29
  char v24; // r11
  double v25; // fp0
  double z; // fp0
  double y; // fp13
  double v29; // fp12
  double v30; // fp30
  double v31; // fp28
  double v32; // fp27
  idPhysics *v33; // r3
  float *v34; // r3
  const idAAS2 *(__fastcall *GetAAS)(struct idAI2 *); // r6
  double v36; // fp10
  double v37; // fp9
  const idAAS2 *v38; // r3
  const idAASPosition *AASPosition; // r3
  idAASPosition *v40; // r29
  idPhysics *v41; // r3
  idAAS2 *aas; // r28
  idPhysics *v43; // r27
  idAASPosition *v44; // r3
  idAAS2_vtbl *v45; // r25
  unsigned int v46; // r29
  int AreaNum; // r18
  int v48; // r3
  bool v49; // r11
  int entityNumber; // r9
  idPlayer *v51; // r3
  idRenderWorld *v52; // r30
  idPhysics *v53; // r3
  int v54; // r3
  int v55; // r5
  damageDirection_t DamageDirection; // r26
  const idIndex<short,enum invalidJointIndex_t> *z_high; // r29
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  const char *JointName; // r3
  idDamageGroup *v60; // r27
  int i; // r28
  idEventArg *v62; // r30
  const idIndex<short,enum invalidJointIndex_t> *v63; // r28
  const idEntity *Inflictor; // r25
  const idEntity *Attacker; // r3
  idEventArg *v66; // r3
  idPhysics *v67; // r30
  idPhysics *v68; // r29
  int GameMs; // r27
  idPresentable *presentable; // r28
  const idMat3 *v71; // r30
  const idVec3 *v72; // r3
  double v73; // fp31
  int v74; // r30
  char *data; // r31
  int v76; // r3
  const idDeclDamage *v77; // [sp+8h] [-298h]
  idVec3 v78; // [sp+60h] [-240h] BYREF
  idHandle<int,enum invalidJointGroupHandle,0> v79; // [sp+6Ch] [-234h] BYREF
  idHandle<int,enum invalidJointGroupHandle,0> v80[2]; // [sp+70h] [-230h] BYREF
  idVec3 v81; // [sp+78h] [-228h] BYREF
  float v82[4]; // [sp+88h] [-218h] BYREF
  idVec3 v83; // [sp+98h] [-208h] BYREF
  float v84; // [sp+A8h] [-1F8h] BYREF
  float v85; // [sp+ACh] [-1F4h]
  float v86; // [sp+B0h] [-1F0h]
  float v87[22]; // [sp+C0h] [-1E0h] BYREF
  idVec3 v88; // [sp+118h] [-188h] BYREF
  char v89; // [sp+128h] [-178h] BYREF
  idEventArg v90; // [sp+140h] [-160h] BYREF
  idEventReceiver v91[2]; // [sp+160h] [-140h] BYREF
  trace_t v92; // [sp+180h] [-120h] BYREF

  p_actionScript = &this->actionScript;
  v5 = 0;
  v6 = idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
    && (this->aiVolatile.script.flags & 0x100) != 0;
  if ( !v6 && idComponentActionScript::RunningActionScript(this: p_actionScript, entity: this) )
    return 0;
  if ( (*((_BYTE *)&this->aiEditable.death + 84) & 0x80) == 0 )
    return 0;
  if ( LODWORD(info->y) == 0 )
    return 0;
  if ( this->IsDead(this) )
    return 0;
  if ( this->aiVolatile.physics.moveState.IsPlayingTraversalAnim(this: &this->aiVolatile.physics.moveState) )
    return 0;
  v7 = idScenePoint_Combat::CastTo(c: (idScenePoint_Combat *)this->aiVolatile.memory.curScenePoint);
  if ( v7 != nullptr && v7->customSet.deathAnim.len != 0 )
    return 0;
  DamageGroup = idActor::GetDamageGroup(this, name: this->aiVolatile.pain.damageInfo.injuryDamageGroup.str);
  if ( DamageGroup != nullptr
    && !DamageGroup->goreLevelInfo.list[this->aiVolatile.pain.damageInfo.injuryGoreLevelIndex].enablePainAndDeath )
  {
    return 0;
  }
  if ( this->GetPosture(this) == POSTURE_STANDING
    && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->actorVolatile.postureChangeTime < 1000 )
  {
    return 0;
  }
  if ( (this->aiVolatile.groupStatus.condition & 8) != 0 && this->GetPosture(this) == POSTURE_CROUCHED )
    return 0;
  y_low = LODWORD(info->y);
  v10 = 0;
  v11 = 0;
  damageDecl = nullptr;
  v13 = 0;
  if ( y_low <= 0 )
    return 0;
  x_low = (idDamageImpulse *)LODWORD(info->x);
  v15 = 0;
  do
  {
    v16 = &x_low[v15];
    if ( x_low[v15].damageDecl != nullptr )
    {
      damageDecl = x_low[v15].damageDecl;
      v10 |= v16->armorPoppedOff;
      v11 |= v16->forceInjured;
      if ( v10 != 0 && v11 != 0 )
        break;
    }
    ++v13;
    ++v15;
  }
  while ( v13 < y_low );
  if ( damageDecl == nullptr || ai_allowStaggerPain.valueInteger == 0 )
    return 0;
  DamageIntensity = idActor::GetDamageIntensity(this, damageDef: damageDecl, damage: info[33].y);
  x = info[34].x;
  v19 = (float)((float)x / this->aiHealth.GetMaxBaseHealth_Impl(this: &this->aiHealth));
  if ( (damageDecl->damageTypes & 0x100) != 0 || damageDecl->isMelee )
  {
    v20 = info[34].x;
    v19 = (float)((float)v20 / this->aiHealth.GetMaxBaseHealth_Impl(this: &this->aiHealth));
  }
  decl = this->aiEditable.behaviors.decl;
  Physics = idEntity::GetPhysics(this);
  Physics->GetLinearVelocity(this: (idPhysics *)&v84, result: (idVec3 *)Physics, a3: 0);
  v23 = (float)((float)(v84 * v84) + (float)((float)(v85 * v85) + (float)(v86 * v86))) > (double)(float)(decl->damageBehaviors.movingPainSpeed * decl->damageBehaviors.movingPainSpeed);
  if ( (float)((float)(v84 * v84) + (float)((float)(v85 * v85) + (float)(v86 * v86))) <= (double)(float)(decl->damageBehaviors.movingPainSpeed * decl->damageBehaviors.movingPainSpeed)
    || (v24 = 1, this->actorVolatile.walkState < WALKSTATE_RUNNING) )
  {
    v24 = 0;
  }
  if ( v10 == 0 && v11 == 0 && HIBYTE(info[35].y) == 0 )
  {
    v25 = v19;
    if ( damageDecl->isMelee )
      v25 = (float)((float)v19 * (float)2.0);
    if ( (damageDecl->damageTypes & ~this->aiEditable.death.ignoreDamageType & 0x400) == 0 )
    {
      if ( v24 != 0 )
      {
        if ( v25 < decl->damageBehaviors.staggerThresholdRunning )
          return 0;
      }
      else if ( (float)((float)(v84 * v84) + (float)((float)(v85 * v85) + (float)(v86 * v86))) <= (double)(float)(decl->damageBehaviors.movingPainSpeed * decl->damageBehaviors.movingPainSpeed) )
      {
        if ( (this->aiVolatile.groupStatus.condition & 8) == 0 && v25 < decl->damageBehaviors.staggerThresholdStanding )
          return 0;
      }
      else if ( v25 < decl->damageBehaviors.staggerThresholdWalking )
      {
        return 0;
      }
    }
  }
  if ( (damageDecl->damageTypes & ~this->aiEditable.death.ignoreDamageType & 0x500) == 0
    && this->aiVolatile.death.nextPainTime > idGameTimeManager::GetGameMs(
                                               this: &clientGame->gameTimeManager,
                                               type: GAMETIME_SCALED) )
  {
    return 0;
  }
  if ( v23 && ai_newMovingPainTest.valueInteger != 0 && (damageDecl->damageTypes & 0x400) == 0 )
  {
    idEntity::GetLinearVelocity(this: (idEntity *)&v78, result: this);
    z = v78.z;
    y = v78.y;
    v29 = v78.x;
    if ( (float)((float)(v78.x * v78.x) + (float)((float)(v78.y * v78.y) + (float)(v78.z * v78.z))) > 0.1 )
    {
      idVec3::NormalizeFast(this: &v78);
      z = v78.z;
      y = v78.y;
      v29 = v78.x;
    }
    v30 = (float)((float)v29 * (float)192.0);
    v31 = (float)((float)y * (float)192.0);
    v32 = (float)((float)z * (float)192.0);
    v33 = idEntity::GetPhysics(this);
    v34 = (float *)v33->GetOrigin(this: v33, a2: 0);
    GetAAS = this->GetAAS;
    v36 = (float)(v34[1] + (float)v31);
    v37 = (float)(v34[2] + (float)v32);
    v82[0] = *v34 + (float)v30;
    v82[1] = v36;
    v82[2] = v37;
    v38 = GetAAS(this);
    AASPosition = idActor::GetAASPosition(this, aas: v38);
    memset(&v87[4], 0, 12);
    v40 = (idAASPosition *)AASPosition;
    v87[10] = 0.0;
    v87[11] = 0.0;
    v87[0] = 0.0;
    memset(&v87[15], 0, 24);
    v87[1] = 0.0;
    v87[2] = 0.0;
    v87[3] = 0.0;
    v87[7] = 0.0;
    v87[8] = 0.0;
    v87[9] = 0.0;
    v87[12] = 0.0;
    v87[13] = 0.0;
    v87[14] = 0.0;
    if ( AASPosition->aas != nullptr )
    {
      v41 = idEntity::GetPhysics(this);
      aas = (idAAS2 *)v40->aas;
      v43 = v41;
      v44 = v40;
      v45 = aas->__vftable;
      v46 = this->aiVolatile.aas.travelFlags & 0xFE78FFFF;
      AreaNum = idAASPosition::GetAreaNum(this: v44);
      v48 = (int)v43->GetOrigin(this: v43, a2: 0);
      ((void (__fastcall *)(idAAS2 *, float *, int, int, float *, unsigned int, _DWORD, int))v45->TraceFloor)(
        a1: aas,
        a2: v87,
        a3: v48,
        a4: AreaNum,
        a5: v82,
        a6: v46,
        a7: 0,
        a8: 1);
    }
    else
    {
      idLib::Warning(fmt: "%s has no aas", this->name.data);
    }
    v49 = v87[0] < 1.0;
    if ( v87[0] >= 1.0 )
    {
      this->GetEyePos(this, a2: &v81);
      entityNumber = this->entityNumber;
      v83.x = (float)(v78.x * (float)192.0) + v81.x;
      v83.y = v81.y + (float)(v78.y * (float)192.0);
      v83.z = v81.z + (float)(v78.z * (float)192.0);
      idClip::TraceBounds(
        this: &clientGame->clip,
        result: &v92,
        start: &v81,
        end: &v83,
        trm: nullptr,
        clipMask: 1025,
        passEntityNumber: entityNumber);
      if ( v92.fraction >= 1.0
        || (v51 = idPlayer::CastTo(c: (idPlayer *)gameLocal->entities.ptr[v92.c.entityNum]), v49 = true, v51 != nullptr) )
      {
        v49 = false;
      }
    }
    if ( v49 )
    {
      if ( ai_debugLevel.valueInteger != 0 && ai_debugPain.valueInteger != 0 )
      {
        v52 = common->RW(this: common);
        v53 = idEntity::GetPhysics(this);
        v54 = (int)v53->GetOrigin(this: v53, a2: 0);
        ((void (__fastcall *)(idRenderWorld *, idColor *, int, float *, double))v52->DebugArrow)(
          a1: v52,
          a2: &idColor::colorRed,
          a3: v54,
          a4: v82,
          a5: 0.5);
        idLib::Printf(fmt: "%s no room for moving pain (approx)\n", this->name.data);
      }
      return 0;
    }
  }
  this->aiVolatile.death.nextPainTime = this->aiEditable.behaviors.decl->damageBehaviors.minStaggerPainInterval
                                      + idGameTimeManager::GetGameMs(
                                          this: &clientGame->gameTimeManager,
                                          type: GAMETIME_SCALED);
  idAIDamageInfo::GetAverageImpactPoint(this: (idAIDamageInfo *)&v89, result: info);
  idAIDamageInfo::GetAverageImpactDir(this: (idAIDamageInfo *)&v88, result: info);
  if ( (damageDecl->damageTypes & 0x100) == 0 || (v55 = 4, (*((_BYTE *)&decl->damageBehaviors + 85) & 4) == 0) )
    v55 = 2;
  DamageDirection = idActor::GetDamageDirection(axis: &this->actorVolatile.modelInfo.modelAxis, dir: &v88, numDirs: v55);
  idActor::GetPainGroupHandle(
    this: (idActor *)&v79,
    result: (idHandle<int,enum invalidJointGroupHandle,0> *)this,
    joint: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(info[32].z));
  if ( v79.value == 0 )
  {
    z_high = (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(info[32].z);
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    JointName = idTreeAnimator::GetJointName(this: TreeAnimatorFromPresentable, jointIndex: z_high);
    idLib::Warning(fmt: "No pain group found for joint '%s'", JointName);
  }
  idActor::GetDamageGroupHandle(
    this: (idActor *)v80,
    result: (idHandle<int,enum invalidJointGroupHandle,0> *)this,
    joint: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(info[32].z));
  v60 = idActor::GetDamageGroup(this, handle: v80);
  if ( v60 != nullptr )
  {
    for ( i = 0; i < this->actorEditable.damageGroups.num; ++v5 )
    {
      if ( idStr::Cmp(s1: this->actorEditable.damageGroups.list[v5].groupName.data, s2: v60->groupName.data) == 0 )
        this->aiVolatile.pain.damageInfo.mostDamagedIndex = i;
      ++i;
    }
  }
  v62 = (idEventArg *)this->aiVolatile.fsms.fsmManager.FindFSM_3(
                        this: &this->aiVolatile.fsms,
                        a2: &idAlertCycleFSM::Type);
  if ( v62 != nullptr )
  {
    v63 = (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(info[32].z);
    Inflictor = idAIDamageInfo::GetInflictor(this: (idAIDamageInfo *)info);
    Attacker = idAIDamageInfo::GetAttacker(this: (idAIDamageInfo *)info);
    idActor::SetPain(
      this,
      type: PAIN_STAGGER,
      jointIndex: v63,
      attacker: Attacker,
      inflictor: Inflictor,
      jgh: &v79,
      damageDir: DamageDirection,
      damageIntensity: DamageIntensity,
      damageDecl: v77);
    v66 = idEventArg::idEventArg(this: &v90, data: this);
    idEventReceiver::ProcessEvent(
      this: v91,
      result: v62,
      ev: *(const idEventDef **)&v66->type,
      arg1: (const idEventArg *)LODWORD(v66->value.v[1]));
  }
  if ( v11 != 0 )
    ++this->aiVolatile.death.injuredCount;
  if ( (damageDecl->damageTypes & 0x400) != 0 )
  {
    v67 = idEntity::GetPhysics(this);
    v68 = idEntity::GetPhysics(this);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    if ( this->presentable == nullptr )
      idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
    v71 = v67->GetAxis(this: v67, a2: 0);
    v72 = v68->GetOrigin(this: v68, a2: 0);
    idFXManager::StartFX(this: &presentable->fxManager, org: v72, axis: v71, time: GameMs, startCondition: 107);
  }
  if ( ai_debugPain.valueInteger != 0 && ai_debugLevel.valueInteger != 0 )
  {
    v73 = info[33].y;
    v74 = LODWORD(info->y);
    data = this->name.data;
    v76 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idLib::Printf(
      fmt: "Staggering pain: (%d) '%s' num: %d body damage: %.0f (recent %.0f%%) intensity: '%s' dir: '%s'\n",
      v76,
      data,
      v74,
      v73,
      (float)((float)v19 * (float)100.0),
      (const char *)(const char *)HIDWORD(COERCE_UNSIGNED_INT64((float)((float)v19 * (float)100.0))),
      (const char *)COERCE_UNSIGNED_INT64((float)((float)v19 * (float)100.0)));
  }
  return 1;
}


// ========================================================================
// ?StartStunningPain@idAI2@@IAA_NABVidAIDamageInfo@@@Z
// EA  : 0x829FEB88
// RVA : 0x009FEB88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::StartStunningPain(idAI2 *this, const idAIDamageInfo *info)
{
  idComponentActionScript *p_actionScript; // r30
  int num; // r8
  int v6; // r10
  idDamageImpulse *list; // r9
  int i; // r11
  const idDeclDamage *damageDecl; // r4
  idDamageImpulse *v10; // r25
  damageIntensity_t DamageIntensity; // r22
  damageDirection_t DamageDirection; // r21
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  const char *JointName; // r3
  painType_t v16; // r23
  idFiniteStateMachine *v17; // r3
  int value; // r7
  idEventArg *v19; // r28
  idGameLocal *v20; // r11
  idEntity *v21; // r3
  idEntity *v22; // r3
  const idEntity *v23; // r30
  int v24; // r9
  idEntity *v25; // r3
  idEntity *v26; // r6
  idEventArg *v27; // r3
  idPhysics *Physics; // r30
  idPhysics *v29; // r29
  int GameMs; // r28
  idPresentable *presentable; // r26
  const idMat3 *v32; // r30
  const idVec3 *v33; // r3
  char *data; // r31
  const char *str; // r30
  int v36; // r3
  const idDeclDamage *v37; // [sp+8h] [-108h]
  idHandle<int,enum invalidJointGroupHandle,0> v38[4]; // [sp+60h] [-B0h] BYREF
  idEventArg v39; // [sp+70h] [-A0h] BYREF
  idEventReceiver v40[10]; // [sp+90h] [-80h] BYREF

  p_actionScript = &this->actionScript;
  if ( idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
    || !idAI2::ActionScriptFlagIsSet(this, flags: 256)
    && idComponentActionScript::RunningActionScript(this: p_actionScript, entity: this) )
  {
    return 0;
  }
  if ( (*((_BYTE *)&this->aiEditable.death + 84) & 0x80) == 0 )
    return 0;
  num = info->impulses.num;
  v6 = 0;
  if ( num <= 0 )
    return 0;
  list = info->impulses.list;
  for ( i = 0; ; ++i )
  {
    damageDecl = list[i].damageDecl;
    v10 = &list[i];
    if ( damageDecl != nullptr && damageDecl->stuns )
      break;
    if ( ++v6 >= num )
      return 0;
  }
  DamageIntensity = idActor::GetDamageIntensity(this, damageDef: damageDecl, damage: info->frameDamage);
  DamageDirection = idActor::GetDamageDirection(
                      axis: &this->actorVolatile.modelInfo.modelAxis,
                      dir: &v10->impactDir,
                      numDirs: 4);
  idActor::GetPainGroupHandle(
    this: (idActor *)v38,
    result: (idHandle<int,enum invalidJointGroupHandle,0> *)this,
    joint: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)v10->jointIndex.value);
  if ( v38[0].value == 0 )
  {
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    JointName = idTreeAnimator::GetJointName(
                  this: TreeAnimatorFromPresentable,
                  jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)v10->jointIndex.value);
    idLib::Warning(fmt: "No pain group found for joint '%s'", JointName);
  }
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.lastStunTime <= this->aiEditable.behaviors.decl->stunIgnoreTime )
  {
    v16 = PAIN_STUN_IGNORE;
  }
  else
  {
    this->aiVolatile.memory.lastStunTime = idGameTimeManager::GetGameMs(
                                             this: &clientGame->gameTimeManager,
                                             type: GAMETIME_SCALED);
    v16 = PAIN_STUN;
  }
  v17 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
  value = info->inflictor.spawnId.value;
  v19 = (idEventArg *)v17;
  v20 = gameLocal;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v21 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v22 = idEntity::CastTo(c: v21);
    v20 = gameLocal;
    v23 = v22;
  }
  else
  {
    v23 = nullptr;
  }
  v24 = info->attacker.spawnId.value;
  if ( v20->spawnIds.ptr[v24 & 0x1FFF] == v24 >> 13 && (v25 = v20->entities.ptr[v24 & 0x1FFF]) != nullptr )
    v26 = idEntity::CastTo(c: v25);
  else
    v26 = nullptr;
  idActor::SetPain(
    this,
    type: v16,
    jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)v10->jointIndex.value,
    attacker: v26,
    inflictor: v23,
    jgh: v38,
    damageDir: DamageDirection,
    damageIntensity: DamageIntensity,
    damageDecl: v37);
  v27 = idEventArg::idEventArg(this: &v39, data: this);
  idEventReceiver::ProcessEvent(
    this: v40,
    result: v19,
    ev: *(const idEventDef **)&v27->type,
    arg1: (const idEventArg *)LODWORD(v27->value.v[1]));
  Physics = idEntity::GetPhysics(this);
  v29 = idEntity::GetPhysics(this);
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  if ( this->presentable == nullptr )
    idEntity::InitPresentableInternal(this);
  presentable = this->presentable;
  v32 = Physics->GetAxis(this: Physics, a2: 0);
  v33 = v29->GetOrigin(this: v29, a2: 0);
  idFXManager::StartFX(this: &presentable->fxManager, org: v33, axis: v32, time: GameMs, startCondition: 107);
  if ( ai_debugPain.valueInteger != 0 && ai_debugLevel.valueInteger != 0 )
  {
    data = this->name.data;
    str = v10->damageDecl->name.str;
    v36 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idLib::Printf(fmt: "Stunning pain: (%d) '%s' '%s'\n", v36, data, str);
  }
  return 1;
}


// ========================================================================
// ?DamageFeedback@idAI2@@UAAXPAVidEntity@@0PBVidDeclDamage@@AAM@Z
// EA  : 0x829FEF30
// RVA : 0x009FEF30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DamageFeedback(
        idAI2 *this,
        idEntity *victim,
        idAI2 *inflictor,
        const idDeclDamage *damageDecl,
        float *damage)
{
  int soonestAngryRageTime; // r11
  unsigned int v10; // r3
  idGameLocal *v11; // r11
  int value; // r9
  idEntity *v13; // r3
  idEntity *v14; // r3
  int GameMs; // r3
  int v16; // r9
  idEntity *v17; // r3
  idEntity *v18; // r3
  idEncounterGroup *v19; // r3
  idBaseHealth *v20; // r31
  const idDeclAIBehavior *decl; // r10
  const idDeclEntityDef *explosionEntity; // r4
  idProjectile *v23; // r3
  idProjectile *v24; // r31
  int v25; // r30
  idPhysics *Physics; // r3
  const idVec3 *v27; // r3
  int v28; // r8
  idProjectileTarget v29; // [sp+50h] [-70h] BYREF

  soonestAngryRageTime = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) + 3000;
  if ( this->aiVolatile.memory.soonestAngryRageTime > soonestAngryRageTime )
    soonestAngryRageTime = this->aiVolatile.memory.soonestAngryRageTime;
  this->aiVolatile.memory.soonestAngryRageTime = soonestAngryRageTime;
  v10 = 1664525 * clientGame->random.seed + 1013904223;
  clientGame->random.seed = v10;
  v11 = gameLocal;
  if ( (signed int)(((v10 >> 10) & 0x7FFF) % 0x64) < this->aiEditable.behaviors.decl->rageBehaviors.tauntRageAfterHitEnemyChance )
  {
    value = this->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v13 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v14 = idEntity::CastTo(c: v13);
      v11 = gameLocal;
    }
    else
    {
      v14 = nullptr;
    }
    if ( victim == v14 )
    {
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idAIMemory::SetWantTauntRageTime(this: &this->aiVolatile.memory, t: GameMs, debugReason: "hit enemy");
      v11 = gameLocal;
    }
  }
  if ( victim != nullptr )
  {
    v16 = this->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( v11->spawnIds.ptr[v16 & 0x1FFF] == v16 >> 13 && (v17 = v11->entities.ptr[v16 & 0x1FFF]) != nullptr )
    {
      v18 = idEntity::CastTo(c: v17);
      v11 = gameLocal;
    }
    else
    {
      v18 = nullptr;
    }
    if ( victim == v18
      && (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &v11->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v19 = (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
          ? nullptr
          : idEncounterGroupManager::GroupForHandle(
              this: &gameLocal->encounterGroupManager,
              handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::ConfidentEnoughToTaunt(this: v19, ai: this) )
      {
        v20 = victim->GetHealthComponent_2(this: victim);
        if ( (unsigned __int8)idPlayer::IsTypeOf(c: victim) == 0
          || ((double (__fastcall *)(idBaseHealth *))v20->GetBaseHealthRatio_Impl)(a1: v20) >= 0.25 )
        {
          v20->GetBaseHealthRatio_Impl(this: v20);
        }
      }
    }
    if ( common->IsMultiplayer(this: common)
      && damageDecl->isMelee
      && (unsigned __int8)idPlayer::IsTypeOf(c: victim) != 0 )
    {
      this->aiVolatile.playerMeleeTime.ptr[victim->entityNumber] = idGameTimeManager::GetGameMs(
                                                                     this: &clientGame->gameTimeManager,
                                                                     type: GAMETIME_SCALED);
    }
    v11 = gameLocal;
  }
  decl = this->aiEditable.behaviors.decl;
  if ( (*((_BYTE *)&decl->damageBehaviors + 85) & 0x40) != 0 )
  {
    explosionEntity = decl->damageBehaviors.explosionEntity;
    if ( explosionEntity != nullptr && inflictor == this )
    {
      v23 = (idProjectile *)v11->SpawnEntityFromDef(this: v11, a2: explosionEntity, a3: -1, a4: -1, a5: -1);
      v24 = idProjectile::CastTo(c: v23);
      if ( v24 != nullptr )
      {
        v29.type = TARGET_NONE;
        v29.presentable.spawnId = 0;
        v29.pos = vec3_origin;
        v25 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        Physics = idEntity::GetPhysics(this);
        v27 = Physics->GetOrigin(this: Physics, a2: 0);
        idProjectile::Launch(
          this: v24,
          attacker_: inflictor,
          start: v27,
          fireAxis: &this->actorVolatile.modelInfo.modelAxis,
          target: &v29,
          initialSpeed: 0.0,
          startTime: v28,
          launchTimeOverride: v25);
      }
    }
  }
}


// ========================================================================
// ?EnemyTooCloseToGoProne@idAI2@@QBA_N_N0@Z
// EA  : 0x829FF2D0
// RVA : 0x009FF2D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::EnemyTooCloseToGoProne(idAI2 *this, const bool facingMatters, const bool obscurityMatters)
{
  int value; // r8
  idEntity *v7; // r3
  idEntity *v8; // r3
  const idEntity *v9; // r29
  idAIEntityState *v10; // r3
  idAIEntityState *v11; // r30
  idPhysics *Physics; // r3
  aiSenseState_t *v13; // r30
  float *v14; // r27
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  double v16; // fp10
  double v17; // fp8
  double enemyTooCloseToGoProne; // fp31
  double v19; // fp30
  int result; // r3

  value = this->aiVolatile.memory.currentEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13 )
    return 0;
  v7 = gameLocal->entities.ptr[value & 0x1FFF];
  if ( v7 == nullptr )
    return 0;
  v8 = idEntity::CastTo(c: v7);
  v9 = v8;
  if ( v8 == nullptr
    || obscurityMatters
    && this->aiVolatile.visibilityObscurity.valid
    && this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[0] == OBSCURITY_PATH_OPEN_WITH_COVER )
  {
    return 0;
  }
  v10 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v8);
  v11 = v10;
  if ( v10 == nullptr || !idAIEntityState::IsVisible(this: v10) )
    return 0;
  Physics = idEntity::GetPhysics(this);
  v13 = v11->senses.ptr[v11->lastSense];
  v14 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: v13);
  v16 = (float)(ConfirmedPhysicalSafe->origin.y - v14[1]);
  v17 = (float)(ConfirmedPhysicalSafe->origin.z - v14[2]);
  enemyTooCloseToGoProne = this->aiEditable.behaviors.decl->enemyTooCloseToGoProne;
  v19 = (float)((float)((float)(ConfirmedPhysicalSafe->origin.x - *v14) * (float)(ConfirmedPhysicalSafe->origin.x - *v14))
              + (float)((float)((float)v17 * (float)v17) + (float)((float)v16 * (float)v16)));
  if ( facingMatters && idAI2::IsFacingMe(this, entity: v9, dotThreshold: 0.93000001) )
    enemyTooCloseToGoProne = this->aiEditable.behaviors.decl->enemyTooCloseToGoProneFacing;
  result = 1;
  if ( v19 >= (float)((float)enemyTooCloseToGoProne * (float)enemyTooCloseToGoProne) )
    return 0;
  return result;
}


// ========================================================================
// ?WantsToAngryRage@idAI2@@QBA_NXZ
// EA  : 0x829FF468
// RVA : 0x009FF468
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WantsToAngryRage(idAI2 *this)
{
  const idDeclAIBehavior *decl; // r24
  char v3; // r11
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r30
  idEncounterGroup *v5; // r28
  idEncounterGroup *v6; // r11
  int noRageMemberCount; // r30
  idHandle<short,enum invalidEncounterGroup_t,-1> *v8; // r30
  idEncounterGroup *v9; // r3
  idEncounterGroup *v10; // r31
  const idEntity *Enemy; // r3
  int result; // r3
  bool v13; // zf

  decl = this->aiEditable.behaviors.decl;
  if ( decl->rageBehaviors.angryRageAfterHurtChance > 0
    || decl->rageBehaviors.angryRageAfterMissingChance > 0
    || decl->rageBehaviors.angryRageAfterAttractChance > 0
    || (v3 = 0, decl->rageBehaviors.angryRageWhenCloseDistance > 0.0) )
  {
    v3 = 1;
  }
  if ( v3 == 0 )
    return 0;
  if ( decl->rageBehaviors.useGroupRageLimit )
  {
    p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v5 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      v6 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      noRageMemberCount = v6->noRageMemberCount;
      if ( idEncounterGroup::NumLivingMembers(this: v5) <= noRageMemberCount )
        return 0;
    }
  }
  if ( this->aiVolatile.memory.wantTauntRageTime > 0
    && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.wantTauntRageTime < 4000 )
  {
    return 0;
  }
  if ( decl->rageBehaviors.useGroupRageLimit )
  {
    v8 = &this->aiVolatile.encounterGroupHandle;
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v9 = (unsigned __int16)v8->value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::NumLivingMembers(this: v9) > 1 )
      {
        v10 = (unsigned __int16)v8->value == 0xFFFF
            ? nullptr
            : idEncounterGroupManager::GroupForHandle(
                this: &gameLocal->encounterGroupManager,
                handle: &this->aiVolatile.encounterGroupHandle);
        Enemy = idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
        if ( idEncounterGroup::GetClosestActiveGroupMemberToEntity(this: v10, ent: Enemy) == this )
          return 0;
      }
    }
  }
  if ( this->aiVolatile.memory.wantAngryRageTime <= 0 )
    return 0;
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.wantAngryRageTime >= decl->rageBehaviors.staleAngryRageThreshold )
    return 0;
  v13 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.memory.soonestAngryRageTime;
  result = 1;
  if ( !v13 )
    return 0;
  return result;
}


// ========================================================================
// ?WantsToTauntRage@idAI2@@QBA_NXZ
// EA  : 0x829FF6D0
// RVA : 0x009FF6D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WantsToTauntRage(idAI2 *this)
{
  const idDeclAIBehavior *decl; // r25
  char v3; // r11
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r30
  idEncounterGroup *v5; // r28
  idEncounterGroup *v6; // r11
  int noRageMemberCount; // r30
  idHandle<short,enum invalidEncounterGroup_t,-1> *v8; // r30
  idEncounterGroup *v9; // r3
  idEncounterGroup *v10; // r31
  const idEntity *Enemy; // r3
  int result; // r3
  bool v13; // zf

  decl = this->aiEditable.behaviors.decl;
  if ( decl->rageBehaviors.tauntRageAfterHitEnemyChance > 0
    || decl->rageBehaviors.tauntRageBehindEnemyChance > 0
    || decl->rageBehaviors.tauntRageFleeingEnemyChance > 0
    || (v3 = 0, decl->rageBehaviors.tauntRageAfterKillingEnemyChance > 0) )
  {
    v3 = 1;
  }
  if ( v3 == 0 )
    return 0;
  if ( decl->rageBehaviors.useGroupRageLimit )
  {
    p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v5 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      v6 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      noRageMemberCount = v6->noRageMemberCount;
      if ( idEncounterGroup::NumLivingMembers(this: v5) <= noRageMemberCount )
        return 0;
    }
  }
  if ( decl->rageBehaviors.useGroupRageLimit )
  {
    v8 = &this->aiVolatile.encounterGroupHandle;
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v9 = (unsigned __int16)v8->value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::NumLivingMembers(this: v9) > 1 )
      {
        v10 = (unsigned __int16)v8->value == 0xFFFF
            ? nullptr
            : idEncounterGroupManager::GroupForHandle(
                this: &gameLocal->encounterGroupManager,
                handle: &this->aiVolatile.encounterGroupHandle);
        Enemy = idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
        if ( idEncounterGroup::GetClosestActiveGroupMemberToEntity(this: v10, ent: Enemy) == this )
          return 0;
      }
    }
  }
  if ( this->aiVolatile.memory.wantTauntRageTime <= 0 )
    return 0;
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.wantTauntRageTime >= decl->rageBehaviors.staleTauntRageThreshold )
    return 0;
  v13 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.memory.soonestTauntRageTime;
  result = 1;
  if ( !v13 )
    return 0;
  return result;
}


// ========================================================================
// ?CanBeTakenDown@idAI2@@QBA?AW4takedownMode_t@@PBVidEntity@@@Z
// EA  : 0x829FF8F8
// RVA : 0x009FF8F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CanBeTakenDown(idAI2 *this, idPlayer *activator)
{
  idPhysics *Physics; // r3
  int v5; // r3
  float v6; // r7
  float v7; // r6
  idPlayer *v8; // r3
  idPresentable *presentable; // r3
  int p_axis; // r11
  idPresentable *v11; // r11
  idRelationship::attitude_t AttitudeTowards; // r31
  float v13; // r8
  float v14; // r7
  const idFaction *(__fastcall *GetFaction_2)(struct idAI2 *); // r6
  idFaction *v16; // r3
  idAIEditable::idInteractions::takeDownType_t takeDownType; // r11
  idPhysics *v18; // r3
  float *v19; // r3
  idPresentable *v20; // r11
  float x; // r10
  float y; // r9
  float z; // r8
  double v24; // fp31
  const idEntity *Enemy; // r30
  bool v26; // r29
  idAIEntityState *v27; // r3
  aiSenseState_t *v28; // r31
  float v30; // [sp+50h] [-80h]
  float v31; // [sp+54h] [-7Ch]
  float v32; // [sp+58h] [-78h]
  idVec3 v33; // [sp+60h] [-70h] BYREF
  float v34; // [sp+70h] [-60h]
  float v35; // [sp+74h] [-5Ch]
  float v36; // [sp+78h] [-58h]
  float v37; // [sp+80h] [-50h]
  float v38; // [sp+84h] [-4Ch]
  float v39; // [sp+88h] [-48h]

  if ( this->IsDead(this) || this->IsDying(this) || (this->aiVolatile.death.deathInfo.deathFlags & 0x10) != 0 )
    return 0;
  Physics = idEntity::GetPhysics(this: activator);
  v5 = (int)Physics->GetOrigin(this: Physics, a2: 0);
  v6 = *(float *)(v5 + 4);
  v7 = *(float *)(v5 + 8);
  v33.x = *(float *)v5;
  v33.y = v6;
  v33.z = v7;
  v8 = idPlayer::CastTo(c: activator);
  if ( v8 != nullptr )
  {
    presentable = v8->presentable;
    p_axis = presentable != nullptr
           ? (int)&presentable->GetPlayerInterface_2(this: presentable)->firstPersonViewAxis
           : 46544;
  }
  else
  {
    v11 = activator->presentable;
    if ( v11 == nullptr )
    {
      idEntity::InitPresentableInternal(this: activator);
      v11 = activator->presentable;
    }
    p_axis = (int)&v11->axis;
  }
  AttitudeTowards = ATTITUDE_DISLIKE;
  v13 = *(float *)(p_axis + 4);
  v14 = *(float *)(p_axis + 8);
  GetFaction_2 = this->GetFaction_2;
  v34 = *(float *)p_axis;
  v35 = v13;
  v36 = v14;
  v16 = (idFaction *)GetFaction_2(this);
  if ( v16 != nullptr )
    AttitudeTowards = idFaction::GetAttitudeTowards(this: v16, otherEnt: activator);
  takeDownType = this->aiEditable.interactions.takeDownType;
  if ( takeDownType == TAKEDOWNTYPE_NOTAKEDOWN )
  {
    AttitudeTowards = ATTITUDE_LOVE;
  }
  else if ( takeDownType == TAKEDOWNTYPE_FORCEFRIENDLYTAKEDOWN )
  {
    AttitudeTowards = ATTITUDE_HATE;
  }
  v18 = idEntity::GetPhysics(this);
  v19 = (float *)v18->GetOrigin(this: v18, a2: 0);
  v20 = this->presentable;
  v30 = *v19;
  v31 = v19[1];
  v32 = v19[2];
  if ( v20 == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    v20 = this->presentable;
  }
  x = v20->axis.mat[0].x;
  y = v20->axis.mat[0].y;
  z = v20->axis.mat[0].z;
  v33.x = v30 - v33.x;
  v33.y = v31 - v33.y;
  v37 = x;
  v33.z = v32 - v33.z;
  v38 = y;
  v39 = z;
  v24 = idVec3::NormalizeFast(this: &v33);
  if ( AttitudeTowards > ATTITUDE_DISLIKE )
    return 0;
  Enemy = idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
  v26 = false;
  v27 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: activator);
  if ( v27 != nullptr && (*((_BYTE *)v27 + 541) & 0x80) != 0 )
  {
    v28 = v27->senses.ptr[1];
    if ( v28->lastUnconfirmedStimTime >= 0 )
      v26 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
          - v28->lastConfirmedStimTime < (int)(float)((float)1000.0 * (float)10.0);
  }
  if ( Enemy != nullptr && Enemy->entityNumber == activator->entityNumber && v26
    || v24 >= 100.0
    || (float)((float)(v34 * v33.x) + (float)((float)(v36 * v33.z) + (float)(v35 * v33.y))) <= 0.80000001
    || (float)((float)(v37 * v33.x) + (float)((float)(v39 * v33.z) + (float)(v38 * v33.y))) <= 0.80000001 )
  {
    return !idAI2::TakedownWindoIsOpen(this) ? 3 : 1;
  }
  else
  {
    return 2;
  }
}


// ========================================================================
// ?PlayerInteractionDone@idAI2@@QAAX_N@Z
// EA  : 0x829FFC68
// RVA : 0x009FFC68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::PlayerInteractionDone(idAI2 *this, bool playerLeft)
{
  const aiPlayerInteraction_t *CurrentPlayerInteraction; // r29
  int value; // r8
  idPlayer *v6; // r3
  idPlayer *v7; // r5
  bool CanBeClosed; // r3
  playerInteractionState_t v9; // r4

  CurrentPlayerInteraction = idAI2::GetCurrentPlayerInteraction(this);
  if ( CurrentPlayerInteraction != nullptr )
  {
    if ( playerLeft
      || ((value = this->aiVolatile.memory.interactionEntity.spawnId.value,
           gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13)
       || (v6 = (idPlayer *)gameLocal->entities.ptr[value & 0x1FFF]) == nullptr
        ? (v7 = nullptr)
        : (v7 = idPlayer::CastTo(c: v6)),
          CanBeClosed = idAIPlayerInteraction::InteractionCanBeClosed(
                          this: &this->aiVolatile.aiPlayerInteraction,
                          interaction: CurrentPlayerInteraction,
                          player: v7),
          v9 = PISTATE_APPROACH_PLAYED,
          CanBeClosed) )
    {
      v9 = PISTATE_INACTIVE;
    }
    idAI2::SetCurrentPlayerInteractionTempInfoState(this, newState: v9);
  }
}


// ========================================================================
// ?AddDynamicGoods@idAI2@@QAAXPAVidPlayer@@@Z
// EA  : 0x829FFD28
// RVA : 0x009FFD28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::AddDynamicGoods(idAI2 *this, idPlayer *player)
{
  int i; // r29
  int v5; // r24
  int v6; // r25
  idAIEditable::idDynamicMerchantInventoryDef *v7; // r11
  const idDeclInventory *inventoryDecl; // r28
  int count; // r26
  idInventoryCollection *v10; // r3
  int TotalInventoryItemCount; // r3
  signed int v12; // r11
  int v13; // r29
  idPresentable *presentable; // r27
  idInventoryCollection *v15; // r3
  idInventoryItem *v16; // r3
  int num; // r10
  int v18; // r29
  int v19; // r11
  int v20; // r11
  bool v21; // zf
  signed int v22; // r29
  idPresentable *v23; // r27
  idInventoryCollection *v24; // r3
  unsigned int v25; // r5
  idPresentable *v26; // r11
  int v27; // r4
  const idDeclInventory **list; // r28
  int v29; // r27
  idPresentable *v30; // r29
  idAI2 *v31; // r3
  const idDeclInventory *v32; // r30
  idInventoryCollection *(__fastcall *GetInventory_2)(struct idAI2 *); // ctr
  idInventoryCollection *v34; // r3
  idInventoryItem *v35; // r3
  encounterGroupRole_t v36[4]; // [sp+50h] [-80h] BYREF
  idList<enum encounterGroupRole_t,5> v37[7]; // [sp+60h] [-70h] BYREF

  for ( i = 0; i < this->aiEditable.interactions.conditionalMerchantInventory.num; ++i )
  {
    if ( idAI2::ShouldAddConditionalGoodList(this, player, index: i) )
      idAI2::AddConditionalGoodList(this, index: i);
  }
  v5 = 0;
  if ( this->aiEditable.interactions.dynamicMerchantInventory.num > 0 )
  {
    v6 = 0;
    do
    {
      if ( (unsigned __int8)idAI2::ShouldAddDynamicGood(this, player, index: v5) != 0 )
      {
        v7 = &this->aiEditable.interactions.dynamicMerchantInventory.list[v6];
        inventoryDecl = v7->inventoryDecl;
        count = v7->count;
        if ( inventoryDecl != nullptr && count > 0 )
        {
          v10 = this->GetInventory_2(this);
          TotalInventoryItemCount = idInventoryCollection::FindTotalInventoryItemCount(this: v10, decl: inventoryDecl);
          v12 = inventoryDecl->count;
          v13 = TotalInventoryItemCount;
          if ( v12 > 0 )
          {
            v13 = TotalInventoryItemCount / v12;
            __twllei(v12, 0);
            __twlgei(v12 & ~(__ROL4__(TotalInventoryItemCount, 1) - 1), 0xFFFFFFFF);
          }
          if ( v13 < count )
          {
            presentable = this->presentable;
            if ( presentable == nullptr )
            {
              idEntity::InitPresentableInternal(this);
              presentable = this->presentable;
            }
            v15 = this->GetInventory_2(this);
            v16 = idInventoryCollection::GiveItem(
                    this: v15,
                    owner: presentable,
                    decl: inventoryDecl,
                    count: count - v13,
                    forceCount: false,
                    canIntro: false);
            if ( v16 != nullptr )
              v16->forSale = true;
            this->aiEditable.interactions.dynamicMerchantInventory.list[v6].itemGiven = true;
          }
        }
      }
      ++v5;
      ++v6;
    }
    while ( v5 < this->aiEditable.interactions.dynamicMerchantInventory.num );
  }
  if ( this->aiEditable.interactions.specialDynamicMerchantInventory.nextGiveTime < 0 )
  {
    *(_WORD *)&v37[0].memTag = 1280;
    memset(v37, 0, 14);
    num = this->aiEditable.interactions.specialDynamicMerchantInventory.itemList.num;
    v18 = 0;
    v36[0] = ROLE_NONE;
    if ( num > 0 )
    {
      v19 = 0;
      do
      {
        if ( this->aiEditable.interactions.specialDynamicMerchantInventory.itemList.list[v19] != nullptr )
          idList<idAnimWebBlendTree *,5>::Append(this: v37, obj: v36);
        v20 = this->aiEditable.interactions.specialDynamicMerchantInventory.itemList.num;
        v36[0] = ++v18;
        v21 = v18 < v20;
        v19 = v18;
      }
      while ( v21 );
      v22 = v37[0].num;
      if ( v37[0].num > 0 )
      {
        this->aiEditable.interactions.specialDynamicMerchantInventory.nextGiveTime = 0;
        this->aiEditable.interactions.specialDynamicMerchantInventory.isDynamicMerchant = true;
        if ( this->aiEditable.interactions.specialDynamicMerchantInventory.shouldWipeInventoryOnGive )
        {
          v23 = this->presentable;
          if ( v23 == nullptr )
          {
            idEntity::InitPresentableInternal(this);
            v23 = this->presentable;
          }
          v24 = this->GetInventory_2(this);
          idInventoryCollection::FreeInventory(this: v24, owner: v23);
        }
        __twllei(v22, 0);
        v25 = 1664525 * clientGame->random.seed + 1013904223;
        clientGame->random.seed = v25;
        v26 = this->presentable;
        v27 = (v25 >> 10) & 0x7FFF;
        list = this->aiEditable.interactions.specialDynamicMerchantInventory.itemList.list;
        v29 = v27 % v22;
        __twlgei(v22 & ~(__ROL4__(v27, 1) - 1), 0xFFFFFFFF);
        if ( v26 != nullptr )
        {
          v30 = v26;
        }
        else
        {
          idEntity::InitPresentableInternal(this);
          v30 = this->presentable;
        }
        v31 = this;
        GetInventory_2 = this->GetInventory_2;
        v32 = list[v29];
        v34 = GetInventory_2(this: v31);
        v35 = idInventoryCollection::GiveItem(
                this: v34,
                owner: v30,
                decl: v32,
                count: 1,
                forceCount: false,
                canIntro: false);
        if ( v35 != nullptr )
          v35->forSale = true;
      }
    }
    if ( (v37[0].listStatic == 0 || v37[0].listStatic == 2) && v37[0].list != nullptr )
      idMem::Free(this: &mem, ptr: v37[0].list, align: ALIGN_16);
  }
}


// ========================================================================
// __unwind$534712
// EA  : 0x82A0004C
// RVA : 0x00A0004C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_534712()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 208 + 96));
}


// ========================================================================
// ?AwareOfEnemy@idAI2@@QAA_NXZ
// EA  : 0x82A00078
// RVA : 0x00A00078
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::AwareOfEnemy(idAI2 *this)
{
  int value; // r8
  idEntity *v2; // r3

  value = this->aiVolatile.memory.currentEnemy.spawnId.value;
  return gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v2 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr
      && idEntity::CastTo(c: v2) != nullptr;
}


// ========================================================================
// ?IsBlockedByFriendly@idAI2@@QAA_NPBVidEntity@@@Z
// EA  : 0x82A00100
// RVA : 0x00A00100
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsBlockedByFriendly(idAI2 *this, idEntity *_pEnemy)
{
  int value; // r8
  idEntity *v5; // r3
  idEntity *v6; // r3
  idEntity *v7; // r31
  idPhysics *Physics; // r3
  float *v9; // r3
  idPhysics *v10; // r3
  float *v11; // r3
  double v12; // fp28
  double v13; // fp27
  double v14; // fp26
  idPhysics *v15; // r3
  float *v16; // r3
  int result; // r3
  double v18; // fp0
  float v19; // [sp+50h] [-60h]
  float v20; // [sp+54h] [-5Ch]
  float v21; // [sp+58h] [-58h]

  if ( _pEnemy == nullptr )
    return 0;
  if ( _pEnemy->IsDead(this: _pEnemy) )
    return 0;
  value = this->aiVolatile.memory.currentFriendlyBlocker.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13 )
    return 0;
  v5 = gameLocal->entities.ptr[value & 0x1FFF];
  if ( v5 == nullptr )
    return 0;
  v6 = idEntity::CastTo(c: v5);
  v7 = v6;
  if ( v6 == nullptr )
    return 0;
  if ( v6->IsDead(this: v6) )
    return 0;
  Physics = idEntity::GetPhysics(this: _pEnemy);
  v9 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v19 = *v9;
  v20 = v9[1];
  v21 = v9[2];
  v10 = idEntity::GetPhysics(this: v7);
  v11 = (float *)v10->GetOrigin(this: v10, a2: 0);
  v12 = (float)(*v11 - v19);
  v13 = (float)(v11[1] - v20);
  v14 = (float)(v11[2] - v21);
  v15 = idEntity::GetPhysics(this);
  v16 = (float *)v15->GetOrigin(this: v15, a2: 0);
  v18 = (float)((float)((float)(v16[1] - v20) * (float)(v16[1] - v20))
              + (float)((float)((float)(*v16 - v19) * (float)(*v16 - v19))
                      + (float)((float)(v16[2] - v21) * (float)(v16[2] - v21))));
  result = 1;
  if ( (float)((float)((float)v14 * (float)v14)
             + (float)((float)((float)v13 * (float)v13) + (float)((float)v12 * (float)v12))) >= v18 )
    return 0;
  return result;
}


// ========================================================================
// ?GetFakeEnemyWeight@idAI2@@QBAMXZ
// EA  : 0x82A002A0
// RVA : 0x00A002A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::GetFakeEnemyWeight(idAI2 *this)
{
  int value; // r10
  idEntity *v3; // r3
  int v4; // r9
  idEntity *v5; // r3
  idTarget_FakeEnemy *v6; // r3
  idTarget_FakeEnemy *v7; // r3
  double weight; // fp1

  value = this->aiVolatile.world.fakeEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v3 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr
    && idEntity::CastTo(c: v3) != nullptr
    && ((v4 = this->aiVolatile.world.fakeEnemy.spawnId.value, gameLocal->spawnIds.ptr[v4 & 0x1FFF] != v4 >> 13)
     || (v5 = gameLocal->entities.ptr[v4 & 0x1FFF]) == nullptr
      ? (v6 = nullptr)
      : (v6 = (idTarget_FakeEnemy *)idEntity::CastTo(c: v5)),
        (v7 = idTarget_FakeEnemy::CastTo(c: v6)) != nullptr) )
  {
    weight = v7->weight;
  }
  else
  {
    weight = 0.0;
  }
  return *((float *)&weight + 1);
}


// ========================================================================
// ?OnAIEvent_Investigate@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A00378
// RVA : 0x00A00378
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Investigate(idAI2 *this, const idAIEventSound *ev)
{
  int value; // r10
  idEntity *v4; // r3
  idEntity *v5; // r30
  idAIGameState *p_aiGameState; // r29
  const idSpawnId *v7; // r30
  const idAILogic *v8; // r3
  const idSpawnId *v9; // r8
  idSpawnId v10; // [sp+50h] [-60h] BYREF
  idSpawnId v11; // [sp+54h] [-5Ch] BYREF
  idAILogic v12[2]; // [sp+60h] [-50h] BYREF

  value = ev->originator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v4 = gameLocal->entities.ptr[value & 0x1FFF];
    if ( v4 != nullptr )
    {
      v5 = idEntity::CastTo(c: v4);
      if ( v5 != nullptr )
      {
        p_aiGameState = &gameLocal->aiGameState;
        idSpawnId::idSpawnId(this: &v10, ent: this);
        v7 = idSpawnId::idSpawnId(this: &v11, ent: v5);
        v8 = idAILogic::idAILogic(this: v12, ai: this);
        idAIWorldState::AddEntityState(
          this: &this->aiVolatile.world.worldState,
          gameState: p_aiGameState,
          owner: v8,
          entId: v7,
          stimulusType: AISTIMULUS_HEARING,
          stimulusAmount: 1.0,
          sourceId: v9);
      }
    }
  }
}


// ========================================================================
// ?OnAIEvent_PlayerAim@idAI2@@AAAXPBVidAIEvent_PlayerAim@@@Z
// EA  : 0x82A00438
// RVA : 0x00A00438
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_PlayerAim(idAI2 *this, idAIEvent_PlayerAim *ev)
{
  int value; // r10
  const idDeclAIBehavior *decl; // r26
  idEntity *v6; // r3
  idEntity *v7; // r4
  idAIEntityState *v8; // r3
  idAIEntityState *v9; // r31
  idActor *Originator; // r3
  idActor *v11; // r3
  idActor *v12; // r28
  idVec3 *v13; // r4
  aiSenseState_t *v14; // r3
  bool v15; // r25
  bool v16; // r27
  bool v17; // r31
  bool v18; // r30
  bool v19; // r29
  idPhysics *Physics; // r3
  float *v21; // r3
  double v22; // fp0
  BOOL v23; // r23
  char v24; // r11
  char v25; // r26
  idWeapon *v26; // r3
  idWeapon *v27; // r3
  const idDeclProjectile *CurrentProjectileDecl; // r3
  idDeclProjectile::aiDodgeType_t aiDodgeType; // r11
  char v30; // r11
  char v31; // r28
  bool v32; // r11
  bool v33; // r10
  bool v34; // r11
  int v35; // r10
  idGameTimeManager *p_gameTimeManager; // r3
  int GameMs; // r28
  int v38; // r4
  int v39; // r3
  idFiniteStateMachine *v40; // r30
  int v41; // r31
  idAIEvent::aiEventClass_t EventClass; // r3
  float v43; // [sp+50h] [-70h]
  float v44; // [sp+54h] [-6Ch]
  float v45; // [sp+58h] [-68h]

  value = ev->originator.spawnId.value;
  decl = this->aiEditable.behaviors.decl;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v6 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v7 = idEntity::CastTo(c: v6);
  }
  else
  {
    v7 = nullptr;
  }
  v8 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v7);
  v9 = v8;
  if ( v8 != nullptr
    && (*((_BYTE *)v8 + 541) & 0x80) != 0
    && v8->senses.ptr[1]->lastUnconfirmedStimTime >= 0
    && idAIEntityState::IsVisible(this: v8) )
  {
    Originator = (idActor *)idAIEvent::GetOriginator(this: ev);
    v11 = idActor::CastTo(c: Originator);
    v12 = v11;
    if ( v11 != nullptr && v11->GetEquippedWeapon(this: v11) != nullptr )
    {
      v14 = v9->senses.ptr[1];
      v15 = false;
      v16 = false;
      v17 = false;
      v18 = false;
      v19 = false;
      aiSenseState_t::ExtrapolatePosition(this: v14, seconds: 0.5, futurePos: v13);
      Physics = idEntity::GetPhysics(this);
      v21 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
      v22 = (float)((float)((float)(v43 - *v21) * (float)(v43 - *v21))
                  + (float)((float)((float)(v45 - v21[2]) * (float)(v45 - v21[2]))
                          + (float)((float)(v44 - v21[1]) * (float)(v44 - v21[1]))));
      v23 = v22 < (float)(decl->dodging.closeRangeDist * decl->dodging.closeRangeDist);
      if ( v22 < (float)(decl->dodging.closeRangeDist * decl->dodging.closeRangeDist)
        || (v24 = 1, v22 >= (float)(decl->dodging.mediumRangeDist * decl->dodging.mediumRangeDist)) )
      {
        v24 = 0;
      }
      v25 = v24;
      v26 = v12->GetEquippedWeapon(this: v12);
      if ( !idWeapon::IsMelee(this: v26) )
      {
        v27 = v12->GetEquippedWeapon(this: v12);
        CurrentProjectileDecl = idWeapon::GetCurrentProjectileDecl(this: v27, secondaryAmmo: false);
        if ( CurrentProjectileDecl != nullptr )
        {
          aiDodgeType = CurrentProjectileDecl->aiDodgeType;
          v15 = (_cntlzw(aiDodgeType - 1) & 0x20) != 0;
          v16 = (_cntlzw(aiDodgeType - 2) & 0x20) != 0;
          v17 = (_cntlzw(aiDodgeType - 3) & 0x20) != 0;
          v18 = (_cntlzw(aiDodgeType - 4) & 0x20) != 0;
          v19 = (_cntlzw(aiDodgeType - 5) & 0x20) != 0;
        }
      }
      if ( v17 && v23 || v18 && (v23 || v25 != 0) || (v30 = 0, v19) )
        v30 = 1;
      v31 = v30;
      v32 = v16 && (v23 || v25 != 0);
      v33 = v32;
      v34 = v15 && (v23 || v25 != 0);
      if ( v34 || v33 || v31 != 0 )
      {
        if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
           - this->aiVolatile.memory.lastAimedAtTime > 1000 )
          this->aiVolatile.memory.justAimedAtTime = idGameTimeManager::GetGameMs(
                                                      this: &clientGame->gameTimeManager,
                                                      type: GAMETIME_SCALED);
        this->aiVolatile.memory.lastAimedAtTime = idGameTimeManager::GetGameMs(
                                                    this: &clientGame->gameTimeManager,
                                                    type: GAMETIME_SCALED);
        if ( v31 != 0 )
        {
          v35 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
              - this->aiVolatile.memory.lastHeavyAimedAtTime;
          p_gameTimeManager = &clientGame->gameTimeManager;
          if ( v35 >= 4000 )
          {
            GameMs = idGameTimeManager::GetGameMs(this: p_gameTimeManager, type: GAMETIME_SCALED);
            v38 = 4000;
            v39 = 2000;
          }
          else
          {
            GameMs = idGameTimeManager::GetGameMs(this: p_gameTimeManager, type: GAMETIME_SCALED);
            v38 = 8000;
            v39 = 4000;
          }
          this->aiVolatile.memory.endHeavyAimedAtTime = GetRandomInterval(_min: v39, _max: v38) + GameMs;
          this->aiVolatile.memory.lastHeavyAimedAtTime = idGameTimeManager::GetGameMs(
                                                           this: &clientGame->gameTimeManager,
                                                           type: GAMETIME_SCALED);
        }
        v40 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
        v41 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        EventClass = idAIEvent::GetEventClass(this: ev);
        idFiniteStateMachine::PostEvent(this: v40, _eventId: EventClass, _eventData: ev, curTime: v41);
      }
    }
  }
}


// ========================================================================
// ?ReserveCover@idAI2@@QAAXABVidAICover@@@Z
// EA  : 0x82A00868
// RVA : 0x00A00868
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ReserveCover(idAI2 *this, idAICover *cover)
{
  if ( !idAICover::operator==(this: &this->aiVolatile.memory.currentCover, other: cover) )
    idAI2::ReleaseCover(this);
  idAICover::Reserve(this: cover, reserver: this);
  idAIMemory::SetCurrentCover(this: &this->aiVolatile.memory, cover);
}


// ========================================================================
// ?SetLookFocusEntity@idAI2@@QAAXPBVidEntity@@_NW4aimPoint_t@@H@Z
// EA  : 0x82A008D8
// RVA : 0x00A008D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetLookFocusEntity(
        idAI2 *this,
        const idEntity *ent,
        bool keepFocusInView,
        aimPoint_t aimPoint,
        int timeout)
{
  int v7; // r3

  idFocusInfo::SetFocusEntity(
    this: &this->aiVolatile.focus.foci.ptr[1],
    owner: this,
    _ent: ent,
    _keepFocusInView: keepFocusInView,
    _aimPoint: aimPoint,
    duration: timeout);
  v7 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
  idCheckSurroundingsState::SetLastLookedAtTime(
    this: &this->aiVolatile.focus.checkSurroundingsState,
    entity: ent,
    setTime: v7);
}


// ========================================================================
// ?GetEnemySenseState@idAI2@@QBAPBVaiSenseState_t@@W4aiSense_t@@@Z
// EA  : 0x82A00958
// RVA : 0x00A00958
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

const aiSenseState_t *__fastcall idAI2::GetEnemySenseState(idAI2 *this, const aiSense_t senseType)
{
  int value; // r8
  idEntity *v5; // r3
  idEntity *v6; // r31
  idAIEntityState *v7; // r3
  int v8; // r11

  value = this->aiVolatile.memory.currentEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v6 = idEntity::CastTo(c: v5);
  }
  else
  {
    v6 = nullptr;
  }
  v7 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v6);
  if ( v6 == nullptr || v7 == nullptr )
    return nullptr;
  if ( senseType == AISENSE_MAX )
    v8 = v7->lastSense + 128;
  else
    v8 = (unsigned __int8)senseType + 128;
  return *((const aiSenseState_t **)&v7->__vftable + v8);
}


// ========================================================================
// ?IsEnemySenseStateValid@idAI2@@QBA_NW4aiSense_t@@@Z
// EA  : 0x82A00A20
// RVA : 0x00A00A20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::IsEnemySenseStateValid(idAI2 *this, const aiSense_t senseType)
{
  int value; // r8
  idEntity *v5; // r3
  idEntity *v6; // r31
  idAIEntityState *v7; // r3

  value = this->aiVolatile.memory.currentEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v6 = idEntity::CastTo(c: v5);
  }
  else
  {
    v6 = nullptr;
  }
  v7 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v6);
  return v6 != nullptr && v7 != nullptr && v7->senses.ptr[senseType]->lastUnconfirmedStimTime >= 0;
}


// ========================================================================
// ?CheckForSuspectedToTrailUpdate@idAI2@@QAA_NH@Z
// EA  : 0x82A00AD0
// RVA : 0x00A00AD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CheckForSuspectedToTrailUpdate(idAI2 *this, const int curTime)
{
  int value; // r8
  idEntity *v5; // r3
  idEntity *v6; // r28
  const aiSenseState_t *EnemySenseState; // r3
  aiSenseState_t *v8; // r25
  int y_low; // r8
  float z; // r7
  float v11; // r6
  idAIEntityState *v12; // r29
  idPhysics *Physics; // r3
  idVec3 *v14; // r3
  double y; // fp30
  double v16; // fp29
  double v17; // fp28
  double v18; // fp27
  double v19; // fp26
  idPhysics *v20; // r3
  float *v21; // r3
  double v22; // fp6
  double v23; // fp4
  double v24; // fp3
  int ConfirmedStimTimeSafe; // r28
  idAIGameState *p_aiGameState; // r26
  const idSpawnId *v27; // r25
  const idAILogic *v28; // r3
  idAIGameState *v29; // r30
  const idSpawnId *v30; // r27
  const idAILogic *v31; // r3
  idSpawnId v33[2]; // [sp+50h] [-120h] BYREF
  idVec3 pos; // [sp+58h] [-118h]
  idAILogic v35; // [sp+70h] [-100h] BYREF
  idAIPos v36; // [sp+90h] [-E0h] BYREF
  aiPhysicalState_t v37; // [sp+A0h] [-D0h] BYREF

  value = this->aiVolatile.memory.currentEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v6 = idEntity::CastTo(c: v5);
  }
  else
  {
    v6 = nullptr;
  }
  EnemySenseState = idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
  v8 = (aiSenseState_t *)EnemySenseState;
  if ( v6 == nullptr )
    return 0;
  if ( EnemySenseState == nullptr )
    return 0;
  if ( curTime - EnemySenseState->lastConfirmedStimTime < 1000 )
    return 0;
  v36.bValid = false;
  y_low = LODWORD(this->aiVolatile.memory.currentEnemySuspectedPos.pos.y);
  z = this->aiVolatile.memory.currentEnemySuspectedPos.pos.z;
  v11 = *(float *)&this->aiVolatile.memory.currentEnemySuspectedPos.bValid;
  v35.spawnId.value = LODWORD(this->aiVolatile.memory.currentEnemySuspectedPos.pos.x);
  v35.curEnemyId.value = y_low;
  v35.combatTimeoutInterval = z;
  v35.searchTimeoutInterval = v11;
  if ( HIBYTE(v11) == 0 )
    return 0;
  if ( !idAIMemory::GetEnemyTrailPos(this: &this->aiVolatile.memory, _Trail: &v36) )
    return 0;
  v12 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v6);
  if ( v12 == nullptr )
    return 0;
  pos = v36.pos;
  Physics = idEntity::GetPhysics(this);
  v14 = (idVec3 *)Physics->GetOrigin(this: Physics, a2: 0);
  if ( idVec3::DistanceFast(this: v14, v: (const idVec3 *)&v35) <= (double)(float)(this->aiEditable.perception.actorPerceptionRadius
                                                                                 * (float)0.5) )
  {
    idAIMemory::ClearCurrentTrailPos(this: &this->aiVolatile.memory);
    aiPhysicalState_t::aiPhysicalState_t(this: &v37);
    idAIGameState::GetPhysicalState(game: gameLocal, ent: v6, ps: &v37);
    y = pos.y;
    v16 = pos.z;
    v17 = (float)(v37.eyePos.x - v37.origin.x);
    v37.origin.x = pos.x;
    v18 = (float)(v37.eyePos.y - v37.origin.y);
    v37.origin.y = pos.y;
    v19 = (float)(v37.eyePos.z - v37.origin.z);
    v37.origin.z = pos.z;
    v20 = idEntity::GetPhysics(this: v6);
    v21 = (float *)v20->GetOrigin(this: v20, a2: 0);
    v22 = (float)(*v21 + (float)v17);
    v23 = (float)(v21[1] + (float)v18);
    v24 = (float)(v21[2] + (float)v19);
    this->aiVolatile.memory.currentEnemySuspectedPos.pos.x = pos.x;
    this->aiVolatile.memory.currentEnemySuspectedPos.pos.y = y;
    this->aiVolatile.memory.currentEnemySuspectedPos.bValid = true;
    this->aiVolatile.memory.currentEnemySuspectedPos.pos.z = v16;
    v37.eyePos.x = v22;
    v37.eyePos.y = v23;
    v37.eyePos.z = v24;
    ConfirmedStimTimeSafe = aiSenseState_t::GetConfirmedStimTimeSafe(this: v8);
    p_aiGameState = &gameLocal->aiGameState;
    v27 = idSpawnId::idSpawnId(this: v33, ent: this);
    v28 = idAILogic::idAILogic(this: &v35, ai: this);
    idAIEntityState::SetSenseState(
      this: v12,
      gameState: p_aiGameState,
      aiOwner: v28,
      sense: AISENSE_HEARING,
      physical: &v37,
      stimType: AISTIMULUS_HEARING,
      sourceId: v27);
    v12->senses.ptr[0]->lastConfirmedStimTime = ConfirmedStimTimeSafe;
    v29 = &gameLocal->aiGameState;
    v30 = idSpawnId::idSpawnId(this: v33, ent: this);
    v31 = idAILogic::idAILogic(this: &v35, ai: this);
    idAIEntityState::SetSenseState(
      this: v12,
      gameState: v29,
      aiOwner: v31,
      sense: AISENSE_SIGHT,
      physical: &v37,
      stimType: AISTIMULUS_SIGHT,
      sourceId: v30);
    v12->senses.ptr[1]->lastConfirmedStimTime = ConfirmedStimTimeSafe;
  }
  return 1;
}


// ========================================================================
// ?FindClosestFocus@idAI2@@AAA_NXZ
// EA  : 0x82A00DE8
// RVA : 0x00A00DE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::FindClosestFocus(idAI2 *this)
{
  const char *v2; // r26
  int v3; // r25
  int value; // r7
  idEntity *v5; // r3
  idEntity *v6; // r3
  idActor *v7; // r28
  idAIEntityState *v9; // r3
  aiSenseState_t *v10; // r29
  idPhysics *Physics; // r29
  idPhysics *v12; // r24
  float *v13; // r29
  float *v14; // r3
  double v15; // fp11
  double v16; // fp9
  double v17; // fp13
  double v20; // fp5
  double v21; // fp1
  double v22; // fp13
  double v23; // fp31
  double v24; // fp30
  double v25; // fp29
  const char *v26; // r29
  int v27; // r3
  idPhysics *v28; // r3
  idPhysics *v29; // r3
  float *v30; // r3
  float v31; // r5
  float v32; // r7
  double v33; // fp29
  double v34; // fp31
  double v35; // fp30
  idPhysics *v36; // r3
  const idVec3 *v37; // r3
  double v38; // fp1
  double v39; // fp0
  double v40; // fp10
  double v41; // fp31
  double v42; // fp30
  double v43; // fp29
  idPhysics *v44; // r3
  float *v45; // r3
  double v46; // fp7
  double v47; // fp3
  idPhysics *v48; // r26
  idPhysics *v49; // r24
  float *v50; // r26
  float *v51; // r3
  double v52; // fp10
  double v53; // fp6
  idActor *v54; // r3
  const idDeclAIBehavior *decl; // r10
  idFaction *v56; // r3
  idRelationship::attitude_t AttitudeTowards; // r3
  idRelationship::attitudeStage_t v58; // r3
  XAUDIO2::CX2Voice::EVoiceState v59; // r4
  actorClass_t actorClass; // [sp+50h] [-C0h]
  idVec3 v61; // [sp+58h] [-B8h] BYREF
  idVec3 v62; // [sp+68h] [-A8h] BYREF
  idAI2 *v63; // [sp+78h] [-98h]
  const char *v64; // [sp+7Ch] [-94h]
  int v65; // [sp+80h] [-90h]
  idVec3 v66; // [sp+88h] [-88h] BYREF

  v63 = this;
  v2 = nullptr;
  v64 = nullptr;
  v3 = gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED);
  v65 = v3;
  value = this->aiVolatile.memory.currentNeutral.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13 )
    return 0;
  v5 = gameLocal->entities.ptr[value & 0x1FFF];
  if ( v5 == nullptr )
    return 0;
  v6 = idEntity::CastTo(c: v5);
  v7 = (idActor *)v6;
  if ( v6 == nullptr )
    return 0;
  v9 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v6);
  if ( v9 == nullptr )
    return 0;
  v10 = v9->senses.ptr[1];
  if ( v10->lastUnconfirmedStimTime < 0 )
    return 0;
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - v10->lastConfirmedStimTime >= 5000 )
    return 0;
  Physics = idEntity::GetPhysics(this);
  v12 = idEntity::GetPhysics(this: v7);
  v13 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v14 = (float *)v12->GetOrigin(this: v12, a2: 0);
  v15 = (float)(v14[1] - v13[1]);
  v16 = (float)(v14[2] - v13[2]);
  v17 = (float)((float)((float)v16 * (float)v16)
              + (float)((float)((float)(*v14 - *v13) * (float)(*v14 - *v13)) + (float)((float)v15 * (float)v15)));
  if ( v17 > 16384.0 )
    goto LABEL_23;
  _FP8 = (float)((float)((float)((float)v16 * (float)v16)
                       + (float)((float)((float)(*v14 - *v13) * (float)(*v14 - *v13)) + (float)((float)v15 * (float)v15)))
               - idMath::FLT_SMALLEST_NON_DENORMAL);
  __asm { fsel      f6, f8, f13, f12 }
  v20 = __frsqrte(_FP6);
  v21 = (float)((float)-(float)((float)((float)((float)v20
                                              * (float)((float)((float)((float)v16 * (float)v16)
                                                              + (float)((float)((float)(*v14 - *v13)
                                                                              * (float)(*v14 - *v13))
                                                                      + (float)((float)v15 * (float)v15)))
                                                      * (float)0.5))
                                      * (float)v20)
                              - (float)1.5)
              * (float)v20);
  v22 = (float)((float)((float)-(float)((float)((float)((float)v20 * (float)((float)v17 * (float)0.5)) * (float)v20)
                                      - (float)1.5)
                      * (float)v20)
              * (float)((float)v17 * (float)0.5));
  v23 = (float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)v22 * (float)v21)
                                                                              - (float)1.5)
                                                              * (float)v21)
                                                      * (float)((float)((float)((float)v16 * (float)v16)
                                                                      + (float)((float)((float)(*v14 - *v13)
                                                                                      * (float)(*v14 - *v13))
                                                                              + (float)((float)v15 * (float)v15)))
                                                              * (float)0.5))
                                              * (float)((float)-(float)((float)((float)v22 * (float)v21) - (float)1.5)
                                                      * (float)v21))
                                      - (float)1.5)
                      * (float)((float)-(float)((float)((float)v22 * (float)v21) - (float)1.5) * (float)v21))
              * (float)(*v14 - *v13));
  v24 = (float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)v22 * (float)v21)
                                                                              - (float)1.5)
                                                              * (float)v21)
                                                      * (float)((float)((float)((float)v16 * (float)v16)
                                                                      + (float)((float)((float)(*v14 - *v13)
                                                                                      * (float)(*v14 - *v13))
                                                                              + (float)((float)v15 * (float)v15)))
                                                              * (float)0.5))
                                              * (float)((float)-(float)((float)((float)v22 * (float)v21) - (float)1.5)
                                                      * (float)v21))
                                      - (float)1.5)
                      * (float)((float)-(float)((float)((float)v22 * (float)v21) - (float)1.5) * (float)v21))
              * (float)v15);
  v25 = (float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)v22 * (float)v21)
                                                                              - (float)1.5)
                                                              * (float)v21)
                                                      * (float)((float)((float)((float)v16 * (float)v16)
                                                                      + (float)((float)((float)(*v14 - *v13)
                                                                                      * (float)(*v14 - *v13))
                                                                              + (float)((float)v15 * (float)v15)))
                                                              * (float)0.5))
                                              * (float)((float)-(float)((float)((float)v22 * (float)v21) - (float)1.5)
                                                      * (float)v21))
                                      - (float)1.5)
                      * (float)((float)-(float)((float)((float)v22 * (float)v21) - (float)1.5) * (float)v21))
              * (float)v16);
  if ( this->aiVolatile.physics.moveState.GetMoveStatus(this: &this->aiVolatile.physics.moveState) != 1 )
  {
    if ( (float)((float)(this->actorVolatile.modelInfo.modelAxis.mat[0].x * (float)v23)
               + (float)((float)(this->actorVolatile.modelInfo.modelAxis.mat[0].z * (float)v25)
                       + (float)(this->actorVolatile.modelInfo.modelAxis.mat[0].y * (float)v24))) >= -0.49999997 )
    {
      v26 = "standing close";
      goto LABEL_13;
    }
LABEL_23:
    XAUDIO2::CX2SourceVoice::SetVoiceState(
      this: (XAUDIO2::CX2Voice *)&this->aiVolatile.faceMgr,
      eNewState: (XAUDIO2::CX2Voice::EVoiceState)this->aiVolatile.faceMgr.defaultMood);
    if ( v2 != nullptr )
      idAI2::LookDebug(this, text: v2, level: 1, duration: v3);
    return 0;
  }
  v28 = idEntity::GetPhysics(this);
  v28->GetLinearVelocity(this: (idPhysics *)&v62, result: (idVec3 *)v28, a3: 0);
  idVec3::NormalizeFast(this: &v62);
  if ( (float)((float)(v62.x * (float)v23) + (float)((float)(v62.z * (float)v25) + (float)(v62.y * (float)v24))) <= -0.70710677 )
    goto LABEL_23;
  v29 = idEntity::GetPhysics(this);
  v30 = (float *)v29->GetOrigin(this: v29, a2: 0);
  v31 = v30[2];
  v32 = *v30;
  v33 = (float)(v62.x * (float)64.0);
  v34 = (float)(v62.z * (float)64.0);
  v35 = (float)(v62.y * (float)64.0);
  v61.y = v30[1];
  v61.z = v31;
  v61.x = v32;
  v66.x = (float)(v62.x * (float)64.0) + v32;
  v66.z = v31 + (float)(v62.z * (float)64.0);
  v66.y = v61.y + (float)(v62.y * (float)64.0);
  v36 = idEntity::GetPhysics(this: v7);
  v37 = v36->GetOrigin(this: v36, a2: 0);
  v38 = idGeometry::PositionOnLineSegment(point: v37, start: &v61, end: &v66);
  v39 = (float)((float)__fsqrts((float)((float)((float)v34 * (float)v34)
                                      + (float)((float)((float)v33 * (float)v33) + (float)((float)v35 * (float)v35))))
              * (float)v38);
  if ( v39 < -16.0 || v39 > 64.0 )
    goto LABEL_23;
  v40 = (float)((float)v35 * (float)v38);
  v42 = (float)(v61.z + (float)((float)v34 * (float)v38));
  v41 = (float)((float)((float)v33 * (float)v38) + v61.x);
  v43 = (float)(v61.y + (float)v40);
  v44 = idEntity::GetPhysics(this: v7);
  v45 = (float *)v44->GetOrigin(this: v44, a2: 0);
  v46 = (float)(v45[1] - (float)v43);
  v47 = (float)(v45[2] - (float)v42);
  if ( __fsqrts((float)((float)((float)v47 * (float)v47)
                      + (float)((float)((float)(*v45 - (float)v41) * (float)(*v45 - (float)v41))
                              + (float)((float)v46 * (float)v46)))) > 48.0 )
  {
    v2 = "moving close";
    v64 = "moving close";
    goto LABEL_23;
  }
  v26 = "squeeze by";
LABEL_13:
  v64 = v26;
  v27 = gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED);
  idAI2::SetLookFocusEntity(this, ent: v7, keepFocusInView: false, aimPoint: AIMPOINT_HEAD, timeout: v27 - 1);
  XAUDIO2::CX2SourceVoice::SetVoiceState(
    this: (XAUDIO2::CX2Voice *)&this->aiVolatile.faceMgr,
    eNewState: (XAUDIO2::CX2Voice::EVoiceState)this->aiVolatile.faceMgr.defaultMood);
  if ( !this->aiVolatile.focus.enableGreetings )
  {
    if ( v26 != nullptr )
      idAI2::LookDebug(this, text: v26, level: 1, duration: v3);
    return 1;
  }
  v48 = idEntity::GetPhysics(this);
  v49 = idEntity::GetPhysics(this: v7);
  v50 = (float *)v48->GetOrigin(this: v48, a2: 0);
  v51 = (float *)v49->GetOrigin(this: v49, a2: 0);
  v52 = (float)(v51[1] - v50[1]);
  v53 = (float)(v51[2] - v50[2]);
  if ( (float)((float)((float)v53 * (float)v53)
             + (float)((float)((float)(*v51 - *v50) * (float)(*v51 - *v50)) + (float)((float)v52 * (float)v52))) <= 16384.0 )
  {
    v54 = idActor::CastTo(c: v7);
    if ( v54 != nullptr )
    {
      decl = this->aiEditable.behaviors.decl;
      actorClass = v54->actorConstants.actorClass;
      if ( actorClass != ACTORCLASS_PLAYER )
      {
        if ( actorClass != ACTORCLASS_HUMAN )
        {
          if ( v26 != nullptr )
LABEL_38:
            idAI2::LookDebug(this, text: v26, level: 1, duration: v3);
          return 0;
        }
        if ( !decl->canGreetHumans )
        {
          if ( v26 != nullptr )
            goto LABEL_38;
          return 0;
        }
      }
      else if ( !decl->canGreetPlayers )
      {
        if ( v26 != nullptr )
          goto LABEL_38;
        return 0;
      }
    }
    v56 = this->GetFaction(this);
    AttitudeTowards = idFaction::GetAttitudeTowards(this: v56, otherEnt: v7);
    v58 = idRelationship::AttitudeToAttitudeStage(attitude: AttitudeTowards);
    v64 = "mood change";
    if ( v58 != ATTITUDESTAGE_OUTSIDER )
      v59 = ((_cntlzw(v58 - 2) & 0x20) != 0) + 1;
    else
      v59 = 4;
    XAUDIO2::CX2SourceVoice::SetVoiceState(this: (XAUDIO2::CX2Voice *)&this->aiVolatile.faceMgr, eNewState: v59);
    idAI2::LookDebug(this, text: "mood change", level: 1, duration: v3);
    return 1;
  }
  if ( v26 == nullptr )
    return 1;
  idAI2::LookDebug(this, text: v26, level: 1, duration: v3);
  return 1;
}


// ========================================================================
// __unwind$536047
// EA  : 0x82A01464
// RVA : 0x00A01464
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536047()
{
  int v0; // r12

  _idAI2::FindClosestFocus_::_2_::idLookDebug::~idLookDebug(a1: v0 - 272 + 120);
}


// ========================================================================
// ?GetAlertCycle@idAI2@@QBA?AW4alertCycle_t@@XZ
// EA  : 0x82A01490
// RVA : 0x00A01490
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

alertCycle_t __fastcall idAI2::GetAlertCycle(idAI2 *this)
{
  if ( idAI2::IsPlayerControlled(this) )
    return ALERTCYCLE_COMBAT;
  else
    return this->aiVolatile.fsms.alertCycle;
}


// ========================================================================
// ?LeaveActionNode@idAI2@@QAAX_N@Z
// EA  : 0x82A014F0
// RVA : 0x00A014F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::LeaveActionNode(idAI2 *this, const bool force)
{
  int value; // r8
  idActionNode *v4; // r3
  idActionNode *v5; // r3

  value = this->aiVolatile.memory.currentActionNode.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v4 = (idActionNode *)gameLocal->entities.ptr[value & 0x1FFF];
    if ( v4 != nullptr )
    {
      v5 = idActionNode::CastTo(c: v4);
      if ( v5 != nullptr )
        idActionNode::LeaveActionNode(this: v5, user: this);
    }
  }
}


// ========================================================================
// ?RestartPlayerInteractions@idAI2@@SAXXZ
// EA  : 0x82A01570
// RVA : 0x00A01570
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

static void __fastcall idAI2::RestartPlayerInteractions()
{
  idLinkList<idActor> *next; // r11
  idAI2 *owner; // r29
  idAI2 *v2; // r3
  idAI2 *v3; // r31
  idAI2::idAIVolatile::idAIFSMInfo *p_fsms; // r30
  idFiniteStateMachine *v5; // r3
  idFiniteStateMachine *v7; // r30
  int GameMs; // r3
  idLinkList<idActor> *v9; // r11
  idAI2 *v10; // r11

  next = gameLocal->actorEntities.next;
  if ( next != nullptr && next != gameLocal->actorEntities.head )
  {
    owner = (idAI2 *)next->owner;
    if ( owner != nullptr )
    {
      do
      {
        v2 = idAI2::CastTo(c: owner);
        v3 = v2;
        if ( v2 != nullptr )
        {
          p_fsms = &v2->aiVolatile.fsms;
          v5 = (idFiniteStateMachine *)v2->aiVolatile.fsms.fsmManager.FindFSM(
                                         this: &v2->aiVolatile.fsms.fsmManager,
                                         a2: &idAlertCycleFSM::Type);
          if ( v5 != nullptr && idFiniteStateMachine::IsChildFSMActive(this: v5, type: &idPlayerInteractFSM::Type) )
          {
            v7 = p_fsms->fsmManager.FindFSM_3(this: &p_fsms->fsmManager, a2: &idAlertCycleFSM::Type);
            if ( v7 != nullptr )
            {
              idAI2::PlayerInteractionDone(this: v3, playerLeft: true);
              idAIVoiceController::FadeVoiceOver(this: &v3->aiVolatile.voiceController, ai: v3);
              GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
              idFiniteStateMachine::Restart(this: v7, curTime: GameMs);
            }
          }
        }
        v9 = owner->actorNode.next;
        if ( v9 == nullptr || v9 == owner->actorNode.head )
          v10 = nullptr;
        else
          v10 = (idAI2 *)v9->owner;
        owner = v10;
      }
      while ( v10 != nullptr );
    }
  }
}


// ========================================================================
// ?SetRunCycleHint@idAI2@@QAAXW4runIndexType_t@@@Z
// EA  : 0x82A016B8
// RVA : 0x00A016B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetRunCycleHint(idAI2 *this, runIndexType_t runType)
{
  idAI2 *LastInflictor; // r28
  idAI2 *LastAttacker; // r30
  idPhysics *Physics; // r3
  idAI2_vtbl *v7; // r29
  const idDeclAIBehavior *decl; // r26

  if ( (runType == ANIMWEBAI_RUNINDEXTYPE_UP_STAIRS || runType == ANIMWEBAI_RUNINDEXTYPE_DOWN_STAIRS)
    && this->GetPosture(this) == POSTURE_CROUCHED
    && this->aiVolatile.animation.animWebAnimator.ptr[0].runIndexType == ANIMWEBAI_RUNINDEXTYPE_INJURED )
  {
    if ( idAIMemory::GetLastInflictor(this: &this->aiVolatile.memory) != nullptr )
      LastInflictor = (idAI2 *)idAIMemory::GetLastInflictor(this: &this->aiVolatile.memory);
    else
      LastInflictor = this;
    if ( idAIMemory::GetLastAttacker(this: &this->aiVolatile.memory) != nullptr )
      LastAttacker = (idAI2 *)idAIMemory::GetLastAttacker(this: &this->aiVolatile.memory);
    else
      LastAttacker = this;
    Physics = idEntity::GetPhysics(this);
    v7 = this->__vftable;
    decl = this->aiEditable.behaviors.decl;
    Physics->GetGravityNormal(this: Physics);
    ((void (__fastcall *)(idAI2 *, idAI2 *, idAI2 *, const idDeclDamage *, double))v7->Damage)(
      a1: this,
      a2: LastInflictor,
      a3: LastAttacker,
      a4: decl->damageBehaviors.bleedOutDamageDecl,
      a5: 100.0);
  }
  idAnimWebAI::SetAnimIndicesForRunType(this: this->aiVolatile.animation.animWebAnimator.ptr, t: runType, blend: true);
}


// ========================================================================
// GetCoverTransionAnimName
// EA  : 0x82A017D0
// RVA : 0x00A017D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idStr *__fastcall GetCoverTransionAnimName(
        idStr *result,
        idAICover *cover,
        unsigned int approach,
        const bool desireScramble,
        const bool desireMicro)
{
  char *v10; // r4
  idStr *v11; // r3
  idCoverActions v13; // [sp+58h] [-A8h] BYREF
  idStr v14; // [sp+60h] [-A0h] BYREF
  idStr v15; // [sp+80h] [-80h] BYREF
  idStr v16[3]; // [sp+A0h] [-60h] BYREF

  idStr::idStr(this: &v15, text: "$weapontransition");
  idStr::idStr(this: &v14, text: "runforward");
  if ( !desireMicro && desireScramble )
  {
    *((_BYTE *)&v13 + 4) &= 7u;
    v13.__vftable = (idCoverActions_vtbl *)&idCoverActions::`vftable';
    idAICover::GetCoverActions(this: cover, actions: &v13);
    idStr::Append(this: &v14, text: "_scramble");
    v13.__vftable = (idCoverActions_vtbl *)&idCoverActions::`vftable';
  }
  if ( approach <= 6 )
  {
    switch ( approach )
    {
      case 1u:
        v10 = "_turn_left_to_fcover";
        break;
      case 2u:
        v10 = "_turn_right_to_fcover";
        break;
      case 3u:
      case 4u:
        v10 = "_turn_back_left_to_fcover";
        break;
      default:
        if ( approach != 0 )
          v10 = "_turn_back_right_to_fcover";
        else
          v10 = "_to_fcover";
        break;
    }
    idStr::Append(this: &v14, text: v10);
  }
  if ( idAICover::GetCoverPosture(this: cover) == POSTURE_CROUCHED )
    idStr::Append(this: &v14, text: "_crouch");
  if ( desireMicro )
    idStr::Append(this: &v14, text: "_micro");
  v11 = operator+(result: v16, a: &v15, b: ":");
  operator+(result, a: v11, b: &v14);
  idStr::FreeData(this: v16);
  idStr::FreeData(this: &v14);
  idStr::FreeData(this: &v15);
  return result;
}


// ========================================================================
// __unwind$536545
// EA  : 0x82A01964
// RVA : 0x00A01964
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536545()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 256 + 128));
}


// ========================================================================
// __unwind$536546
// EA  : 0x82A0198C
// RVA : 0x00A0198C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536546()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 256 + 96));
}


// ========================================================================
// __unwind$536547
// EA  : 0x82A019B4
// RVA : 0x00A019B4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536547()
{
  int v0; // r12

  idCoverActions::~idCoverActions(this: (idCoverActions *)(v0 - 256 + 88));
}


// ========================================================================
// __unwind$536548
// EA  : 0x82A019DC
// RVA : 0x00A019DC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536548()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 256 + 160));
}


// ========================================================================
// __unwind$536549
// EA  : 0x82A01A04
// RVA : 0x00A01A04
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536549()
{
  int v0; // r12
  int v1; // r31

  v1 = v0 - 256;
  if ( (*(_DWORD *)(v0 - 256 + 80) & 1) != 0 )
  {
    *(_DWORD *)(v1 + 80) &= ~1u;
    idStrStatic<260>::~idStrStatic<260>(this: *(idStr **)(v1 + 276));
  }
}


// ========================================================================
// ?GetCoverTransitionRadius@idAI2@@QBAMABVidAICover@@_N1AAVidStr@@AAMAAVidVec3@@AAH@Z
// EA  : 0x82A01A50
// RVA : 0x00A01A50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::GetCoverTransitionRadius(
        idAI2 *this,
        idAICover *cover,
        bool desireScramble,
        bool desireMicro,
        idStr *outAnimName,
        float *outYaw,
        idVec3 *outDelta,
        int *outFrames)
{
  idPhysics *Physics; // r30
  const idVec3 *Origin; // r26
  float *v18; // r3
  double v19; // fp29
  double v20; // fp28
  double v21; // fp30
  const idObstacleInfo *v22; // r3
  idPhysics *v23; // r26
  const idVec3 *v24; // r3
  double v25; // fp30
  double v26; // fp29
  double v27; // fp28
  const idObstacleInfo *v28; // r3
  double v29; // fp27
  double v30; // fp30
  double v31; // fp28
  float *v32; // r3
  double v33; // fp5
  double v34; // fp29
  int numFrames; // r26
  bool v36; // r5
  bool v37; // r4
  idAI2::coverApproach_t v38; // r30
  char v39; // r9
  double v40; // fp1
  const idAAS2 *aas; // r3
  int v42; // r3
  idStr *CoverTransionAnimName; // r28
  size_t len; // r30
  __int16 *SubWebIndexForName; // r3
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *decl; // r4
  const idMD6Anim *AnimForAnimWebNode; // r3
  const idMD6Anim *v48; // r30
  long double v49; // fp2
  long double v50; // fp4
  long double v51; // fp2
  idMD6AnimData *animData; // r11
  double v53; // fp31
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> v55; // [sp+50h] [-150h] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> v56; // [sp+52h] [-14Eh] BYREF
  idCoverActions v57; // [sp+58h] [-148h] BYREF
  idDeclAnimWeb v58; // [sp+60h] [-140h] BYREF

  Physics = idEntity::GetPhysics(this);
  Origin = idAICover::GetOrigin(this: cover);
  v18 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v19 = (float)(v18[2] - Origin->z);
  v20 = (float)(v18[1] - Origin->y);
  v21 = (float)(*v18 - Origin->x);
  v22 = this->aiVolatile.physics.moveState.GetObstacleInfo(this: &this->aiVolatile.physics.moveState);
  if ( ((LODWORD(v22->wallCorners[0].z) | LODWORD(v22->wallCorners[0].y) | LODWORD(v22->wallCorners[0].x)) & 0x7FFFFFFF) != 0 )
  {
    v23 = idEntity::GetPhysics(this);
    v24 = idAICover::GetOrigin(this: cover);
    v25 = (float)(v24->z * (float)0.0);
    v26 = (float)(v24->y * (float)0.0);
    v27 = (float)(v24->x * (float)0.0);
    v28 = this->aiVolatile.physics.moveState.GetObstacleInfo(this: &this->aiVolatile.physics.moveState);
    v29 = (float)(v28->wallCorners[0].x + (float)v27);
    v30 = (float)(v28->wallCorners[0].z + (float)v25);
    v31 = (float)(v28->wallCorners[0].y + (float)v26);
    v32 = (float *)v23->GetOrigin(this: v23, a2: 0);
    v19 = (float)(v32[2] - (float)v30);
    v20 = (float)(v32[1] - (float)v31);
    v21 = (float)(*v32 - (float)v29);
  }
  idAICover::GetAxis(this: cover, axis: (idMat3 *)&v58.states.size);
  *(float *)&v58.resourceListPtr = 0.0;
  *((_BYTE *)&v57 + 4) &= 7u;
  v57.__vftable = (idCoverActions_vtbl *)&idCoverActions::`vftable';
  v33 = (float)((float)(*(float *)&v58.models.granularity * (float)v19)
              + (float)(*(float *)&v58.models.size * (float)v20));
  v34 = (float)((float)(*(float *)&v58.states.size * (float)v21)
              + (float)((float)(*(float *)&v58.models.list * (float)v19)
                      + (float)(*(float *)&v58.states.granularity * (float)v20)));
  *(float *)&v58.nextOnHashChain = v34;
  *(float *)&v58.name.str = (float)(*(float *)&v58.models.num * (float)v21) + (float)v33;
  idAICover::GetCoverActions(this: cover, actions: &v57);
  numFrames = 0;
  if ( (*((_BYTE *)&v57 + 4) & 0x10) != 0 || (v36 = false, (*((_BYTE *)&v57 + 4) & 8) != 0) )
    v36 = true;
  if ( (*((_BYTE *)&v57 + 4) & 0x40) != 0 || (v37 = false, (*((_BYTE *)&v57 + 4) & 0x20) != 0) )
    v37 = true;
  v38 = CoverApproachForDirection(
          relativePosition: (const idVec3 *)&v58.name,
          allowTurnAroundLeft: v37,
          allowTurnAroundRight: v36);
  if ( v38 == COVER_APPROACH_MAX )
  {
    v40 = -1.0;
    return *((float *)&v40 + 1);
  }
  aas = cover->aas;
  v58.trackedMemory = (int)cover->aas;
  if ( v58.trackedMemory != 0 )
  {
    v42 = (int)aas->GetCoverPoint(this: aas, a2: cover->coverIndex);
    switch ( v38 )
    {
      case COVER_APPROACH_WRAP_AROUND_LEFT:
        v40 = -1.0;
        return *((float *)&v40 + 1);
      case COVER_APPROACH_WRAP_AROUND_RIGHT:
        v40 = -1.0;
        return *((float *)&v40 + 1);
      case COVER_APPROACH_FORWARD:
        if ( (*(_WORD *)(v42 + 26) & 0x4000) == 0 )
        {
          v40 = -1.0;
          return *((float *)&v40 + 1);
        }
        goto LABEL_34;
      case COVER_APPROACH_LEFT:
        if ( (*(_WORD *)(v42 + 26) & 0x8000) == 0 )
        {
          v40 = -1.0;
          return *((float *)&v40 + 1);
        }
        v39 = *((_BYTE *)&v57 + 4);
        goto LABEL_37;
      case COVER_APPROACH_TURN_AROUND_LEFT:
        if ( (*(__int16 *)(v42 + 26) & 0x10000) == 0 )
        {
          v40 = -1.0;
          return *((float *)&v40 + 1);
        }
        goto LABEL_34;
      case COVER_APPROACH_RIGHT:
        if ( (*(__int16 *)(v42 + 26) & 0x40000) == 0 )
        {
          v40 = -1.0;
          return *((float *)&v40 + 1);
        }
        v39 = *((_BYTE *)&v57 + 4);
LABEL_42:
        if ( (v39 & 0x10) == 0 && (v39 & 8) == 0 && v34 > 0.0 )
        {
          v40 = -1.0;
          return *((float *)&v40 + 1);
        }
        goto LABEL_34;
      case COVER_APPROACH_TURN_AROUND_RIGHT:
        if ( (*(__int16 *)(v42 + 26) & 0x80000) == 0 )
        {
          v40 = -1.0;
          return *((float *)&v40 + 1);
        }
        goto LABEL_34;
      default:
        break;
    }
    v39 = *((_BYTE *)&v57 + 4);
  }
  if ( v38 == COVER_APPROACH_LEFT )
  {
LABEL_37:
    if ( (v39 & 0x40) == 0 && (v39 & 0x20) == 0 && v34 > 0.0 )
    {
      v40 = -1.0;
      return *((float *)&v40 + 1);
    }
    goto LABEL_34;
  }
  if ( v38 == COVER_APPROACH_RIGHT )
    goto LABEL_42;
LABEL_34:
  CoverTransionAnimName = GetCoverTransionAnimName(
                            result: (idStr *)&v58.edgeCache.size,
                            cover,
                            approach: v38,
                            desireScramble,
                            desireMicro);
  len = CoverTransionAnimName->len;
  idStr::EnsureAlloced(
    this: outAnimName,
    amount: CoverTransionAnimName->len + 1,
    keepold: false,
    geometricGrowth: false);
  memcpy(Dst: outAnimName->data, Src: CoverTransionAnimName->data, Size: len);
  outAnimName->data[len] = 0;
  outAnimName->len = len;
  idStr::FreeData(this: (idStr *)&v58.edgeCache.size);
  v58.nodes.size = 0;
  v58.subWebs.list = (idDeclAnimWeb::idSubWebInfo *)20;
  *(_DWORD *)&v58.nodes.granularity = &v58.subWebs.num;
  HIBYTE(v58.subWebs.num) = 0;
  v58.textLength = 20;
  v58.textSource = (char *)&v58.md5Checksum;
  *((_DWORD *)&v58.idResource + 8) = 0;
  HIBYTE(v58.md5Checksum) = 0;
  idAI2::GetSubWebAndStateFromAnimWebPath(
    this,
    animWebPath: outAnimName->data,
    subWebName: (idStr *)&v58.nodes.size,
    stateName: (idStr *)&v58.idResource + 1);
  v55.value = -1;
  v56.value = -1;
  SubWebIndexForName = (__int16 *)idDeclAnimWeb::GetSubWebIndexForName(
                                    this: &v58,
                                    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                                    subWebName: *(const char **)&v58.nodes.granularity);
  decl = (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl;
  v55.value = *SubWebIndexForName;
  v56.value = HIWORD(idDeclAnimWeb::GetStateIndexForName(
                       this: (idDeclAnimWeb *)&v58.trackedMemory,
                       result: decl,
                       name: v58.textSource)->__vftable);
  AnimForAnimWebNode = idAI2::GetAnimForAnimWebNode(this, swi: &v55, si: &v56);
  v48 = AnimForAnimWebNode;
  if ( AnimForAnimWebNode != nullptr )
  {
    idAI2::GetAnimationDelta(this, anim: AnimForAnimWebNode, outDelta);
    *((double *)&v49 + 1) = outDelta->x;
    *(double *)&v49 = outDelta->y;
    v51 = atan2(v: v49, u: v50);
    *outYaw = *(double *)&v51;
    animData = v48->animData;
    if ( animData != nullptr )
      numFrames = animData->numFrames;
    *outFrames = 2 * numFrames;
    v53 = __fsqrts((float)((float)(outDelta->y * outDelta->y) + (float)(outDelta->x * outDelta->x)));
    idStr::FreeData(this: (idStr *)&v58.idResource + 1);
    idStr::FreeData(this: (idStr *)&v58.nodes.size);
    v40 = v53;
  }
  else
  {
    idStr::FreeData(this: (idStr *)&v58.idResource + 1);
    idStr::FreeData(this: (idStr *)&v58.nodes.size);
    v40 = -1.0;
  }
  return *((float *)&v40 + 1);
}


// ========================================================================
// __unwind$536657_0
// EA  : 0x82A01FA4
// RVA : 0x00A01FA4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536657_0()
{
  int v0; // r12

  idCoverActions::~idCoverActions(this: (idCoverActions *)(v0 - 416 + 88));
}


// ========================================================================
// __unwind$536658
// EA  : 0x82A01FCC
// RVA : 0x00A01FCC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536658()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 416 + 240));
}


// ========================================================================
// __unwind$536659
// EA  : 0x82A01FF4
// RVA : 0x00A01FF4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536659()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 416 + 160));
}


// ========================================================================
// __unwind$536660
// EA  : 0x82A0201C
// RVA : 0x00A0201C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_536660()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 416 + 128));
}


// ========================================================================
// ?DamageRobot@idAI2@@QAA_NPAVidEntity@@PBVidDeclDamage@@PAUtrace_t@@@Z
// EA  : 0x82A02B68
// RVA : 0x00A02B68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::DamageRobot(
        idAI2 *this,
        idEntity *_pAttacker,
        const idDeclDamage *_pDamageDecl,
        trace_t *p_Trace)
{
  double v8; // fp29
  idPhysics *Physics; // r3
  float *v10; // r26
  idPhysics *v11; // r3
  float *v12; // r3
  double v13; // fp7
  double v14; // fp6
  double v15; // fp1
  __int64 v16; // r9
  __int64 v17; // r7
  double v18; // fp1
  double v19; // fp31
  unsigned int v20; // r28
  const idMaterial *frontImpactFX; // r24
  idMat3 *v22; // r23
  idImpactManager *v23; // r3
  const idSoundShader *rearImpactSound; // r4
  unsigned int GameMs; // r28
  const idMaterial *rearImpactFX; // r24
  idMat3 *v27; // r23
  idImpactManager *WeaponImpactMgr; // r3
  BOOL isCharging; // r11
  double v30; // fp0
  idEventArg *v31; // r3
  int *v32; // r10
  _DWORD *v33; // r11
  int i; // ctr
  idEntity *v35; // r3
  double chargeHealthFract; // fp0
  double stageHealth; // fp13
  double v38; // fp12
  int v40; // [sp+8h] [-158h]
  const idColor *v41; // [sp+Ch] [-154h]
  int v42; // [sp+10h] [-150h]
  int v43; // [sp+14h] [-14Ch]
  int v44; // [sp+18h] [-148h]
  int v45; // [sp+1Ch] [-144h]
  int v46; // [sp+20h] [-140h]
  int v47; // [sp+24h] [-13Ch]
  int v48; // [sp+28h] [-138h]
  int v49; // [sp+2Ch] [-134h]
  int v50; // [sp+30h] [-130h]
  int v51; // [sp+34h] [-12Ch]
  int v52; // [sp+38h] [-128h]
  int v53; // [sp+3Ch] [-124h]
  int v54; // [sp+40h] [-120h]
  int v55; // [sp+44h] [-11Ch]
  int v56; // [sp+48h] [-118h]
  int v57; // [sp+4Ch] [-114h]
  int v58; // [sp+50h] [-110h]
  int v59; // [sp+58h] [-108h]
  int v60; // [sp+5Ch] [-104h]
  int v61; // [sp+60h] [-100h]
  int v62; // [sp+68h] [-F8h]
  int v63; // [sp+6Ch] [-F4h] BYREF
  idVec3 v64; // [sp+70h] [-F0h] BYREF
  idEventArg v65[2]; // [sp+90h] [-D0h] BYREF
  float v66[20]; // [sp+C0h] [-A0h] BYREF

  if ( _pDamageDecl == nullptr
    || (_pDamageDecl->damageTypes & 0x80) == 0
    || idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) < this->aiEditable.actionSettings.customRobot.immuneDoneTime )
  {
    return 0;
  }
  v8 = 0.0;
  if ( _pAttacker != nullptr )
  {
    Physics = idEntity::GetPhysics(this);
    v10 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v11 = idEntity::GetPhysics(this: _pAttacker);
    v12 = (float *)v11->GetOrigin(this: v11, a2: 0);
    v13 = (float)(v12[1] - v10[1]);
    v14 = (float)(v12[2] - v10[2]);
    v64.x = *v12 - *v10;
    v64.y = v13;
    v64.z = v14;
    v15 = idVec3::NormalizeFast(this: &v64);
    ((void (__fastcall *)(idAI2 *, float *, double))this->GetEyeAxis)(a1: this, a2: v66, a3: v15);
    v8 = (float)((float)(v66[2] * v64.z) + (float)((float)(v66[1] * v64.y) + (float)(v66[0] * v64.x)));
  }
  v18 = idDeclDamage::DamageAmount(this: _pDamageDecl);
  if ( v8 < 0.0 )
  {
    v19 = (float)(this->aiEditable.actionSettings.customRobot.rearDamageMultiplier * (float)v18);
    if ( p_Trace != nullptr && p_Trace->fraction < 1.0 )
    {
      if ( this->aiEditable.actionSettings.customRobot.rearImpactFX != nullptr )
      {
        GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        rearImpactFX = (const idMaterial *)this->aiEditable.actionSettings.customRobot.rearImpactFX;
        v27 = idVec3::ToZAxis(this: (idVec3 *)v65, result: (idMat3 *)&p_Trace->c.normal);
        WeaponImpactMgr = idClientGame::GetWeaponImpactMgr(this: clientGame);
        idImpactManager::UseImpact(
          this: WeaponImpactMgr,
          org: &p_Trace->c.point,
          axis: v27,
          prt: rearImpactFX,
          startTime: GameMs,
          bindToParent: false,
          parentOrg: &vec3_origin,
          parentAxis: &mat3_identity,
          distSqr: 0.0,
          playerIndex: v40,
          color: v41,
          numCycles: v42,
          a13: v43,
          a14: v44,
          a15: v45,
          a16: v46,
          a17: v47,
          a18: v48,
          a19: v49,
          a20: v50,
          a21: v51,
          a22: v52,
          a23: v53,
          a24: v54,
          a25: v55,
          a26: v56,
          a27: v57,
          a28: v58,
          a29: 0,
          a30: v59,
          a31: v60,
          a32: v61,
          a33: &idColor::colorWhite.r,
          a34: v62,
          a35: 1);
      }
      rearImpactSound = this->aiEditable.actionSettings.customRobot.rearImpactSound;
      goto LABEL_17;
    }
  }
  else
  {
    v19 = (float)(this->aiEditable.actionSettings.customRobot.frontDamageMultiplier * (float)v18);
    if ( p_Trace != nullptr && p_Trace->fraction < 1.0 )
    {
      if ( this->aiEditable.actionSettings.customRobot.frontImpactFX != nullptr )
      {
        v20 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        frontImpactFX = (const idMaterial *)this->aiEditable.actionSettings.customRobot.frontImpactFX;
        v22 = idVec3::ToZAxis(this: (idVec3 *)v65, result: (idMat3 *)&p_Trace->c.normal);
        v23 = idClientGame::GetWeaponImpactMgr(this: clientGame);
        idImpactManager::UseImpact(
          this: v23,
          org: &p_Trace->c.point,
          axis: v22,
          prt: frontImpactFX,
          startTime: v20,
          bindToParent: false,
          parentOrg: &vec3_origin,
          parentAxis: &mat3_identity,
          distSqr: 0.0,
          playerIndex: v40,
          color: v41,
          numCycles: v42,
          a13: v43,
          a14: v44,
          a15: v45,
          a16: v46,
          a17: v47,
          a18: v48,
          a19: v49,
          a20: v50,
          a21: v51,
          a22: v52,
          a23: v53,
          a24: v54,
          a25: v55,
          a26: v56,
          a27: v57,
          a28: v58,
          a29: 0,
          a30: v59,
          a31: v60,
          a32: v61,
          a33: &idColor::colorWhite.r,
          a34: v62,
          a35: 1);
      }
      rearImpactSound = this->aiEditable.actionSettings.customRobot.frontImpactSound;
LABEL_17:
      if ( rearImpactSound != nullptr )
        idClientGame::PlayShaderDirectly(
          this: clientGame,
          shader: rearImpactSound,
          channel: SND_CHANNEL_DAMAGE,
          pos: &p_Trace->c.point,
          axis: &mat3_identity,
          peerMask: 0);
    }
  }
  if ( v19 > 0.0 )
  {
    if ( v8 < 0.0
      && this->aiEditable.actionSettings.customRobot.isCharging
      && this->aiEditable.actionSettings.customRobot.chargeDoneTime > 0 )
    {
      v19 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth + (float)1.0);
    }
    isCharging = this->aiEditable.actionSettings.customRobot.isCharging;
    v30 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth - (float)v19);
    this->aiEditable.actionSettings.customRobot.curStageHealth = this->aiEditable.actionSettings.customRobot.curStageHealth
                                                               - (float)v19;
    if ( !isCharging
      && (float)((float)v30 / this->aiEditable.actionSettings.customRobot.stageHealth) <= (double)this->aiEditable.actionSettings.customRobot.chargeHealthFract )
    {
      if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut) != nullptr )
      {
        v31 = idEventArg::idEventArg(this: v65, data: this);
        v32 = &v63;
        v33 = (_DWORD *)&v31[-1].value.q[3];
        for ( i = 5; i != 0; --i )
          *++v32 = *++v33;
        v35 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut);
        idEventReceiver::PostEventMS(this: v35, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)LODWORD(v64.z));
      }
      chargeHealthFract = this->aiEditable.actionSettings.customRobot.chargeHealthFract;
      stageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
      this->aiEditable.actionSettings.customRobot.isCharging = true;
      this->aiEditable.actionSettings.customRobot.curStageHealth = (float)chargeHealthFract * (float)stageHealth;
      this->aiEditable.actionSettings.customRobot.chargeDoneTime = -1;
    }
    if ( this->aiEditable.actionSettings.customRobot.curStageHealth <= 0.0 )
      idAI2::RobotBatteryExplodes(this, _pAttacker);
    LODWORD(v16) = this->aiEditable.actionSettings.customRobot.numStages;
    v38 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth
                / this->aiEditable.actionSettings.customRobot.stageHealth);
    LODWORD(v17) = v16 - this->aiEditable.actionSettings.customRobot.curStage - 1;
    *(_QWORD *)&v64.x = v17;
    this->aiEditable.actionSettings.customRobot.bossHealth = (float)((float)v17 + (float)v38) / (float)v16;
  }
  return 0;
}


// ========================================================================
// ?ThinkRobot@idAI2@@QAAXH@Z
// EA  : 0x82A02F88
// RVA : 0x00A02F88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

// local variable allocation has failed, the output may be wrong!
void __fastcall idAI2::ThinkRobot(idAI2 *this, int _curTime, __int64 a3)
{
  int chargeDoneTime; // r11
  __int64 v6; // r9
  idEventArg *v7; // r3
  int *v8; // r10
  _DWORD *v9; // r11
  int j; // ctr
  idEntity *v11; // r3
  double stageHealth; // fp0
  int v13; // r7
  double v14; // fp12
  int v15; // r7
  idLegsFSM *p_legsFSM; // r3
  idAIAction *CurrentAction; // r3
  idEventArg *v18; // r3
  int *v19; // r10
  _DWORD *v20; // r11
  int i; // ctr
  idEntity *v22; // r3
  int nextTurnfastTime; // r11
  idAIOrientation *BodyOrientation; // r3
  double v25; // fp6
  idPhysics *Physics; // r3
  const idVec3 *v27; // r3
  idAIOrientation *v28; // r3
  double v29; // fp31
  idPresentable *presentable; // r3
  idEntity *NextTeamEntity; // r29
  idEntity *v32; // r27
  idPresentable *v33; // r3
  idPhysics *v34; // r3
  int v35; // r3
  int v36; // r7
  int v37; // r6
  int curStage; // r11
  idColor *v39; // r9
  float r; // r8
  float g; // r7
  float b; // r6
  float a; // r5
  const char *v44; // r4
  idAIAction *v45; // r3
  __int64 v46; // r6
  __int64 v47; // r10
  __int64 v48; // r8
  va *v49; // r3
  int v50; // [sp+8h] [-1118h]
  int v51; // [sp+Ch] [-1114h]
  int v52; // [sp+10h] [-1110h]
  int v53; // [sp+14h] [-110Ch]
  int v54; // [sp+18h] [-1108h]
  int v55; // [sp+1Ch] [-1104h]
  double v56; // [sp+20h] [-1100h]
  int v57; // [sp+5Ch] [-10C4h] BYREF
  __int64 v58; // [sp+60h] [-10C0h] BYREF
  float v59; // [sp+68h] [-10B8h]
  idStr v60; // [sp+80h] [-10A0h] BYREF
  _DWORD v61[4]; // [sp+A0h] [-1080h] BYREF
  idEventArg v62; // [sp+B0h] [-1070h] BYREF
  va v63; // [sp+D0h] [-1050h] BYREF

  if ( this->aiEditable.actionSettings.customRobot.usesRobot )
  {
    if ( this->aiEditable.actionSettings.customRobot.isBoss )
    {
      HIDWORD(v58) = this->entityNumber;
      HIDWORD(a3) = gameLocal->spawnIds.ptr[HIDWORD(v58)] << 13;
      gameLocal->bossEntity.spawnId.value = HIDWORD(a3) | HIDWORD(v58);
    }
    if ( this->aiEditable.actionSettings.customRobot.isCharging )
    {
      chargeDoneTime = this->aiEditable.actionSettings.customRobot.chargeDoneTime;
      if ( chargeDoneTime <= 0 )
      {
        if ( this->aiEditable.actionSettings.customRobot.curStageHealth <= (double)this->aiEditable.actionSettings.customRobot.chargeHealthFract
          && _curTime >= this->aiEditable.actionSettings.customRobot.nextMTSPCheck )
        {
          p_legsFSM = &this->aiVolatile.fsms.actionManager.legsFSM;
          if ( this == (idAI2 *)-32672 )
            CurrentAction = nullptr;
          else
            CurrentAction = idAIActionFSM::GetCurrentAction(this: p_legsFSM);
          if ( (unsigned __int8)idAction_MoveToScenePoint::IsTypeOf(c: CurrentAction) == 0
            && idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut) != nullptr )
          {
            v18 = idEventArg::idEventArg(this: &v62, data: this);
            v19 = &v57;
            v20 = (_DWORD *)&v18[-1].value.q[3];
            for ( i = 5; i != 0; --i )
              *++v19 = *++v20;
            v22 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnPowerOut);
            idEventReceiver::PostEventMS(this: v22, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)LODWORD(v59));
          }
          LODWORD(v58) = (int)1000.0;
          this->aiEditable.actionSettings.customRobot.nextMTSPCheck = (int)1000.0 + _curTime;
        }
      }
      else
      {
        if ( _curTime < chargeDoneTime )
        {
          stageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
          HIDWORD(v6) = chargeDoneTime - this->aiEditable.actionSettings.customRobot.chargeStartTime;
          v13 = chargeDoneTime - _curTime;
          LODWORD(a3) = HIDWORD(v6);
          v58 = a3;
          this->aiEditable.actionSettings.customRobot.curStageHealth = (float)stageHealth
                                                                     * (float)((float)1.0
                                                                             - (float)((float)*(__int64 *)((char *)&a3 - 4)
                                                                                     / (float)a3));
        }
        else
        {
          if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnChargingDone) != nullptr )
          {
            v7 = idEventArg::idEventArg(this: &v62, data: this);
            v8 = &v57;
            v9 = (_DWORD *)&v7[-1].value.q[3];
            for ( j = 5; j != 0; --j )
              *++v8 = *++v9;
            v11 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.actionSettings.customRobot.triggerOnChargingDone);
            idEventReceiver::PostEventMS(this: v11, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)LODWORD(v59));
          }
          stageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
          this->aiEditable.actionSettings.customRobot.curStageHealth = this->aiEditable.actionSettings.customRobot.stageHealth;
          this->aiEditable.actionSettings.customRobot.isCharging = false;
          this->aiEditable.actionSettings.customRobot.chargeStartTime = -1;
          this->aiEditable.actionSettings.customRobot.chargeDoneTime = -1;
        }
        v14 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth / (float)stageHealth);
        LODWORD(v6) = this->aiEditable.actionSettings.customRobot.numStages;
        v15 = v6 - this->aiEditable.actionSettings.customRobot.curStage - 1;
        v58 = *(__int64 *)((char *)&a3 - 4);
        this->aiEditable.actionSettings.customRobot.bossHealth = (float)((float)*(__int64 *)((char *)&a3 - 4)
                                                                       + (float)v14)
                                                               / (float)v6;
      }
    }
    if ( this->aiEditable.actionSettings.customRobot.turnfastSound != nullptr )
    {
      nextTurnfastTime = this->aiEditable.actionSettings.customRobot.nextTurnfastTime;
      if ( nextTurnfastTime < 0 )
      {
        this->aiEditable.actionSettings.customRobot.nextTurnfastTime = 0;
      }
      else if ( _curTime >= nextTurnfastTime )
      {
        BodyOrientation = idAI2::GetBodyOrientation(this);
        v25 = (float)((float)(BodyOrientation->axis.mat[0].x * this->aiEditable.actionSettings.customRobot.lastBodyDir.x)
                    + (float)((float)(this->aiEditable.actionSettings.customRobot.lastBodyDir.z
                                    * BodyOrientation->axis.mat[0].z)
                            + (float)(this->aiEditable.actionSettings.customRobot.lastBodyDir.y
                                    * BodyOrientation->axis.mat[0].y)));
        HIDWORD(v58) = &BodyOrientation->axis;
        if ( v25 < 0.99900001 )
        {
          Physics = idEntity::GetPhysics(this);
          v27 = Physics->GetOrigin(this: Physics, a2: 0);
          idClientGame::PlayShaderDirectly(
            this: clientGame,
            shader: this->aiEditable.actionSettings.customRobot.turnfastSound,
            channel: SND_CHANNEL_DAMAGE,
            pos: v27,
            axis: &mat3_identity,
            peerMask: 0);
          LODWORD(v58) = (int)(float)(1000.0 * (float)-2.0);
          this->aiEditable.actionSettings.customRobot.nextTurnfastTime = _curTime - v58;
        }
      }
      v28 = idAI2::GetBodyOrientation(this);
      this->aiEditable.actionSettings.customRobot.lastBodyDir.x = v28->axis.mat[0].x;
      HIDWORD(v58) = &v28->axis;
      this->aiEditable.actionSettings.customRobot.lastBodyDir.y = v28->axis.mat[0].y;
      this->aiEditable.actionSettings.customRobot.lastBodyDir.z = v28->axis.mat[0].z;
    }
    v29 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth
                / this->aiEditable.actionSettings.customRobot.stageHealth);
    if ( v29 <= this->aiEditable.actionSettings.customRobot.chargeHealthFract
      || this->IsDead(this)
      || this->IsDying(this) )
    {
      v29 = 0.0;
    }
    presentable = this->presentable;
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
    }
    idPresentable::SetParm(this: presentable, parm: rp->Diversity, scalar: v29);
    NextTeamEntity = idEntity::GetNextTeamEntity(this);
    if ( NextTeamEntity != nullptr )
    {
      do
      {
        v32 = idEntity::GetNextTeamEntity(this: NextTeamEntity);
        if ( idEntity::GetBindMaster(this: NextTeamEntity) == this )
        {
          v33 = NextTeamEntity->presentable;
          if ( v33 == nullptr )
          {
            idEntity::InitPresentableInternal(this: NextTeamEntity);
            v33 = NextTeamEntity->presentable;
          }
          idPresentable::SetParm(this: v33, parm: rp->Diversity, scalar: v29);
          idEntity::UpdateVisuals(this: NextTeamEntity);
        }
        NextTeamEntity = v32;
      }
      while ( v32 != nullptr );
    }
    if ( ai_debugLevel.valueInteger >= 1 )
    {
      v34 = idEntity::GetPhysics(this);
      v35 = (int)v34->GetOrigin(this: v34, a2: 0);
      v36 = *(_DWORD *)v35;
      v37 = *(_DWORD *)(v35 + 4);
      curStage = this->aiEditable.actionSettings.customRobot.curStage;
      v59 = *(float *)(v35 + 8);
      v59 = v59 + (float)250.0;
      HIDWORD(v58) = v36;
      LODWORD(v58) = v37;
      if ( curStage != 0 )
      {
        if ( curStage == 1 )
        {
          v39 = &idColor::colorYellow;
          r = idColor::colorYellow.r;
        }
        else
        {
          v39 = &idColor::colorRed;
          r = idColor::colorRed.r;
        }
      }
      else
      {
        v39 = &idColor::colorGreen;
        r = idColor::colorGreen.r;
      }
      g = v39->g;
      b = v39->b;
      a = v39->a;
      v60.len = 0;
      v60.baseBuffer[0] = 0;
      *(float *)v61 = r;
      *(float *)&v61[1] = g;
      *(float *)&v61[2] = b;
      *(float *)&v61[3] = a;
      v60.allocedAndFlag = 20;
      v60.data = v60.baseBuffer;
      if ( this->aiEditable.actionSettings.customRobot.isCharging )
      {
        if ( this->aiEditable.actionSettings.customRobot.chargeDoneTime <= 0 )
        {
          if ( this == (idAI2 *)-32672 )
            v45 = nullptr;
          else
            v45 = idAIActionFSM::GetCurrentAction(this: &this->aiVolatile.fsms.actionManager.legsFSM);
          if ( (unsigned __int8)idAction_MoveToScenePoint::IsTypeOf(c: v45) != 0 )
            v44 = "Moving to charge";
          else
            v44 = "No chargepoint found";
        }
        else
        {
          v44 = "Charging";
        }
      }
      else
      {
        v44 = "Fighting";
      }
      idStr::operator=(this: &v60, text: v44);
      v56 = (float)(this->aiEditable.actionSettings.customRobot.curStageHealth
                  / this->aiEditable.actionSettings.customRobot.stageHealth);
      HIDWORD(v46) = LODWORD(v56);
      v49 = va::va(
              this: &v63,
              fmt: (const char *)HIDWORD(v56),
              a3: v46,
              a4: v48,
              a5: v47,
              a6: v50,
              a7: v51,
              a8: v52,
              a9: v53,
              a10: v54,
              a11: v55);
      idStr::Append(this: &v60, text: v49);
      ((void (__fastcall *)(idRenderWorld *, char *, __int64 *, idRenderWorld_vtbl *, _DWORD *, int, _DWORD, _DWORD, double))clientGame->renderWorld->DebugText)(
        a1: clientGame->renderWorld,
        a2: v60.data,
        a3: &v58,
        a4: clientGame->renderWorld->__vftable,
        a5: v61,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 1.0);
      idStr::FreeData(this: &v60);
    }
  }
}


// ========================================================================
// __unwind$540194
// EA  : 0x82A035BC
// RVA : 0x00A035BC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_540194()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 4384 + 128));
}


// ========================================================================
// ?Hide@idAI2@@UAAXXZ
// EA  : 0x82A035E8
// RVA : 0x00A035E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Hide(idAI2 *this)
{
  char idCombatStage_useRelaxedChatterVO; // r30
  idEntityPtr<idAI2> v3[12]; // [sp+50h] [-30h] BYREF

  idCombatStage_useRelaxedChatterVO = Get_idCombatStage_useRelaxedChatterVO(ptr: this);
  idActor::Hide(this);
  idEntity::BecomeInactive(this, flags: 7);
  if ( idCombatStage_useRelaxedChatterVO == 0 )
  {
    if ( this != nullptr )
      v3[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
    else
      v3[0].spawnId.value = 0x1FFF;
    idList<idEntityPtr<idPlayer>,5>::Remove(this: &gameLocal->activeAI, obj: v3);
    if ( this != nullptr )
      v3[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
    else
      v3[0].spawnId.value = 0x1FFF;
    idList<idEntityPtr<idPlayer>,5>::Remove(
      this: (idList<idEntityPtr<idAI2>,5> *)&gameLocal->aiWorldStateUsers,
      obj: v3);
    idAI2::SetSolid(this, isSolid: false);
  }
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    this->aiVolatile.animation.animFSM.EnterHiddenMode(this: &this->aiVolatile.animation.animFSM, a2: true);
}


// ========================================================================
// ?ShouldDeadThink@idAI2@@QBA_NXZ
// EA  : 0x82A036F0
// RVA : 0x00A036F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::ShouldDeadThink(idAI2 *this)
{
  int GameMs; // r3
  unsigned __int8 v3; // r11

  if ( idAI2::IsPlayerControlled(this) )
    return 0;
  if ( this->aiVolatile.fsms.alertCycle != ALERTCYCLE_DEAD )
    return 0;
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v3 = 1;
  if ( GameMs - this->aiVolatile.death.deathTime <= 500 )
    return 0;
  return v3;
}


// ========================================================================
// ?ShouldEnterDormancy@idAI2@@UAA_NXZ
// EA  : 0x82A03770
// RVA : 0x00A03770
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ShouldEnterDormancy(idAI2 *this)
{
  idPhysics *Physics; // r3
  char v4; // r11
  idAnimator_AF *v5; // r3
  char v6; // r11
  idAnimator_AF *v7; // r3
  idProp_Zipline *BindMaster; // r3
  alertCycle_t AlertCycle; // r30
  int GameMs; // r29

  if ( ai_enableDormancy.valueInteger == 0 )
    return false;
  Physics = idEntity::GetPhysics(this);
  if ( Physics->IsInNonResidentCollisionArea(this: Physics, a2: false) )
    return true;
  if ( idAI2::GetControllingPlayer(this) != nullptr )
    return false;
  if ( (unsigned __int16)this->aiVolatile.animation.animWebAnimator.ptr[0].curEdgeNodeIndex.value >= 0x8000u
    || (v4 = 1, (unsigned __int16)this->aiVolatile.animation.animWebAnimator.ptr[0].curEdgeIndex >= 0x8000u) )
  {
    v4 = 0;
  }
  if ( v4 != 0 )
    return false;
  v5 = this->GetAF_2(this);
  if ( v5->isActive || (v6 = 0, v5->isClientAuthoritativeActive) )
    v6 = 1;
  if ( v6 != 0 )
  {
    v7 = this->GetAF_2(this);
    if ( !v7->physicsObj.IsAtRest(this: &v7->physicsObj) )
      return false;
  }
  if ( idEntity::GetBindMaster(this) != nullptr )
  {
    BindMaster = (idProp_Zipline *)idEntity::GetBindMaster(this);
    if ( idProp_Zipline::CastTo(c: BindMaster) != nullptr )
      return false;
  }
  AlertCycle = idAI2::GetAlertCycle(this);
  if ( this->aiVolatile.fsms.previousAlertCycle != ALERTCYCLE_MAX )
  {
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    if ( GameMs
       - this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type)->lastTransitionTime < 250 )
      return false;
  }
  if ( AlertCycle != ALERTCYCLE_RELAXED
    || idAI2::IsExecutingScript(this)
    || this->aiVolatile.physics.moveState.movementMode == AIMOVEMODE_DROP )
  {
    return false;
  }
  return idEntity::ShouldEnterDormancy(this);
}


// ========================================================================
// ?DamageGroupPopOffArmor@idAI2@@QAAXPAVidDamageGroup@@VidVec3@@1MAA_N@Z
// EA  : 0x82A03960
// RVA : 0x00A03960
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DamageGroupPopOffArmor(
        idAI2 *this,
        __int64 impactPoint,
        __int64 outArmorPoppedOff,
        double damage,
        int a5,
        int a6,
        _BYTE *a7)
{
  int v11; // r28
  int v12; // r30
  const char *v13; // r29
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  int MeshIndex; // r29
  int v16; // ctr
  float *p_y; // r11
  char *v18; // r10
  idPhysics *Physics; // r3
  int *v20; // r3
  int v21; // r11
  int v22; // r10
  idGameLocal_vtbl *v23; // r9
  idProp_ElectricArmor *v24; // r26
  idProp_AIArmor *v25; // r23
  size_t len; // r30
  const idDeclMD6 *decl; // r11
  const tagData_t *Tag; // r3
  idTreeAnimator *v29; // r3
  double x; // fp27
  double y; // fp28
  double z; // fp29
  idClientGame *v33; // r8
  double v34; // fp6
  __int64 v35; // r6
  __int64 v36; // r10
  __int64 v37; // r8
  __int64 v38; // fp5
  double v39; // fp29
  double v40; // fp27
  double v41; // fp28
  idPhysics *v42; // r3
  idPhysics *v43; // r3
  idPhysics *v44; // r23
  int GameMs; // r18
  idPhysics *v46; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r17
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r23
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  const idVec3 *v50; // r3
  idProp_ElectricArmor *v51; // r26
  const char *v52; // r23
  idTreeAnimator *v53; // r3
  const tagData_t *v54; // r23
  idIndex<short,enum invalidJointIndex_t> *v55; // r3
  __int64 v56; // r10
  unsigned int v57; // r7
  double v58; // fp31
  int GameMsPerFrame; // r29
  int v60; // r30
  const idDeclParticle *v61; // r28
  idRenderModelEffects *MergeBranch; // r3
  const idVec3 *v63; // r7
  const idSoundShader *v64; // r5
  int v65; // [sp+8h] [-1E8h]
  int v66; // [sp+Ch] [-1E4h]
  int v67; // [sp+10h] [-1E0h]
  int v68; // [sp+14h] [-1DCh]
  int v69; // [sp+18h] [-1D8h]
  int v70; // [sp+1Ch] [-1D4h]
  int v71; // [sp+20h] [-1D0h]
  int v72; // [sp+24h] [-1CCh]
  int v73; // [sp+28h] [-1C8h]
  int v74; // [sp+2Ch] [-1C4h]
  int v75; // [sp+30h] [-1C0h]
  int v76; // [sp+34h] [-1BCh]
  int v77; // [sp+38h] [-1B8h]
  int v78; // [sp+3Ch] [-1B4h]
  int v79; // [sp+40h] [-1B0h]
  int v80; // [sp+44h] [-1ACh]
  int v81; // [sp+48h] [-1A8h]
  int v82; // [sp+4Ch] [-1A4h]
  int v83; // [sp+50h] [-1A0h]
  idAIEventManager v84; // [sp+60h] [-190h] BYREF
  float v85[4]; // [sp+B0h] [-140h] BYREF
  idVec3 v86; // [sp+C0h] [-130h] BYREF
  float v87[4]; // [sp+D0h] [-120h] BYREF
  float v88[4]; // [sp+E0h] [-110h] BYREF
  idStr v89; // [sp+F0h] [-100h] BYREF
  idMat3 v90[2]; // [sp+110h] [-E0h] BYREF
  float v93; // [sp+228h] [+38h]

  v93 = *((float *)&outArmorPoppedOff + 1);
  if ( HIDWORD(impactPoint) == 0 )
    return;
  v11 = 0;
  if ( *(int *)(HIDWORD(impactPoint) + 60) > 0 )
  {
    v12 = 0;
    do
    {
      v13 = *(const char **)(v12 + *(_DWORD *)(HIDWORD(impactPoint) + 56) + 4);
      TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      MeshIndex = idTreeAnimator::GetMeshIndex(this: TreeAnimatorFromPresentable, meshName: v13);
      if ( MeshIndex < 0 )
        idLib::Warning(
          fmt: "%s: damage group '%s', unknown hideMesh[%d] = '%s'",
          this->name.data,
          *(const char **)(HIDWORD(impactPoint) + 4),
          v11,
          *(const char **)(v12 + *(_DWORD *)(HIDWORD(impactPoint) + 56) + 4));
      else
        idAnimatedEntity::GetTreeAnimatorFromPresentable(this)->meshVisibility.list[MeshIndex] = false;
      ++v11;
      v12 += 32;
    }
    while ( v11 < *(_DWORD *)(HIDWORD(impactPoint) + 60) );
  }
  v16 = 9;
  p_y = &mat2_identity.mat[1].y;
  *(float *)&v84.receivers.list = 0.0;
  *(float *)&v84.receivers.num = 0.0;
  v84.eventPools.granularity = -1;
  *(float *)&v84.receivers.size = 0.0;
  *(_QWORD *)&v84.eventList.size = impactPoint;
  *(float *)&v84.receivers.granularity = 0.0;
  v84.eventHash.hash = (int *)impactPoint;
  *(float *)&v84.eventPools.list = 0.0;
  v18 = &v89.baseBuffer[16];
  *(float *)&v84.eventPools.num = 0.0;
  *(float *)&v84.eventPools.size = 0.0;
  do
  {
    ++p_y;
    v18 += 4;
    *(float *)v18 = *p_y;
    --v16;
  }
  while ( v16 != 0 );
  Physics = idEntity::GetPhysics(this);
  v20 = (int *)Physics->GetGravityNormal(this: Physics);
  v21 = v20[1];
  v22 = v20[2];
  v23 = gameLocal->__vftable;
  v84.eventHash.hashSize = *v20;
  v84.eventHash.indexSize = v21;
  v84.eventHash.granularity = v22;
  v24 = (idProp_ElectricArmor *)((int (*)(void))v23->SpawnEntityFromDef)();
  v25 = idProp_AIArmor::CastTo(c: v24);
  idStr::idStr(this: &v89, text: (const idStr *)(HIDWORD(impactPoint) + 80));
  if ( v25 != nullptr )
  {
    len = v25->tagName.len;
    if ( len != 0 )
    {
      v84.eventList.list = (idAIEvent **)v25->tagName.len;
      idStr::EnsureAlloced(this: &v89, amount: len + 1, keepold: false, geometricGrowth: false);
      memcpy(Dst: v89.data, Src: v25->tagName.data, Size: len);
      v89.data[len] = 0;
      v89.len = len;
    }
  }
  if ( idAnimatedEntity::GetTreeAnimatorFromPresentable(this) == nullptr )
    goto LABEL_21;
  decl = idAnimatedEntity::GetTreeAnimatorFromPresentable(this)->decl;
  if ( decl == nullptr || decl == (const idDeclMD6 *)-352 || v89.len == 0 )
    goto LABEL_21;
  Tag = idPropsCollection::GetTag(this: &decl->props, propName: idPropInfo::INFO_PROP_NAME, tagName: v89.data);
  *(float *)&v84.receivers.list = Tag->trans.x;
  *(float *)&v84.receivers.num = Tag->trans.y;
  v84.eventList.list = (idAIEvent **)&Tag->rot;
  *(float *)&v84.receivers.size = Tag->trans.z;
  *(idQuat *)&v84.receivers.granularity = Tag->rot;
  v84.eventPools.granularity = Tag->parentJoint.value;
  if ( (unsigned __int16)v84.eventPools.granularity == 0xFFFF )
  {
    idLib::Warning(fmt: "idAI2::DamageGroupPopOffArmor %s tag name %s is not valid", this->name.data, v89.data);
    goto LABEL_21;
  }
  v29 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
  if ( (unsigned __int8)idTreeAnimator::GetWorldSpaceTagTransform(
                          this: v29,
                          tagData: (const tagData_t *)&v84.receivers,
                          origin: &v86,
                          axis: v90) == 0 )
  {
LABEL_21:
    x = *(float *)&v84.eventHash.hashSize;
    y = *(float *)&v84.eventHash.indexSize;
    z = *(float *)&v84.eventHash.granularity;
    goto LABEL_22;
  }
  x = v90[0].mat[0].x;
  y = v90[0].mat[0].y;
  z = v90[0].mat[0].z;
  *(float *)&v84.eventList.size = v86.x;
  *(float *)&v84.eventList.granularity = v86.y;
  *(float *)&v84.eventHash.hash = v86.z;
LABEL_22:
  if ( v25 != nullptr )
  {
    *a7 = 1;
    idEntity::SetOrigin(this: v24, org: (const idVec3 *)&v84.eventList.size);
    v24->SetAxis(this: v24, a2: v90);
    if ( ai_debugHealth.valueInteger >= 2 )
    {
      clientGame->renderWorld->DebugPoint(
        this: clientGame->renderWorld,
        a2: (const idVec4 *)&idColor::colorOrange,
        a3: (const idVec3 *)&v84.eventList.size,
        a4: 3000,
        a5: true);
      v85[1] = *(float *)&v84.eventList.granularity + (float)((float)((float)y * (float)damage) * (float)100.0);
      v85[0] = (float)((float)((float)x * (float)damage) * (float)100.0) + *(float *)&v84.eventList.size;
      v85[2] = *(float *)&v84.eventHash.hash + (float)((float)((float)z * (float)damage) * (float)100.0);
      ((void (__fastcall *)(idRenderWorld *, idColor *, int *, float *, double))clientGame->renderWorld->DebugArrow)(
        a1: clientGame->renderWorld,
        a2: &idColor::colorRed,
        a3: &v84.eventList.size,
        a4: v85,
        a5: 2.0);
    }
    v33 = clientGame;
    v34 = __fsqrts(damage);
    HIDWORD(v35) = clientGame->random.seed;
    clientGame->random.seed = 1664525 * clientGame->random.seed + 1013904223;
    HIDWORD(v36) = v33->random.seed;
    LODWORD(v35) = (v33->random.seed >> 10) & 0x7FFF;
    HIDWORD(v37) = clientGame->random.seed;
    *(_QWORD *)&v84.eventList.list = v35;
    clientGame->random.seed = 1664525 * HIDWORD(v37) + 1013904223;
    LODWORD(v37) = ((unsigned int)(1664525 * HIDWORD(v37) + 1013904223) >> 10) & 0x7FFF;
    v38 = *(_QWORD *)&v84.eventList.list;
    *(_QWORD *)&v84.eventList.list = v37;
    LODWORD(v35) = 1664525 * clientGame->random.seed;
    clientGame->random.seed = v35 + 1013904223;
    LODWORD(v36) = ((unsigned int)(v35 + 1013904223) >> 10) & 0x7FFF;
    *(_QWORD *)&v84.eventList.list = v36;
    v87[2] = (float)((float)((float)((float)((float)((float)((float)v38 * (float)0.000061037019) - (float)1.0)
                                           * (float)0.0)
                                   + (float)((float)z * (float)0.75))
                           + (float)(v93 * (float)0.25))
                   * (float)120.0)
           * (float)v34;
    v39 = (float)((float)((float)v38 * (float)0.000061037019) - (float)1.0);
    v87[0] = (float)((float)((float)((float)((float)((float)((float)v36 * (float)0.000061037019) - (float)1.0)
                                           * (float)0.0)
                                   + (float)((float)x * (float)0.75))
                           + (float)(*(float *)&outArmorPoppedOff * (float)0.25))
                   * (float)120.0)
           * (float)v34;
    v40 = (float)((float)((float)v36 * (float)0.000061037019) - (float)1.0);
    v87[1] = (float)((float)((float)((float)((float)((float)((float)v37 * (float)0.000061037019) - (float)1.0)
                                           * (float)0.0)
                                   + (float)((float)y * (float)0.75))
                           + (float)(*((float *)&outArmorPoppedOff + 1) * (float)0.25))
                   * (float)120.0)
           * (float)v34;
    v41 = (float)((float)((float)v37 * (float)0.000061037019) - (float)1.0);
    v42 = idEntity::GetPhysics(this: v24);
    v42->SetLinearVelocity(this: v42, a2: (const idVec3 *)v87, a3: 0);
    v43 = idEntity::GetPhysics(this: v24);
    v88[2] = (float)v39 * (float)100.0;
    v88[1] = (float)v41 * (float)100.0;
    v88[0] = (float)v40 * (float)100.0;
    v43->SetAngularVelocity(this: v43, a2: (const idVec3 *)v88, a3: 0);
    if ( idStr::Cmp(s1: *(const char **)(HIDWORD(impactPoint) + 4), s2: "head") == 0
      && this->aiEditable.behaviors.declBehaviorEvents != nullptr )
    {
      v44 = idEntity::GetPhysics(this);
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      v46 = v44;
      declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
      GetOrigin = v44->GetOrigin;
      p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
      v50 = GetOrigin(this: v46, a2: 0);
      idAIEventManager::AddEvent(
        this: &v84,
        result: p_aiEventManager,
        eventDecl: declBehaviorEvents->crapVOEventDecl,
        curTime: GameMs,
        originator: nullptr,
        instigator: this,
        origin: v50,
        delay: 400);
    }
    if ( (unsigned __int8)idProp_ElectricArmor::IsTypeOf(c: v24) != 0 )
    {
      v51 = idProp_ElectricArmor::CastTo(c: v24);
      v52 = *(const char **)(HIDWORD(impactPoint) + 84);
      v53 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      v54 = idPropsCollection::GetTag(this: &v53->decl->props, propName: idPropInfo::INFO_PROP_NAME, tagName: v52);
      if ( this != nullptr )
      {
        v84.eventList.list = (idAIEvent **)this->entityNumber;
        v51->owner.spawnId.value = (*((_DWORD *)&gameLocal->__vftable + (int)v84.eventList.list + 29755) << 13)
                                 | (int)v84.eventList.list;
      }
      else
      {
        v51->owner.spawnId.value = 0x1FFF;
      }
      v55 = (idIndex<short,enum invalidJointIndex_t> *)idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      v51->OwnerJoint.value = HIWORD(idTreeAnimator::GetJointIndex(
                                       this: (idTreeAnimator *)&v84,
                                       result: v55,
                                       jointHandle: &v54->parentJoint)->__vftable);
      idProp_ElectricArmor::SetUpElectricShock(this: v51);
    }
  }
  if ( *(_DWORD *)(HIDWORD(impactPoint) + 48) != 0 )
  {
    HIDWORD(v56) = &unk_82270000;
    v84.eventList.list = (idAIEvent **)-1;
    v57 = 1664525 * clientGame->random.seed;
    clientGame->random.seed = v57 + 1013904223;
    LODWORD(v56) = ((v57 + 1013904223) >> 10) & 0x7FFF;
    *(_QWORD *)&v84.eventHash.hashSize = v56;
    v58 = (float)((float)v56 * (float)0.000030518509);
    GameMsPerFrame = idGameTimeManager::GetGameMsPerFrame(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    v60 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    v61 = *(const idDeclParticle **)(HIDWORD(impactPoint) + 48);
    MergeBranch = (idRenderModelEffects *)idAnimator_BlendEq::InternalGetMergeBranch(this: (idAnimator_BlendEq *)clientGame);
    idRenderModelEffects::AddParticles(
      this: MergeBranch,
      particle: v61,
      systemStartTime: v60,
      gameMsPerFrame: GameMsPerFrame,
      diversity: v58,
      origin: v63,
      axis: (const idMat3 *)&v84.eventList.size,
      velocity: v90[0].mat,
      color: &vec3_origin.x,
      a10: v65,
      a11: v66,
      a12: v67,
      a13: v68,
      a14: v69,
      a15: v70,
      a16: v71,
      a17: v72,
      a18: v73,
      a19: v74,
      a20: v75,
      a21: v76,
      a22: v77,
      a23: v78,
      a24: v79,
      a25: v80,
      a26: v81,
      a27: v82,
      a28: v83,
      a29: (unsigned int *)&v84);
    *a7 = 1;
  }
  v64 = *(const idSoundShader **)(HIDWORD(impactPoint) + 52);
  if ( v64 != nullptr )
    idEntity::StartSoundShader(this, channel: SND_CHANNEL_BODY, shader: v64, soundShaderFlags: 0, peerMask: 0xFFu);
  idStr::FreeData(this: &v89);
}


// ========================================================================
// __unwind$540734
// EA  : 0x82A04118
// RVA : 0x00A04118
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_540734()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 496 + 240));
}


// ========================================================================
// ?KilledNotification@idAI2@@UAAXPBVidEntity@@0PBVidDeclDamage@@M@Z
// EA  : 0x82A04140
// RVA : 0x00A04140
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::KilledNotification(
        idAI2 *this,
        const idEntity *victim,
        const idEntity *inflictor,
        const idDeclDamage *damageDecl,
        double damage)
{
  idFaction *v7; // r3
  idPhysics *Physics; // r26
  int GameMs; // r25
  idPhysics *v10; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r24
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r26
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  const idVec3 *v14; // r3
  idEntityPtr<idEntity const > *p_actionEntity; // r9
  unsigned int v16; // r4
  int value; // r8
  idEntity *v18; // r3
  idEntity *v19; // r3
  int v20; // r3
  idAIEventManager v21; // [sp+50h] [-50h] BYREF

  if ( victim != nullptr )
  {
    v7 = this->GetFaction(this);
    if ( idFaction::GetAttitudeTowards(this: v7, otherEnt: victim) < ATTITUDE_NEUTRAL
      && this->aiEditable.behaviors.declBehaviorEvents != nullptr )
    {
      Physics = idEntity::GetPhysics(this);
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      v10 = Physics;
      declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
      GetOrigin = Physics->GetOrigin;
      p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
      v14 = GetOrigin(this: v10, a2: 0);
      idAIEventManager::AddEvent(
        this: &v21,
        result: p_aiEventManager,
        eventDecl: declBehaviorEvents->enemyKilledVOEventDecl,
        curTime: GameMs,
        originator: nullptr,
        instigator: this,
        origin: v14,
        delay: 1000);
    }
  }
  p_actionEntity = &this->aiVolatile.memory.actionEntity;
  if ( victim != nullptr )
    p_actionEntity->spawnId.value = (gameLocal->spawnIds.ptr[victim->entityNumber] << 13) | victim->entityNumber;
  else
    p_actionEntity->spawnId.value = 0x1FFF;
  v16 = 1664525 * clientGame->random.seed + 1013904223;
  clientGame->random.seed = v16;
  if ( (signed int)(((v16 >> 10) & 0x7FFF) % 0x64) < this->aiEditable.behaviors.decl->rageBehaviors.tauntRageAfterKillingEnemyChance )
  {
    value = this->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v18 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v19 = idEntity::CastTo(c: v18);
    }
    else
    {
      v19 = nullptr;
    }
    if ( victim == v19 )
    {
      v20 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idAIMemory::SetWantTauntRageTime(this: &this->aiVolatile.memory, t: v20, debugReason: "killed enemy");
    }
  }
  if ( (unsigned __int8)idPlayer::IsTypeOf(c: &victim->idEventReceiver) != 0 )
    *((_BYTE *)&this->aiVolatile + 49704) |= 0x40u;
}


// ========================================================================
// ?IsFacingMeMoreThanAnyoneElse@idAI2@@QBA_NPBVidEntity@@M@Z
// EA  : 0x82A04350
// RVA : 0x00A04350
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::IsFacingMeMoreThanAnyoneElse(idAI2 *this, idPlayer *entity, double dotThreshold)
{
  idPlayer *v6; // r30
  idAI2 *v7; // r29
  idPresentable *presentable; // r3
  int p_firstPersonViewAxis; // r11
  idAIOrientation *BodyOrientation; // r3
  idRenderModel *RenderModelFromPresentable; // r3
  idEncounterGroup *v13; // r3
  idAI2 *v14; // r26
  int v15; // r28
  double v16; // fp28
  int v17; // r29
  idAI2 *v18; // r30
  idPhysics *Physics; // r23
  idPhysics *v20; // r22
  float *v21; // r23
  float *v22; // r3
  double v23; // fp8
  double v24; // fp4
  double v27; // fp5
  double v28; // fp5
  double v29; // fp11
  double v30; // fp9
  double v31; // fp8
  double v32; // fp0
  BOOL v33; // r30
  idVec3 v34; // [sp+50h] [-1A0h] BYREF
  idStaticList<idAI2 *,64> v35; // [sp+60h] [-190h] BYREF

  v6 = idPlayer::CastTo(c: entity);
  v7 = idAI2::CastTo(c: (idAI2 *)entity);
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
    || idEncounterGroupManager::GroupForHandle(
         this: &gameLocal->encounterGroupManager,
         handle: &this->aiVolatile.encounterGroupHandle) == nullptr )
  {
    return 1;
  }
  v34.x = 1.0;
  v34.y = 0.0;
  v34.z = 0.0;
  if ( v6 != nullptr )
  {
    presentable = v6->presentable;
    if ( presentable != nullptr )
      p_firstPersonViewAxis = (int)&presentable->GetPlayerInterface_2(this: presentable)->firstPersonViewAxis;
    else
      p_firstPersonViewAxis = 46544;
LABEL_13:
    v34 = *(idVec3 *)p_firstPersonViewAxis;
    goto LABEL_14;
  }
  if ( v7 != nullptr )
  {
    BodyOrientation = idAI2::GetBodyOrientation(this: v7);
    idRotationTracker::GetWorldSpaceDir(
      this: &v7->aiVolatile.focus.foci.ptr[0].aimTracker,
      refAxis: &BodyOrientation->axis,
      wsDir: &v34);
  }
  else if ( idEntity::GetRenderModelFromPresentable(this: entity) != nullptr )
  {
    RenderModelFromPresentable = idEntity::GetRenderModelFromPresentable(this: entity);
    p_firstPersonViewAxis = (int)&RenderModelFromPresentable->deferredAxis;
    if ( !RenderModelFromPresentable->useDeferredPosition )
      p_firstPersonViewAxis = (int)&RenderModelFromPresentable->g.axis;
    goto LABEL_13;
  }
LABEL_14:
  v35.granularity = 1;
  v35.size = 64;
  v35.list = v35.staticList;
  v35.num = 0;
  v35.memTag = 5;
  v35.listStatic = 1;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
    v13 = nullptr;
  else
    v13 = idEncounterGroupManager::GroupForHandle(
            this: &gameLocal->encounterGroupManager,
            handle: &this->aiVolatile.encounterGroupHandle);
  idEncounterGroup::GetLivingMembers(this: v13, list: &v35);
  v14 = nullptr;
  v15 = 0;
  v16 = -2.0;
  if ( v35.num > 0 )
  {
    v17 = 0;
    do
    {
      v18 = v35.list[v17];
      Physics = idEntity::GetPhysics(this: entity);
      v20 = idEntity::GetPhysics(this: v18);
      v21 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
      v22 = (float *)v20->GetOrigin(this: v20, a2: 0);
      v23 = (float)(v22[1] - v21[1]);
      v24 = (float)(v22[2] - v21[2]);
      _FP11 = (float)((float)((float)((float)v24 * (float)v24)
                            + (float)((float)((float)(*v22 - *v21) * (float)(*v22 - *v21))
                                    + (float)((float)v23 * (float)v23)))
                    - idMath::FLT_SMALLEST_NON_DENORMAL);
      __asm { fsel      f7, f11, f12, f0 }
      v27 = __frsqrte(_FP7);
      v28 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v27
                                                                                          * (float)((float)((float)((float)v24 * (float)v24) + (float)((float)((float)(*v22 - *v21) * (float)(*v22 - *v21)) + (float)((float)v23 * (float)v23)))
                                                                                                  * (float)0.5))
                                                                                  * (float)v27)
                                                                          - (float)1.5)
                                                          * (float)v27)
                                                  * (float)((float)((float)((float)v24 * (float)v24)
                                                                  + (float)((float)((float)(*v22 - *v21)
                                                                                  * (float)(*v22 - *v21))
                                                                          + (float)((float)v23 * (float)v23)))
                                                          * (float)0.5))
                                          * (float)((float)-(float)((float)((float)((float)v27
                                                                                  * (float)((float)((float)((float)v24 * (float)v24)
                                                                                                  + (float)((float)((float)(*v22 - *v21) * (float)(*v22 - *v21)) + (float)((float)v23 * (float)v23)))
                                                                                          * (float)0.5))
                                                                          * (float)v27)
                                                                  - (float)1.5)
                                                  * (float)v27))
                                  - (float)1.5)
                  * (float)((float)-(float)((float)((float)((float)v27
                                                          * (float)((float)((float)((float)v24 * (float)v24)
                                                                          + (float)((float)((float)(*v22 - *v21)
                                                                                          * (float)(*v22 - *v21))
                                                                                  + (float)((float)v23 * (float)v23)))
                                                                  * (float)0.5))
                                                  * (float)v27)
                                          - (float)1.5)
                          * (float)v27));
      v29 = (float)((float)((float)-(float)((float)((float)((float)v28
                                                          * (float)((float)((float)((float)v24 * (float)v24)
                                                                          + (float)((float)((float)(*v22 - *v21)
                                                                                          * (float)(*v22 - *v21))
                                                                                  + (float)((float)v23 * (float)v23)))
                                                                  * (float)0.5))
                                                  * (float)v28)
                                          - (float)1.5)
                          * (float)v28)
                  * (float)v23);
      v30 = (float)((float)((float)-(float)((float)((float)((float)v28
                                                          * (float)((float)((float)((float)v24 * (float)v24)
                                                                          + (float)((float)((float)(*v22 - *v21)
                                                                                          * (float)(*v22 - *v21))
                                                                                  + (float)((float)v23 * (float)v23)))
                                                                  * (float)0.5))
                                                  * (float)v28)
                                          - (float)1.5)
                          * (float)v28)
                  * (float)(*v22 - *v21));
      v31 = (float)((float)((float)((float)-(float)((float)((float)((float)v28
                                                                  * (float)((float)((float)((float)v24 * (float)v24)
                                                                                  + (float)((float)((float)(*v22 - *v21)
                                                                                                  * (float)(*v22 - *v21))
                                                                                          + (float)((float)v23
                                                                                                  * (float)v23)))
                                                                          * (float)0.5))
                                                          * (float)v28)
                                                  - (float)1.5)
                                  * (float)v28)
                          * (float)v24)
                  * v34.z);
      v32 = (float)((float)((float)v30 * v34.x) + (float)((float)((float)v29 * v34.y) + (float)v31));
      if ( v32 > dotThreshold && v32 > v16 )
      {
        v16 = (float)((float)((float)v30 * v34.x) + (float)((float)((float)v29 * v34.y) + (float)v31));
        v14 = v18;
      }
      ++v15;
      ++v17;
    }
    while ( v15 < v35.num );
  }
  v33 = (_cntlzw((char *)this - (char *)v14) & 0x20) != 0;
  if ( (v35.listStatic == 0 || v35.listStatic == 2) && v35.list != nullptr )
    idMem::Free(this: &mem, ptr: v35.list, align: ALIGN_16);
  return v33;
}


// ========================================================================
// __unwind$541477
// EA  : 0x82A0467C
// RVA : 0x00A0467C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_541477()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 496 + 96));
}


// ========================================================================
// ?RelinquishControl@idAI2@@QAA_NXZ
// EA  : 0x82A046A8
// RVA : 0x00A046A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::RelinquishControl(idAI2 *this)
{
  idEntityPtr<idPlayer> *p_player; // r26
  int value; // r9
  idPlayer *v5; // r3
  idPlayer *ControllingPlayer; // r3
  idPlayer *v7; // r30
  idPresentable *presentable; // r3
  int v9; // r3
  idEntity *deathCamera; // r24
  idPresentable *v11; // r3
  int v12; // r3
  idPresentable *v13; // r3
  int v14; // r3
  idPlayer *v15; // r3
  idPlayer *v16; // r3
  idPresentable *v17; // r3
  int v18; // r3
  int entityNumber; // r5
  float v20[36]; // [sp+60h] [-90h] BYREF

  if ( !idAI2::IsPlayerControlled(this) )
    return 0;
  p_player = &this->aiVolatile.playerControl.player;
  value = this->aiVolatile.playerControl.player.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13 )
    return 0;
  v5 = (idPlayer *)gameLocal->entities.ptr[value & 0x1FFF];
  if ( v5 == nullptr || idPlayer::CastTo(c: v5) == nullptr )
    return 0;
  ControllingPlayer = idAI2::GetControllingPlayer(this);
  v7 = ControllingPlayer;
  if ( ControllingPlayer != nullptr )
  {
    idEntity::StopSound(this: ControllingPlayer, channel: SND_CHANNEL_VOICE, peerMask: 0xFFu);
    v7->isControllingAi = false;
  }
  idAIEventManager::RemoveEvent(
    this: &gameLocal->aiEventManager,
    handle: &this->aiVolatile.playerControl.possessionEvent);
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
  {
    idAnimBaseFSM::ClearDestination(this: &this->aiVolatile.animation.animFSM);
  }
  else
  {
    idAIMoveState::SetMovementModeForReal(this: &this->aiVolatile.physics.moveState, mode: AIMOVEMODE_GROUND);
    idAIMoveState::Stop(this: &this->aiVolatile.physics.moveState, newStatus: AIMOVESTATUS_DONE);
  }
  if ( v7 != nullptr )
  {
    idPlayer::RemoveControl(this: v7, entity: this);
    idPlayer::SetViewAngles(this: v7, angles: &this->aiVolatile.playerControl.viewAngle, force: true);
    presentable = v7->presentable;
    v9 = presentable != nullptr ? (int)presentable->GetPlayerInterface_2(this: presentable) : 0;
    *(_BYTE *)(v9 + 19040) = 0;
    deathCamera = v7->deathCamera;
    *(_DWORD *)&deathCamera[1].name.baseBuffer[8] = (gameLocal->spawnIds.ptr[this->entityNumber] << 13)
                                                  | this->entityNumber;
    ((void (__fastcall *)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))deathCamera->__vftable[1].PostSpawn)(
      a1: *(_DWORD *)LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[0].x),
      a2: *(_DWORD *)(LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[0].x) + 4),
      a3: __ROL4__(*(_DWORD *)(LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[0].x) + 8), 32),
      a4: LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[0].z),
      a5: LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[1].y),
      a6: LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[2].x),
      a7: LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[2].y),
      a8: __ROL4__(LODWORD(this->aiVolatile.playerControl.camera.camAxis.mat[2].z), 32));
    idPlayer::AddControl(this: v7, entity: deathCamera);
    v11 = v7->presentable;
    v12 = v11 != nullptr ? (int)v11->GetPlayerInterface_2(this: v11) : 0;
    if ( v12 != -37616 )
    {
      v13 = v7->presentable;
      if ( v13 != nullptr )
        v14 = (int)v13->GetPlayerInterface_2(this: v13);
      else
        v14 = 0;
      idHands::Hide(this: (idHands *)(v14 + 37616), hideReason: HAND_HIDE_VEHICLE);
      v7->Show(this: v7);
    }
  }
  _jxr_rbitstream_syncbyte(pLeafNode: (bfx::DynKDNode *)&this->aiVolatile.playerControl);
  if ( gameLocal->spawnIds.ptr[p_player->spawnId.value & 0x1FFF] == p_player->spawnId.value >> 13
    && (v15 = (idPlayer *)gameLocal->entities.ptr[p_player->spawnId.value & 0x1FFF]) != nullptr )
  {
    v16 = idPlayer::CastTo(c: v15);
  }
  else
  {
    v16 = nullptr;
  }
  v17 = v16->presentable;
  if ( v17 != nullptr )
    v18 = (int)v17->GetPlayerInterface_2(this: v17);
  else
    v18 = 0;
  idHands::Show(this: (idHands *)(v18 + 37616), hideReason: HAND_HIDE_GENERIC);
  p_player->spawnId.value = 0x1FFF;
  if ( v7 != nullptr )
  {
    entityNumber = v7->entityNumber;
    v20[12] = 0.0;
    v20[11] = 5000.0;
    LODWORD(v20[7]) = 20;
    v20[14] = 0.0;
    LODWORD(v20[3]) = 100;
    v20[13] = 0.0;
    LODWORD(v20[4]) = 200;
    v20[0] = 0.0;
    LODWORD(v20[8]) = 40;
    v20[6] = -60.0;
    v20[1] = -60.0;
    v20[2] = 0.0;
    v20[5] = -60.0;
    v20[10] = 1.0;
    v20[9] = 1.0;
    clientGame->soundWorld->OverrideEnvironmentParams(
      this: clientGame->soundWorld,
      a2: (const soundEnvironment_t *)v20,
      a3: entityNumber);
  }
  return 1;
}


// ========================================================================
// ?Takedown@idAI2@@QAAXPAVidEntity@@_N1W4takedownMode_t@@@Z
// EA  : 0x82A04A20
// RVA : 0x00A04A20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Takedown(idAI2 *this, idPlayer *activator, bool dualWield, bool reversedGrip, int takeDownMode)
{
  idPlayer *v9; // r25
  deathFlags_t deathFlags; // r11
  idPhysics *Physics; // r3
  int v12; // r3
  float v13; // r6
  float v14; // r5
  int *v15; // r10
  __int16 *p_granularity; // r11
  int i; // ctr
  takedownTypes_t *p_counterDWREV; // r4
  idPhysics_Player *v19; // r3
  idPhysics_Player *PhysicsObj; // r3
  double x; // fp0
  double y; // fp13
  double z; // fp12
  double v24; // fp11
  idEventArg *v25; // r20
  int v26; // r27
  const idAnimStack *v27; // r3
  idPhysics *v28; // r3
  const idVec3 *v29; // r30
  idPresentable *presentable; // r3
  idPresentablePlayer *v31; // r3
  idPresentable *v32; // r3
  int v33; // r3
  const idEventArg *v34; // [sp+8h] [-2F8h]
  const idEventArg *v35; // [sp+Ch] [-2F4h]
  _BYTE v36[20]; // [sp+70h] [-290h] BYREF
  _BYTE v37[20]; // [sp+90h] [-270h] BYREF
  _BYTE v38[20]; // [sp+B0h] [-250h] BYREF
  _BYTE v39[20]; // [sp+D0h] [-230h] BYREF
  _BYTE v40[20]; // [sp+F0h] [-210h] BYREF
  idVec3 v41; // [sp+110h] [-1F0h] BYREF
  idFSMManager::idFSMStack v42; // [sp+120h] [-1E0h] BYREF
  idMat3 v43; // [sp+140h] [-1C0h] BYREF
  idStr v44; // [sp+170h] [-190h] BYREF
  deathFlags_t *p_deathFlags; // [sp+190h] [-170h]
  int v46; // [sp+1A0h] [-160h]
  float v47; // [sp+1A4h] [-15Ch]
  float v48; // [sp+1A8h] [-158h]
  float v49; // [sp+1ACh] [-154h]
  int v50; // [sp+1BCh] [-144h] BYREF
  idMat3 v51; // [sp+1C0h] [-140h] BYREF
  _DWORD v52[5]; // [sp+1F0h] [-110h] BYREF
  _DWORD v53[5]; // [sp+210h] [-F0h] BYREF
  _DWORD v54[5]; // [sp+230h] [-D0h] BYREF
  _DWORD v55[5]; // [sp+250h] [-B0h] BYREF
  idMat3 v56[4]; // [sp+270h] [-90h] BYREF

  v9 = idPlayer::CastTo(c: activator);
  if ( v9 != nullptr )
  {
    if ( takeDownMode == 3 )
    {
      vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v42);
      idFSMManager::idFSMStack::Add(
        this: &v42,
        fsmType: &idAlertCycleFSM::Type,
        stateType: &idAlertCycle_CombatScenePoint::Type);
      idFSMManager::idFSMStack::Add(
        this: &v42,
        fsmType: &idCombatScenePointFSM::Type,
        stateType: &idCombatScenePoint_SharedWaitForAnimation::Type);
      idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v42);
    }
    else
    {
      deathFlags = this->aiVolatile.death.deathInfo.deathFlags;
      p_deathFlags = &this->aiVolatile.death.deathInfo.deathFlags;
      this->aiVolatile.death.deathInfo.deathFlags = deathFlags | 0x18;
      vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v42);
      idFSMManager::idFSMStack::Add(this: &v42, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Dying::Type);
      idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v42);
      idAI2::SetSolid(this, isSolid: false);
    }
    idPLog::~idPLog(this: &v42);
    idMat3::ToQuat(this: v56, result: (idQuat *)&v9->actorVolatile);
    Physics = idEntity::GetPhysics(this);
    v12 = (int)Physics->GetOrigin(this: Physics, a2: 0);
    v13 = *(float *)(v12 + 4);
    v14 = *(float *)(v12 + 8);
    v41.x = *(float *)v12;
    v41.y = v13;
    v41.z = v14;
    idStr::idStr(this: &v44, text: &byte_8200D768);
    if ( takedownType.valueInteger != -1 )
      takeDownMode = takedownType.valueInteger + 1;
    v15 = &v50;
    p_granularity = &v9->takedownTypes.AITakedowns.granularity;
    for ( i = 9; i != 0; --i )
    {
      p_granularity += 2;
      *++v15 = *(_DWORD *)p_granularity;
    }
    if ( takeDownMode == 1 )
    {
      PhysicsObj = idPlayer::GetPhysicsObj(this: v9);
      v41.z = PhysicsObj->GetOrigin(this: PhysicsObj, a2: 0)->z;
      idMat3::RotateSelf(this: &v51, axis: &v51.mat[2], angle: 3.1415927);
      if ( dualWield )
      {
        p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.counterDWREV;
        if ( !reversedGrip )
          p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.counterDWFWD;
      }
      else
      {
        p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.counterSWREV;
        if ( !reversedGrip )
          p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.counterSWFWD;
      }
    }
    else if ( takeDownMode == 2 )
    {
      v19 = idPlayer::GetPhysicsObj(this: v9);
      v41.z = v19->GetOrigin(this: v19, a2: 0)->z;
      if ( dualWield )
      {
        p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.stealthDWREV;
        if ( !reversedGrip )
          p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.stealthDWFWD;
      }
      else
      {
        p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.stealthSWREV;
        if ( !reversedGrip )
          p_counterDWREV = &this->takedownTypes;
      }
    }
    else
    {
      idMat3::RotateSelf(this: &v51, axis: &v51.mat[2], angle: 3.1415927);
      p_counterDWREV = (takedownTypes_t *)&this->takedownTypes.AITakedowns;
    }
    idAI2::GetTakedownName(this, tdList: &p_counterDWREV->stealthSWFWD, takedownName: &v44);
    idMat3::ToQuat(this: &v43, result: (idQuat *)&v51);
    x = v43.mat[0].x;
    y = v43.mat[0].y;
    z = v43.mat[0].z;
    v24 = v43.mat[1].x;
    HIBYTE(v52[0]) = 105;
    HIBYTE(v55[0]) = 105;
    this->scriptProxy.blocking = false;
    v43.mat[1].z = x;
    v43.mat[2].x = y;
    v52[1] = 0;
    v43.mat[2].y = z;
    v55[1] = 1;
    v43.mat[2].z = v24;
    HIBYTE(v53[0]) = 115;
    v47 = v41.x;
    HIBYTE(v54[0]) = 115;
    v48 = v41.y;
    v54[1] = "takedowns";
    v49 = v41.z;
    HIBYTE(v43.mat[1].y) = 113;
    HIBYTE(v46) = 118;
    v53[1] = v44.data;
    v25 = idEventArg::idEventArg(this: (idEventArg *)&v56[0].mat[1].y, data: this);
    memcpy(Dst: v40, Src: v52, Size: sizeof(v40));
    memcpy(Dst: v39, Src: v55, Size: sizeof(v39));
    memcpy(Dst: v38, Src: v53, Size: sizeof(v38));
    memcpy(Dst: v37, Src: v54, Size: sizeof(v37));
    memcpy(Dst: v36, Src: &v43.mat[1].y, Size: sizeof(v36));
    idEventReceiver::ProcessEvent(
      this: (idEventReceiver *)&v42,
      result: (idEventArg *)&this->scriptProxy,
      ev: *(const idEventDef **)&v25->type,
      arg1: (const idEventArg *)LODWORD(v25->value.v[1]),
      arg2: (const idEventArg *)LODWORD(v25->value.v[2]),
      arg3: (const idEventArg *)__ROL4__(v46, 32),
      arg4: (const idEventArg *)LODWORD(v48),
      arg5: (const idEventArg *)LODWORD(v49),
      arg6: v34,
      arg7: v35);
    if ( takeDownMode != 3 )
    {
      this->aiHealth.Kill_Impl(this: &this->aiHealth, a2: 0.0);
      this->aiHealth.SetDeadFlag(this: &this->aiHealth);
      idAnimator_WalkIK::DisableAll(this: &this->walkIK);
      v26 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
      v27 = this->GetAnimStack_2(this);
      idAnimator_Base::End(this: &this->walkIK, stack: v27, curTime: v26, blendDurationMS: 200, reset: false);
    }
    v28 = idEntity::GetPhysics(this: v9);
    v29 = v28->GetOrigin(this: v28, a2: 0);
    presentable = v9->presentable;
    if ( presentable != nullptr )
      v31 = presentable->GetPlayerInterface_2(this: presentable);
    else
      v31 = nullptr;
    idPresentablePlayer::StartPerfectOrigin(this: v31, idealAxis: (const idQuat *)v56, idealPos: v29, lerpTimeMs: 100);
    v32 = v9->presentable;
    if ( v32 != nullptr )
      v33 = (int)v32->GetPlayerInterface_2(this: v32);
    else
      v33 = 0;
    idHands::SetPendingAction(this: (idHands *)(v33 + 37616), action: HANDSACTION_TAKEDOWN, secondary: false);
    idPlayer::PlayerBehavior_Takedown_StartTakedown(this: v9, takedownName: v44.data, enemyPos: &v41, enemyAxis: &v51);
    idStr::FreeData(this: &v44);
  }
}


// ========================================================================
// __unwind$542398
// EA  : 0x82A04F20
// RVA : 0x00A04F20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_542398()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 768 + 288));
}


// ========================================================================
// __unwind$542399
// EA  : 0x82A04F48
// RVA : 0x00A04F48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_542399()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 768 + 288));
}


// ========================================================================
// __unwind$542400
// EA  : 0x82A04F70
// RVA : 0x00A04F70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_542400()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 768 + 368));
}


// ========================================================================
// ?Use@idAI2@@UAA_NPAVidEntity@@W4usableState_t@@@Z
// EA  : 0x82A04F98
// RVA : 0x00A04F98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::Use(idAI2 *this, idPlayer *activator, const usableState_t usable)
{
  idPlayer *v6; // r3
  idPlayer *v7; // r28
  double v8; // fp31
  bool v9; // r30
  idDisassembleLoot *DisassembleLoot; // r3
  idAnimator_AF *v12; // r3
  idPhysics_AF *p_physicsObj; // r30
  idPhysics *Physics; // r29
  float *v15; // r30
  float *v16; // r3
  double v17; // fp9
  double v18; // fp7
  double v19; // fp1
  idAnimator_AF *v20; // r3
  idEntity *v21; // r3
  idEntityPtr<idEntity> *p_droppedItem1; // r3
  bool v23; // zf
  idProp_Loot *v24; // r3
  idProp_Loot *v25; // r30
  idAnimator_AF *v26; // r3
  char v27; // r11
  idPhysics *v28; // r26
  idPhysics_AF *v29; // r25
  float *v30; // r26
  float *v31; // r3
  double v32; // fp10
  double v33; // fp6
  idEntity *v34; // r3
  idProp_Moveable *v35; // r3
  idProp_Moveable *v36; // r30
  idEntity *v37; // r3
  idProp_Loot *v38; // r3
  idProp_Loot *v39; // r30
  idAnimator_AF *v40; // r3
  char v41; // r11
  idPhysics *v42; // r26
  idPhysics_AF *v43; // r25
  float *v44; // r26
  float *v45; // r3
  double v46; // fp0
  double v47; // fp12
  double v48; // fp11
  double v49; // fp7
  idPhysics *v50; // r26
  idPhysics *v51; // r25
  idPresentable *presentable; // r3
  const idDeclInventory *mutantTag; // r29
  idPresentable *v54; // r30
  idInventoryCollection *v55; // r3
  idFaction *v56; // r30
  const idFaction *v57; // r3
  idVec3 v58[2]; // [sp+50h] [-60h] BYREF

  v6 = idPlayer::CastTo(c: activator);
  v7 = v6;
  if ( v6 == nullptr )
    return false;
  if ( usable == USABLE_DISASSEMBLE )
  {
    v8 = ((double (__fastcall *)(idAIHealth *))this->aiHealth.GetTotalCurHealth_Impl)(a1: &this->aiHealth);
    v9 = v8 == ((double (__fastcall *)(idAIHealth *))this->aiHealth.GetTotalMaxHealth_Impl)(a1: &this->aiHealth);
    DisassembleLoot = idActor::GetDisassembleLoot(this);
    idPlayer::Disassemble(this: v7, loot: DisassembleLoot, ent: this);
    idActor::SetLooted(this, b: true);
    if ( v9 )
    {
      idEventReceiver::PostEventMS(this, ev: &EV_Remove, time: 0);
      return true;
    }
    else
    {
      if ( this->GetAF_2(this)->isLoaded )
      {
        this->StartRagdoll(this, a2: &this->ragdollInfo);
        v12 = this->GetAF_2(this);
        v12->physicsObj.SetGravity(this: &v12->physicsObj, a2: &gameLocal->clientGame.gravity);
        p_physicsObj = &this->GetAF_2(this)->physicsObj;
        Physics = idEntity::GetPhysics(this: activator);
        v15 = (float *)p_physicsObj->GetOrigin(this: p_physicsObj, a2: 0);
        v16 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
        v17 = (float)(v16[2] - v15[2]);
        v18 = (float)(v16[1] - v15[1]);
        v58[0].x = *v16 - *v15;
        v58[0].z = v17;
        v58[0].y = v18;
        v19 = idVec3::NormalizeFast(this: v58);
        v20 = (idAnimator_AF *)((int (__fastcall *)(idAI2 *, double))this->GetAF_2)(a1: this, a2: v19);
        idAnimator_AF::UnattachBones(this: v20, dir: v58);
      }
      idEventReceiver::PostEventMS(this, ev: &EV_Remove, time: 3000);
      return true;
    }
  }
  if ( usable != USABLE_LOOT )
  {
    if ( usable == USABLE_AI_TAGGABLE )
    {
      presentable = v6->presentable;
      mutantTag = v7->mutantTag;
      if ( presentable != nullptr )
        v54 = presentable->GetPlayerInterface_2(this: presentable);
      else
        v54 = nullptr;
      v55 = this->GetInventory_2(this);
      idInventoryCollection::GiveItem(
        this: v55,
        owner: v54,
        decl: mutantTag,
        count: 1,
        forceCount: false,
        canIntro: false);
      return true;
    }
    if ( usable == USABLE_AI_TALK )
    {
      v56 = v6->GetFaction(this: v6);
      if ( v56 == nullptr
        || (v57 = this->GetFaction(this), idFaction::GetAttitudeTowards(this: v56, otherFaction: v57) >= ATTITUDE_NEUTRAL) )
      {
        if ( idAI2::GetCurrentPlayerInteraction(this) != nullptr && this->aiVolatile.memory.interactionIsUsable )
        {
          this->aiVolatile.memory.triggeredInteraction.spawnId.value = (gameLocal->spawnIds.ptr[v7->entityNumber] << 13)
                                                                     | v7->entityNumber;
          return true;
        }
      }
    }
    return false;
  }
  if ( idEntityPtr<idEntity const>::operator->(this: &this->droppedItem1) != nullptr )
  {
    v21 = idEntityPtr<idEntity const>::operator->(this: &this->droppedItem1);
    v23 = (unsigned __int8)idProp_Loot::IsTypeOf(c: v21) == 0;
    p_droppedItem1 = &this->droppedItem1;
    if ( v23 )
    {
      v34 = idEntityPtr<idEntity const>::operator->(this: p_droppedItem1);
      if ( (unsigned __int8)idProp_Moveable::IsTypeOf(c: v34) != 0 )
      {
        v35 = (idProp_Moveable *)idEntityPtr<idEntity const>::operator->(this: &this->droppedItem1);
        v36 = idProp_Moveable::CastTo(c: v35);
        idProp_Usable::SetUsable(this: v36, b: false);
        v36->removeCondition = REMOVE_CONDITION_TIMEOUT;
        v36->fadeTimeDelay = 0.0;
        v36->fadeTime = 0.1;
        idEntity::BecomeActive(this: v36, flags: 1);
      }
    }
    else
    {
      v24 = (idProp_Loot *)idEntityPtr<idEntity const>::operator->(this: p_droppedItem1);
      v25 = idProp_Loot::CastTo(c: v24);
      v26 = this->GetAF_2(this);
      if ( v26->isActive || (v27 = 0, v26->isClientAuthoritativeActive) )
        v27 = 1;
      if ( v27 != 0 )
      {
        v28 = idEntity::GetPhysics(this: v25);
        v29 = &this->GetAF_2(this)->physicsObj;
      }
      else
      {
        v28 = idEntity::GetPhysics(this: v25);
        v29 = (idPhysics_AF *)idEntity::GetPhysics(this);
      }
      v30 = (float *)v28->GetOrigin(this: v28, a2: 0);
      v31 = (float *)v29->GetOrigin(this: v29, a2: 0);
      v32 = (float)(v30[2] - v31[2]);
      v33 = (float)(v30[1] - v31[1]);
      if ( (float)((float)((float)v33 * (float)v33)
                 + (float)((float)((float)(*v30 - *v31) * (float)(*v30 - *v31)) + (float)((float)v32 * (float)v32))) <= (double)(float)(ai_droppedLootDistance.valueFloat * ai_droppedLootDistance.valueFloat) )
        v25->Use(this: v25, a2: activator, a3: USABLE_LOOT);
    }
  }
  if ( idEntityPtr<idEntity const>::operator->(this: &this->droppedItem2) != nullptr )
  {
    v37 = idEntityPtr<idEntity const>::operator->(this: &this->droppedItem2);
    if ( (unsigned __int8)idProp_Loot::IsTypeOf(c: v37) != 0 )
    {
      v38 = (idProp_Loot *)idEntityPtr<idEntity const>::operator->(this: &this->droppedItem2);
      v39 = idProp_Loot::CastTo(c: v38);
      v40 = this->GetAF_2(this);
      if ( v40->isActive || (v41 = 0, v40->isClientAuthoritativeActive) )
        v41 = 1;
      if ( v41 != 0 )
      {
        v42 = idEntity::GetPhysics(this: v39);
        v43 = &this->GetAF_2(this)->physicsObj;
        v44 = (float *)v42->GetOrigin(this: v42, a2: 0);
        v45 = (float *)v43->GetOrigin(this: v43, a2: 0);
        v46 = v44[1];
        v47 = v44[2];
        v48 = v45[1];
        v49 = v45[2];
      }
      else
      {
        v50 = idEntity::GetPhysics(this: v39);
        v51 = idEntity::GetPhysics(this);
        v44 = (float *)v50->GetOrigin(this: v50, a2: 0);
        v45 = (float *)v51->GetOrigin(this: v51, a2: 0);
        v46 = v44[2];
        v47 = v44[1];
        v48 = v45[2];
        v49 = v45[1];
      }
      if ( (float)((float)((float)((float)v47 - (float)v49) * (float)((float)v47 - (float)v49))
                 + (float)((float)((float)(*v44 - *v45) * (float)(*v44 - *v45))
                         + (float)((float)((float)v46 - (float)v48) * (float)((float)v46 - (float)v48)))) <= (double)(float)(ai_droppedLootDistance.valueFloat * ai_droppedLootDistance.valueFloat) )
        v39->Use(this: v39, a2: activator, a3: USABLE_LOOT);
    }
  }
  return idPlayer::LootItems(this: v7, ent: this, disassemble: nullptr);
}


// ========================================================================
// ?SetupInteractionView@idAI2@@QAAXPAVidPlayer@@@Z
// EA  : 0x82A05658
// RVA : 0x00A05658
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetupInteractionView(idAI2 *this, idPlayer *player)
{
  idPresentable *presentable; // r3
  int v5; // r3
  idPresentable *v6; // r3
  int v7; // r3
  int num; // r28
  int v9; // r26
  int v10; // r30
  double v11; // fp31
  int v12; // r31
  idGameLocal *v13; // r11
  int value; // r9
  idInteractionCamera *v15; // r3
  idInteractionCamera *v16; // r3
  idPhysics *Physics; // r22
  idPhysics *v18; // r21
  float *v19; // r22
  float *v20; // r3
  double v21; // fp8
  double v22; // fp6
  int v23; // r9
  idInteractionCamera *v24; // r3
  idInteractionCamera *v25; // r11
  int v26; // r9
  idInteractionCamera *v27; // r3
  idInteractionCamera *v28; // r3
  idInteractionCamera *dynamicInteractionCamera; // r31
  idEntityPtr<idInteractionCamera> *p_interactionCamera; // r9
  idPresentable *v31; // r3
  int v32; // r3

  presentable = player->presentable;
  if ( presentable != nullptr )
    v5 = (int)presentable->GetPlayerInterface_2(this: presentable);
  else
    v5 = 0;
  idHands::Hide(this: (idHands *)(v5 + 37616), hideReason: HAND_HIDE_GENERIC);
  v6 = player->presentable;
  if ( v6 != nullptr )
    v7 = (int)v6->GetPlayerInterface_2(this: v6);
  else
    v7 = 0;
  idHands::UpdateHidden(this: (idHands *)(v7 + 37616));
  num = this->aiEditable.interactions.interactionCameras.num;
  if ( num <= 0 || ai_interactionView_useCamera.valueInteger == 0 )
    goto LABEL_29;
  v9 = -1;
  v10 = 0;
  v11 = 1.0e30;
  v12 = 0;
  do
  {
    v13 = gameLocal;
    value = this->aiEditable.interactions.interactionCameras.list[v12].spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13 )
      goto LABEL_17;
    v15 = (idInteractionCamera *)gameLocal->entities.ptr[value & 0x1FFF];
    if ( v15 == nullptr )
      goto LABEL_17;
    v16 = idInteractionCamera::CastTo(c: v15);
    if ( v16 == nullptr )
    {
      v13 = gameLocal;
LABEL_17:
      v23 = this->aiEditable.interactions.interactionCameras.list[v12].spawnId.value;
      if ( v13->spawnIds.ptr[v23 & 0x1FFF] == v23 >> 13
        && (v24 = (idInteractionCamera *)v13->entities.ptr[v23 & 0x1FFF]) != nullptr
        && (v25 = idInteractionCamera::CastTo(c: v24)) != nullptr )
      {
        idLib::Warning(fmt: "Invalid entity '%s' specified for an interaction camera!", v25->name.data);
      }
      else
      {
        idLib::Warning(fmt: "NULL entity specified for an interaction camera!");
      }
      goto LABEL_22;
    }
    Physics = idEntity::GetPhysics(this: v16);
    v18 = idEntity::GetPhysics(this: player);
    v19 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v20 = (float *)v18->GetOrigin(this: v18, a2: 0);
    v21 = (float)(v20[1] - v19[1]);
    v22 = (float)(v20[2] - v19[2]);
    if ( (float)((float)((float)v22 * (float)v22)
               + (float)((float)((float)v21 * (float)v21) + (float)((float)(*v20 - *v19) * (float)(*v20 - *v19)))) < v11 )
    {
      v11 = (float)((float)((float)v22 * (float)v22)
                  + (float)((float)((float)v21 * (float)v21) + (float)((float)(*v20 - *v19) * (float)(*v20 - *v19))));
      v9 = v10;
    }
LABEL_22:
    ++v10;
    ++v12;
  }
  while ( v10 < num );
  if ( v9 <= -1 )
  {
    idLib::Warning(fmt: "Could not find an interaction camera!");
    goto LABEL_29;
  }
  v26 = this->aiEditable.interactions.interactionCameras.list[v9].spawnId.value;
  if ( gameLocal->spawnIds.ptr[v26 & 0x1FFF] == v26 >> 13
    && (v27 = (idInteractionCamera *)gameLocal->entities.ptr[this->aiEditable.interactions.interactionCameras.list[v9].spawnId.value
                                                           & 0x1FFF]) != nullptr )
  {
    v28 = idInteractionCamera::CastTo(c: v27);
  }
  else
  {
    v28 = nullptr;
  }
  dynamicInteractionCamera = v28;
  if ( v28 != nullptr )
  {
LABEL_31:
    idCamera::Activate(this: dynamicInteractionCamera, activator_: player);
    p_interactionCamera = &this->aiVolatile.memory.interactionCamera;
    if ( dynamicInteractionCamera != nullptr )
      p_interactionCamera->spawnId.value = (gameLocal->spawnIds.ptr[dynamicInteractionCamera->entityNumber] << 13)
                                         | dynamicInteractionCamera->entityNumber;
    else
      p_interactionCamera->spawnId.value = 0x1FFF;
    idAI2::SetLookFocusEntity(
      this,
      ent: dynamicInteractionCamera,
      keepFocusInView: false,
      aimPoint: AIMPOINT_ORIGIN,
      timeout: -1);
  }
  else
  {
LABEL_29:
    dynamicInteractionCamera = player->dynamicInteractionCamera;
    if ( dynamicInteractionCamera != nullptr )
    {
      idInteractionCamera::DynamicSetup(this: player->dynamicInteractionCamera, ai: this, player);
      goto LABEL_31;
    }
  }
  v31 = player->presentable;
  if ( v31 != nullptr )
    v32 = (int)v31->GetPlayerInterface_2(this: v31);
  else
    v32 = 0;
  *(_BYTE *)(v32 + 47123) = 1;
}


// ========================================================================
// ?EndInteractionView@idAI2@@QAAXPAVidPlayer@@@Z
// EA  : 0x82A05998
// RVA : 0x00A05998
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::EndInteractionView(idAI2 *this, idPlayer *player)
{
  idEntityPtr<idInteractionCamera> *p_interactionCamera; // r30
  int value; // r9
  idInteractionCamera *v6; // r3
  idGameLocal *v7; // r10
  idInteractionCamera *v8; // r3
  idInteractionCamera *v9; // r3
  idInteractionCamera *v10; // r3
  idInteractionCamera *v11; // r3

  p_interactionCamera = &this->aiVolatile.memory.interactionCamera;
  value = this->aiVolatile.memory.interactionCamera.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v6 = (idInteractionCamera *)gameLocal->entities.ptr[value & 0x1FFF]) != nullptr
    && idInteractionCamera::CastTo(c: v6) != nullptr )
  {
    v7 = gameLocal;
    if ( gameLocal->spawnIds.ptr[p_interactionCamera->spawnId.value & 0x1FFF] == p_interactionCamera->spawnId.value >> 13
      && (v8 = (idInteractionCamera *)gameLocal->entities.ptr[p_interactionCamera->spawnId.value & 0x1FFF]) != nullptr )
    {
      v9 = idInteractionCamera::CastTo(c: v8);
      v7 = gameLocal;
    }
    else
    {
      v9 = nullptr;
    }
    v9->deactivateCallbackAI.spawnId.value = (v7->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
    if ( gameLocal->spawnIds.ptr[p_interactionCamera->spawnId.value & 0x1FFF] == p_interactionCamera->spawnId.value >> 13
      && (v10 = (idInteractionCamera *)gameLocal->entities.ptr[p_interactionCamera->spawnId.value & 0x1FFF]) != nullptr )
    {
      v11 = idInteractionCamera::CastTo(c: v10);
    }
    else
    {
      v11 = nullptr;
    }
    idEventReceiver::PostEventMS(this: v11, ev: &EV_Deactivate, time: 0);
    p_interactionCamera->spawnId.value = 0x1FFF;
    idPlayer::SetInInteractionView(this: player, inView: false);
  }
  else
  {
    idAI2::SetLookFocusEntity(this, ent: player, keepFocusInView: true, aimPoint: AIMPOINT_HEAD, timeout: -1);
    idPlayer::SetInInteractionView(this: player, inView: false);
  }
}


// ========================================================================
// ?InteractionCameraDeactivateCallback@idAI2@@QAAXPAVidPlayer@@@Z
// EA  : 0x82A05B00
// RVA : 0x00A05B00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InteractionCameraDeactivateCallback(idAI2 *this, idPlayer *player)
{
  idAI2::SetLookFocusEntity(this, ent: player, keepFocusInView: true, aimPoint: AIMPOINT_HEAD, timeout: -1);
}


// ========================================================================
// ?SetActionNodeGroupName@idAI2@@QAAXPBD@Z
// EA  : 0x82A05B10
// RVA : 0x00A05B10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetActionNodeGroupName(idAI2 *this, const char *groupName)
{
  if ( idStr::Cmp(s1: this->aiEditable.interactions.actionNodeGroup.data, s2: groupName) != 0 )
  {
    idStr::operator=(this: &this->aiEditable.interactions.actionNodeGroup, text: groupName);
    idAI2::LeaveActionNode(this, force: true);
    this->aiVolatile.memory.currentActionNode.spawnId.value = 0x1FFF;
  }
}


// ========================================================================
// ?UpdateAvoidCharacter@idAI2@@IAAXXZ
// EA  : 0x82A05B80
// RVA : 0x00A05B80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateAvoidCharacter(idAI2 *this)
{
  idEntityPtr<idEntity const > *p_avoidEntity; // r27
  idGameLocal *v3; // r11
  int value; // r9
  idEntity *v5; // r3
  idEntity *v6; // r3
  idAI2 *v7; // r29
  int v8; // r8
  idEntity *v9; // r3
  idPlayer *v10; // r31
  idAI2 *v11; // r3
  idPhysics *Physics; // r3
  float *v13; // r26
  idPhysics *v14; // r3
  float *v15; // r3
  double v16; // fp6
  double v17; // fp4
  idPhysics *v18; // r3
  float *v19; // r31
  idPhysics *v20; // r3
  float *v21; // r3
  double v22; // fp6
  double v23; // fp4

  if ( this->aiEditable.behaviors.avoidRadius > 0.0 )
  {
    p_avoidEntity = &this->aiVolatile.memory.avoidEntity;
    v3 = gameLocal;
    value = this->aiVolatile.memory.avoidEntity.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v6 = idEntity::CastTo(c: v5);
      v3 = gameLocal;
      v7 = (idAI2 *)v6;
    }
    else
    {
      v7 = nullptr;
    }
    v8 = this->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( v3->spawnIds.ptr[v8 & 0x1FFF] == v8 >> 13 && (v9 = v3->entities.ptr[v8 & 0x1FFF]) != nullptr )
    {
      v11 = (idAI2 *)idEntity::CastTo(c: v9);
      v10 = (idPlayer *)v11;
      if ( v11 != nullptr
        && (idAI2::CastTo(c: v11) != nullptr
         || idPlayer::CastTo(c: v10) != nullptr
         || idRobot::CastTo(c: (idRobot *)v10) != nullptr) )
      {
        Physics = idEntity::GetPhysics(this);
        v13 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
        v14 = idEntity::GetPhysics(this: v10);
        v15 = (float *)v14->GetOrigin(this: v14, a2: 0);
        v16 = (float)(v13[1] - v15[1]);
        v17 = (float)(v13[2] - v15[2]);
        if ( (float)((float)((float)v17 * (float)v17)
                   + (float)((float)((float)v16 * (float)v16) + (float)((float)(*v13 - *v15) * (float)(*v13 - *v15)))) <= (double)(float)(this->aiEditable.behaviors.avoidRadius * this->aiEditable.behaviors.avoidRadius) )
          p_avoidEntity->spawnId.value = (gameLocal->spawnIds.ptr[v10->entityNumber] << 13) | v10->entityNumber;
      }
    }
    else
    {
      v10 = nullptr;
    }
    if ( v7 != nullptr
      && v7 != (idAI2 *)v10
      && (idAI2::CastTo(c: v7) != nullptr
       || idPlayer::CastTo(c: (idPlayer *)v7) != nullptr
       || idRobot::CastTo(c: (idRobot *)v7) != nullptr) )
    {
      v18 = idEntity::GetPhysics(this);
      v19 = (float *)v18->GetOrigin(this: v18, a2: 0);
      v20 = idEntity::GetPhysics(this: v7);
      v21 = (float *)v20->GetOrigin(this: v20, a2: 0);
      v22 = (float)(v19[2] - v21[2]);
      v23 = (float)(v19[1] - v21[1]);
      if ( (float)((float)((float)v23 * (float)v23)
                 + (float)((float)((float)v22 * (float)v22) + (float)((float)(*v19 - *v21) * (float)(*v19 - *v21)))) >= (double)(float)(this->aiEditable.behaviors.avoidRadius * this->aiEditable.behaviors.avoidRadius) )
        p_avoidEntity->spawnId.value = 0x1FFF;
    }
  }
}


// ========================================================================
// ?SetFakeEnemy@idAI2@@QAAXPAVidEntity@@@Z
// EA  : 0x82A05DE8
// RVA : 0x00A05DE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::SetFakeEnemy(idAI2 *this, idEntity *entity)
{
  idGameLocal *v3; // r11
  idEntity *v5; // r3
  idEntity *v6; // r3

  v3 = gameLocal;
  if ( gameLocal->spawnIds.ptr[this->aiVolatile.world.fakeEnemy.spawnId.value & 0x1FFF] == this->aiVolatile.world.fakeEnemy.spawnId.value >> 13
    && (v5 = gameLocal->entities.ptr[this->aiVolatile.world.fakeEnemy.spawnId.value & 0x1FFF]) != nullptr )
  {
    v6 = idEntity::CastTo(c: v5);
    v3 = gameLocal;
  }
  else
  {
    v6 = nullptr;
  }
  if ( v6 != entity )
  {
    if ( entity != nullptr )
      this->aiVolatile.world.fakeEnemy.spawnId.value = (v3->spawnIds.ptr[entity->entityNumber] << 13)
                                                     | entity->entityNumber;
    else
      this->aiVolatile.world.fakeEnemy.spawnId.value = 0x1FFF;
    this->aiVolatile.memory.currentEnemy.spawnId.value = 0x1FFF;
  }
}


// ========================================================================
// ?ClearFakeEnemy@idAI2@@QAAXXZ
// EA  : 0x82A05EA8
// RVA : 0x00A05EA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearFakeEnemy(idAI2 *this)
{
  int value; // r10
  idEntity *v3; // r3

  value = this->aiVolatile.world.fakeEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v3 = gameLocal->entities.ptr[value & 0x1FFF];
    if ( v3 != nullptr && idEntity::CastTo(c: v3) != nullptr )
    {
      this->aiVolatile.world.fakeEnemy.spawnId.value = 0x1FFF;
      this->aiVolatile.memory.currentEnemy.spawnId.value = 0x1FFF;
    }
  }
}


// ========================================================================
// ?ClearWorldState@idAI2@@QAAXXZ
// EA  : 0x82A05F30
// RVA : 0x00A05F30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ClearWorldState(idAI2 *this)
{
  this->aiVolatile.memory.currentEnemy.spawnId.value = 0x1FFF;
  idAIWorldState::Clear(this: &this->aiVolatile.world.worldState);
  this->aiVolatile.world.fakeEnemy.spawnId.value = 0x1FFF;
}


// ========================================================================
// ?OnAIEvent_Voice@idAI2@@AAAXPBVidAIEventVoice@@@Z
// EA  : 0x82A05F80
// RVA : 0x00A05F80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Voice(idAI2 *this, idAIEventVoice *ev)
{
  int value; // r10
  idEntity *v5; // r3
  idAI2 *v6; // r3
  idAI2 *v7; // r25
  bool v8; // r23
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r24
  idEncounterGroup *v10; // r28
  idEncounterGroup *v11; // r3
  int v12; // r9
  idGameLocal *v13; // r11
  idEntity *v14; // r3
  idEntity *v15; // r3
  const idEntity *v16; // r26
  const idAIGameState *v17; // r23
  const idSpawnId *v18; // r20
  const idAILogic *v19; // r3
  double v20; // fp31
  const idSpawnId *v21; // r8
  voiceMessageType_t VoiceMessageType; // r3
  idAIGameState *v23; // r31
  const idSpawnId *v24; // r27
  const idSpawnId *v25; // r8
  const idAILogic *v26; // r3
  aiStimulus_t v27; // r7
  idEncounterGroup *v28; // r3
  idEncounterGroup *v29; // r27
  int v30; // r24
  idPhysics *v31; // r27
  int GameMs; // r24
  idPhysics *v33; // r3
  const idDeclAIBehaviorEvents *v34; // r23
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r27
  const idVec3 *(__fastcall *v36)(idPhysics *, int); // ctr
  const idVec3 *v37; // r9
  const idDeclAiEvent *memberKilledVOEventDecl; // r5
  idAIEventManager *v39; // r3
  idPhysics *Physics; // r27
  idPhysics *v41; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r23
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  idEntity *Originator; // r3
  idPhysics *v45; // r3
  idAIGameState *v46; // r31
  const idVec3 *v47; // r27
  const idSpawnId *v48; // r26
  const idAILogic *v49; // r3
  const idSpawnId *v50; // r8
  idAIGameState *v51; // r31
  const idSpawnId *v52; // r26
  const idAILogic *v53; // r3
  const idSpawnId *v54; // r8
  idEncounterGroup *v55; // r3
  idPhysics *v56; // r3
  float *v57; // r3
  double v58; // fp10
  double v59; // fp8
  double v60; // fp6
  const char **v61; // r3
  const idAIGameState *p_aiGameState; // r27
  const idSpawnId *v63; // r23
  const idAILogic *v64; // r3
  const idSpawnId *v65; // r8
  idSpawnId v66; // [sp+50h] [-F0h] BYREF
  idSpawnId v67; // [sp+54h] [-ECh] BYREF
  char v68; // [sp+58h] [-E8h] BYREF
  char v69; // [sp+5Ch] [-E4h] BYREF
  idSpawnId v70; // [sp+60h] [-E0h] BYREF
  idSpawnId v71; // [sp+64h] [-DCh] BYREF
  idSpawnId v72; // [sp+68h] [-D8h] BYREF
  idSpawnId v73; // [sp+6Ch] [-D4h] BYREF
  idAILogic v74; // [sp+70h] [-D0h] BYREF
  idAILogic v75; // [sp+90h] [-B0h] BYREF
  idAILogic v76; // [sp+B0h] [-90h] BYREF

  value = ev->originator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v6 = (idAI2 *)idEntity::CastTo(c: v5);
  }
  else
  {
    v6 = nullptr;
  }
  v7 = idAI2::CastTo(c: v6);
  if ( v7 != nullptr )
  {
    v8 = false;
    p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
      v10 = nullptr;
    else
      v10 = idEncounterGroupManager::GroupForHandle(
              this: &gameLocal->encounterGroupManager,
              handle: &this->aiVolatile.encounterGroupHandle);
    if ( (unsigned __int16)v7->aiVolatile.encounterGroupHandle.value == 0xFFFF )
      v11 = nullptr;
    else
      v11 = idEncounterGroupManager::GroupForHandle(
              this: &gameLocal->encounterGroupManager,
              handle: &v7->aiVolatile.encounterGroupHandle);
    if ( v10 != nullptr && v11 != nullptr )
      v8 = (_cntlzw((char *)v11 - (char *)v10) & 0x20) != 0;
    v12 = ev->instigator.spawnId.value;
    v13 = gameLocal;
    if ( gameLocal->spawnIds.ptr[v12 & 0x1FFF] == v12 >> 13 && (v14 = gameLocal->entities.ptr[v12 & 0x1FFF]) != nullptr )
    {
      v15 = idEntity::CastTo(c: v14);
      v13 = gameLocal;
      v16 = v15;
    }
    else
    {
      v16 = nullptr;
    }
    if ( !v8 )
    {
      p_aiGameState = &v13->aiGameState;
      idSpawnId::idSpawnId(this: &v73, ent: v7);
      v63 = idSpawnId::idSpawnId(this: &v72, ent: v7);
      v64 = idAILogic::idAILogic(this: &v76, ai: this);
      v20 = 1.0;
      idAIWorldState::AddEntityState(
        this: &this->aiVolatile.world.worldState,
        gameState: p_aiGameState,
        owner: v64,
        entId: v63,
        stimulusType: AISTIMULUS_HEARING,
        stimulusAmount: 1.0,
        sourceId: v65);
      v23 = &gameLocal->aiGameState;
      idSpawnId::idSpawnId(this: &v73, ent: v7);
      v24 = idSpawnId::idSpawnId(this: &v72, ent: v16);
      v26 = idAILogic::idAILogic(this: &v76, ai: this);
      v27 = AISTIMULUS_HEARING;
      goto LABEL_49;
    }
    v17 = &v13->aiGameState;
    idSpawnId::idSpawnId(this: &v66, ent: v7);
    v18 = idSpawnId::idSpawnId(this: &v67, ent: v7);
    v19 = idAILogic::idAILogic(this: &v74, ai: this);
    v20 = 1.0;
    idAIWorldState::AddEntityState(
      this: &this->aiVolatile.world.worldState,
      gameState: v17,
      owner: v19,
      entId: v18,
      stimulusType: AISTIMULUS_HEARING,
      stimulusAmount: 1.0,
      sourceId: v21);
    VoiceMessageType = idAIEventVoice::GetVoiceMessageType(this: ev);
    if ( (unsigned int)VoiceMessageType > VOICEMSG_MEMBER_KILLED )
    {
      v61 = (const char **)ev->GetType(this: ev);
      idLib::Warning(fmt: "idAI2::OnAIEvent_Voice - unhandled event '%s'", *v61);
      return;
    }
    if ( VoiceMessageType != VOICEMSG_HEARD_SOMETHING && VoiceMessageType != VOICEMSG_SAW_SOMETHING )
    {
      if ( VoiceMessageType == VOICEMSG_TOOK_DAMAGE || VoiceMessageType == VOICEMSG_GOT_KILLED )
        return;
      if ( VoiceMessageType != VOICEMSG_FOUND_DEAD_BODY )
      {
        if ( VoiceMessageType == VOICEMSG_SIGHTED_ENEMY )
        {
          v23 = &gameLocal->aiGameState;
          idSpawnId::idSpawnId(this: &v67, ent: v7);
          v24 = idSpawnId::idSpawnId(this: &v66, ent: v16);
          v26 = idAILogic::idAILogic(this: &v74, ai: this);
          v27 = AISTIMULUS_GROUP_CONFIRMED;
LABEL_49:
          idAIWorldState::AddEntityState(
            this: &this->aiVolatile.world.worldState,
            gameState: v23,
            owner: v26,
            entId: v24,
            stimulusType: v27,
            stimulusAmount: v20,
            sourceId: v25);
          return;
        }
        if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
          goto LABEL_36;
        v28 = idEncounterGroupManager::GroupForHandle(
                this: &gameLocal->encounterGroupManager,
                handle: &this->aiVolatile.encounterGroupHandle);
        v29 = v28;
        if ( v28 == nullptr )
          goto LABEL_36;
        if ( idEncounterGroup::NumLivingMembers(this: v28) > 1
          || (v30 = idEncounterGroup::NumDeadMembers(this: v29)) < idEncounterGroup::NumLivingMembers(this: v29) )
        {
          if ( idEncounterGroup::NumDeadMembers(this: v29) > 1 )
            goto LABEL_36;
          Physics = idEntity::GetPhysics(this);
          GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
          v41 = Physics;
          declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
          GetOrigin = Physics->GetOrigin;
          p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
          v37 = GetOrigin(this: v41, a2: 0);
          memberKilledVOEventDecl = declBehaviorEvents->memberKilledVOEventDecl;
          v39 = (idAIEventManager *)&v69;
        }
        else
        {
          v31 = idEntity::GetPhysics(this);
          GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
          v33 = v31;
          v34 = this->aiEditable.behaviors.declBehaviorEvents;
          v36 = v31->GetOrigin;
          p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
          v37 = v36(this: v33, a2: 0);
          memberKilledVOEventDecl = v34->losingBattleVOEventDecl;
          v39 = (idAIEventManager *)&v68;
        }
        idAIEventManager::AddEvent(
          this: v39,
          result: p_aiEventManager,
          eventDecl: memberKilledVOEventDecl,
          curTime: GameMs,
          originator: nullptr,
          instigator: this,
          origin: v37,
          delay: 600);
LABEL_36:
        if ( idAI2::GetAlertCycle(this) < ALERTCYCLE_COMBAT )
        {
          Originator = (idEntity *)idAIEvent::GetOriginator(this: ev);
          v45 = idEntity::GetPhysics(this: Originator);
          v45->GetOrigin(this: v45, a2: 0);
          v46 = &gameLocal->aiGameState;
          v47 = (const idVec3 *)idSpawnId::idSpawnId(this: &v70, ent: v7);
          v48 = idSpawnId::idSpawnId(this: &v71, ent: v16);
          v49 = idAILogic::idAILogic(this: &v75, ai: this);
          idAIWorldState::AddEntityStateFakePosition(
            this: &this->aiVolatile.world.worldState,
            gameState: v46,
            owner: v49,
            entId: v48,
            stimulusType: AISTIMULUS_GROUP_SUSPECTED,
            stimulusAmount: 1.0,
            sourceId: v50,
            fakePosition: v47);
        }
        return;
      }
    }
    v51 = &gameLocal->aiGameState;
    idSpawnId::idSpawnId(this: &v72, ent: v7);
    v52 = idSpawnId::idSpawnId(this: &v73, ent: v16);
    v53 = idAILogic::idAILogic(this: &v76, ai: this);
    idAIWorldState::AddEntityState(
      this: &this->aiVolatile.world.worldState,
      gameState: v51,
      owner: v53,
      entId: v52,
      stimulusType: AISTIMULUS_GROUP_SUSPECTED,
      stimulusAmount: 1.0,
      sourceId: v54);
    if ( (unsigned __int16)p_encounterGroupHandle->value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr
      && ((unsigned __int16)p_encounterGroupHandle->value != 0xFFFF
        ? (v55 = idEncounterGroupManager::GroupForHandle(
                   this: &gameLocal->encounterGroupManager,
                   handle: &this->aiVolatile.encounterGroupHandle))
        : (v55 = nullptr),
          idEncounterGroup::GetClosestActiveGroupMemberToPoint(this: v55, point: &ev->origin) == this)
      || (v56 = idEntity::GetPhysics(this),
          v57 = (float *)v56->GetOrigin(this: v56, a2: 0),
          v58 = (float)(ev->origin.y - v57[1]),
          v59 = (float)(ev->origin.z - v57[2]),
          (float)((float)((float)(v60 = (float)(ev->origin.x - *v57)) * (float)v60)
                + (float)((float)((float)v59 * (float)v59) + (float)((float)v58 * (float)v58))) < (double)(float)(ai_searchToStimDist.valueFloat * ai_searchToStimDist.valueFloat)) )
    {
      if ( idAIEventVoice::GetVoiceMessageType(this: ev) != VOICEMSG_HEARD_SOMETHING )
        idAIEventVoice::GetVoiceMessageType(this: ev);
    }
  }
}


// ========================================================================
// ?OnAIEvent_Footstep@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A06580
// RVA : 0x00A06580
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Footstep(idAI2 *this, idAIEventSound *ev)
{
  double v4; // fp31
  idEntity *Instigator; // r3
  idPhysics *Physics; // r3
  const idVec3 *v7; // r29
  const idEntity *v8; // r3
  idAIGameState *p_aiGameState; // r29
  const idAILogic *v10; // r3
  const idSpawnId *v11; // r8
  idSpawnId v12; // [sp+50h] [-70h] BYREF
  idAILogic v13; // [sp+60h] [-60h] BYREF

  gameLocal->GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED);
  if ( (unsigned __int8)idAIEventSound::IsTypeOf(c: ev) != 0 )
    v4 = (float)(idInfoNavFlightVolume::Spawn(this: ev, ent: this) * this->aiEditable.perception.hearingStimulus);
  else
    v4 = 0.0;
  if ( idAI2::IsPlayerControlled(this)
    || this->aiVolatile.fsms.alertCycle >= ALERTCYCLE_COMBAT
    || this->aiEditable.perception.combatTimeoutInterval <= -1.0 )
  {
    p_aiGameState = &gameLocal->aiGameState;
    idSpawnId::idSpawnId(this: &v12, ent: this);
    v10 = idAILogic::idAILogic(this: &v13, ai: this);
    idAIWorldState::AddEntityStateFromEvent(
      this: &this->aiVolatile.world.worldState,
      gameState: p_aiGameState,
      owner: v10,
      event: ev,
      stimType: AISTIMULUS_HEARING,
      stimAmount: v4,
      sourceId: v11);
  }
  else if ( v4 > 0.0 )
  {
    Instigator = (idEntity *)idAIEvent::GetInstigator(this: ev);
    Physics = idEntity::GetPhysics(this: Instigator);
    v7 = Physics->GetOrigin(this: Physics, a2: 0);
    v8 = idAIEvent::GetInstigator(this: ev);
    idAI2::SetupFakePosition(this, _pInstigator: v8, _fakePos: v7);
  }
}


// ========================================================================
// ?OnAIEvent_Gunfire@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A066D8
// RVA : 0x00A066D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Gunfire(idAI2 *this, idAIEventSound *ev)
{
  const idDeclAIBehavior *decl; // r23
  idGameLocal *v4; // r11
  idEntity *v6; // r3
  idEntity *v7; // r3
  idAI2 *v8; // r28
  int value; // r9
  idEntity *v10; // r3
  idEntity *v11; // r3
  const idEntity *v12; // r26
  const idAIGameState *p_aiGameState; // r29
  const idSpawnId *v14; // r21
  const idAILogic *v15; // r3
  const idSpawnId *v16; // r8
  idAIEntityState *v17; // r29
  double v18; // fp31
  double v19; // fp30
  double v20; // fp29
  idPhysics *Physics; // r3
  float *v22; // r3
  idPhysics *v23; // r3
  float *v24; // r3
  idAIGameState *v25; // r22
  double v26; // fp1
  double v27; // fp0
  const idSpawnId *v28; // r21
  const idAILogic *v29; // r3
  idAIGameState *v30; // r22
  const idSpawnId *v31; // r21
  const idAILogic *v32; // r3
  idAI2 *v33; // r3
  idAIEntityState *v34; // r3
  aiSenseState_t *v35; // r29
  idAIEntityState *v36; // r3
  int ConfirmedStimTimeSafe; // r22
  idAIGameState *v38; // r30
  const aiSenseState_t *v39; // r22
  const idSpawnId *v40; // r26
  const idAILogic *v41; // r3
  const idSpawnId *v42; // r8
  char v43; // r27
  idFaction *v44; // r3
  double mediumFiredAtAngle; // fp31
  idActor *v46; // r3
  long double v47; // fp2
  idEntity *v48; // r30
  idWeapon *v49; // r29
  idPhysics *v50; // r3
  float *v51; // r26
  idPhysics *v52; // r3
  float *v53; // r3
  double v54; // fp10
  double v55; // fp6
  double v56; // fp30
  const idDeclProjectile *CurrentProjectileDecl; // r3
  idDeclProjectile::aiDodgeType_t aiDodgeType; // r11
  long double v59; // fp2
  double v60; // fp30
  idFiniteStateMachine *v61; // r28
  int GameMs; // r26
  idAIEvent::aiEventClass_t EventClass; // r3
  idCombatStage *CurrentCombatStage; // r28
  idAICombatHint::combatHintType_t v65; // r3
  idAICombatHint::combatHintType_t v66; // r27
  idAICombatHint::combatHintClass_t combatHintClass; // r26
  idPhysics *v68; // r3
  const idVec3 *v69; // r3
  idAICombatHint *ContainingHintNodePtr; // r28
  idPhysics *v71; // r3
  float *v72; // r29
  const idVec3 *v73; // r3
  double v74; // fp10
  double v75; // fp8
  idSpawnId v76; // [sp+50h] [-100h] BYREF
  idSpawnId v77[3]; // [sp+54h] [-FCh] BYREF
  idAILogic v78; // [sp+60h] [-F0h] BYREF
  aiPhysicalState_t v79; // [sp+80h] [-D0h] BYREF

  decl = this->aiEditable.behaviors.decl;
  v4 = gameLocal;
  if ( gameLocal->spawnIds.ptr[ev->originator.spawnId.value & 0x1FFF] == ev->originator.spawnId.value >> 13
    && (v6 = gameLocal->entities.ptr[ev->originator.spawnId.value & 0x1FFF]) != nullptr )
  {
    v7 = idEntity::CastTo(c: v6);
    v4 = gameLocal;
    v8 = (idAI2 *)v7;
  }
  else
  {
    v8 = nullptr;
  }
  value = ev->instigator.spawnId.value;
  if ( v4->spawnIds.ptr[value & 0x1FFF] == value >> 13 && (v10 = v4->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v11 = idEntity::CastTo(c: v10);
    v4 = gameLocal;
    v12 = v11;
  }
  else
  {
    v12 = nullptr;
  }
  p_aiGameState = &v4->aiGameState;
  idSpawnId::idSpawnId(this: &v76, ent: this);
  v14 = idSpawnId::idSpawnId(this: v77, ent: v8);
  v15 = idAILogic::idAILogic(this: &v78, ai: this);
  idAIWorldState::AddEntityState(
    this: &this->aiVolatile.world.worldState,
    gameState: p_aiGameState,
    owner: v15,
    entId: v14,
    stimulusType: AISTIMULUS_GUNFIRE,
    stimulusAmount: 1.0,
    sourceId: v16);
  v17 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v8);
  if ( v17 != nullptr )
  {
    aiPhysicalState_t::aiPhysicalState_t(this: &v79);
    idAIGameState::GetPhysicalState(game: gameLocal, ent: v8, ps: &v79);
    v18 = (float)(v79.eyePos.x - v79.origin.x);
    v19 = (float)(v79.eyePos.y - v79.origin.y);
    v20 = (float)(v79.eyePos.z - v79.origin.z);
    Physics = idEntity::GetPhysics(this: v8);
    v22 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v79.origin.x = *v22;
    v79.origin.y = v22[1];
    v79.origin.z = v22[2];
    v23 = idEntity::GetPhysics(this: v8);
    v24 = (float *)v23->GetOrigin(this: v23, a2: 0);
    v25 = &gameLocal->aiGameState;
    v26 = (float)(v24[1] + (float)v19);
    v27 = (float)(v24[2] + (float)v20);
    v79.eyePos.x = *v24 + (float)v18;
    v79.eyePos.y = v26;
    v79.eyePos.z = v27;
    v28 = idSpawnId::idSpawnId(this: v77, ent: this);
    v29 = idAILogic::idAILogic(this: &v78, ai: this);
    idAIEntityState::SetSenseState(
      this: v17,
      gameState: v25,
      aiOwner: v29,
      sense: AISENSE_HEARING,
      physical: &v79,
      stimType: AISTIMULUS_HEARING,
      sourceId: v28);
    v30 = &gameLocal->aiGameState;
    v31 = idSpawnId::idSpawnId(this: v77, ent: this);
    v32 = idAILogic::idAILogic(this: &v78, ai: this);
    idAIEntityState::SetSenseState(
      this: v17,
      gameState: v30,
      aiOwner: v32,
      sense: AISENSE_SIGHT,
      physical: &v79,
      stimType: AISTIMULUS_SIGHT,
      sourceId: v31);
  }
  v33 = idAI2::CastTo(c: v8);
  if ( v33 != nullptr )
  {
    v34 = idAIWorldState::StateForEntity(this: &v33->aiVolatile.world.worldState, ent: v12);
    if ( v34 != nullptr && (*((_BYTE *)v34 + 541) & 0x80) != 0 )
    {
      v35 = v34->senses.ptr[1];
      if ( v35->lastUnconfirmedStimTime >= 0 )
      {
        v36 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v12);
        if ( v36 == nullptr
          || (*((_BYTE *)v36 + 541) & 0x80) == 0
          || (ConfirmedStimTimeSafe = aiSenseState_t::GetConfirmedStimTimeSafe(this: v36->senses.ptr[v36->lastSense])) < aiSenseState_t::GetConfirmedStimTimeSafe(this: v35) )
        {
          v38 = &gameLocal->aiGameState;
          v39 = (const aiSenseState_t *)idSpawnId::idSpawnId(this: v77, ent: v8);
          v40 = idSpawnId::idSpawnId(this: &v76, ent: v12);
          v41 = idAILogic::idAILogic(this: &v78, ai: this);
          idAIWorldState::AddEntityState(
            this: &this->aiVolatile.world.worldState,
            gameState: v38,
            owner: v41,
            entId: v40,
            stimulusType: AISTIMULUS_GUNFIRE,
            stimulusAmount: 0.30000001,
            sourceId: v42,
            sourceSense: v39);
        }
      }
    }
  }
  v43 = 0;
  if ( v8 != nullptr && v8->GetFaction_2(this: v8) != nullptr )
  {
    v44 = (idFaction *)v8->GetFaction_2(this: v8);
    if ( idFaction::GetAttitudeTowards(this: v44, otherEnt: this) < ATTITUDE_NEUTRAL )
    {
      mediumFiredAtAngle = decl->dodging.mediumFiredAtAngle;
      v46 = idActor::CastTo(c: v8);
      v48 = v46;
      if ( v46 == nullptr )
        goto LABEL_39;
      v49 = v46->GetEquippedWeapon(this: v46);
      v50 = idEntity::GetPhysics(this);
      v51 = (float *)v50->GetOrigin(this: v50, a2: 0);
      v52 = idEntity::GetPhysics(this: v48);
      v53 = (float *)v52->GetOrigin(this: v52, a2: 0);
      v54 = (float)(v53[2] - v51[2]);
      v55 = (float)(v53[1] - v51[1]);
      v56 = (float)((float)((float)v55 * (float)v55)
                  + (float)((float)((float)(*v53 - *v51) * (float)(*v53 - *v51)) + (float)((float)v54 * (float)v54)));
      if ( v49 == nullptr )
        goto LABEL_39;
      if ( idWeapon::IsMelee(this: v49) )
        goto LABEL_39;
      CurrentProjectileDecl = idWeapon::GetCurrentProjectileDecl(this: v49, secondaryAmmo: false);
      if ( CurrentProjectileDecl == nullptr )
        goto LABEL_39;
      aiDodgeType = CurrentProjectileDecl->aiDodgeType;
      if ( aiDodgeType == AI_DODGE_TYPE_LIGHT )
      {
        mediumFiredAtAngle = decl->dodging.lightFiredAtAngle;
LABEL_39:
        *(double *)&v47 = (float)(idMath::M_DEG2RAD * (float)mediumFiredAtAngle);
        v59 = cos(x: v47);
        v60 = (float)*(double *)&v59;
        if ( mediumFiredAtAngle > 0.0
          && (decl->dodging.mustBeDirectTarget
           && (unsigned __int8)idAI2::IsFacingMeMoreThanAnyoneElse(
                                 this,
                                 entity: (idPlayer *)v8,
                                 dotThreshold: (float)*(double *)&v59) != 0
           || !decl->dodging.mustBeDirectTarget && idAI2::IsFacingMe(this, entity: v8, dotThreshold: v60)) )
        {
          v61 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
          GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
          EventClass = idAIEvent::GetEventClass(this: ev);
          idFiniteStateMachine::PostEvent(this: v61, _eventId: EventClass, _eventData: ev, curTime: GameMs);
          this->aiVolatile.memory.lastFiredAtTime = idGameTimeManager::GetGameMs(
                                                      this: &clientGame->gameTimeManager,
                                                      type: GAMETIME_SCALED);
          if ( v43 != 0 )
            this->aiVolatile.memory.lastHeavyFiredAtTime = idGameTimeManager::GetGameMs(
                                                             this: &clientGame->gameTimeManager,
                                                             type: GAMETIME_SCALED);
          if ( decl->dodging.disableHintNodeUnderFire
            && (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
            && idEncounterGroupManager::GroupForHandle(
                 this: &gameLocal->encounterGroupManager,
                 handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
          {
            CurrentCombatStage = idAI2::GetCurrentCombatStage(this);
            v65 = idCombatStage::RoleToHintType(role: (const encounterGroupRole_t)this->aiVolatile.groupStatus.currentRole);
            v66 = v65;
            if ( CurrentCombatStage != nullptr && v65 != COMBAT_HINT_MAX )
            {
              combatHintClass = this->aiEditable.movement.combatHintClass;
              v68 = idEntity::GetPhysics(this);
              v69 = v68->GetOrigin(this: v68, a2: 0);
              ContainingHintNodePtr = idCombatStage::GetContainingHintNodePtr(
                                        this: CurrentCombatStage,
                                        hintType: v66,
                                        currentPos: v69,
                                        hintClass: combatHintClass);
              if ( ContainingHintNodePtr != nullptr )
                ContainingHintNodePtr->dontUseUntil = idGameTimeManager::GetGameMs(
                                                        this: &clientGame->gameTimeManager,
                                                        type: GAMETIME_SCALED)
                                                    + ai_dontUseHintTime.valueInteger;
            }
          }
          v71 = idEntity::GetPhysics(this);
          v72 = (float *)v71->GetOrigin(this: v71, a2: 0);
          v73 = this->aiVolatile.physics.moveState.GetNextPoint(this: &this->aiVolatile.physics.moveState);
          v74 = (float)(v72[1] - v73->y);
          v75 = (float)(v72[2] - v73->z);
          if ( (float)((float)((float)(*v72 - v73->x) * (float)(*v72 - v73->x))
                     + (float)((float)((float)v75 * (float)v75) + (float)((float)v74 * (float)v74))) > 65536.0
            && ai_enableScrambles.valueInteger != 0
            && this->aiEditable.behaviors.decl->runTypeBehaviors.scrambleRunIndex != -1 )
          {
            idAnimWebAI::SetAnimIndicesForRunType(
              this: this->aiVolatile.animation.animWebAnimator.ptr,
              t: ANIMWEBAI_RUNINDEXTYPE_SCRAMBLE,
              blend: true);
          }
        }
        return;
      }
      if ( aiDodgeType != AI_DODGE_TYPE_MEDIUM )
      {
        switch ( aiDodgeType )
        {
          case AI_DODGE_TYPE_HEAVY_CLOSE_RANGE:
            if ( v56 < (float)(decl->dodging.closeRangeDist * decl->dodging.closeRangeDist) )
            {
              mediumFiredAtAngle = decl->dodging.heavyFiredAtAngle;
              v43 = 1;
              goto LABEL_39;
            }
            break;
          case AI_DODGE_TYPE_HEAVY_MEDIUM_RANGE:
            if ( v56 < (float)(decl->dodging.mediumRangeDist * decl->dodging.mediumRangeDist) )
            {
              mediumFiredAtAngle = decl->dodging.heavyFiredAtAngle;
              v43 = 1;
              goto LABEL_39;
            }
            break;
          case AI_DODGE_TYPE_HEAVY_LONG_RANGE:
            v43 = 1;
            if ( v56 < (float)(decl->dodging.mediumRangeDist * decl->dodging.mediumRangeDist) )
            {
              mediumFiredAtAngle = decl->dodging.heavyFiredAtAngle;
              goto LABEL_39;
            }
            break;
          default:
            goto LABEL_39;
        }
      }
      mediumFiredAtAngle = decl->dodging.mediumFiredAtAngle;
      goto LABEL_39;
    }
  }
}


// ========================================================================
// ?OnAIEvent_Explosion@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A06E80
// RVA : 0x00A06E80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Explosion(idAI2 *this, idAIEventSound *ev)
{
  idGameLocal *v4; // r10
  idEntity *v5; // r3
  idEntity *v6; // r29
  idFaction *v7; // r3
  idEncounterGroup *v8; // r3
  idFiniteStateMachine *v9; // r25
  int GameMs; // r24
  idAIEvent::aiEventClass_t EventClass; // r3
  idAIGameState *p_aiGameState; // r25
  const idVec3 *v13; // r24
  const idSpawnId *v14; // r23
  const idAILogic *v15; // r3
  const idSpawnId *v16; // r8
  idPhysics *Physics; // r28
  int v18; // r30
  idPhysics *v19; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r27
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // r9
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r28
  const idVec3 *v23; // r3
  idSpawnId v24; // [sp+50h] [-80h] BYREF
  idAIEventManager v25; // [sp+54h] [-7Ch] BYREF

  if ( !idAI2::IsPlayerControlled(this) && this->aiVolatile.fsms.alertCycle < ALERTCYCLE_COMBAT )
  {
    v4 = gameLocal;
    if ( gameLocal->spawnIds.ptr[ev->instigator.spawnId.value & 0x1FFF] == ev->instigator.spawnId.value >> 13
      && (v5 = gameLocal->entities.ptr[ev->instigator.spawnId.value & 0x1FFF]) != nullptr )
    {
      v6 = idEntity::CastTo(c: v5);
      if ( v6 != nullptr )
      {
        v7 = this->GetFaction(this);
        if ( idFaction::GetAttitudeTowards(this: v7, otherEnt: v6) >= ATTITUDE_NEUTRAL )
          return;
      }
      v4 = gameLocal;
    }
    else
    {
      v6 = nullptr;
    }
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &v4->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
        v8 = nullptr;
      else
        v8 = idEncounterGroupManager::GroupForHandle(
               this: &gameLocal->encounterGroupManager,
               handle: &this->aiVolatile.encounterGroupHandle);
      idEncounterGroup::AnyMemberHighestAlertCycle(this: v8);
    }
    v9 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    EventClass = idAIEvent::GetEventClass(this: ev);
    idFiniteStateMachine::PostEvent(this: v9, _eventId: EventClass, _eventData: ev, curTime: GameMs);
    if ( v6 != nullptr && idAI2::GetAlertCycle(this) < ALERTCYCLE_COMBAT )
    {
      p_aiGameState = &gameLocal->aiGameState;
      v13 = (const idVec3 *)idSpawnId::idSpawnId(this: &v24, ent: v6);
      v14 = idSpawnId::idSpawnId(this: (idSpawnId *)&v25, ent: v6);
      v15 = idAILogic::idAILogic(this: (idAILogic *)&v25.eventList.granularity, ai: this);
      idAIWorldState::AddEntityStateFakePosition(
        this: &this->aiVolatile.world.worldState,
        gameState: p_aiGameState,
        owner: v15,
        entId: v14,
        stimulusType: AISTIMULUS_HEARING,
        stimulusAmount: 1.0,
        sourceId: v16,
        fakePosition: v13);
      if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
      {
        Physics = idEntity::GetPhysics(this);
        v18 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        v19 = Physics;
        GetOrigin = Physics->GetOrigin;
        declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
        p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
        v23 = GetOrigin(this: v19, a2: 0);
        idAIEventManager::AddEvent(
          this: &v25,
          result: p_aiEventManager,
          eventDecl: declBehaviorEvents->heardSomethingVoiceEventDecl,
          curTime: v18,
          originator: this,
          instigator: v6,
          origin: v23,
          delay: 500);
      }
    }
  }
}


// ========================================================================
// ?OnAIEvent_ProjectileImpact@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A070E0
// RVA : 0x00A070E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_ProjectileImpact(idAI2 *this, idAIEventSound *ev)
{
  int value; // r10
  idEntity *v5; // r3
  idEntity *v6; // r25
  idEncounterGroup *v7; // r3
  idPhysics *Physics; // r3
  idFiniteStateMachine *v9; // r30
  int GameMs; // r29
  idAIEvent::aiEventClass_t EventClass; // r3
  idAIGameState *p_aiGameState; // r30
  const idSpawnId *v13; // r26
  const idAILogic *v14; // r3
  const idSpawnId *v15; // r8
  idPhysics *v16; // r30
  int v17; // r29
  idPhysics *v18; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r28
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // r9
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r30
  const idVec3 *v22; // r3
  idSpawnId v23; // [sp+50h] [-80h] BYREF
  idAIEventManager v24; // [sp+54h] [-7Ch] BYREF

  value = ev->instigator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v6 = idEntity::CastTo(c: v5);
  }
  else
  {
    v6 = nullptr;
  }
  if ( !idAI2::IsPlayerControlled(this) && this->aiVolatile.fsms.alertCycle < ALERTCYCLE_COMBAT )
  {
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v7 = (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::AnyMemberHighestAlertCycle(this: v7) == ALERTCYCLE_RELAXED )
      {
        Physics = idEntity::GetPhysics(this);
        Physics->GetOrigin(this: Physics, a2: 0);
      }
    }
    v9 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    EventClass = idAIEvent::GetEventClass(this: ev);
    idFiniteStateMachine::PostEvent(this: v9, _eventId: EventClass, _eventData: ev, curTime: GameMs);
  }
  if ( v6 != nullptr )
  {
    p_aiGameState = &gameLocal->aiGameState;
    idSpawnId::idSpawnId(this: &v23, ent: v6);
    v13 = idSpawnId::idSpawnId(this: (idSpawnId *)&v24, ent: v6);
    v14 = idAILogic::idAILogic(this: (idAILogic *)&v24.eventList.granularity, ai: this);
    idAIWorldState::AddEntityState(
      this: &this->aiVolatile.world.worldState,
      gameState: p_aiGameState,
      owner: v14,
      entId: v13,
      stimulusType: AISTIMULUS_HEARING,
      stimulusAmount: 1.0,
      sourceId: v15);
    if ( !idAI2::IsPlayerControlled(this)
      && this->aiVolatile.fsms.alertCycle < ALERTCYCLE_COMBAT
      && this->aiEditable.behaviors.declBehaviorEvents != nullptr )
    {
      v16 = idEntity::GetPhysics(this);
      v17 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      v18 = v16;
      GetOrigin = v16->GetOrigin;
      declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
      p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
      v22 = GetOrigin(this: v18, a2: 0);
      idAIEventManager::AddEvent(
        this: &v24,
        result: p_aiEventManager,
        eventDecl: declBehaviorEvents->heardSomethingVoiceEventDecl,
        curTime: v17,
        originator: this,
        instigator: v6,
        origin: v22,
        delay: 500);
    }
  }
}


// ========================================================================
// ?OnAIEvent_DeadBodyLand@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A07348
// RVA : 0x00A07348
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_DeadBodyLand(idAI2 *this, idAIEventSound *ev)
{
  idGameLocal *v4; // r11
  idEntity *v5; // r3
  idEntity *v6; // r3
  const idEntity *v7; // r28
  idEncounterGroup *v8; // r3
  idFiniteStateMachine *v9; // r25
  int GameMs; // r24
  idAIEvent::aiEventClass_t EventClass; // r3
  idAIGameState *p_aiGameState; // r26
  const idSpawnId *v13; // r24
  const idAILogic *v14; // r3
  const idSpawnId *v15; // r8
  idPhysics *Physics; // r29
  int v17; // r30
  idPhysics *v18; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r27
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // r9
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r29
  const idVec3 *v22; // r3
  idSpawnId v23; // [sp+50h] [-80h] BYREF
  idAIEventManager v24; // [sp+54h] [-7Ch] BYREF

  if ( !idAI2::IsPlayerControlled(this) && this->aiVolatile.fsms.alertCycle < ALERTCYCLE_COMBAT )
  {
    v4 = gameLocal;
    if ( gameLocal->spawnIds.ptr[ev->instigator.spawnId.value & 0x1FFF] == ev->instigator.spawnId.value >> 13
      && (v5 = gameLocal->entities.ptr[ev->instigator.spawnId.value & 0x1FFF]) != nullptr )
    {
      v6 = idEntity::CastTo(c: v5);
      v4 = gameLocal;
      v7 = v6;
    }
    else
    {
      v7 = nullptr;
    }
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &v4->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
        v8 = nullptr;
      else
        v8 = idEncounterGroupManager::GroupForHandle(
               this: &gameLocal->encounterGroupManager,
               handle: &this->aiVolatile.encounterGroupHandle);
      idEncounterGroup::AnyMemberHighestAlertCycle(this: v8);
    }
    v9 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    EventClass = idAIEvent::GetEventClass(this: ev);
    idFiniteStateMachine::PostEvent(this: v9, _eventId: EventClass, _eventData: ev, curTime: GameMs);
    if ( v7 != nullptr && idAI2::GetAlertCycle(this) < ALERTCYCLE_COMBAT )
    {
      p_aiGameState = &gameLocal->aiGameState;
      idSpawnId::idSpawnId(this: &v23, ent: v7);
      v13 = idSpawnId::idSpawnId(this: (idSpawnId *)&v24, ent: v7);
      v14 = idAILogic::idAILogic(this: (idAILogic *)&v24.eventList.granularity, ai: this);
      idAIWorldState::AddEntityState(
        this: &this->aiVolatile.world.worldState,
        gameState: p_aiGameState,
        owner: v14,
        entId: v13,
        stimulusType: AISTIMULUS_HEARING,
        stimulusAmount: 1.0,
        sourceId: v15);
      if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
      {
        Physics = idEntity::GetPhysics(this);
        v17 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        v18 = Physics;
        GetOrigin = Physics->GetOrigin;
        declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
        p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
        v22 = GetOrigin(this: v18, a2: 0);
        idAIEventManager::AddEvent(
          this: &v24,
          result: p_aiEventManager,
          eventDecl: declBehaviorEvents->heardSomethingVoiceEventDecl,
          curTime: v17,
          originator: this,
          instigator: v7,
          origin: v22,
          delay: 500);
      }
    }
  }
}


// ========================================================================
// ?OnAIEvent_DoorMotion@idAI2@@AAAXPBVidAIEventSound@@@Z
// EA  : 0x82A07578
// RVA : 0x00A07578
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_DoorMotion(idAI2 *this, idAIEventSound *ev)
{
  int value; // r10
  idEntity *v5; // r3
  idEntity *v6; // r27
  idEncounterGroup *v7; // r3
  idPhysics *Physics; // r3
  idPhysics *v9; // r30
  int GameMs; // r29
  idPhysics *v11; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r23
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r30
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  const idVec3 *v15; // r3
  idFiniteStateMachine *v16; // r30
  int v17; // r29
  idAIEvent::aiEventClass_t EventClass; // r3
  idAIGameState *p_aiGameState; // r30
  const idVec3 *v20; // r29
  const idSpawnId *v21; // r28
  const idAILogic *v22; // r3
  const idSpawnId *v23; // r8
  idAIEventManager v24; // [sp+50h] [-80h] BYREF

  value = ev->instigator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v5 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v6 = idEntity::CastTo(c: v5);
  }
  else
  {
    v6 = nullptr;
  }
  if ( !idAI2::IsPlayerControlled(this) && this->aiVolatile.fsms.alertCycle < ALERTCYCLE_COMBAT )
  {
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
      && idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
    {
      v7 = (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
         ? nullptr
         : idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::AnyMemberHighestAlertCycle(this: v7) == ALERTCYCLE_RELAXED )
      {
        Physics = idEntity::GetPhysics(this);
        Physics->GetOrigin(this: Physics, a2: 0);
      }
    }
    if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
    {
      v9 = idEntity::GetPhysics(this);
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      v11 = v9;
      declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
      GetOrigin = v9->GetOrigin;
      p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
      v15 = GetOrigin(this: v11, a2: 0);
      idAIEventManager::AddEvent(
        this: &v24,
        result: p_aiEventManager,
        eventDecl: declBehaviorEvents->heardSomethingVoiceEventDecl,
        curTime: GameMs,
        originator: this,
        instigator: v6,
        origin: v15,
        delay: 500);
    }
  }
  v16 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
  v17 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  EventClass = idAIEvent::GetEventClass(this: ev);
  idFiniteStateMachine::PostEvent(this: v16, _eventId: EventClass, _eventData: ev, curTime: v17);
  if ( v6 != nullptr )
  {
    p_aiGameState = &gameLocal->aiGameState;
    v20 = (const idVec3 *)idSpawnId::idSpawnId(this: (idSpawnId *)&v24, ent: v6);
    v21 = idSpawnId::idSpawnId(this: (idSpawnId *)&v24.eventList.num, ent: v6);
    v22 = idAILogic::idAILogic(this: (idAILogic *)&v24.eventHash, ai: this);
    idAIWorldState::AddEntityStateFakePosition(
      this: &this->aiVolatile.world.worldState,
      gameState: p_aiGameState,
      owner: v22,
      entId: v21,
      stimulusType: AISTIMULUS_HEARING,
      stimulusAmount: 1.0,
      sourceId: v23,
      fakePosition: v20);
  }
}


// ========================================================================
// ?OnAIEvent_Projectile@idAI2@@AAAXPBVidAIEventProjectile@@@Z
// EA  : 0x82A077C8
// RVA : 0x00A077C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Projectile(idAI2 *this, const idAIEventProjectile *ev)
{
  int value; // r10
  idEntity *v4; // r3
  idEntity *v5; // r3
  idEntity *v6; // r30
  idPhysics *Physics; // r3
  float *v8; // r3
  idAIOrientation *BodyOrientation; // r3
  char *v10; // r10
  _DWORD *p_z; // r11
  int i; // ctr
  idAIGameState *p_aiGameState; // r29
  const idSpawnId *v14; // r30
  const idAILogic *v15; // r3
  float v16; // [sp+50h] [-E0h]
  float v17; // [sp+54h] [-DCh]
  float v18; // [sp+58h] [-D8h]
  idVec3 v19; // [sp+60h] [-D0h] BYREF
  float v20[3]; // [sp+70h] [-C0h] BYREF
  idSpawnId v21; // [sp+7Ch] [-B4h] BYREF
  idSpawnId v22; // [sp+80h] [-B0h] BYREF
  char v23; // [sp+8Ch] [-A4h] BYREF
  idVec3 v24[4]; // [sp+90h] [-A0h] BYREF
  idAILogic v25; // [sp+C0h] [-70h] BYREF
  char v26; // [sp+E0h] [-50h] BYREF

  value = ev->originator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v4 = gameLocal->entities.ptr[value & 0x1FFF];
    if ( v4 != nullptr )
    {
      v5 = idEntity::CastTo(c: v4);
      v6 = v5;
      if ( v5 != nullptr
        && !v5->IsDead(this: v5)
        && !idAIMemory::IsIgnoringProjectile(this: &this->aiVolatile.memory, ent: v6) )
      {
        Physics = idEntity::GetPhysics(this: v6);
        v8 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
        v16 = *v8;
        v17 = v8[1];
        v18 = v8[2];
        this->GetLastEyePos(this, a2: (idVec3 *)v20);
        this->GetEyeAxis(this, a2: (idMat3 *)&v26);
        BodyOrientation = idAI2::GetBodyOrientation(this);
        v10 = &v23;
        p_z = (_DWORD *)&BodyOrientation->idealDir.z;
        for ( i = 9; i != 0; --i )
        {
          ++p_z;
          v10 += 4;
          *(_DWORD *)v10 = *p_z;
        }
        v19.x = v16 - v20[0];
        v19.y = v17 - v20[1];
        v19.z = v18 - v20[2];
        idVec3::NormalizeFast(this: &v19);
        if ( idAIVisibility::CheckFOV(dir: &v19, eyeFwd: v24, cosFOV: this->aiVolatile.perception.fovDot) > 0.0 )
        {
          this->aiVolatile.memory.avoidEntity.spawnId.value = (gameLocal->spawnIds.ptr[v6->entityNumber] << 13)
                                                            | v6->entityNumber;
          p_aiGameState = &gameLocal->aiGameState;
          idSpawnId::idSpawnId(this: &v22, ent: this);
          v14 = idSpawnId::idSpawnId(this: &v21, ent: v6);
          v15 = idAILogic::idAILogic(this: &v25, ai: this);
          idAIWorldState::AddEntityState(
            this: &this->aiVolatile.world.worldState,
            gameState: p_aiGameState,
            owner: v15,
            entId: v14,
            stimulusType: AISTIMULUS_HEARING,
            stimulusAmount: 1.0,
            sourceId: (const idSpawnId *)0x82000000);
        }
      }
    }
  }
}


// ========================================================================
// ?OnAIEvent_Grenade@idAI2@@AAAXPBVidAIEventProjectedSphere@@@Z
// EA  : 0x82A079E0
// RVA : 0x00A079E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Grenade(idAI2 *this, idAIEventProjectedSphere *ev)
{
  int value; // r10
  idEntity *v5; // r3
  idEntity *v6; // r3
  idEntity *v7; // r29
  idPlayer *Instigator; // r3
  double v9; // fp31
  idFaction *v10; // r3
  idPhysics *Physics; // r3
  float *v12; // r3
  idAIGameState *p_aiGameState; // r25
  const idSpawnId *v14; // r29
  const idAILogic *v15; // r3
  const idSpawnId *v16; // r8
  const idEntity *v17; // r29
  idAIGameState *v18; // r30
  const idSpawnId *v19; // r29
  const idAILogic *v20; // r3
  const idSpawnId *v21; // r8
  idFiniteStateMachine *v22; // r31
  int GameMs; // r30
  idAIEvent::aiEventClass_t EventClass; // r3
  idSpawnId v25; // [sp+50h] [-90h] BYREF
  idSpawnId v26; // [sp+54h] [-8Ch] BYREF
  char v27; // [sp+58h] [-88h] BYREF
  idAILogic v28; // [sp+70h] [-70h] BYREF

  value = ev->originator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v5 = gameLocal->entities.ptr[value & 0x1FFF];
    if ( v5 != nullptr )
    {
      v6 = idEntity::CastTo(c: v5);
      v7 = v6;
      if ( v6 != nullptr
        && !v6->IsDead(this: v6)
        && !idAIMemory::IsIgnoringProjectile(this: &this->aiVolatile.memory, ent: v7) )
      {
        Instigator = (idPlayer *)idAIEvent::GetInstigator(this: ev);
        if ( idPlayer::CastTo(c: Instigator) == nullptr || ev->hasProjection )
        {
          v9 = 10000.0;
          v10 = (idFaction *)v7->GetFaction_2(this: v7);
          if ( v10 != nullptr && idFaction::GetAttitudeTowards(this: v10, otherEnt: this) >= ATTITUDE_NEUTRAL )
            v9 = 10.0;
          Physics = idEntity::GetPhysics(this: v7);
          v12 = (float *)Physics->GetLinearVelocity(this: (idPhysics *)&v27, result: (idVec3 *)Physics, a3: 0);
          if ( (float)((float)(v12[2] * v12[2]) + (float)((float)(*v12 * *v12) + (float)(v12[1] * v12[1]))) <= (double)(float)((float)v9 * (float)v9) )
          {
            this->aiVolatile.memory.avoidEntity.spawnId.value = (gameLocal->spawnIds.ptr[v7->entityNumber] << 13)
                                                              | v7->entityNumber;
            p_aiGameState = &gameLocal->aiGameState;
            idSpawnId::idSpawnId(this: &v25, ent: this);
            v14 = idSpawnId::idSpawnId(this: &v26, ent: v7);
            v15 = idAILogic::idAILogic(this: &v28, ai: this);
            idAIWorldState::AddEntityState(
              this: &this->aiVolatile.world.worldState,
              gameState: p_aiGameState,
              owner: v15,
              entId: v14,
              stimulusType: AISTIMULUS_HEARING,
              stimulusAmount: 1.0,
              sourceId: v16);
            v17 = idAIEvent::GetInstigator(this: ev);
            if ( v17 != nullptr )
            {
              v18 = &gameLocal->aiGameState;
              idSpawnId::idSpawnId(this: &v26, ent: this);
              v19 = idSpawnId::idSpawnId(this: &v25, ent: v17);
              v20 = idAILogic::idAILogic(this: &v28, ai: this);
              idAIWorldState::AddEntityState(
                this: &this->aiVolatile.world.worldState,
                gameState: v18,
                owner: v20,
                entId: v19,
                stimulusType: AISTIMULUS_GUNFIRE,
                stimulusAmount: 1.0,
                sourceId: v21);
            }
            v22 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type);
            GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
            EventClass = idAIEvent::GetEventClass(this: ev);
            idFiniteStateMachine::PostEvent(this: v22, _eventId: EventClass, _eventData: ev, curTime: GameMs);
          }
        }
      }
    }
  }
}


// ========================================================================
// ?OnAIEvent_Vehicle@idAI2@@AAAXPBVidAIEvent_Vehicle@@@Z
// EA  : 0x82A07C80
// RVA : 0x00A07C80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent_Vehicle(idAI2 *this, idAIEvent_Vehicle *ev)
{
  int value; // r10
  idEntity *v5; // r3
  idEntity *v6; // r3
  idVehicle *v7; // r27
  idVehicle *v8; // r3
  const idEntity *Instigator; // r3
  const idEntity *v10; // r29
  idFaction *v11; // r3
  idAIGameState *v12; // r26
  const idSpawnId *v13; // r29
  const idAILogic *v14; // r3
  const idSpawnId *v15; // r8
  idAIGameState *p_aiGameState; // r30
  const idSpawnId *v17; // r28
  const idAILogic *v18; // r3
  const idSpawnId *v19; // r8
  idSpawnId v20; // [sp+50h] [-80h] BYREF
  idSpawnId v21[3]; // [sp+54h] [-7Ch] BYREF
  idAILogic v22; // [sp+60h] [-70h] BYREF

  value = ev->originator.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v5 = gameLocal->entities.ptr[value & 0x1FFF];
    if ( v5 != nullptr )
    {
      v6 = idEntity::CastTo(c: v5);
      v7 = (idVehicle *)v6;
      if ( v6 != nullptr && !v6->IsDead(this: v6) )
      {
        v8 = idVehicle::CastTo(c: v7);
        if ( v8 == nullptr || idVehicle::GetDriver(this: v8) != nullptr )
        {
          Instigator = idAIEvent::GetInstigator(this: ev);
          v10 = Instigator;
          if ( Instigator == nullptr )
          {
LABEL_12:
            this->aiVolatile.memory.avoidEntity.spawnId.value = (gameLocal->spawnIds.ptr[v7->entityNumber] << 13)
                                                              | v7->entityNumber;
            p_aiGameState = &gameLocal->aiGameState;
            idSpawnId::idSpawnId(this: v21, ent: this);
            v17 = idSpawnId::idSpawnId(this: &v20, ent: v7);
            v18 = idAILogic::idAILogic(this: &v22, ai: this);
            idAIWorldState::AddEntityState(
              this: &this->aiVolatile.world.worldState,
              gameState: p_aiGameState,
              owner: v18,
              entId: v17,
              stimulusType: AISTIMULUS_HEARING,
              stimulusAmount: 1.0,
              sourceId: v19);
            return;
          }
          v11 = (idFaction *)Instigator->GetFaction_2(this: Instigator);
          if ( !this->aiEditable.movement.ignoreFriendlyVehicles
            || v11 == nullptr
            || idFaction::GetAttitudeTowards(this: v11, otherEnt: this) <= ATTITUDE_NEUTRAL )
          {
            v12 = &gameLocal->aiGameState;
            idSpawnId::idSpawnId(this: &v20, ent: this);
            v13 = idSpawnId::idSpawnId(this: v21, ent: v10);
            v14 = idAILogic::idAILogic(this: &v22, ai: this);
            idAIWorldState::AddEntityState(
              this: &this->aiVolatile.world.worldState,
              gameState: v12,
              owner: v14,
              entId: v13,
              stimulusType: AISTIMULUS_GUNFIRE,
              stimulusAmount: 1.0,
              sourceId: v15);
            goto LABEL_12;
          }
        }
      }
    }
  }
}


// ========================================================================
// ?StartMoveToCover@idAI2@@QAA_NABVidAICover@@PAVidAIFSM@@PAVidAIState@@_NH@Z
// EA  : 0x82A07E50
// RVA : 0x00A07E50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::StartMoveToCover(
        idAI2 *this,
        idAICover *cover,
        idAIFSM *fsm,
        idAIState *state,
        bool allowWalk,
        const int curTime)
{
  idPhysics *Physics; // r3
  float *v14; // r28
  const idVec3 *Origin; // r3
  double v16; // fp10
  double v17; // fp6
  double v18; // fp31
  posture_t CoverPosture; // r27
  char v20; // r22
  const idDeclAIBehavior *decl; // r11
  double injuredCrouchMoveMax; // fp0
  idEventArg *v23; // r3
  idPhysics *v24; // r3
  float *v25; // r3
  coverOrientation_t BestCoverOrientation; // r3
  const idMat3 *v27; // r3
  idPhysics *v28; // r21
  const idVec3 *v29; // r20
  float *v30; // r3
  double v31; // fp13
  double v32; // fp12
  const idVec3 *v33; // r3
  double y; // fp10
  double z; // fp9
  idEventArg *v36; // r30
  int GameMs; // r3
  char v38; // r28
  char v39; // r29
  aiSenseState_t *EnemySenseState; // r30
  idPhysics *v41; // r3
  float *v42; // r27
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  double v44; // fp7
  double v45; // fp6
  idPhysics *v46; // r3
  float *v47; // r30
  const idVec3 *v48; // r3
  double v49; // fp0
  double x; // fp12
  double v51; // fp13
  idAIOrientation *BodyOrientation; // r3
  int v53; // r30
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r29
  int value; // r8
  idEntity *v56; // r3
  idEntity *v57; // r5
  aiFireMode_t v58; // r5
  idAIOrientation *v59; // r3
  int v60; // r30
  idAI2::idAIVolatile::idAIFocusInfo *v61; // r29
  const idEntity *Enemy; // r3
  idAIOrientation *v63; // r3
  idAICombatHint::combatHintType_t v64; // r30
  idAICombatHint::combatHintClass_t combatHintClass; // r28
  const idVec3 *v66; // r27
  idCombatStage *CurrentCombatStage; // r3
  idAICombatHint *ContainingHintNodePtr; // r3
  idAICombatHint *v69; // r30
  idPhysics *v70; // r3
  float *v71; // r3
  idAICombatHint::combatHintClass_t hintClass; // r11
  const idEventArg *v73; // [sp+8h] [-328h]
  const idEventArg *v74; // [sp+Ch] [-324h]
  _BYTE v75[20]; // [sp+70h] [-2C0h] BYREF
  _BYTE v76[20]; // [sp+90h] [-2A0h] BYREF
  _BYTE v77[20]; // [sp+B0h] [-280h] BYREF
  _BYTE v78[20]; // [sp+D0h] [-260h] BYREF
  _BYTE v79[20]; // [sp+F0h] [-240h] BYREF
  idVec3 v80; // [sp+110h] [-220h] BYREF
  idVec3 v81; // [sp+120h] [-210h] BYREF
  idRotation v82; // [sp+130h] [-200h] BYREF
  float v83[5]; // [sp+180h] [-1B0h] BYREF
  float v84[5]; // [sp+1A0h] [-190h] BYREF
  idEventReceiver v85[2]; // [sp+1C0h] [-170h] BYREF
  idEventArg v86; // [sp+1E0h] [-150h] BYREF
  _DWORD v87[5]; // [sp+200h] [-130h] BYREF
  _DWORD v88[5]; // [sp+220h] [-110h] BYREF
  idMat3 v89; // [sp+240h] [-F0h] BYREF
  idEventReceiver v90[2]; // [sp+270h] [-C0h] BYREF
  idEventArg v91; // [sp+290h] [-A0h] BYREF

  if ( !idAICover::IsValid(this: cover) )
    return 0;
  Physics = idEntity::GetPhysics(this);
  v14 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  Origin = idAICover::GetOrigin(this: cover);
  v16 = (float)(Origin->z - v14[2]);
  v17 = (float)(Origin->y - v14[1]);
  v18 = (float)((float)((float)v17 * (float)v17)
              + (float)((float)((float)(Origin->x - *v14) * (float)(Origin->x - *v14)) + (float)((float)v16 * (float)v16)));
  CoverPosture = idAICover::GetCoverPosture(this: cover);
  v20 = 0;
  if ( this->GetPosture(this) == POSTURE_CROUCHED )
  {
    decl = this->aiEditable.behaviors.decl;
    if ( (this->aiVolatile.groupStatus.condition & 8) != 0 )
      injuredCrouchMoveMax = decl->movementBehaviors.injuredCrouchMoveMax;
    else
      injuredCrouchMoveMax = decl->movementBehaviors.crouchMoveMax;
    if ( CoverPosture == POSTURE_CROUCHED && v18 <= (float)((float)injuredCrouchMoveMax * (float)injuredCrouchMoveMax) )
    {
      v20 = 1;
      this->SetWalkState(this, a2: WALKSTATE_WALKING);
    }
    else if ( ai_useTransitions.valueInteger != 0 && ai_useStartTransitions.valueInteger != 0 )
    {
      this->SetPosture(this, a2: POSTURE_STANDING);
    }
    else
    {
      v23 = idEventArg::idEventArg(this: &v86, data: this);
      idEventReceiver::ProcessEvent(
        this: v85,
        result: (idEventArg *)&this->aiVolatile.fsms.actionManager.legsFSM.actionsQueue,
        ev: *(const idEventDef **)&v23->type,
        arg1: (const idEventArg *)LODWORD(v23->value.v[1]));
    }
  }
  idAICover::GetAxis(this: cover, axis: &v89);
  v24 = idEntity::GetPhysics(this);
  v25 = (float *)v24->GetGravityNormal(this: v24);
  v82.origin.x = vec3_origin.x;
  v82.origin.y = vec3_origin.y;
  v82.origin.z = vec3_origin.z;
  v82.vec.x = *v25;
  v82.vec.y = v25[1];
  v82.vec.z = v25[2];
  v82.axisValid = false;
  v82.angle = 180.0;
  v82.axis.mat[0].x = mat3_identity.mat[0].x;
  v82.axis.mat[0].y = mat3_identity.mat[0].y;
  v82.axis.mat[0].z = mat3_identity.mat[0].z;
  v82.axis.mat[1].x = mat3_identity.mat[1].x;
  v82.axis.mat[1].y = mat3_identity.mat[1].y;
  v82.axis.mat[1].z = mat3_identity.mat[1].z;
  v82.axis.mat[2].x = mat3_identity.mat[2].x;
  v82.axis.mat[2].y = mat3_identity.mat[2].y;
  v82.axis.mat[2].z = mat3_identity.mat[2].z;
  BestCoverOrientation = idAIBehaviors::FindBestCoverOrientation(this: &this->aiEditable.behaviors, ai: this, cover);
  this->aiVolatile.cover.coverOrientation = BestCoverOrientation;
  if ( BestCoverOrientation == COVERORIENT_BACKWARD )
  {
    v27 = idRotation::ToMat3(this: &v82);
    idMat3::operator*=(this: &v89, a: v27);
  }
  v28 = idEntity::GetPhysics(this);
  v29 = idAICover::GetOrigin(this: cover);
  v30 = (float *)v28->GetOrigin(this: v28, a2: 0);
  if ( allowWalk )
  {
    v31 = (float)(v30[1] - v29->y);
    v32 = (float)(v30[2] - v29->z);
    idAI2::GetDesiredWalkStateForDistance(
      this,
      distance: __fsqrts((float)((float)((float)(*v30 - v29->x) * (float)(*v30 - v29->x))
                     + (float)((float)((float)v32 * (float)v32) + (float)((float)v31 * (float)v31)))),
      maxWalkState: (const walkState_t)~((curTime - this->aiVolatile.memory.lastFiredAtTime) ^ 0x7D0),
      firedAt: WALKSTATE_RUNNING,
      a5: ((curTime - this->aiVolatile.memory.lastFiredAtTime >= 0)
     + ((unsigned int)(curTime - this->aiVolatile.memory.lastFiredAtTime) >= 0x7D0))
    & 1);
  }
  this->SetWalkState(this, a2: WALKSTATE_RUNNING);
  v87[1] = CoverPosture;
  v84[1] = v89.mat[0].x;
  v88[1] = 1;
  v84[2] = v89.mat[0].y;
  HIBYTE(v88[0]) = 105;
  v84[3] = v89.mat[0].z;
  HIBYTE(v84[0]) = 118;
  HIBYTE(v87[0]) = 105;
  HIBYTE(v85[0].__vftable) = 105;
  v85[0].listenerList = (idList<idEventReceiver *,5> *)2;
  v33 = idAICover::GetOrigin(this: cover);
  HIBYTE(v83[0]) = 118;
  v86.type = 105;
  v86.value.i = 32;
  y = v33->y;
  z = v33->z;
  v83[1] = v33->x;
  v83[2] = y;
  v83[3] = z;
  v36 = idEventArg::idEventArg(this: &v91, data: this);
  memcpy(Dst: v79, Src: v84, Size: sizeof(v79));
  memcpy(Dst: v78, Src: v88, Size: sizeof(v78));
  memcpy(Dst: v77, Src: v87, Size: sizeof(v77));
  memcpy(Dst: v76, Src: v85, Size: sizeof(v76));
  memcpy(Dst: v75, Src: v83, Size: sizeof(v75));
  idEventReceiver::ProcessEvent(
    this: v90,
    result: (idEventArg *)&this->aiVolatile.fsms.actionManager.legsFSM.actionsQueue,
    ev: *(const idEventDef **)&v36->type,
    arg1: (const idEventArg *)LODWORD(v36->value.v[1]),
    arg2: (const idEventArg *)LODWORD(v36->value.v[2]),
    arg3: (const idEventArg *)__ROL4__(*(_DWORD *)&v86.type, 32),
    arg4: (const idEventArg *)LODWORD(v86.value.v[1]),
    arg5: (const idEventArg *)LODWORD(v86.value.v[2]),
    arg6: v73,
    arg7: v74);
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  idAIState::StartQueuedActions(this: state, ai: this, parentFSM: fsm, curTime: GameMs);
  idAICover::Reserve(this: cover, reserver: this);
  v38 = 0;
  v39 = 0;
  v80.x = 1.0;
  v80.y = 0.0;
  v80.z = 0.0;
  EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
  if ( EnemySenseState != nullptr )
  {
    v41 = idEntity::GetPhysics(this);
    v42 = (float *)v41->GetOrigin(this: v41, a2: 0);
    ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: EnemySenseState);
    v44 = (float)(ConfirmedPhysicalSafe->origin.y - v42[1]);
    v45 = (float)(ConfirmedPhysicalSafe->origin.z - v42[2]);
    v80.x = ConfirmedPhysicalSafe->origin.x - *v42;
    v80.y = v44;
    v80.z = v45;
    idVec3::NormalizeFast(this: &v80);
  }
  v46 = idEntity::GetPhysics(this);
  v47 = (float *)v46->GetOrigin(this: v46, a2: 0);
  v48 = idAICover::GetOrigin(this: cover);
  v49 = (float)(v48->y - v47[1]);
  x = (float)(v48->x - *v47);
  v51 = (float)(v48->z - v47[2]);
  v81.y = v48->y - v47[1];
  v81.x = x;
  v81.z = v51;
  if ( (float)((float)((float)v51 * (float)v51)
             + (float)((float)((float)x * (float)x) + (float)((float)v49 * (float)v49))) > 1.0 )
  {
    idVec3::NormalizeFast(this: &v81);
    x = v81.x;
  }
  if ( v20 != 0 || this->aiConstants.movement.allowStrafing )
  {
    v38 = 1;
  }
  else if ( (float)((float)((float)x * v80.x) + (float)((float)(v81.z * v80.z) + (float)(v81.y * v80.y))) <= 0.70700002 )
  {
    if ( this->aiConstants.movement.useMoveFSM )
      v39 = 1;
  }
  else
  {
    v39 = 1;
  }
  if ( v38 != 0 )
  {
    BodyOrientation = idAI2::GetBodyOrientation(this);
    idAIOrientation::SetIdealDir(this: BodyOrientation, ai: this, dir: &v80);
    this->aiVolatile.focus.enableHeadTracking = true;
    v53 = 2;
    p_focus = &this->aiVolatile.focus;
    do
    {
      idFocusInfo::SetEnableTracking(this: p_focus->foci.ptr, owner: this, enable: true);
      --v53;
      p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)p_focus + 272);
    }
    while ( v53 != 0 );
    value = this->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v56 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v57 = idEntity::CastTo(c: v56);
    }
    else
    {
      v57 = nullptr;
    }
    idFocusInfo::SetFocusEntity(
      this: this->aiVolatile.focus.foci.ptr,
      owner: this,
      _ent: v57,
      _keepFocusInView: true,
      _aimPoint: AIMPOINT_BEST,
      duration: -1);
    if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0
      && !this->aiConstants.movement.allowStrafing )
    {
      v58 = FIREMODE_SPRAYWHENREADY;
      goto LABEL_47;
    }
    goto LABEL_39;
  }
  if ( v39 != 0 )
  {
    v59 = idAI2::GetBodyOrientation(this);
    idAIOrientation::SetIdealDir(this: v59, ai: this, dir: &v81);
    this->aiVolatile.focus.enableHeadTracking = true;
    v60 = 2;
    v61 = &this->aiVolatile.focus;
    do
    {
      idFocusInfo::SetEnableTracking(this: v61->foci.ptr, owner: this, enable: true);
      --v60;
      v61 = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)v61 + 272);
    }
    while ( v60 != 0 );
    Enemy = idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
    idFocusInfo::SetFocusEntity(
      this: this->aiVolatile.focus.foci.ptr,
      owner: this,
      _ent: Enemy,
      _keepFocusInView: false,
      _aimPoint: AIMPOINT_BEST,
      duration: -1);
    if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) == 0
      || this->aiConstants.movement.allowStrafing )
    {
LABEL_39:
      v58 = FIREMODE_FIREWHENREADY;
      goto LABEL_47;
    }
    v58 = FIREMODE_SPRAYWHENREADY;
  }
  else
  {
    v63 = idAI2::GetBodyOrientation(this);
    idAIOrientation::SetIdealDir(this: v63, ai: this, dir: &v81);
    idFocusInfo::Clear(this: this->aiVolatile.focus.foci.ptr, owner: this);
    idFocusInfo::Clear(this: &this->aiVolatile.focus.foci.ptr[1], owner: this);
    v58 = FIREMODE_HOLDFIRE;
  }
LABEL_47:
  idAIFireControl::SetFireMode(this: this->aiVolatile.fireControl, owner: this, mode: v58);
  if ( this->aiVolatile.groupStatus.currentRole != ROLE_MAX && idAI2::GetCurrentCombatStage(this) != nullptr )
  {
    v64 = idCombatStage::RoleToHintType(role: (const encounterGroupRole_t)this->aiVolatile.groupStatus.currentRole);
    if ( v64 != COMBAT_HINT_MAX )
    {
      combatHintClass = this->aiEditable.movement.combatHintClass;
      v66 = idAICover::GetOrigin(this: cover);
      CurrentCombatStage = idAI2::GetCurrentCombatStage(this);
      ContainingHintNodePtr = idCombatStage::GetContainingHintNodePtr(
                                this: CurrentCombatStage,
                                hintType: v64,
                                currentPos: v66,
                                hintClass: combatHintClass);
      v69 = ContainingHintNodePtr;
      if ( ContainingHintNodePtr != nullptr )
      {
        v70 = idEntity::GetPhysics(this: ContainingHintNodePtr);
        v71 = (float *)v70->GetOrigin(this: v70, a2: 0);
        this->aiVolatile.memory.cachedDestination.x = *v71;
        this->aiVolatile.memory.cachedDestination.y = v71[1];
        this->aiVolatile.memory.cachedDestination.z = v71[2];
        hintClass = v69->hintClass;
        if ( hintClass != CLASS_ALL )
          this->aiEditable.movement.combatHintClass = hintClass;
      }
    }
  }
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    this->aiVolatile.fireControl->ResetNextPullTriggerTime(this: this->aiVolatile.fireControl, a2: this);
  return 1;
}


// ========================================================================
// ?Debug_Perception@idAI2@@QAAXXZ
// EA  : 0x82A08760
// RVA : 0x00A08760
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Debug_Perception(idAI2 *this)
{
  idPlayer *Player; // r24
  idSpawnId *v3; // r4
  char *v4; // r27
  int value; // r7
  int v6; // r30
  idEntity *v7; // r3
  idEntity *v8; // r3
  const idEntity *v9; // r5
  const idSpawnId *SpawnId; // r3
  idAIEntityState *v11; // r25
  const idSpawnId *v12; // r3
  int curAwareness; // r11
  idColor *v14; // r11
  float g; // r7
  float b; // r6
  float a; // r5
  idScenePoint *curScenePoint; // r11
  idPhysics *Physics; // r3
  int v20; // r3
  float v21; // r6
  float v22; // r5
  idPresentable *presentable; // r9
  idPresentable *v24; // r11
  float y; // r9
  float z; // r8
  float v27; // r9
  float v28; // r8
  BOOL usesRobot; // r7
  int v30; // r31
  idFaction *v31; // r3
  idRelationship::attitude_t AttitudeTowards; // r3
  float *p_x; // r6
  float *v34; // r5
  idRenderWorld *v35; // r3
  aiSenseState_t *EnemySenseState; // r3
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  float v38; // r10
  float v39; // r7
  float v40; // r3
  idAI2 *FriendlyBlocker; // r3
  idAI2 *v42; // r3
  idPhysics *v43; // r3
  int v44; // r30
  idPhysics *v45; // r3
  int v46; // r3
  float v47; // [sp+60h] [-170h] BYREF
  float v48; // [sp+64h] [-16Ch]
  float v49; // [sp+68h] [-168h]
  float x; // [sp+70h] [-160h] BYREF
  float v51; // [sp+74h] [-15Ch]
  float v52; // [sp+78h] [-158h]
  float v53; // [sp+80h] [-150h] BYREF
  float v54; // [sp+84h] [-14Ch]
  float v55; // [sp+88h] [-148h]
  idColor v56; // [sp+90h] [-140h] BYREF
  float v57; // [sp+A0h] [-130h] BYREF
  float v58; // [sp+A4h] [-12Ch]
  float v59; // [sp+A8h] [-128h]
  idAIPos v60; // [sp+B0h] [-120h] BYREF
  float v61[4]; // [sp+C0h] [-110h] BYREF
  float v62[4]; // [sp+D0h] [-100h] BYREF
  float v63[4]; // [sp+E0h] [-F0h] BYREF
  float v64[4]; // [sp+F0h] [-E0h] BYREF
  float v65[4]; // [sp+100h] [-D0h] BYREF
  float v66[3]; // [sp+110h] [-C0h] BYREF
  char v67; // [sp+11Ch] [-B4h] BYREF
  char v68; // [sp+120h] [-B0h] BYREF
  idColor v69; // [sp+130h] [-A0h] BYREF
  float v70[12]; // [sp+140h] [-90h] BYREF

  Player = idGameLocal::GetPlayer(this: gameLocal, i: 0);
  if ( Player != nullptr )
  {
    v3 = (idSpawnId *)gameLocal;
    v4 = &byte_8200D768;
    value = this->aiVolatile.memory.currentEnemy.spawnId.value;
    v6 = 0;
    v56 = idColor::colorWhite;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v7 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v8 = idEntity::CastTo(c: v7);
      v3 = (idSpawnId *)gameLocal;
      v9 = v8;
    }
    else
    {
      v9 = nullptr;
    }
    SpawnId = idGameLocal::GetSpawnId(this: (idGameLocal *)&v67, result: v3, ent: v9);
    v11 = idAIWorldState::StateForSpawnId(this: &this->aiVolatile.world.worldState, entId: SpawnId);
    if ( v11 != nullptr
      || (v12 = idGameLocal::GetSpawnId(this: (idGameLocal *)&v68, result: (idSpawnId *)gameLocal, ent: Player),
          (v11 = idAIWorldState::StateForSpawnId(this: &this->aiVolatile.world.worldState, entId: v12)) != nullptr) )
    {
      curAwareness = v11->curAwareness;
      if ( v11->curAwareness != 0 )
      {
        switch ( curAwareness )
        {
          case 1:
            v4 = "?";
            v56 = idColor::colorGreen;
            break;
          case 2:
            v4 = "?";
            v56 = idColor::colorYellow;
            break;
          case 3:
            if ( idAIEntityState::IsVisible(this: v11) )
              v14 = &idColor::colorRed;
            else
              v14 = &idColor::colorYellow;
            g = v14->g;
            b = v14->b;
            a = v14->a;
            v4 = "!";
            v56.r = v14->r;
            v56.g = g;
            v56.b = b;
            v56.a = a;
            break;
          default:
            break;
        }
      }
      else
      {
        v4 = ".";
        v56 = idColor::colorWhite;
      }
    }
    curScenePoint = this->aiVolatile.memory.curScenePoint;
    if ( curScenePoint != nullptr && (curScenePoint->scriptFlags & 1) != 0 )
    {
      v4 = "S";
      v56 = idColor::colorBlue;
    }
    Physics = idEntity::GetPhysics(this);
    v20 = (int)Physics->GetOrigin(this: Physics, a2: 0);
    v21 = *(float *)v20;
    v22 = *(float *)(v20 + 4);
    presentable = this->presentable;
    v49 = *(float *)(v20 + 8) + (float)100.0;
    v47 = v21;
    v48 = v22;
    if ( presentable == nullptr )
      idEntity::InitPresentableInternal(this);
    v24 = this->presentable;
    if ( v24 == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      v24 = this->presentable;
    }
    y = v24->axis.mat[2].y;
    z = v24->axis.mat[2].z;
    x = v24->axis.mat[2].x;
    v51 = y;
    v52 = z;
    if ( v24 == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      v24 = this->presentable;
    }
    v27 = v24->axis.mat[0].y;
    v28 = v24->axis.mat[0].z;
    usesRobot = this->aiEditable.actionSettings.customRobot.usesRobot;
    v53 = v24->axis.mat[0].x;
    v54 = v27;
    v55 = v28;
    if ( usesRobot )
    {
      this->GetEyeAxis(this, a2: (idMat3 *)v70);
      v53 = v70[0];
      v54 = v70[1];
      v55 = v70[2];
    }
    LOBYTE(v30) = 1;
    v31 = this->GetFaction(this);
    if ( v31 != nullptr )
    {
      AttitudeTowards = idFaction::GetAttitudeTowards(this: v31, otherEnt: Player);
      if ( AttitudeTowards >= ATTITUDE_DESPISE )
        v30 = (((unsigned int)AttitudeTowards >> 31) - ((unsigned int)AttitudeTowards > ATTITUDE_DISLIKE)) & 1;
    }
    if ( (_BYTE)v30 != 0 )
    {
      p_x = &x;
    }
    else
    {
      p_x = v65;
      v65[0] = -x;
      v65[1] = -v51;
      v65[2] = -v52;
    }
    if ( (_BYTE)v30 != 0 )
    {
      v34 = &v47;
    }
    else
    {
      v34 = v61;
      v61[0] = v47;
      v61[1] = v48;
      v61[2] = v49 + (float)30.0;
    }
    ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, float *, double))clientGame->renderWorld->DebugPyramid)(
      a1: clientGame->renderWorld,
      a2: &v56,
      a3: v34,
      a4: p_x,
      a5: &v53,
      a6: 30.0);
    v66[0] = (float)(v53 * (float)10.0) + v47;
    v66[1] = (float)(v54 * (float)10.0) + v48;
    v66[2] = (float)(v55 * (float)10.0) + v49;
    ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))clientGame->renderWorld->DebugArrow3)(
      a1: clientGame->renderWorld,
      a2: &v56,
      a3: &v47,
      a4: v66,
      a5: 3.0);
    if ( (this->aiVolatile.perception.flags & 1) != 0 )
    {
      v63[0] = (float)(x * (float)5.0) + v47;
      v63[1] = (float)(v51 * (float)5.0) + v48;
      v63[2] = (float)(v52 * (float)5.0) + v49;
      ((void (__fastcall *)(idRenderWorld *, const char *, float *, idRenderWorld_vtbl *, idColor *, int, _DWORD, _DWORD, double))clientGame->renderWorld->DebugText)(
        a1: clientGame->renderWorld,
        a2: "X",
        a3: v63,
        a4: clientGame->renderWorld->__vftable,
        a5: &v56,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 1.0);
    }
    else
    {
      v64[0] = (float)(x * (float)10.0) + v47;
      v64[1] = (float)(v51 * (float)10.0) + v48;
      v64[2] = (float)(v52 * (float)10.0) + v49;
      ((void (__fastcall *)(idRenderWorld *, char *, float *, idRenderWorld_vtbl *, idColor *, int, _DWORD, _DWORD, double))clientGame->renderWorld->DebugText)(
        a1: clientGame->renderWorld,
        a2: v4,
        a3: v64,
        a4: clientGame->renderWorld->__vftable,
        a5: &v56,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 1.0);
    }
    if ( this->aiVolatile.memory.enableGangstaPose )
    {
      v35 = common->RW(this: common);
      v62[2] = (float)(v52 * (float)50.0) + v49;
      v62[0] = (float)(x * (float)50.0) + v47;
      v62[1] = (float)(v51 * (float)50.0) + v48;
      ((void (__fastcall *)(idRenderWorld *, const char *, float *, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, int, _DWORD, double))v35->DebugText)(
        a1: v35,
        a2: "Gangsta",
        a3: v62,
        a4: v35->DebugText,
        a5: &v56,
        a6: 1,
        a7: 1,
        a8: 0,
        a9: 0.25);
    }
    if ( v11 != nullptr && ai_debugPerception.valueInteger >= 2 )
    {
      EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
      if ( EnemySenseState != nullptr )
      {
        ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: EnemySenseState);
        v38 = ConfirmedPhysicalSafe->origin.x;
        v39 = ConfirmedPhysicalSafe->origin.y;
        v40 = ConfirmedPhysicalSafe->origin.z;
        v57 = v38;
        v58 = v39;
        v59 = v40;
        ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))clientGame->renderWorld->DebugArrow3)(
          a1: clientGame->renderWorld,
          a2: &v56,
          a3: &v47,
          a4: &v57,
          a5: 3.0);
        if ( ai_debugPerception.valueInteger >= 4 )
        {
          v69 = idColor::colorGreen;
          do
          {
            v60 = *idAIMemory::DebugGetEnemyTrailPos(this: &this->aiVolatile.memory, _i: v6);
            if ( v60.bValid )
            {
              ((void (__fastcall *)(idRenderWorld *, idColor *, float *, idAIPos *, double))clientGame->renderWorld->DebugArrow3)(
                a1: clientGame->renderWorld,
                a2: &v69,
                a3: &v57,
                a4: &v60,
                a5: 3.0);
              v57 = v60.pos.x;
              v58 = v60.pos.y;
              v59 = v60.pos.z;
            }
            ++v6;
          }
          while ( v6 < 5 );
        }
      }
      if ( ai_debugPerception.valueInteger >= 3 )
      {
        FriendlyBlocker = (idAI2 *)idAIMemory::GetFriendlyBlocker(this: &this->aiVolatile.memory);
        v42 = idAI2::CastTo(c: FriendlyBlocker);
        if ( v42 != nullptr )
        {
          v43 = idEntity::GetPhysics(this: v42);
          v44 = (int)v43->GetOrigin(this: v43, a2: 0);
          v45 = idEntity::GetPhysics(this);
          v46 = (int)v45->GetOrigin(this: v45, a2: 0);
          ((void (__fastcall *)(idRenderWorld *, idColor *, int, int, char *, _DWORD, _DWORD, double))clientGame->renderWorld->DebugArrow3)(
            a1: clientGame->renderWorld,
            a2: &idColor::colorPurple,
            a3: v46,
            a4: v44,
            a5: &aAvSsobjectVCom[20],
            a6: 0,
            a7: 0,
            a8: 3.0);
        }
      }
    }
  }
}


// ========================================================================
// ?ShouldDiveOrDodgeOrCrouch@idAI2@@QAA?AW4aiTransCode_t@idAIStateTransition@@PBVidAIFSM@@@Z
// EA  : 0x82A08FD8
// RVA : 0x00A08FD8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIStateTransition::aiTransCode_t __fastcall idAI2::ShouldDiveOrDodgeOrCrouch(idAI2 *this, idOpenCombatFSM *parentFSM)
{
  char *v4; // r4
  idAIMoveState *p_moveState; // r31
  unsigned int v6; // r4
  signed int v7; // r21
  char v8; // r11
  unsigned __int8 v9; // r30
  char v10; // r11
  unsigned __int8 v11; // r29
  BOOL v12; // r31
  BOOL v13; // r22
  const idDeclAIBehavior *decl; // r11
  int v15; // r25
  idDeclAIBehavior::idAIDodgingBehaviors *v16; // r30
  bool v17; // zf
  int GameMs; // r3
  char v19; // r11
  unsigned __int8 v20; // r31
  signed int aimDodgeCoverChance; // r9
  aiSkill_t ModifiedSkill; // r3
  signed int aimHeavyDodgeNoCoverChance; // r11
  int v24; // r9
  signed int gunfireForwardDiveChance; // r11
  int v26; // r15
  signed int painDiveNoCoverChance; // r11
  signed int avoidDiveChance; // r11
  idEntity *AvoidEntity; // r3
  idEntity *Originator; // r3
  idActor *v31; // r28
  idAI2 *v32; // r3
  idVec3 *v33; // r4
  aiSenseState_t *EnemySenseState; // r3
  idPhysics *Physics; // r3
  float *v36; // r3
  double v37; // fp0
  double v38; // fp12
  BOOL v39; // r22
  char v40; // r11
  char v41; // r23
  idWeapon *v42; // r31
  idActor *v43; // r3
  bool v44; // r25
  bool v45; // r30
  bool v46; // r29
  const idDeclProjectile *CurrentProjectileDecl; // r3
  unsigned int aiDodgeType; // r11
  char v49; // r11
  bool v50; // r21
  char v51; // r16
  idPhysics *v52; // r31
  idPhysics *v53; // r30
  float *v54; // r31
  float *v55; // r3
  double v56; // fp7
  double v57; // fp6
  bool v58; // r14
  double v59; // fp0
  bool v60; // r29
  bool v61; // r28
  bool v62; // r19
  bool v63; // r17
  bool v64; // r18
  bool v65; // r20
  bool v66; // r23
  bool v67; // r22
  char v68; // r11
  char v69; // r25
  idPhysics *v70; // r3
  float *v71; // r3
  idPhysics *v72; // r3
  const idDeclAIBehavior *v73; // r30
  float *v74; // r3
  bool v75; // r11
  idAI2_vtbl *v76; // r10
  bool v77; // r30
  int v78; // r3
  char v79; // r10
  unsigned __int8 v80; // r26
  int v81; // r3
  char v82; // r27
  char *v83; // r29
  idPhysics *v84; // r30
  idRenderWorld *v85; // r14
  idPhysics *v86; // r3
  idRenderWorld_vtbl *v87; // r30
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  int v89; // r3
  char *v90; // r29
  idPhysics *v91; // r30
  idRenderWorld *v92; // r14
  idPhysics *v93; // r3
  idRenderWorld_vtbl *v94; // r30
  const idVec3 *(__fastcall *v95)(idPhysics *, int); // ctr
  int v96; // r3
  char *v97; // r29
  idPhysics *v98; // r30
  idRenderWorld *v99; // r14
  idPhysics *v100; // r3
  idRenderWorld_vtbl *v101; // r30
  const idVec3 *(__fastcall *v102)(idPhysics *, int); // ctr
  int v103; // r3
  char *v104; // r30
  idPhysics *v105; // r31
  idRenderWorld *v106; // r29
  idPhysics *v107; // r3
  idRenderWorld_vtbl *v108; // r31
  const idVec3 *(__fastcall *v109)(idPhysics *, int); // ctr
  int v110; // r3
  idAIStateTransition::aiTransCode_t v111; // r5
  idAIStateTransition::aiTransCode_t v113; // r3
  int v114; // r31
  idAIStateTransition::aiTransCode_t v115; // r5
  idAIStateTransition::aiTransCode_t v116; // r5
  idAIStateTransition::aiTransCode_t v117; // r5
  idAIStateTransition::aiTransCode_t v118; // r5
  int v119; // r31
  idDeclAIBehavior::idAIDodgingBehaviors *v120; // r15
  signed int v121; // r27
  idAIStateTransition::aiTransCode_t v122; // r5
  idAIStateTransition::aiTransCode_t v123; // r5
  idAIStateTransition::aiTransCode_t v124; // r5
  int v125; // r25
  bool v126; // r26
  BOOL v127; // r27
  bool v128; // r7
  bool v129; // r5
  idAIStateTransition::aiTransCode_t v130; // r5
  signed int v131; // r23
  bool v132; // r7
  bool v133; // r5
  idAIStateTransition::aiTransCode_t v134; // r5
  bool *v135; // [sp+8h] [-178h]
  bool *v136; // [sp+Ch] [-174h]
  bool *v137; // [sp+10h] [-170h]
  bool *v138; // [sp+14h] [-16Ch]
  bool *v139; // [sp+18h] [-168h]
  bool *v140; // [sp+1Ch] [-164h]
  int v141; // [sp+20h] [-160h]
  int v142; // [sp+24h] [-15Ch]
  int v143; // [sp+28h] [-158h]
  int v144; // [sp+2Ch] [-154h]
  int v145; // [sp+30h] [-150h]
  int v146; // [sp+34h] [-14Ch]
  int v147; // [sp+38h] [-148h]
  int v148; // [sp+3Ch] [-144h]
  int v149; // [sp+40h] [-140h]
  int v150; // [sp+44h] [-13Ch]
  int v151; // [sp+48h] [-138h]
  int v152; // [sp+4Ch] [-134h]
  int v153; // [sp+50h] [-130h]
  int v154; // [sp+58h] [-128h]
  int v155; // [sp+60h] [-120h]
  int v156; // [sp+68h] [-118h]
  int v157; // [sp+70h] [-110h]
  int v158; // [sp+78h] [-108h]
  char v159; // [sp+80h] [-100h]
  char v160; // [sp+81h] [-FFh]
  bool v161; // [sp+82h] [-FEh] BYREF
  bool v162; // [sp+83h] [-FDh]
  bool v163; // [sp+84h] [-FCh]
  bool v164; // [sp+85h] [-FBh] BYREF
  bool v165; // [sp+86h] [-FAh] BYREF
  bool v166; // [sp+87h] [-F9h] BYREF
  bool v167; // [sp+88h] [-F8h]
  char v168; // [sp+89h] [-F7h]
  bool v169; // [sp+8Ah] [-F6h] BYREF
  bool v170; // [sp+8Bh] [-F5h] BYREF
  bool v171; // [sp+8Ch] [-F4h] BYREF
  bool v172; // [sp+8Dh] [-F3h] BYREF
  bool v173; // [sp+8Eh] [-F2h] BYREF
  bool v174; // [sp+8Fh] [-F1h] BYREF
  bool v175; // [sp+90h] [-F0h] BYREF
  bool v176; // [sp+91h] [-EFh] BYREF
  bool v177; // [sp+92h] [-EEh]
  bool v178; // [sp+93h] [-EDh] BYREF
  bool IsFacingMe; // [sp+94h] [-ECh]
  bool v180; // [sp+95h] [-EBh]
  signed int v181; // [sp+98h] [-E8h]
  idDeclAIBehavior::idAIDodgingBehaviors *p_dodging; // [sp+9Ch] [-E4h]
  BOOL v183; // [sp+A0h] [-E0h]
  int v184; // [sp+A4h] [-DCh]
  int v185; // [sp+A8h] [-D8h]
  BOOL v186; // [sp+ACh] [-D4h]
  idVec3 v187; // [sp+B0h] [-D0h] BYREF
  float v188; // [sp+C0h] [-C0h]
  float v189; // [sp+C4h] [-BCh]
  float v190; // [sp+C8h] [-B8h]

  if ( ai_enableDodge.valueInteger == 0 )
  {
    v4 = "disabled";
LABEL_271:
    v32 = this;
    return DebugDodge(ai: v32, txt: v4, trans: (idAIStateTransition::aiTransCode_t)0);
  }
  p_moveState = &this->aiVolatile.physics.moveState;
  if ( this->aiVolatile.physics.moveState.IsPlayingTraversalAnim(this: &this->aiVolatile.physics.moveState)
    || p_moveState->GetDestinationTraversal(this: &this->aiVolatile.physics.moveState) != nullptr )
  {
    v4 = "traversal";
    goto LABEL_271;
  }
  if ( this->aiVolatile.animation.animWebAnimator.ptr[0].runIndexType == ANIMWEBAI_RUNINDEXTYPE_INJURED )
  {
    v4 = "injured";
    goto LABEL_271;
  }
  v6 = 1664525 * clientGame->random.seed + 1013904223;
  clientGame->random.seed = v6;
  v7 = ((v6 >> 10) & 0x7FFF) % 0x64;
  v181 = v7;
  if ( parentFSM == nullptr || (v8 = 1, parentFSM->eventId != 2) )
    v8 = 0;
  v9 = v8;
  if ( parentFSM == nullptr || (v10 = 1, parentFSM->eventId != 64) )
    v10 = 0;
  v11 = v10;
  v12 = (_cntlzw((unsigned int)parentFSM) & 0x20) != 0;
  v186 = v12;
  v13 = v12;
  v180 = idOpenCombatFSM::CastTo(c: parentFSM) != nullptr;
  if ( !v12
    && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) < this->aiVolatile.memory.nextDodgeTime )
  {
    v4 = "throttled";
    goto LABEL_271;
  }
  decl = this->aiEditable.behaviors.decl;
  v15 = v9;
  v185 = v9;
  p_dodging = &decl->dodging;
  v17 = v9 != 0;
  v16 = &decl->dodging;
  if ( !v17 && v11 == 0 && !v12 )
  {
    v4 = "no shot or aim or avoid";
    goto LABEL_271;
  }
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.lastDamageTime >= 750
    || (GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED),
        v19 = 1,
        GameMs - this->aiVolatile.memory.lastDamageTime <= 100) )
  {
    v19 = 0;
  }
  v20 = v19;
  v184 = v11;
  aimDodgeCoverChance = 0;
  if ( v11 != 0 )
  {
    ModifiedSkill = idAI2::GetModifiedSkill(this);
    aimHeavyDodgeNoCoverChance = v16->aimHeavyDodgeNoCoverChance;
    v24 = 4 * (ModifiedSkill + 14);
    if ( aimHeavyDodgeNoCoverChance <= *(int *)((char *)&v16->gunfireDodgeCoverChance + v24) )
      aimHeavyDodgeNoCoverChance = *(int *)((char *)&v16->gunfireDodgeCoverChance + v24);
    if ( v16->aimLightDiveNoCoverChance > aimHeavyDodgeNoCoverChance )
      aimHeavyDodgeNoCoverChance = v16->aimLightDiveNoCoverChance;
    if ( v16->aimHeavyDiveNoCoverChance > aimHeavyDodgeNoCoverChance )
      aimHeavyDodgeNoCoverChance = v16->aimHeavyDiveNoCoverChance;
    if ( v16->aimHeavyDiveCoverChance > aimHeavyDodgeNoCoverChance )
      aimHeavyDodgeNoCoverChance = v16->aimHeavyDiveCoverChance;
    aimDodgeCoverChance = v16->aimDodgeCoverChance;
    if ( aimDodgeCoverChance <= aimHeavyDodgeNoCoverChance )
      aimDodgeCoverChance = aimHeavyDodgeNoCoverChance;
  }
  if ( v15 != 0 )
  {
    gunfireForwardDiveChance = v16->gunfireForwardDiveChance;
    if ( v16->gunfireLightDiveNoCoverChance > gunfireForwardDiveChance )
      gunfireForwardDiveChance = v16->gunfireLightDiveNoCoverChance;
    if ( v16->gunfireHeavyDiveNoCoverChance > gunfireForwardDiveChance )
      gunfireForwardDiveChance = v16->gunfireHeavyDiveNoCoverChance;
    if ( v16->gunfireHeavyDiveCoverChance > gunfireForwardDiveChance )
      gunfireForwardDiveChance = v16->gunfireHeavyDiveCoverChance;
    if ( v16->gunfireFlinchChance > gunfireForwardDiveChance )
      gunfireForwardDiveChance = v16->gunfireFlinchChance;
    if ( v16->gunfireDodgeNoCoverChance > gunfireForwardDiveChance )
      gunfireForwardDiveChance = v16->gunfireDodgeNoCoverChance;
    if ( v16->gunfireDodgeCoverChance > gunfireForwardDiveChance )
      gunfireForwardDiveChance = v16->gunfireDodgeCoverChance;
    if ( aimDodgeCoverChance <= gunfireForwardDiveChance )
      aimDodgeCoverChance = gunfireForwardDiveChance;
  }
  v26 = v20;
  if ( v20 != 0 )
  {
    painDiveNoCoverChance = v16->painDiveNoCoverChance;
    if ( v16->painDiveCoverChance > painDiveNoCoverChance )
      painDiveNoCoverChance = v16->painDiveCoverChance;
    if ( aimDodgeCoverChance <= painDiveNoCoverChance )
      aimDodgeCoverChance = painDiveNoCoverChance;
  }
  if ( v13 )
  {
    avoidDiveChance = v16->avoidDiveChance;
    if ( v16->avoidForwardDiveChance > avoidDiveChance )
      avoidDiveChance = v16->avoidForwardDiveChance;
    if ( aimDodgeCoverChance <= avoidDiveChance )
      aimDodgeCoverChance = avoidDiveChance;
  }
  if ( v7 > aimDodgeCoverChance )
  {
    v4 = "chance";
    goto LABEL_271;
  }
  if ( v13 )
  {
    AvoidEntity = (idEntity *)idAIMemory::GetAvoidEntity(this: &this->aiVolatile.memory);
  }
  else
  {
    Originator = (idEntity *)idAIEvent::GetOriginator(this: parentFSM->eventData);
    AvoidEntity = idEntity::CastTo(c: Originator);
  }
  v31 = (idActor *)AvoidEntity;
  v17 = AvoidEntity != nullptr;
  v32 = this;
  if ( !v17 )
  {
    v4 = "no target";
    return DebugDodge(ai: v32, txt: v4, trans: (idAIStateTransition::aiTransCode_t)0);
  }
  EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
  if ( EnemySenseState == nullptr )
  {
    v4 = "no sense";
    goto LABEL_271;
  }
  aiSenseState_t::ExtrapolatePosition(this: EnemySenseState, seconds: 0.5, futurePos: v33);
  Physics = idEntity::GetPhysics(this);
  v36 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v37 = (float)((float)((float)(v188 - *v36) * (float)(v188 - *v36))
              + (float)((float)((float)(v190 - v36[2]) * (float)(v190 - v36[2]))
                      + (float)((float)(v189 - v36[1]) * (float)(v189 - v36[1]))));
  v38 = (float)(v16->closeRangeDist * v16->closeRangeDist);
  v177 = v37 < (float)(v16->tooCloseDist * v16->tooCloseDist);
  v39 = v37 < v38;
  v183 = v39;
  if ( v37 < v38 || (v40 = 1, v37 >= (float)(v16->mediumRangeDist * v16->mediumRangeDist)) )
    v40 = 0;
  v41 = v40;
  v159 = v40;
  v42 = nullptr;
  if ( idActor::CastTo(c: v31) != nullptr )
  {
    v43 = idActor::CastTo(c: v31);
    v42 = v43->GetEquippedWeapon(this: v43);
  }
  v44 = false;
  v167 = true;
  v163 = false;
  v45 = false;
  v46 = false;
  v162 = false;
  if ( v42 != nullptr && !idWeapon::IsMelee(this: v42) )
  {
    CurrentProjectileDecl = idWeapon::GetCurrentProjectileDecl(this: v42, secondaryAmmo: false);
    if ( CurrentProjectileDecl != nullptr )
    {
      aiDodgeType = CurrentProjectileDecl->aiDodgeType;
      v44 = (_cntlzw(aiDodgeType - 5) & 0x20) != 0;
      v167 = (_cntlzw(aiDodgeType) & 0x20) != 0;
      v163 = (_cntlzw(aiDodgeType - 2) & 0x20) != 0;
      v45 = (_cntlzw(aiDodgeType - 3) & 0x20) != 0;
      v46 = (_cntlzw(aiDodgeType - 4) & 0x20) != 0;
      v162 = v44;
    }
  }
  if ( v45 && v39 || v46 && (v39 || v41 != 0) || (v49 = 0, v44) )
    v49 = 1;
  v160 = v49;
  v50 = idAI2::AmIToEntitysLeft(this, entity: v31);
  IsFacingMe = idAI2::IsFacingMe(this, entity: v31, dotThreshold: 0.99599999);
  v176 = false;
  v175 = false;
  v166 = false;
  v165 = false;
  v169 = false;
  v170 = false;
  v171 = false;
  v172 = false;
  v178 = false;
  v164 = false;
  v173 = false;
  v161 = false;
  v174 = false;
  idAI2::CoverAvoidanceOptions(
    this,
    outDodgeRoomToLeft: &v176,
    outDiveRoomToLeft: &v166,
    outDodgeCoverToLeft: &v169,
    outDiveCoverToLeft: &v171,
    outDodgeRoomToRight: &v175,
    outDiveRoomToRight: &v165,
    outDodgeCoverToRight: &v170,
    outDiveCoverToRight: v135,
    outDiveRoomForward: v136,
    outDiveCoverForward: v137,
    outDiveRoomBack: v138,
    outDiveCoverBack: v139,
    outCoverByCrouching: v140,
    a15: v141,
    a16: v142,
    a17: v143,
    a18: v144,
    a19: v145,
    a20: v146,
    a21: v147,
    a22: v148,
    a23: v149,
    a24: v150,
    a25: v151,
    a26: v152,
    a27: v153,
    a28: &v172,
    a29: v154,
    a30: &v164,
    a31: v155,
    a32: &v173,
    a33: v156,
    a34: &v161,
    a35: v157,
    outDiveCoverToRighta: &v174,
    a37: v158,
    outDiveRoomForwarda: &v178);
  v168 = 0;
  v51 = 0;
  v52 = idEntity::GetPhysics(this);
  v53 = idEntity::GetPhysics(this: v31);
  v54 = (float *)v52->GetOrigin(this: v52, a2: 0);
  v55 = (float *)v53->GetOrigin(this: v53, a2: 0);
  v56 = (float)(v55[1] - v54[1]);
  v57 = (float)(v55[2] - v54[2]);
  v187.x = *v55 - *v54;
  v187.y = v56;
  v187.z = v57;
  idVec3::NormalizeFast(this: &v187);
  v58 = v164;
  v59 = (float)((float)(v187.y * this->actorVolatile.modelInfo.modelAxis.mat[0].y)
              + (float)((float)(v187.z * this->actorVolatile.modelInfo.modelAxis.mat[0].z)
                      + (float)(v187.x * this->actorVolatile.modelInfo.modelAxis.mat[0].x)));
  v178 = v164;
  if ( v59 > 0.89999998 )
    v168 = 1;
  if ( __fabs(v59) > 0.70700002 )
  {
    v58 = false;
    v161 = false;
    v164 = false;
  }
  if ( __fabs((float)((float)(v187.x * this->actorVolatile.modelInfo.modelAxis.mat[1].x)
                    + (float)((float)(this->actorVolatile.modelInfo.modelAxis.mat[1].z * v187.z)
                            + (float)(this->actorVolatile.modelInfo.modelAxis.mat[1].y * v187.y)))) <= 0.70700002 )
  {
    v60 = v166;
    v61 = v165;
  }
  else
  {
    v60 = false;
    v166 = false;
    v61 = false;
    v165 = false;
  }
  if ( v59 < 0.70700002 )
    v51 = 1;
  v62 = v169;
  v63 = v170;
  v64 = v171;
  v65 = v172;
  v66 = v173;
  v67 = v174;
  if ( v169 || v170 || v171 || v172 || v173 || (v68 = 0, v174) )
    v68 = 1;
  v69 = v68;
  v70 = idEntity::GetPhysics(this);
  v71 = (float *)v70->GetLinearVelocity(this: (idPhysics *)&v187, result: (idVec3 *)v70, a3: 0);
  v173 = (float)((float)(v71[2] * v71[2]) + (float)((float)(*v71 * *v71) + (float)(v71[1] * v71[1]))) > 0.0;
  v72 = idEntity::GetPhysics(this);
  v73 = this->aiEditable.behaviors.decl;
  v74 = (float *)v72->GetLinearVelocity(this: (idPhysics *)&v187, result: (idVec3 *)v72, a3: 0);
  v75 = (float)((float)(this->actorVolatile.modelInfo.modelAxis.mat[0].x * *v74)
              + (float)((float)(v74[2] * this->actorVolatile.modelInfo.modelAxis.mat[0].z)
                      + (float)(v74[1] * this->actorVolatile.modelInfo.modelAxis.mat[0].y))) > (double)v73->damageBehaviors.movingDeathSpeed;
  v76 = this->__vftable;
  v77 = v75;
  v174 = v75;
  v172 = (_cntlzw(v76->GetPosture(this) - 2) & 0x20) != 0;
  if ( v184 == 0
    || (v78 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED),
        v79 = 1,
        v78 - this->aiVolatile.memory.justAimedAtTime >= 25) )
  {
    v79 = 0;
  }
  v80 = v79;
  v81 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v82 = ((v81 - this->aiVolatile.memory.lastSurprisedTime >= 0)
       + ((unsigned int)(v81 - this->aiVolatile.memory.lastSurprisedTime) >= 0x2EE))
      & 1;
  if ( ai_debugLevel.valueInteger > 0 && ai_debugDodge.valueInteger > 0 )
  {
    if ( (((v81 - this->aiVolatile.memory.lastSurprisedTime >= 0)
         + ((unsigned int)(v81 - this->aiVolatile.memory.lastSurprisedTime) >= 0x2EE))
        & 1) != 0 )
      v83 = "SUR";
    else
      v83 = &byte_8200D768;
    v84 = idEntity::GetPhysics(this);
    v85 = common->RW(this: common);
    v86 = v84;
    GetOrigin = v84->GetOrigin;
    v87 = v85->__vftable;
    v89 = (int)GetOrigin(this: v86, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, char *, int, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, int, _DWORD, double))v87->DebugText)(
      a1: v85,
      a2: v83,
      a3: v89,
      a4: v87->DebugText,
      a5: &idColor::colorOrange,
      a6: 1,
      a7: 800,
      a8: 0,
      a9: 1.0);
    if ( v26 != 0 )
      v90 = "\nPAIN";
    else
      v90 = &byte_8200D768;
    v91 = idEntity::GetPhysics(this);
    v92 = common->RW(this: common);
    v93 = v91;
    v95 = v91->GetOrigin;
    v94 = v92->__vftable;
    v96 = (int)v95(this: v93, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, char *, int, _DWORD, idColor *, int, int, _DWORD, double))v94->DebugText)(
      a1: v92,
      a2: v90,
      a3: v96,
      a4: 0,
      a5: &idColor::colorRed,
      a6: 1,
      a7: 800,
      a8: 0,
      a9: 1.0);
    if ( v51 != 0 )
      v97 = "\n\nFACE";
    else
      v97 = &byte_8200D768;
    v98 = idEntity::GetPhysics(this);
    v99 = common->RW(this: common);
    v100 = v98;
    v102 = v98->GetOrigin;
    v101 = v99->__vftable;
    v103 = (int)v102(this: v100, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, char *, int, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, int, _DWORD, double))v101->DebugText)(
      a1: v99,
      a2: v97,
      a3: v103,
      a4: v101->DebugText,
      a5: &idColor::colorPurple,
      a6: 1,
      a7: 800,
      a8: 0,
      a9: 1.0);
    if ( v80 != 0 )
      v104 = "\n\n\nAIM";
    else
      v104 = &byte_8200D768;
    v105 = idEntity::GetPhysics(this);
    v106 = common->RW(this: common);
    v107 = v105;
    v109 = v105->GetOrigin;
    v108 = v106->__vftable;
    v110 = (int)v109(this: v107, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, char *, int, _DWORD, idColor *, int, int, _DWORD, double))v108->DebugText)(
      a1: v106,
      a2: v104,
      a3: v110,
      a4: 0,
      a5: &idColor::colorCyan,
      a6: 1,
      a7: 800,
      a8: 0,
      a9: 1.0);
    v77 = v174;
    v58 = v164;
    v61 = v165;
    v60 = v166;
  }
  if ( v181 < p_dodging->avoidDiveChance && v186 )
  {
    v111 = idAI2::BestDiveOrDodge(
             this,
             leftDodge: false,
             leftDive: v64,
             rightDodge: false,
             rightDive: v65,
             forwardDive: v66,
             backwardDive: v67,
             preferLeft: v50);
    if ( v111 != 0 )
      return DebugDodge(ai: this, txt: "avoid dive cover", trans: v111);
    v113 = idAI2::BestDiveOrDodge(
             this,
             leftDodge: false,
             leftDive: v60,
             rightDodge: false,
             rightDive: v61,
             forwardDive: v58,
             backwardDive: v161,
             preferLeft: v50);
    return DebugDodge(ai: this, txt: "avoid dive no cover", trans: v113);
  }
  v114 = v185;
  if ( v181 < p_dodging->gunfireDodgeCoverChance
    && v185 != 0
    && v69 != 0
    && (v163 || v160 != 0)
    && (v82 != 0 || v51 != 0)
    && (v183 || v159 != 0 || v162)
    || v181 < p_dodging->aimDodgeCoverChance
    && (v80 != 0 || v184 != 0)
    && v69 != 0
    && (v163 || v160 != 0)
    && (v82 != 0 || v51 != 0)
    && (v183 || v159 != 0 || v162) )
  {
    return idAI2::BestDiveOrDodge(
             this,
             leftDodge: v62,
             leftDive: v64,
             rightDodge: v63,
             rightDive: v65,
             forwardDive: v66,
             backwardDive: v67,
             preferLeft: v50);
  }
  if ( v26 == 0 )
    goto LABEL_160;
  if ( v184 != 0 || v185 != 0 )
  {
    if ( (v163 || v160 != 0) && (v183 || v159 != 0) )
    {
      if ( v181 < p_dodging->painDiveCoverChance )
      {
        v115 = idAI2::BestDiveOrDodge(
                 this,
                 leftDodge: false,
                 leftDive: v64,
                 rightDodge: false,
                 rightDive: v65,
                 forwardDive: v66,
                 backwardDive: v67,
                 preferLeft: v50);
        if ( v115 != 0 )
          return DebugDodge(ai: this, txt: "pain cover", trans: v115);
      }
      if ( v181 < p_dodging->painDiveNoCoverChance && v51 == 0 )
      {
        v116 = idAI2::BestDiveOrDodge(
                 this,
                 leftDodge: false,
                 leftDive: v60,
                 rightDodge: false,
                 rightDive: v61,
                 forwardDive: v58,
                 backwardDive: v161,
                 preferLeft: v50);
        if ( v116 != 0 )
          return DebugDodge(ai: this, txt: "pain no cover", trans: v116);
      }
    }
LABEL_160:
    if ( v114 != 0 && v160 != 0 )
    {
      if ( v181 < p_dodging->gunfireHeavyDiveCoverChance )
      {
        v117 = idAI2::BestDiveOrDodge(
                 this,
                 leftDodge: false,
                 leftDive: v64,
                 rightDodge: false,
                 rightDive: v65,
                 forwardDive: v66,
                 backwardDive: v67,
                 preferLeft: v50);
        if ( v117 != 0 )
          return DebugDodge(ai: this, txt: "heavy weapon cover", trans: v117);
      }
      if ( v181 < p_dodging->gunfireHeavyDiveNoCoverChance && v51 == 0 )
      {
        v118 = idAI2::BestDiveOrDodge(
                 this,
                 leftDodge: false,
                 leftDive: v60,
                 rightDodge: false,
                 rightDive: v61,
                 forwardDive: v58,
                 backwardDive: v161,
                 preferLeft: v50);
        if ( v118 != 0 )
          return DebugDodge(ai: this, txt: "heavy weapon no cover", trans: v118);
      }
    }
  }
  v119 = v80;
  if ( (v80 != 0 || v184 != 0) && v160 != 0 && !v77 )
  {
    v120 = p_dodging;
    v121 = v181;
    if ( v181 < p_dodging->aimHeavyDiveCoverChance )
    {
      v122 = idAI2::BestDiveOrDodge(
               this,
               leftDodge: false,
               leftDive: v64,
               rightDodge: false,
               rightDive: v65,
               forwardDive: v66,
               backwardDive: v67,
               preferLeft: v50);
      if ( v122 != 0 )
        return DebugDodge(ai: this, txt: "heavy weapon aim no cover", trans: v122);
    }
    if ( v121 < v120->aimHeavyDiveNoCoverChance && v51 == 0 )
    {
      v122 = idAI2::BestDiveOrDodge(
               this,
               leftDodge: false,
               leftDive: v60,
               rightDodge: false,
               rightDive: v61,
               forwardDive: v58,
               backwardDive: v161,
               preferLeft: v50);
      if ( v122 != 0 )
        return DebugDodge(ai: this, txt: "heavy weapon aim no cover", trans: v122);
    }
  }
  else
  {
    v121 = v181;
    v120 = p_dodging;
  }
  if ( v121 < v120->aimHeavyDodgeNoCoverChance && v160 != 0 && !v77 && v51 == 0 )
  {
    v123 = idAI2::BestDiveOrDodge(
             this,
             leftDodge: v62,
             leftDive: false,
             rightDodge: v63,
             rightDive: false,
             forwardDive: false,
             backwardDive: false,
             preferLeft: v50);
    if ( v123 != 0 )
      return DebugDodge(ai: this, txt: "heavy dodge cover", trans: v123);
    v124 = idAI2::BestDiveOrDodge(
             this,
             leftDodge: v176,
             leftDive: false,
             rightDodge: v175,
             rightDive: false,
             forwardDive: false,
             backwardDive: false,
             preferLeft: v50);
    if ( v124 != 0 )
      return DebugDodge(ai: this, txt: "heavy dodge no cover", trans: v124);
  }
  v125 = v185;
  v126 = v167;
  v17 = v121 >= v120->gunfireLightDiveNoCoverChance;
  v127 = v183;
  if ( !v17 && v185 != 0 && !v167 && (v183 || v159 != 0) && v51 == 0 )
  {
    if ( !v61 || (v128 = true, v65) )
      v128 = false;
    if ( !v60 || (v129 = true, v64) )
      v129 = false;
    v130 = idAI2::BestDiveOrDodge(
             this,
             leftDodge: false,
             leftDive: v129,
             rightDodge: false,
             rightDive: v128,
             forwardDive: false,
             backwardDive: false,
             preferLeft: v50);
    if ( v130 != 0 )
      return DebugDodge(ai: this, txt: "light gunfire no cover", trans: v130);
  }
  v131 = v181;
  if ( v181 < v120->aimLightDiveNoCoverChance && v184 != 0 && !v126 && (v127 || v159 != 0) && v51 == 0 )
  {
    if ( !v61 || (v132 = true, v65) )
      v132 = false;
    if ( !v60 || (v133 = true, v64) )
      v133 = false;
    v134 = idAI2::BestDiveOrDodge(
             this,
             leftDodge: false,
             leftDive: v133,
             rightDodge: false,
             rightDive: v132,
             forwardDive: false,
             backwardDive: false,
             preferLeft: v50);
    if ( v134 != 0 )
      return DebugDodge(ai: this, txt: "light aim no cover", trans: v134);
  }
  if ( v131 < v120->aimForwardDiveChance.setting[idAI2::GetModifiedSkill(this)]
    && v77
    && (v119 != 0 || v184 != 0)
    && !v126
    && (v127 || v159 != 0 || v162)
    && !v177
    && v178
    && v168 != 0 )
  {
    if ( IsFacingMe )
      goto LABEL_234;
    if ( v50 )
    {
      if ( this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[3] > OBSCURITY_PATH_BLOCKED )
      {
        this->aiVolatile.animation.animWebAnimator.ptr[0].diveIndex = 1.0;
        return DebugDodge(ai: this, txt: "aim forward dive", trans: TRANSCODE_OC_DIVE_FORWARD);
      }
      if ( v50 )
        goto LABEL_234;
    }
    if ( this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[4] <= OBSCURITY_PATH_BLOCKED )
    {
LABEL_234:
      this->aiVolatile.animation.animWebAnimator.ptr[0].diveIndex = 0.0;
      return DebugDodge(ai: this, txt: "aim forward dive", trans: TRANSCODE_OC_DIVE_FORWARD);
    }
    else
    {
      this->aiVolatile.animation.animWebAnimator.ptr[0].diveIndex = 2.0;
      return DebugDodge(ai: this, txt: "aim forward dive", trans: TRANSCODE_OC_DIVE_FORWARD);
    }
  }
  else
  {
    if ( v131 >= v120->gunfireForwardDiveChance
      || !v77
      || v125 == 0
      || v126
      || !v127 && v159 == 0 && !v162
      || v177
      || !v178
      || v168 == 0 )
    {
      if ( v131 < v120->gunfireDodgeNoCoverChance
        && v180
        && v168 != 0
        && v125 != 0
        && !v77
        && (v163 || v160 != 0)
        && (v127 || v159 != 0 || v162) )
      {
        return idAI2::BestDiveOrDodge(
                 this,
                 leftDodge: false,
                 leftDive: v60,
                 rightDodge: false,
                 rightDive: v61,
                 forwardDive: v58,
                 backwardDive: v161,
                 preferLeft: v50);
      }
      if ( v131 < v120->gunfireFlinchChance && v125 != 0 && !v126 && !v173 && !v172 )
        return DebugDodge(
                 ai: this,
                 txt: "flinch",
                 trans: (idAIStateTransition::aiTransCode_t)(((_cntlzw(v50) & 0x20) != 0) + 306));
      v4 = "no rule";
      goto LABEL_271;
    }
    if ( IsFacingMe )
      goto LABEL_252;
    if ( v50 )
    {
      if ( this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[3] > OBSCURITY_PATH_BLOCKED )
      {
        this->aiVolatile.animation.animWebAnimator.ptr[0].diveIndex = 1.0;
        return DebugDodge(ai: this, txt: "gunfire forward dive", trans: TRANSCODE_OC_DIVE_FORWARD);
      }
      if ( v50 )
        goto LABEL_252;
    }
    if ( this->aiVolatile.visibilityObscurity.visibilityObscurity.ptr[4] <= OBSCURITY_PATH_BLOCKED )
    {
LABEL_252:
      this->aiVolatile.animation.animWebAnimator.ptr[0].diveIndex = 0.0;
      return DebugDodge(ai: this, txt: "gunfire forward dive", trans: TRANSCODE_OC_DIVE_FORWARD);
    }
    else
    {
      this->aiVolatile.animation.animWebAnimator.ptr[0].diveIndex = 2.0;
      return DebugDodge(ai: this, txt: "gunfire forward dive", trans: TRANSCODE_OC_DIVE_FORWARD);
    }
  }
}


// ========================================================================
// ?DormantBegin@idAI2@@UAAXXZ
// EA  : 0x82A0A720
// RVA : 0x00A0A720
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DormantBegin(idAI2 *this)
{
  idGameLocal *v2; // r9
  int v3; // r7
  int v4; // r4
  idList<idEntityPtr<idEntity>,58> *p_activeAI; // r3
  int num; // r10
  int v7; // r11
  int v8; // r8
  int v9; // r4
  idList<idEntityPtr<idEntity>,58> *p_aiWorldStateUsers; // r3
  int v11; // r10
  int i; // r11

  idAIEventManager::RemoveReceiver(this: &gameLocal->aiEventManager, receiver: this);
  v2 = gameLocal;
  if ( this != nullptr )
    v3 = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
  else
    v3 = 0x1FFF;
  v4 = 0;
  p_activeAI = (idList<idEntityPtr<idEntity>,58> *)&gameLocal->activeAI;
  num = gameLocal->activeAI.num;
  if ( num > 0 )
  {
    v7 = 0;
    while ( p_activeAI->list[v7].spawnId.value != v3 )
    {
      ++v4;
      ++v7;
      if ( v4 >= num )
        goto LABEL_11;
    }
    if ( v4 >= 0 )
    {
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(this: p_activeAI, index: v4);
      v2 = gameLocal;
    }
  }
LABEL_11:
  if ( this != nullptr )
    v8 = (v2->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
  else
    v8 = 0x1FFF;
  v9 = 0;
  p_aiWorldStateUsers = (idList<idEntityPtr<idEntity>,58> *)&v2->aiWorldStateUsers;
  v11 = v2->aiWorldStateUsers.num;
  if ( v11 > 0 )
  {
    for ( i = 0; p_aiWorldStateUsers->list[i].spawnId.value != v8; ++i )
    {
      if ( ++v9 >= v11 )
        return;
    }
    if ( v9 >= 0 )
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(this: p_aiWorldStateUsers, index: v9);
  }
}


// ========================================================================
// ?CanUse@idCheckSurroundingsState@@QBA_NPBVidAI2@@@Z
// EA  : 0x82A0A858
// RVA : 0x00A0A858
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idCheckSurroundingsState::CanUse(idCheckSurroundingsState *this, idAI2 *ai)
{
  int GameMs; // r3
  idAIFSMManager_vtbl *v4; // r10
  idAI2::idAIVolatile::idAIFSMInfo *p_fsms; // r11
  int v6; // r31
  int v7; // r3
  unsigned __int8 v8; // r11

  if ( idAI2::IsPlayerControlled(this: ai) )
    return 0;
  if ( ai->aiVolatile.fsms.alertCycle > ALERTCYCLE_SEARCH )
    return 0;
  if ( ai->actorConstants.actorClass != ACTORCLASS_HUMAN )
    return 0;
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v4 = ai->aiVolatile.fsms.fsmManager.__vftable;
  p_fsms = &ai->aiVolatile.fsms;
  v6 = GameMs;
  v7 = (int)v4->FindFSM(this: &p_fsms->fsmManager, a2: &idAlertCycleFSM::Type);
  v8 = 1;
  if ( v6 - *(_DWORD *)(v7 + 76) <= 500 )
    return 0;
  return v8;
}


// ========================================================================
// ?FindBestLookInterestPoint@idCheckSurroundingsState@@QBAMPBVidAI2@@AAVidVec3@@@Z
// EA  : 0x82A0A910
// RVA : 0x00A0A910
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idCheckSurroundingsState::FindBestLookInterestPoint(
        idCheckSurroundingsState *this,
        idAI2 *ai,
        idVec3 *lookTo)
{
  __int64 v6; // r7
  long double v7; // fp4
  double v8; // fp1
  idPresentable *presentable; // r11
  int v10; // r28
  int v11; // r23
  double v12; // fp31
  double v13; // fp30
  float *p_axis; // r30
  int v15; // r26
  int i; // r29
  float *v17; // r11
  double v18; // fp0
  double NetDirectionInterest; // fp1
  long double v20; // fp2
  long double v21; // fp2
  float *v22; // r11
  double v23; // fp8
  double v24; // fp7
  double v25; // fp5

  if ( (unsigned __int8)idCheckSurroundingsState::CanUse(this, ai) != 0 )
  {
    presentable = ai->presentable;
    v10 = 0;
    v11 = -1;
    v12 = -1.0;
    v13 = -1.0;
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this: ai);
      presentable = ai->presentable;
    }
    p_axis = (float *)&presentable->axis;
    v15 = 0;
    for ( i = 0; i < 8; ++i )
    {
      v17 = (float *)((char *)gameLocal + i * 12);
      v18 = (float)((float)(v17[437432] * *p_axis)
                  + (float)((float)(v17[437433] * p_axis[1]) + (float)(v17[437434] * p_axis[2])));
      if ( v18 >= -0.050000001 )
      {
        if ( v18 > v13 )
        {
          v11 = v15;
          v13 = (float)((float)(v17[437432] * *p_axis)
                      + (float)((float)(v17[437433] * p_axis[1]) + (float)(v17[437434] * p_axis[2])));
        }
        NetDirectionInterest = idCheckSurroundingsState::FindNetDirectionInterest(
                                 this,
                                 ai,
                                 testDirection: &gameLocal->directionVector[i]);
        if ( NetDirectionInterest > v12 )
        {
          v10 = v15;
          v12 = NetDirectionInterest;
        }
      }
      ++v15;
    }
    *(double *)&v20 = __fsqrts(2.0);
    LODWORD(v6) = this->distanceExponent.ptr[v10];
    *((double *)&v20 + 1) = (float)v6;
    v21 = pow(x: v20, y: v7);
    v22 = (float *)((char *)gameLocal + 12 * v10);
    v23 = v22[437433];
    v24 = v22[437434];
    v25 = (float)((float)((float)((float)*(double *)&v21 * (float)10.0) * UNITS_PER_INCH_2) * (float)12.0);
    lookTo->x = v22[437432]
              * (float)((float)((float)((float)*(double *)&v21 * (float)10.0) * UNITS_PER_INCH_2) * (float)12.0);
    lookTo->y = (float)v23 * (float)v25;
    lookTo->z = (float)v24 * (float)v25;
    if ( v10 == v11 )
      v12 = 0.0;
    v8 = v12;
  }
  else
  {
    v8 = 0.0;
  }
  return *((float *)&v8 + 1);
}


// ========================================================================
// ?FindAutoFocusEntity@idAI2@@AAAMAAPBVidEntity@@@Z
// EA  : 0x82A0AAE8
// RVA : 0x00A0AAE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::FindAutoFocusEntity(idAI2 *this, idAI2 **bestEntity)
{
  int v3; // r10
  idAIEntityState *es; // r3
  idTargetInfo *v5; // r30
  idAI2 *Entity; // r28
  double v7; // fp11
  double v10; // fp0
  double v11; // fp0
  double v13; // fp0
  double v15; // fp24
  double v16; // fp25
  double v17; // fp1
  double v18; // fp26
  double v19; // fp28
  int visChangeTime; // r30
  __int64 v21; // r10
  double v22; // fp0
  double v23; // fp29
  idAI2 *v24; // r3
  int value; // r9
  idEntityPtr<idEntity const > *p_currentFriendly; // r30
  idEntity *v27; // r3
  idAI2 *v28; // r3
  idAI2 *v29; // r3
  idEntity *v30; // r3
  __int64 v31; // r11
  int LookedAtElapsedTime; // r3
  double v33; // fp31
  double v34; // fp0
  idPhysics *Physics; // r3
  float *v36; // r30
  const idVec3 *v37; // r3
  double v38; // fp9
  double v39; // fp7
  idPhysics *v40; // r30
  float *v41; // r3
  double v42; // fp13
  double v43; // fp11
  __int128 v44; // r6
  __int64 v45; // r10
  va *v46; // r4
  double v47; // fp1
  int v49; // [sp+8h] [-1288h]
  int v50; // [sp+Ch] [-1284h]
  int v51; // [sp+10h] [-1280h]
  int v52; // [sp+14h] [-127Ch]
  int v53; // [sp+18h] [-1278h]
  int v54; // [sp+1Ch] [-1274h]
  float v55; // [sp+60h] [-1230h]
  int v56; // [sp+64h] [-122Ch]
  const idVec3 *v57; // [sp+68h] [-1228h]
  int v58; // [sp+70h] [-1220h]
  float v59; // [sp+78h] [-1218h] BYREF
  float v60; // [sp+7Ch] [-1214h]
  float v61; // [sp+80h] [-1210h]
  float v62; // [sp+88h] [-1208h] BYREF
  float v63; // [sp+8Ch] [-1204h]
  float v64; // [sp+90h] [-1200h]
  float v65; // [sp+94h] [-11FCh]
  idCVar *v66; // [sp+98h] [-11F8h]
  float v67; // [sp+9Ch] [-11F4h]
  float v68; // [sp+A0h] [-11F0h]
  float v69; // [sp+A4h] [-11ECh]
  float v70; // [sp+A8h] [-11E8h]
  float v71; // [sp+ACh] [-11E4h]
  int v73; // [sp+B4h] [-11DCh]
  float v74; // [sp+B8h] [-11D8h]
  float v75; // [sp+BCh] [-11D4h]
  float v76[4]; // [sp+C0h] [-11D0h] BYREF
  idNonEnemyTargetFilter v77; // [sp+D0h] [-11C0h] BYREF
  int v79; // [sp+DCh] [-11B4h]
  int v81; // [sp+E4h] [-11ACh]
  __int64 v82; // [sp+E8h] [-11A8h]
  int v84; // [sp+F4h] [-119Ch]
  __int64 v85; // [sp+F8h] [-1198h]
  idTargetList v86; // [sp+100h] [-1190h] BYREF
  int v87; // [sp+138h] [-1158h] BYREF
  int v88; // [sp+148h] [-1148h] BYREF
  va v89; // [sp+160h] [-1130h] BYREF

  *bestEntity = nullptr;
  v55 = -1.0;
  idNonEnemyTargetFilter::idNonEnemyTargetFilter(this: &v77, minAwareness_: AIAWARE_CONFIRMED);
  idTargetList::idTargetList(this: &v86, targetCache_: &this->aiVolatile.world.worldState.targetCache);
  idTargetList::Filter(this: &v86, owner: this, filter: &v77);
  v58 = 0;
  if ( v86.viableTargets.num > 0 )
  {
    v56 = 0;
    v74 = 0.00014999999;
    v68 = 10000.0;
    v65 = 0.0099999998;
    v71 = 0.40000001;
    v69 = 0.00025000001;
    v75 = 0.30000001;
    v70 = 3.0;
    v67 = 0.89999998;
    v66 = &ai_debugLevel;
    do
    {
      v3 = v86.viableTargets.list[v56];
      es = (idAIEntityState *)v86.targetCache->targets.list[v3].es;
      v5 = &v86.targetCache->targets.list[v3];
      if ( es != nullptr )
      {
        Entity = (idAI2 *)idAIEntityState::GetEntity(this: es);
        if ( Entity != nullptr && idAIEntityState::IsVisible(this: (idAIEntityState *)v5->es) )
        {
          v7 = (float)(v5->distSqr * (float)0.5);
          _FP10 = (float)(v5->distSqr - idMath::FLT_SMALLEST_NON_DENORMAL);
          __asm { fsel      f2, f10, f12, f0 }
          v10 = __frsqrte(_FP2);
          v11 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v10 * (float)v7) * (float)v10) - (float)1.5) * (float)v10)
                                                                                              * (float)v7)
                                                                                      * (float)((float)-(float)((float)((float)((float)v10 * (float)v7) * (float)v10) - (float)1.5)
                                                                                              * (float)v10))
                                                                              - (float)1.5)
                                                              * (float)((float)-(float)((float)((float)((float)v10 * (float)v7)
                                                                                              * (float)v10)
                                                                                      - (float)1.5)
                                                                      * (float)v10))
                                                      * (float)v7)
                                              * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v10 * (float)v7) * (float)v10) - (float)1.5)
                                                                                              * (float)v10)
                                                                                      * (float)v7)
                                                                              * (float)((float)-(float)((float)((float)((float)v10 * (float)v7) * (float)v10) - (float)1.5)
                                                                                      * (float)v10))
                                                                      - (float)1.5)
                                                      * (float)((float)-(float)((float)((float)((float)v10 * (float)v7)
                                                                                      * (float)v10)
                                                                              - (float)1.5)
                                                              * (float)v10)))
                                      - (float)1.5)
                      * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v10 * (float)v7)
                                                                                              * (float)v10)
                                                                                      - (float)1.5)
                                                                      * (float)v10)
                                                              * (float)v7)
                                                      * (float)((float)-(float)((float)((float)((float)v10 * (float)v7)
                                                                                      * (float)v10)
                                                                              - (float)1.5)
                                                              * (float)v10))
                                              - (float)1.5)
                              * (float)((float)-(float)((float)((float)((float)v10 * (float)v7) * (float)v10)
                                                      - (float)1.5)
                                      * (float)v10)));
          _FP6 = (float)((float)((float)(v5->distSqr * (float)v11)
                               / (float)((float)(UNITS_PER_INCH_2 * (float)200.0) * (float)12.0))
                       - (float)1.0);
          v13 = (float)((float)(this->actorVolatile.modelInfo.modelAxis.mat[0].x * (float)(v5->delta.x * (float)v11))
                      + (float)((float)(this->actorVolatile.modelInfo.modelAxis.mat[0].y
                                      * (float)(v5->delta.y * (float)v11))
                              + (float)(this->actorVolatile.modelInfo.modelAxis.mat[0].z
                                      * (float)(v5->delta.z * (float)v11))));
          __asm { fsel      f5, f6, f27, f8 }
          v15 = (float)((float)1.0 - (float)_FP5);
          if ( v13 >= 0.0 )
          {
            if ( v13 > 0.0 )
            {
              if ( v13 < 1.0 )
                v16 = (float)((float)((float)v13 * v67) + (float)0.1);
              else
                v16 = 1.0;
            }
            else
            {
              v16 = 0.1;
            }
            v17 = idRelationship::FloatForAttitude(attitude: (idRelationship::attitude_t)v5->attitude);
            v18 = 0.5;
            if ( v17 < v70 || v17 >= 5.0 )
              v18 = 1.0;
            v19 = v75;
            if ( v5->es->senses.ptr[1]->lastUnconfirmedStimTime >= 0 )
            {
              visChangeTime = v5->es->visChangeTime;
              if ( visChangeTime >= 0 )
              {
                LODWORD(v21) = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
                             - visChangeTime;
                v82 = v21;
                v22 = (float)v21;
                if ( v22 < 2000.0 )
                {
                  if ( v22 > 0.0 )
                    v19 = (float)-(float)((float)((float)v21 * v69) - (float)1.0);
                  else
                    v19 = 1.0;
                }
              }
              else
              {
                v19 = 1.0;
              }
            }
            v23 = v71;
            v24 = idAI2::CastTo(c: Entity);
            if ( v24 != nullptr && idAIMemory::GetNeutral(this: &v24->aiVolatile.focus.foci.ptr[1]) == this )
              v23 = 1.0;
            value = this->aiVolatile.memory.currentFriendly.spawnId.value;
            p_currentFriendly = &this->aiVolatile.memory.currentFriendly;
            if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
              && (v27 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
            {
              v28 = (idAI2 *)idEntity::CastTo(c: v27);
            }
            else
            {
              v28 = nullptr;
            }
            v29 = idAI2::CastTo(c: v28);
            if ( v29 != nullptr )
              idAI2::GetLookFocusEntity(this: v29);
            if ( gameLocal->spawnIds.ptr[p_currentFriendly->spawnId.value & 0x1FFF] == p_currentFriendly->spawnId.value >> 13 )
            {
              v30 = gameLocal->entities.ptr[p_currentFriendly->spawnId.value & 0x1FFF];
              if ( v30 != nullptr )
                idEntity::CastTo(c: v30);
            }
            if ( (unsigned __int8)idCheckSurroundingsState::CanUse(
                                    this: &this->aiVolatile.focus.checkSurroundingsState,
                                    ai: this) != 0 )
              LookedAtElapsedTime = idCheckSurroundingsState::GetLookedAtElapsedTime(
                                      this: &this->aiVolatile.focus.checkSurroundingsState,
                                      entity: Entity);
            else
              LookedAtElapsedTime = 0;
            v33 = v65;
            if ( LookedAtElapsedTime >= 4000 )
            {
              LODWORD(v31) = LookedAtElapsedTime;
              v85 = v31;
              v34 = (float)v31;
              if ( v34 > 4000.0 )
              {
                if ( v34 < v68 )
                  v33 = (float)((float)((float)((float)v31 - (float)4000.0) * v74) + (float)0.1);
                else
                  v33 = 1.0;
              }
              else
              {
                v33 = 0.1;
              }
            }
            if ( ai_debugLook.valueInteger >= 2 && v66->valueInteger >= 1 )
            {
              Physics = idEntity::GetPhysics(this);
              v36 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
              v37 = this->GetEyeOffset(this: &v87, result: this);
              v38 = (float)(v36[2] + v37->z);
              v39 = (float)(v36[1] + v37->y);
              v59 = v37->x + *v36;
              v61 = v38;
              v60 = v39;
              v40 = idEntity::GetPhysics(this: Entity);
              v57 = this->GetEyeOffset(this: &v88, result: this);
              v41 = (float *)v40->GetOrigin(this: v40, a2: 0);
              v42 = (float)(v57->z + v41[2]);
              v43 = (float)(v57->y + v41[1]);
              v62 = v57->x + *v41;
              v64 = v42;
              v63 = v43;
              ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))clientGame->renderWorld->DebugArrow)(
                a1: clientGame->renderWorld,
                a2: &idColor::colorYellow,
                a3: &v59,
                a4: &v62,
                a5: 5.0);
              *(double *)((char *)&v44 + 4) = (float)((float)((float)((float)((float)((float)((float)v33 * (float)v23)
                                                                                    * (float)v19)
                                                                            * (float)v18)
                                                                    * (float)v16)
                                                            * (float)v15)
                                                    * 100.0);
              v76[1] = (float)(v60 * (float)0.2) + (float)(v63 * (float)0.80000001);
              HIDWORD(v45) = (int)(float)((float)v19 * 100.0);
              v79 = (int)(float)((float)v18 * 100.0);
              v81 = (int)(float)((float)v16 * 100.0);
              v84 = (int)(float)((float)v15 * 100.0);
              LODWORD(v45) = (int)(float)((float)v23 * 100.0);
              v73 = (int)(float)((float)v33 * 100.0);
              LODWORD(v44) = v84;
              v76[2] = (float)(v61 * (float)0.2) + (float)(v64 * (float)0.80000001);
              v76[0] = (float)(v59 * (float)0.2) + (float)(v62 * (float)0.80000001);
              v46 = va::va(
                      this: &v89,
                      fmt: (const char *)DWORD1(v44),
                      a3: v44,
                      a4: __SPAIR64__(v81, v79),
                      a5: v45,
                      a6: v49,
                      a7: v50,
                      a8: v51,
                      a9: v52,
                      a10: v53,
                      a11: v54,
                      *(double *)((char *)&v44 + 4));
              ((void (__fastcall *)(idRenderWorld *, va *, float *, idRenderWorld_vtbl *, idColor *, int, int, int, double))clientGame->renderWorld->DebugText)(
                a1: clientGame->renderWorld,
                a2: v46,
                a3: v76,
                a4: clientGame->renderWorld->__vftable,
                a5: &idColor::colorYellow,
                a6: 1,
                a7: lifeTime,
                a8: 1,
                a9: scale_0);
            }
            if ( (float)((float)((float)((float)((float)((float)((float)v33 * (float)v23) * (float)v19) * (float)v18)
                                       * (float)v16)
                               * (float)v15)
                       * 100.0) > (double)v55 )
            {
              v55 = (float)((float)((float)((float)((float)((float)v33 * (float)v23) * (float)v19) * (float)v18)
                                  * (float)v16)
                          * (float)v15)
                  * 100.0;
              *bestEntity = Entity;
            }
          }
        }
      }
      ++v58;
      ++v56;
    }
    while ( v58 < v86.viableTargets.num );
  }
  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v86);
  v47 = v55;
  return *((float *)&v47 + 1);
}


// ========================================================================
// __unwind$548969
// EA  : 0x82A0B208
// RVA : 0x00A0B208
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_548969()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 4752 + 208));
}


// ========================================================================
// __unwind$548970
// EA  : 0x82A0B230
// RVA : 0x00A0B230
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_548970()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 4752 + 256));
}


// ========================================================================
// ?StartActionScript@idAI2@@QAAXH@Z
// EA  : 0x82A0B260
// RVA : 0x00A0B260
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::StartActionScript(idAI2 *this, const int curTime)
{
  idFSMManager::idFSMStack v3[2]; // [sp+50h] [-40h] BYREF

  if ( !this->IsDead(this) )
  {
    if ( this->actorConstants.actorClass != ACTORCLASS_MUTANT )
    {
      if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x40) != 0 )
        idFaceMgr::SetEnableMoodAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x20) != 0 )
        idFaceMgr::SetEnableLipSyncAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x10) != 0 )
        idFaceMgr::SetEnableGestureAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 0x10) != 0 )
        idFaceMgr::SetEnableEyeTracking(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 4) != 0 )
        idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 2) != 0 )
        idFaceMgr::SetEnableLidDeformation(this: &this->aiVolatile.faceMgr, owner: this, enable: true);
    }
    vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)v3);
    idFSMManager::idFSMStack::Add(
      this: v3,
      fsmType: &idAlertCycleFSM::Type,
      stateType: &idAlertCycle_ActionScript::Type);
    idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: v3);
    idAI2::SetAlertCycle(this, ac: ALERTCYCLE_RELAXED);
    idComponentTimeLine::Start(this: &this->actionScript);
    idPLog::~idPLog(this: v3);
  }
}


// ========================================================================
// __unwind$549337
// EA  : 0x82A0B3B8
// RVA : 0x00A0B3B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_549337()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 144 + 80));
}


// ========================================================================
// ?GiveAwarenessOfEntity@idAI2@@QAAXPBVidEntity@@W4alertCycle_t@@@Z
// EA  : 0x82A0B3E0
// RVA : 0x00A0B3E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GiveAwarenessOfEntity(idAI2 *this, const idEntity *ent, alertCycle_t alertCycle)
{
  aiStimulus_t v6; // r26
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r28
  idEncounterGroup *v8; // r3
  idAI2::idAIVolatile::idAIWorldStateInfo *p_world; // r30
  idAIGameState *p_aiGameState; // r28
  const idSpawnId *v11; // r23
  const idAILogic *v12; // r3
  const idSpawnId *v13; // r8
  idAIGameState *v14; // r24
  const aiSenseState_t *v15; // r23
  const idSpawnId *v16; // r22
  const idAILogic *v17; // r3
  const idSpawnId *v18; // r8
  idAIEntityState *v19; // r3
  idSpawnId v20; // [sp+50h] [-90h] BYREF
  idSpawnId v21[3]; // [sp+54h] [-8Ch] BYREF
  idAILogic v22[4]; // [sp+60h] [-80h] BYREF

  if ( ent == nullptr )
  {
    idLib::Warning(fmt: "idAI2::GiveAwarenessOfEntity - entity is NULL");
    return;
  }
  v6 = AISTIMULUS_TRIGGER;
  if ( alertCycle == ALERTCYCLE_SEARCH )
    v6 = AISTIMULUS_HEARING;
  p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
    || idEncounterGroupManager::GroupForHandle(
         this: &gameLocal->encounterGroupManager,
         handle: &this->aiVolatile.encounterGroupHandle) == nullptr )
  {
    idLib::Warning(
      fmt: "idAI2::GiveAwarenessOfEntity: ai %s does not yet have a group to inherit enemy location, must use real location",
      this->name.data);
LABEL_12:
    p_world = &this->aiVolatile.world;
    p_aiGameState = &gameLocal->aiGameState;
    idSpawnId::idSpawnId(this: &v20, ent: this);
    v11 = idSpawnId::idSpawnId(this: v21, ent);
    v12 = idAILogic::idAILogic(this: v22, ai: this);
    idAIWorldState::AddEntityState(
      this: &this->aiVolatile.world.worldState,
      gameState: p_aiGameState,
      owner: v12,
      entId: v11,
      stimulusType: v6,
      stimulusAmount: 1.0,
      sourceId: v13);
    goto LABEL_14;
  }
  if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
    v8 = nullptr;
  else
    v8 = idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle);
  if ( idEncounterGroup::GetFreshestSenseOfEntity(this: v8, ent) == nullptr )
    goto LABEL_12;
  p_world = &this->aiVolatile.world;
  v14 = &gameLocal->aiGameState;
  v15 = (const aiSenseState_t *)idSpawnId::idSpawnId(this: v21, ent: this);
  v16 = idSpawnId::idSpawnId(this: &v20, ent);
  v17 = idAILogic::idAILogic(this: v22, ai: this);
  idAIWorldState::AddEntityState(
    this: &this->aiVolatile.world.worldState,
    gameState: v14,
    owner: v17,
    entId: v16,
    stimulusType: v6,
    stimulusAmount: 1.0,
    sourceId: v18,
    sourceSense: v15);
LABEL_14:
  v19 = idAIWorldState::StateForEntity(this: &p_world->worldState, ent);
  if ( alertCycle == ALERTCYCLE_COMBAT && v19 != nullptr )
    *((_BYTE *)v19 + 541) &= ~0x40u;
  this->aiVolatile.memory.currentEnemy.spawnId.value = (gameLocal->spawnIds.ptr[ent->entityNumber] << 13)
                                                     | ent->entityNumber;
  if ( !idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this) )
  {
    if ( idAI2::GetAlertCycle(this) == ALERTCYCLE_COMBAT )
      idFocusInfo::SetFocusEntity(
        this: this->aiVolatile.focus.foci.ptr,
        owner: this,
        _ent: ent,
        _keepFocusInView: true,
        _aimPoint: AIMPOINT_BEST,
        duration: -1);
    idWanderingAim::Diverge(this: (idWanderingAim *)&this->aiVolatile.focus, ai: this);
  }
  idAI2::SetAlertCycle(this, ac: alertCycle);
}


// ========================================================================
// ?GiveAwarenessOfNearestPlayer@idAI2@@QAAXW4alertCycle_t@@@Z
// EA  : 0x82A0B630
// RVA : 0x00A0B630
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GiveAwarenessOfNearestPlayer(idAI2 *this, alertCycle_t alertCycle)
{
  idPlayer *PlayerTarget; // r3

  PlayerTarget = idAI2::GetPlayerTarget(this, player: AIPLAYER_CLOSEST);
  if ( PlayerTarget != nullptr || (PlayerTarget = idAI2::GetPlayerTarget(this, player: AIPLAYER_CLOSEST)) != nullptr )
    idAI2::GiveAwarenessOfEntity(this, ent: PlayerTarget, alertCycle);
  else
    idLib::Warning(fmt: "idAI2::ForceAwarenessOfNearestPlayer - no players found.");
}


// ========================================================================
// ?ForceOpenCombat@idAI2@@QAAXPBVidEntity@@@Z
// EA  : 0x82A0B6B0
// RVA : 0x00A0B6B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceOpenCombat(idAI2 *this, const idEntity *enemy)
{
  idAI2::idAIVolatile::idAIWorldStateInfo *p_world; // r28
  idAIGameState *p_aiGameState; // r26
  const idSpawnId *v6; // r24
  const idAILogic *v7; // r3
  const idSpawnId *v8; // r8
  idAIEntityState *v9; // r3
  idEntityPtr<idEntity const > *p_currentEnemy; // r8
  idSpawnId v11; // [sp+50h] [-A0h] BYREF
  idSpawnId v12; // [sp+54h] [-9Ch] BYREF
  idFSMManager::idFSMStack v13; // [sp+60h] [-90h] BYREF
  idAILogic v14[3]; // [sp+80h] [-70h] BYREF

  p_world = &this->aiVolatile.world;
  p_aiGameState = &gameLocal->aiGameState;
  idSpawnId::idSpawnId(this: &v11, ent: this);
  v6 = idSpawnId::idSpawnId(this: &v12, ent: enemy);
  v7 = idAILogic::idAILogic(this: v14, ai: this);
  idAIWorldState::AddEntityState(
    this: &p_world->worldState,
    gameState: p_aiGameState,
    owner: v7,
    entId: v6,
    stimulusType: AISTIMULUS_TRIGGER,
    stimulusAmount: 1.0,
    sourceId: v8);
  v9 = idAIWorldState::StateForEntity(this: &p_world->worldState, ent: enemy);
  if ( v9 != nullptr )
    *((_BYTE *)v9 + 541) &= ~0x40u;
  p_currentEnemy = &this->aiVolatile.memory.currentEnemy;
  if ( enemy != nullptr )
  {
    v12.value = enemy->entityNumber;
    p_currentEnemy->spawnId.value = (gameLocal->spawnIds.ptr[v12.value] << 13) | v12.value;
  }
  else
  {
    p_currentEnemy->spawnId.value = 0x1FFF;
  }
  idFocusInfo::SetFocusEntity(
    this: this->aiVolatile.focus.foci.ptr,
    owner: this,
    _ent: enemy,
    _keepFocusInView: true,
    _aimPoint: AIMPOINT_BEST,
    duration: -1);
  idAI2::ResetAnimState(this, web: AIANIMWEB_BODY, subWeb: AISUBWEB_COMBAT, stateName: "idle");
  vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v13);
  idFSMManager::idFSMStack::Add(this: &v13, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Combat::Type);
  idFSMManager::idFSMStack::Add(this: &v13, fsmType: &idCombatFSM::Type, stateType: &idCombat_OpenCombat::Type);
  idFSMManager::idFSMStack::Add(this: &v13, fsmType: &idOpenCombatFSM::Type, stateType: &idOpenCombat_Default::Type);
  idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v13);
  idPLog::~idPLog(this: &v13);
}


// ========================================================================
// __unwind$549553_0
// EA  : 0x82A0B834
// RVA : 0x00A0B834
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_549553_0()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 240 + 96));
}


// ========================================================================
// ?ForcePlayerInteraction@idAI2@@QAAXPBVidEntity@@@Z
// EA  : 0x82A0B868
// RVA : 0x00A0B868
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForcePlayerInteraction(idAI2 *this, idPlayer *ent)
{
  idPlayer *v3; // r3
  idEntityPtr<idPlayer> *p_interactionEntity; // r8
  idFSMManager::idFSMStack v5; // [sp+60h] [-40h] BYREF

  v3 = idPlayer::CastTo(c: ent);
  p_interactionEntity = &this->aiVolatile.memory.interactionEntity;
  if ( v3 != nullptr )
    p_interactionEntity->spawnId.value = (gameLocal->spawnIds.ptr[v3->entityNumber] << 13) | v3->entityNumber;
  else
    p_interactionEntity->spawnId.value = 0x1FFF;
  vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v5);
  idFSMManager::idFSMStack::Add(this: &v5, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Relaxed::Type);
  idFSMManager::idFSMStack::Add(this: &v5, fsmType: &idRelaxedFSM::Type, stateType: &idRelaxed_InteractWithPlayer::Type);
  idFSMManager::idFSMStack::Add(
    this: &v5,
    fsmType: &idPlayerInteractFSM::Type,
    stateType: &idPlayerInteract_WaitBriefly::Type);
  idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v5);
  idPLog::~idPLog(this: &v5);
}


// ========================================================================
// __unwind$549678
// EA  : 0x82A0B950
// RVA : 0x00A0B950
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_549678()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 160 + 96));
}


// ========================================================================
// ?ForceFollowFriendly@idAI2@@QAAXPBVidEntity@@@Z
// EA  : 0x82A0B980
// RVA : 0x00A0B980
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceFollowFriendly(idAI2 *this, const idEntity *friendly)
{
  idAIGameState *p_aiGameState; // r28
  const idSpawnId *v5; // r29
  const idAILogic *v6; // r3
  const idSpawnId *v7; // r8
  const idDeclAIBehavior *v8; // r29
  const idDeclFaction *v9; // r3
  idSpawnId v10; // [sp+50h] [-80h] BYREF
  idSpawnId v11; // [sp+54h] [-7Ch] BYREF
  idFSMManager::idFSMStack v12; // [sp+60h] [-70h] BYREF
  idAILogic v13[2]; // [sp+80h] [-50h] BYREF

  p_aiGameState = &gameLocal->aiGameState;
  idSpawnId::idSpawnId(this: &v10, ent: this);
  v5 = idSpawnId::idSpawnId(this: &v11, ent: friendly);
  v6 = idAILogic::idAILogic(this: v13, ai: this);
  idAIWorldState::AddEntityState(
    this: &this->aiVolatile.world.worldState,
    gameState: p_aiGameState,
    owner: v6,
    entId: v5,
    stimulusType: AISTIMULUS_TRIGGER,
    stimulusAmount: 1.0,
    sourceId: v7);
  v8 = (const idDeclAIBehavior *)idDeclInfo::FindWithInheritance(
                                   this: &idDeclAIBehavior::resourceList,
                                   name: "behaviors/settlers/buddy",
                                   makeDefault: true);
  v9 = (const idDeclFaction *)idDeclInfo::FindWithInheritance(
                                this: &idDeclFaction::resourceList,
                                name: "faction/settlers/buddy",
                                makeDefault: true);
  if ( v8 != nullptr || v9 != nullptr )
  {
    this->aiEditable.behaviors.decl = v8;
    idActor::SetFaction(this, faction: v9);
    vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v12);
    idFSMManager::idFSMStack::Add(this: &v12, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Relaxed::Type);
    idFSMManager::idFSMStack::Add(this: &v12, fsmType: &idRelaxedFSM::Type, stateType: &idRelaxed_FollowFriendly::Type);
    idFSMManager::idFSMStack::Add(
      this: &v12,
      fsmType: &idFollowFriendlyFSM::Type,
      stateType: &idFollowFriendly_Default::Type);
    idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v12);
    idPLog::~idPLog(this: &v12);
  }
  else
  {
    idLib::Warning(fmt: "idAI2::ForceFollow failed.", 0);
  }
}


// ========================================================================
// __unwind$549789
// EA  : 0x82A0BACC
// RVA : 0x00A0BACC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_549789()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 208 + 96));
}


// ========================================================================
// ?PositionScore@idAI2@@QAAMABVidVec3@@PBVaiSenseState_t@@AAM222@Z
// EA  : 0x82A0BB00
// RVA : 0x00A0BB00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::PositionScore(
        idAI2 *this,
        const idVec3 *candidatePosition,
        aiSenseState_t *ss,
        float *targetDistScore,
        float *aiDistScore,
        float *groupScore,
        float *hintNodeScore)
{
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  float y; // r8
  float z; // r7
  idVec3 *v17; // r4
  const idDeclAIBehavior *decl; // r28
  double v19; // fp28
  double v20; // fp1
  idPhysics *Physics; // r3
  float *v22; // r3
  double v23; // fp10
  double v24; // fp6
  double v25; // fp13
  double closeMeleeDist; // fp30
  double v27; // fp29
  double v28; // fp27
  double v29; // fp31
  idWeapon *v30; // r3
  float *v31; // r11
  idEncounterGroup *v32; // r3
  double v33; // fp30
  encounterGroupRole_t currentRole; // r22
  idCombatStage *CurrentCombatStage; // r3
  double v36; // fp31
  float v37; // r6
  float x; // r9
  idPhysics *v39; // r3
  idRenderWorld_vtbl *v40; // r29
  int v41; // r3
  va *v42; // r3
  int v44; // [sp+8h] [-1238h]
  int v45; // [sp+Ch] [-1234h]
  int v46; // [sp+10h] [-1230h]
  int v47; // [sp+14h] [-122Ch]
  int v48; // [sp+18h] [-1228h]
  int v49; // [sp+1Ch] [-1224h]
  _DWORD v50[2]; // [sp+60h] [-11E0h] BYREF
  float v51; // [sp+68h] [-11D8h]
  float v52[4]; // [sp+70h] [-11D0h] BYREF
  _DWORD v53[4]; // [sp+80h] [-11C0h] BYREF
  idStaticList<idAI2 *,64> v54; // [sp+90h] [-11B0h] BYREF
  va v55; // [sp+1A0h] [-10A0h] BYREF

  ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: ss);
  y = ConfirmedPhysicalSafe->origin.y;
  z = ConfirmedPhysicalSafe->origin.z;
  v53[0] = LODWORD(ConfirmedPhysicalSafe->origin.x);
  *(float *)&v53[1] = y;
  *(float *)&v53[2] = z;
  aiSenseState_t::ExtrapolatePosition(this: ss, seconds: 0.0, futurePos: v17);
  decl = this->aiEditable.behaviors.decl;
  v19 = __fsqrts((float)((float)((float)(candidatePosition->z - v52[2]) * (float)(candidatePosition->z - v52[2]))
                       + (float)((float)((float)(candidatePosition->x - v52[0]) * (float)(candidatePosition->x - v52[0]))
                               + (float)((float)(candidatePosition->y - v52[1]) * (float)(candidatePosition->y - v52[1])))));
  if ( decl == nullptr )
    goto LABEL_2;
  *aiDistScore = 0.0;
  Physics = idEntity::GetPhysics(this);
  v22 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  v23 = (float)(candidatePosition->y - v22[1]);
  v24 = (float)(candidatePosition->z - v22[2]);
  v25 = __fsqrts((float)((float)((float)v24 * (float)v24)
                       + (float)((float)((float)(candidatePosition->x - *v22) * (float)(candidatePosition->x - *v22))
                               + (float)((float)v23 * (float)v23))));
  if ( v25 < (float)((float)(UNITS_PER_INCH_2 * (float)25.0) * (float)12.0) )
    *aiDistScore = (float)1.0 - (float)((float)v25 / (float)((float)(UNITS_PER_INCH_2 * (float)25.0) * (float)12.0));
  closeMeleeDist = decl->closeMeleeDist;
  v27 = closeMeleeDist;
  v28 = closeMeleeDist;
  v29 = 0.0;
  v30 = this->GetEquippedWeapon(this);
  if ( v30 != nullptr )
  {
    v31 = (float *)v30->decl;
    v28 = v31[144];
    v27 = v31[145];
    closeMeleeDist = v31[146];
    v29 = v31[147];
  }
  *targetDistScore = 0.0;
  if ( v19 >= v29 || v29 <= 0.0 )
  {
    if ( v19 >= closeMeleeDist )
    {
      if ( v19 >= (float)((float)((float)closeMeleeDist + (float)v27) * (float)0.5) )
      {
        if ( v19 >= v27 )
        {
          if ( v19 >= v28 )
            *targetDistScore = v19 <= 0.0 ? 0.0 : (float)((float)v28 / (float)v19) * (float)0.1;
          else
            *targetDistScore = (float)((float)((float)((float)v28 - (float)v19) * (float)0.40000001)
                                     / (float)((float)v28 - (float)v27))
                             + (float)0.1;
        }
        else
        {
          *targetDistScore = (float)((float)((float)((float)v27 - (float)v19) * (float)0.5)
                                   / (float)((float)v27
                                           - (float)((float)((float)closeMeleeDist + (float)v27) * (float)0.5)))
                           + (float)0.5;
        }
      }
      else
      {
        *targetDistScore = (float)((float)((float)((float)v19 - (float)closeMeleeDist) * (float)0.5)
                                 / (float)((float)((float)((float)closeMeleeDist + (float)v27) * (float)0.5)
                                         - (float)closeMeleeDist))
                         + (float)0.5;
      }
    }
    else
    {
      *targetDistScore = (float)((float)((float)((float)v19 - (float)v29) * (float)0.40000001)
                               / (float)((float)closeMeleeDist - (float)v29))
                       + (float)0.1;
    }
  }
  else
  {
    *targetDistScore = (float)((float)v19 / (float)v29) * (float)0.1;
  }
  *groupScore = 1.0;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
    && (v32 = idEncounterGroupManager::GroupForHandle(
                this: &gameLocal->encounterGroupManager,
                handle: &this->aiVolatile.encounterGroupHandle)) != nullptr )
  {
    v54.granularity = 1;
    v54.num = 0;
    v54.size = 64;
    v54.list = v54.staticList;
    v54.memTag = 5;
    v54.listStatic = 1;
    idEncounterGroup::GetLivingMembers(this: v32, list: &v54);
    *hintNodeScore = 1.0;
    v33 = 1.0;
    if ( idAI2::GetCurrentCombatStage(this) != nullptr )
    {
      currentRole = this->aiVolatile.groupStatus.currentRole;
      CurrentCombatStage = idAI2::GetCurrentCombatStage(this);
      if ( idCombatStage::GetRolePositionWeight(
             this: CurrentCombatStage,
             role: currentRole,
             pos: candidatePosition,
             hintClass: CLASS_ALL) <= 0.0 )
        v33 = 0.0;
    }
    v36 = (float)((float)((float)((float)(*targetDistScore * *aiDistScore) * *groupScore) * *hintNodeScore) * (float)v33);
    if ( ai_debugOpenCombatMove.valueInteger != 0 && ai_debugLevel.valueInteger > 0 )
    {
      v37 = candidatePosition->y;
      x = candidatePosition->x;
      v51 = candidatePosition->z;
      *(float *)&v50[1] = v37;
      *(float *)v50 = x;
      v51 = (float)((float)((float)(UNITS_PER_INCH_2 * (float)4.0) * (float)12.0) * (float)v36) + v51;
      clientGame->renderWorld->DebugLine(
        this: clientGame->renderWorld,
        a2: (const idVec4 *)&idColor::colorOrange,
        a3: candidatePosition,
        a4: (const idVec3 *)v50,
        a5: 2500,
        a6: true);
      v39 = idEntity::GetPhysics(this);
      v40 = clientGame->renderWorld->__vftable;
      v41 = (int)v39->GetOrigin(this: v39, a2: 0);
      v40->DebugLine(
        this: clientGame->renderWorld,
        a2: (const idVec4 *)&idColor::colorOrange,
        a3: candidatePosition,
        a4: (const idVec3 *)v41,
        a5: 2500,
        a6: true);
      v42 = va::va(
              this: &v55,
              fmt: (const char *)(const char *)HIDWORD(COERCE_UNSIGNED_INT64(*targetDistScore)),
              a3: __SPAIR64__(COERCE_UNSIGNED_INT64(*targetDistScore), COERCE_UNSIGNED_INT64(*aiDistScore)),
              a4: __SPAIR64__(COERCE_UNSIGNED_INT64(*groupScore), COERCE_UNSIGNED_INT64(*hintNodeScore)),
              a5: __SPAIR64__(LODWORD(v33), LODWORD(v36)),
              a6: v44,
              a7: v45,
              a8: v46,
              a9: v47,
              a10: v48,
              a11: v49);
      ((void (__fastcall *)(idRenderWorld *, va *, const idVec3 *, idRenderWorld *, idColor *, int, int, _DWORD, double))clientGame->renderWorld->DebugText)(
        a1: clientGame->renderWorld,
        a2: v42,
        a3: candidatePosition,
        a4: clientGame->renderWorld,
        a5: &idColor::colorOrange,
        a6: 1,
        a7: 2500,
        a8: 0,
        a9: 0.2);
      ((void (__fastcall *)(idRenderWorld *, idColor *, _DWORD *, float *, double))clientGame->renderWorld->DebugArrow)(
        a1: clientGame->renderWorld,
        a2: &idColor::colorRed,
        a3: v53,
        a4: v52,
        a5: 1.0);
    }
    idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)&v54);
    v20 = v36;
  }
  else
  {
LABEL_2:
    v20 = 0.0;
  }
  return *((float *)&v20 + 1);
}


// ========================================================================
// __unwind$550481
// EA  : 0x82A0C040
// RVA : 0x00A0C040
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_550481()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 4672 + 144));
}


// ========================================================================
// ?Cmd_ForceFollow_f@idAI2@@SAXABVidCmdArgs@@@Z
// EA  : 0x82A0C068
// RVA : 0x00A0C068
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Cmd_ForceFollow_f(const idCmdArgs *args)
{
  int value; // r8
  idEntity *v2; // r3
  idAI2 *v3; // r3
  idAI2 *v4; // r31
  idPlayer *DebugPlayer; // r3

  if ( idGameLocal::CheckCheats(this: gameLocal, player: nullptr) )
  {
    value = gameLocal->debugEntity.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v2 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v3 = (idAI2 *)idEntity::CastTo(c: v2);
    }
    else
    {
      v3 = nullptr;
    }
    v4 = idAI2::CastTo(c: v3);
    if ( v4 != nullptr )
    {
      DebugPlayer = idGameLocal::GetDebugPlayer(this: gameLocal);
      idAI2::ForceFollowFriendly(this: v4, friendly: DebugPlayer);
    }
    else
    {
      idLib::Printf(fmt: "No current AI debug target was found.\n");
    }
  }
}


// ========================================================================
// ?ForceFSMIntoExecutingScript@idAIScriptProxy@@AAA_NXZ
// EA  : 0x82A0C138
// RVA : 0x00A0C138
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAIScriptProxy::ForceFSMIntoExecutingScript(idAIScriptProxy *this)
{
  idFiniteStateMachine *v2; // r3
  idFSMManager::idFSMStack v4[2]; // [sp+50h] [-40h] BYREF

  v2 = this->owner->aiVolatile.fsms.fsmManager.FindFSM_3(
         this: &this->owner->aiVolatile.fsms,
         a2: &idAlertCycleFSM::Type);
  if ( v2 == nullptr
    || idAlertCycle_ExecuteDoomscript::CastTo(c: (idAlertCycle_ExecuteDoomscript *)v2->curState) != nullptr )
  {
    return 0;
  }
  vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)v4);
  idFSMManager::idFSMStack::Add(
    this: v4,
    fsmType: &idAlertCycleFSM::Type,
    stateType: &idAlertCycle_ExecuteDoomscript::Type);
  idFSMManager::SetFSMStack(this: &this->owner->aiVolatile.fsms.fsmManager, stack: v4);
  idPLog::~idPLog(this: v4);
  return 1;
}


// ========================================================================
// __unwind$550690
// EA  : 0x82A0C1D0
// RVA : 0x00A0C1D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_550690()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 144 + 80));
}


// ========================================================================
// ?Damage@idAI2@@UAAMPAVidEntity@@0PBVidDeclDamage@@MABVidVec3@@PAUtrace_t@@@Z
// EA  : 0x82A0CAC8
// RVA : 0x00A0CAC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

float __fastcall idAI2::Damage(
        idAI2 *this,
        idWorldspawn *inflictor,
        idAI2 *attacker,
        const idDeclDamage *damageDecl,
        double damageScale,
        const idVec3 *dir,
        idVec3 *trace,
        int a8)
{
  double v15; // fp1
  idAIHealth *p_aiHealth; // r15
  const idDeclAIBehavior *decl; // r27
  idIndex<short,enum invalidJointIndex_t> *v18; // r18
  int v19; // r25
  int v20; // r11
  idAnimator_AF *v21; // r3
  double v22; // fp13
  double v23; // fp12
  idPhysics *Physics; // r3
  float *v25; // r3
  idPhysics *v26; // r3
  float *v27; // r3
  double v28; // fp6
  double v29; // fp4
  double damageTakenMultiplier; // fp30
  double v31; // fp25
  double v32; // fp26
  double AIIncomingDamageScale; // fp29
  __int32 v34; // r10
  double v35; // fp29
  int GameMs; // r30
  double v37; // fp29
  double v38; // fp27
  idFaction *v39; // r3
  double v40; // fp29
  const idVec3 *v41; // r9
  const idVec3 *v42; // r8
  idAI2 *v43; // r3
  const idVec3 *v44; // r5
  const idDamageGroup *v45; // r4
  idAI2 *v46; // r4
  idEventArg *v47; // r3
  float *v48; // r10
  _DWORD *v49; // r11
  int j; // ctr
  idEntity *v51; // r3
  idDamageGroup *DamageGroup; // r23
  float *v53; // r6
  const idVec3 *v54; // r5
  idDamageGroup *v55; // r4
  bool v56; // r3
  __int64 v57; // r10
  bool v58; // r20
  double locationArmor; // fp28
  int num; // r11
  int v61; // r29
  double v62; // fp29
  int v63; // r30
  idDamageGroup *v64; // r5
  double v65; // fp30
  __int128 v66; // r8
  __int128 v67; // r8
  const idVec3 *v68; // r6
  idActor *v69; // r30
  idFaction *v70; // r3
  idFaction *v71; // r29
  idRelationship::attitude_t AttitudeTowards; // r3
  double neutralAttitudeAdjust; // fp1
  char v74; // r29
  const idVec3 *v75; // r8
  int valueInteger; // r30
  idAI2 *v77; // r30
  idTurret *v78; // r3
  idPlayer *v79; // r4
  double v80; // fp1
  const idVec3 *v81; // r6
  idSpawnId *SpawnId; // r3
  const idVec3 *v83; // r7
  idPresentable *presentable; // r3
  idPresentable *v85; // r11
  const idDeclAIBehavior *v86; // r30
  idScriptObject *v87; // r30
  double v88; // fp1
  BOOL v89; // r5
  idAI2 *v90; // r4
  idEventArg *v91; // r3
  float *v92; // r10
  _DWORD *v93; // r11
  int i; // ctr
  idEntity *v95; // r3
  idSpawnId *v96; // r3
  char v97; // r30
  idPresentable *v98; // r3
  int eventTime; // r30
  int ServerGameTime; // r3
  char v101; // r11
  idPresentable *v102; // r3
  idPresentable *v103; // r3
  idPlayer *v104; // r3
  idDamageGroup *v105; // r3
  int v106; // r11
  unsigned int v107; // r5
  int v108; // r3
  int entityNumber; // r10
  char v110; // r11
  int soonestTauntRageTime; // r11
  bool v112; // r5
  runIndexType_t v113; // r4
  aiInjuredRunMode_t injuredRunMode; // r11
  char v115; // r5
  runIndexType_t v116; // r4
  idList<idDamageGroup,5> *p_damageGroups; // r10
  double v118; // fp0
  int v119; // r30
  int v120; // r8
  int v121; // r9
  idDamageGroup *v122; // r11
  int v123; // r3
  int v124; // r6
  int v125; // r11
  double v126; // fp1
  double forwardRunIndex; // fp1
  idPresentable *v128; // r11
  idPresentable *v129; // r4
  float *v131; // [sp+8h] [-358h]
  bool v132; // [sp+Bh] [-355h]
  float *v133; // [sp+Ch] [-354h]
  bool v134; // [sp+Fh] [-351h]
  idDeclDamage::damageType_t v135; // [sp+10h] [-350h]
  bool v136; // [sp+13h] [-34Dh]
  float v137; // [sp+90h] [-2D0h] BYREF
  _BYTE v138[4]; // [sp+94h] [-2CCh] BYREF
  idVec3 v139; // [sp+98h] [-2C8h] BYREF
  float v140[2]; // [sp+A4h] [-2BCh] BYREF
  float v141; // [sp+ACh] [-2B4h] BYREF
  float v142[2]; // [sp+B0h] [-2B0h] BYREF
  float v143[2]; // [sp+B8h] [-2A8h] BYREF
  float v144[2]; // [sp+C0h] [-2A0h] BYREF
  float v145; // [sp+C8h] [-298h] BYREF
  float v146; // [sp+CCh] [-294h] BYREF
  __int64 v147; // [sp+D8h] [-288h]
  _BYTE v148[16]; // [sp+E8h] [-278h] BYREF
  _BYTE v149[24]; // [sp+F8h] [-268h] BYREF
  idEventArg v150[2]; // [sp+110h] [-250h] BYREF
  idScriptFunction v151; // [sp+140h] [-220h] BYREF

  if ( !this->TakesDamage(this)
    || (p_aiHealth = &this->aiHealth, idAI2::ActionScriptFlagIsSet(this, flags: 64))
    || damageDecl == nullptr
    || this->aiEditable.ignoreDamageWhileDropping && (unsigned int)this->aiVolatile.dropState <= 2 )
  {
    v15 = 0.0;
  }
  else
  {
    if ( damageDecl->maxDamage <= 0.0 )
    {
LABEL_10:
      v15 = 0.0;
      return *((float *)&v15 + 1);
    }
    if ( this->aiEditable.actionSettings.customRobot.usesRobot )
    {
      idAI2::DamageRobot(this, _pAttacker: attacker, _pDamageDecl: damageDecl, p_Trace: (trace_t *)a8);
      goto LABEL_10;
    }
    decl = this->aiEditable.behaviors.decl;
    v139.x = 0.0;
    v139.y = 0.0;
    v18 = (idIndex<short,enum invalidJointIndex_t> *)-1;
    v139.z = 0.0;
    v19 = 0;
    if ( a8 != 0 )
    {
      if ( *(_DWORD *)(a8 + 52) == 4 )
        v20 = *(_DWORD *)(a8 + 104);
      else
        LOWORD(v20) = -1;
      v18 = (idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)v20;
      if ( (__int16)v20 == -1 )
      {
        v19 = 0;
      }
      else
      {
        v21 = this->GetAF_2(this);
        v19 = idAnimator_AF::BodyForJoint(this: v21, joint: v18);
      }
      v22 = *(float *)(a8 + 8);
      v23 = *(float *)(a8 + 12);
      v139.x = *(float *)(a8 + 4);
      v139.y = v22;
      v139.z = v23;
    }
    else if ( inflictor != nullptr )
    {
      Physics = idEntity::GetPhysics(this: inflictor);
      v25 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
      v139.x = *v25;
      v139.y = v25[1];
      v139.z = v25[2];
    }
    else
    {
      v26 = idEntity::GetPhysics(this);
      v27 = (float *)v26->GetAbsBounds(this: v26, a2: -1);
      v28 = (float)(v27[5] + v27[2]);
      v29 = (float)((float)(v27[4] + v27[1]) * (float)0.5);
      v139.x = (float)(v27[3] + *v27) * (float)0.5;
      v139.y = v29;
      v139.z = (float)v28 * (float)0.5;
    }
    idAIMemory::SetLastDamage(this: &this->aiVolatile.memory, attacker, inflictor);
    damageTakenMultiplier = this->actorVolatile.damageTakenMultiplier;
    v31 = 1.0;
    v32 = (float)((float)(idDeclDamage::DamageAmount(this: damageDecl) * (float)damageTakenMultiplier)
                * (float)damageScale);
    if ( inflictor != gameLocal->world )
    {
      AIIncomingDamageScale = idGameLocal::GetAIIncomingDamageScale(this: gameLocal);
      v34 = 4 * (idAI2::GetModifiedSkill(this) + 38);
      v31 = (float)(*(float *)((char *)&decl->__vftable + v34) * (float)AIIncomingDamageScale);
      v32 = (float)((float)(*(float *)((char *)&decl->__vftable + v34) * (float)AIIncomingDamageScale) * (float)v32);
    }
    if ( damageDecl->damageIsCurrentHealth
      && ((double (__fastcall *)(idAIHealth *))p_aiHealth->GetTotalCurHealth_Impl)(a1: &this->aiHealth) > 0.0 )
    {
      v32 = ((double (__fastcall *)(idAIHealth *))p_aiHealth->GetTotalCurHealth_Impl)(a1: &this->aiHealth);
    }
    v35 = 1.0;
    if ( idAI2::GetAlertCycle(this) == ALERTCYCLE_RELAXED && damageDecl->isStealthy )
    {
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      if ( GameMs
         - this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type)->lastTransitionTime > 500 )
        v35 = 2.0;
    }
    v37 = (float)((float)v35 * (float)v32);
    v38 = 1.0;
    if ( !damageDecl->ignoreFriendlyFire && attacker != nullptr && attacker->GetFaction(this: attacker) != nullptr )
    {
      v39 = attacker->GetFaction(this: attacker);
      if ( idFaction::GetAttitudeTowards(this: v39, otherEnt: this) > ATTITUDE_NEUTRAL )
        v38 = 0.5;
    }
    v40 = (float)((float)v38 * (float)v37);
    v43 = idAI2::CastTo(c: attacker);
    if ( v43 != nullptr )
      v40 = (float)(v43->aiEditable.damageMultiplier * (float)v40);
    if ( (damageDecl->damageTypes & 0x400) != 0 )
      idAIDamageInfo::Update(
        this: &this->aiVolatile.pain.damageInfo,
        ai: this,
        inflictor,
        attacker,
        damageDecl,
        damage: 0.0,
        unscaledDamage: 0.0,
        damageScale: 0.0,
        armorDamage: 0.0,
        impactPoint: v42,
        impactDir: v41,
        impactJoint: (const idIndex<short,enum invalidJointIndex_t> *)&v139,
        killed: (const bool)v131,
        armorPoppedOff: (const bool)v133,
        forceInjured: v135);
    if ( (damageDecl->damageTypes & ~this->aiEditable.death.ignoreDamageType) != 0 )
    {
      DamageGroup = idActor::GetDamageGroup(this, joint: v18);
      if ( DamageGroup != nullptr && a8 != 0 )
        DamageGroup->lastHitAxis = *idVec3::ToMat3(this: (idVec3 *)v150, result: (idMat3 *)(a8 + 68));
      v56 = this->IsDead(this);
      HIDWORD(v57) = damageDecl->instantRagdoll;
      v58 = v56;
      locationArmor = 0.0;
      if ( damageDecl->instantRagdoll )
        idBaseHealth::Kill(this: &this->aiHealth, d: v32);
      if ( DamageGroup != nullptr )
        locationArmor = DamageGroup->locationArmor;
      v137 = 0.0;
      v138[0] = 0;
      v146 = 0.0;
      v140[0] = 0.0;
      v141 = 1.0;
      v142[0] = 0.0;
      v142[1] = 0.0;
      v140[1] = 0.0;
      if ( DamageGroup != nullptr )
      {
        idActor::DoLocationDamage(
          this,
          declDamage: damageDecl,
          damageGroup: DamageGroup,
          baseDamage: v40,
          outBodyDamage: v53,
          outLimbDamage: &v137,
          outArmorDamage: &v146,
          outArmorDamageScale: v140,
          outArmoredHealthDamageScale: &v141,
          outBleedThroughDamage: v131,
          outExcessDamage: v133,
          damageTypes: v135);
        if ( DamageGroup->locationArmor == 0.0
          && locationArmor > 0.0
          && idStr::Cmp(s1: DamageGroup->groupName.data, s2: "tank") != 0
          && damageDecl->knocksOffArmor )
        {
          LODWORD(v67) = __ROL4__(LODWORD(trace->z), 32);
          *(_QWORD *)((char *)&v67 + 4) = *(_QWORD *)&trace->x;
          idAI2::DamageGroupPopOffArmor(
            this,
            impactPoint: __SPAIR64__(LODWORD(v139.y), __ROL4__(LODWORD(v139.z), 32)),
            outArmorPoppedOff: v67,
            damage: v40,
            a5: SLODWORD(v139.z),
            a6: (int)v138,
            a7: v131);
        }
      }
      else
      {
        num = this->actorEditable.damageGroups.num;
        if ( num <= 0 )
        {
          v137 = v40;
        }
        else
        {
          LODWORD(v57) = this->actorEditable.damageGroups.num;
          v145 = 0.0;
          v143[0] = 0.0;
          v61 = 0;
          LODWORD(v144[1]) = num;
          v144[0] = 0.0;
          v62 = (float)((float)v40 / (float)v57);
          v63 = 0;
          do
          {
            v64 = &this->actorEditable.damageGroups.list[v63];
            v65 = v64->locationArmor;
            idActor::DoLocationDamage(
              this,
              declDamage: damageDecl,
              damageGroup: v64,
              baseDamage: v62,
              outBodyDamage: v142,
              outLimbDamage: &v145,
              outArmorDamage: v144,
              outArmorDamageScale: v143,
              outArmoredHealthDamageScale: &v141,
              outBleedThroughDamage: v131,
              outExcessDamage: v133,
              damageTypes: v135);
            v55 = &this->actorEditable.damageGroups.list[v63];
            v137 = v145 + v137;
            v140[0] = v143[0] + v140[0];
            if ( v55->locationArmor == 0.0 && v65 > 0.0 && damageDecl->knocksOffArmor )
            {
              LODWORD(v66) = __ROL4__(LODWORD(trace->z), 32);
              *(_QWORD *)((char *)&v66 + 4) = *(_QWORD *)&trace->x;
              idAI2::DamageGroupPopOffArmor(
                this,
                impactPoint: __SPAIR64__(LODWORD(v139.y), __ROL4__(LODWORD(v139.z), 32)),
                outArmorPoppedOff: v66,
                damage: v145,
                a5: SLODWORD(v139.z),
                a6: (int)v138,
                a7: v131);
            }
            ++v61;
            ++v63;
          }
          while ( v61 < this->actorEditable.damageGroups.num );
        }
      }
      idAI2::ShowDebugDamageText(
        this,
        baseDamage: v32,
        difficultyScale: v31,
        bodyDamage: v137,
        limbDamage: v146,
        armorDamage: v140[0],
        shieldDamage: 0.0,
        armorDamageScale: v141,
        armoredHealthDamageScale: v142[0],
        bleedThroughDamage: *(const float *)&v131,
        excessDamage: *(const float *)&v133,
        attitudeDamageScale: *(const float *)&v135,
        damageGroup: v55,
        impactPoint: v54);
      if ( attacker != nullptr )
      {
        attacker->DamageFeedback(this: attacker, a2: this, a3: inflictor, a4: damageDecl, a5: &v137);
        v69 = idActor::CastTo(c: attacker);
        if ( v69 != nullptr )
        {
          v70 = this->GetFaction(this);
          v71 = v70;
          if ( v70 != nullptr && attacker != this )
          {
            AttitudeTowards = idFaction::GetAttitudeTowards(this: v70, otherEnt: v69);
            if ( AttitudeTowards <= ATTITUDE_NEUTRAL )
            {
              if ( AttitudeTowards == ATTITUDE_NEUTRAL )
                neutralAttitudeAdjust = decl->neutralAttitudeAdjust;
              else
                neutralAttitudeAdjust = decl->attitudeAdjust;
            }
            else
            {
              if ( !this->IsDead(this) )
                this->IsDying(this);
              neutralAttitudeAdjust = decl->friendlyAttitudeAdjust;
            }
            idFaction::AdjustAttitudeTowards(this: v71, otherEnt: v69, adjust: neutralAttitudeAdjust);
          }
        }
      }
      if ( v137 > 0.0 )
      {
        if ( a8 != 0 && *(_DWORD *)(a8 + 52) == 4 )
          idGoreComponent::AddDamage(
            this: &this->aiVolatile.death.goreComponent,
            hitJoint: (idIndex<short,enum invalidJointIndex_t> *)(__int16)*(_DWORD *)(a8 + 104),
            damageDecl,
            damage: v137,
            impulse: v68,
            pos: trace,
            normal: (const idVec3 *)(a8 + 4),
            damageGroup: (const idDamageGroup *)(a8 + 68));
        v74 = 1;
        if ( !p_aiHealth->IsDead_Impl(this: &this->aiHealth) && attacker != this )
        {
          valueInteger = ai_ragdollKillLimit.valueInteger;
          if ( idGameLocal::NumDyingAI(this: gameLocal) >= valueInteger )
          {
            v77 = idAI2::CastTo(c: attacker);
            v78 = idTurret::CastTo(c: (idTurret *)attacker);
            if ( v77 != nullptr || v78 != nullptr )
              v74 = 0;
          }
        }
        if ( v74 == 0
          || this->IsDying(this)
          || p_aiHealth->IsDead_Impl(this: &this->aiHealth)
          || !idAI2::CheckForOneShotKill(this, (idPlayer *)attacker) )
        {
          if ( ai_invulnerable.valueInteger == 0 && (*((_BYTE *)&this->aiEditable.death + 84) & 4) != 0 )
          {
            p_aiHealth->IsDead_Impl(this: &this->aiHealth);
            ((void (__fastcall *)(idAIHealth *, _DWORD, double))p_aiHealth->DamageComponent_Impl)(
              a1: &this->aiHealth,
              a2: 0,
              a3: v137);
          }
        }
        else
        {
          v79 = idPlayer::CastTo(c: (idPlayer *)attacker);
          if ( v79 != nullptr )
            idRageMetrics::ShotAuthorityJetpackerInAir(this: clientGame->rageMetrics, player: v79);
          v80 = v137;
          *((_BYTE *)&this->aiVolatile.death + 1760) |= 0x20u;
          idBaseHealth::Kill(this: &this->aiHealth, d: v80);
          v137 = v137 * (float)5.0;
        }
        if ( !v58 )
          this->IsDead(this);
        idAIDamageInfo::Update(
          this: &this->aiVolatile.pain.damageInfo,
          ai: this,
          inflictor,
          attacker,
          damageDecl,
          damage: v137,
          unscaledDamage: v32,
          damageScale,
          armorDamage: v140[0],
          impactPoint: v75,
          impactDir: (const idVec3 *)v138[0],
          impactJoint: (const idIndex<short,enum invalidJointIndex_t> *)&v139,
          killed: v132,
          armorPoppedOff: v134,
          forceInjured: v136);
        if ( (unsigned __int8)idAI2::UpdateGoreLevel(this, painTest: false) != 0 )
          this->aiVolatile.pain.damageInfo.shouldPain = true;
        if ( this->IsDying(this) )
        {
          if ( a8 != 0 && *(_DWORD *)(a8 + 52) == 4 )
            idGoreComponent::UpdateKillshot(
              this: &this->aiVolatile.death.goreComponent,
              hitJoint: (idIndex<short,enum invalidJointIndex_t> *)(__int16)*(_DWORD *)(a8 + 104),
              damageDecl,
              damage: v137,
              impulse: v81,
              pos: trace,
              normal: (const idVec3 *)(a8 + 4),
              damageGroup: (const idDamageGroup *)(a8 + 68));
          if ( attacker != nullptr )
          {
            attacker->KilledNotification(this: attacker, a2: this, a3: inflictor, a4: damageDecl, a5: v137);
            SpawnId = idGameLocal::GetSpawnId(this: (idGameLocal *)v144, result: (idSpawnId *)gameLocal, ent: inflictor);
            idEntity::SendNotify_OnDeath(this, attacker: SpawnId->value);
          }
        }
        else if ( this->IsDead(this) )
        {
          ((void (__fastcall *)(idAI2 *, idWorldspawn *, idAI2 *, const idDeclDamage *, double))this->CalcDamageImpulse)(
            a1: this,
            a2: inflictor,
            a3: attacker,
            a4: damageDecl,
            a5: damageScale);
          this->ApplyImpulseFromEntity(this, a2: inflictor, a3: v19, a4: (const idVec3 *)v149, a5: (const idVec3 *)v148);
        }
        else
        {
          idAI2::CheckPain(
            this,
            inflictor,
            attacker,
            damageDecl,
            damage: v137,
            impactPoint: v83,
            impactDir: &v139,
            jointIndex: (idIndex<short,enum invalidJointIndex_t> *)trace,
            a9: v18);
        }
      }
      if ( this->IsDead(this) )
      {
        presentable = this->presentable;
        if ( presentable == nullptr )
        {
          idEntity::InitPresentableInternal(this);
          presentable = this->presentable;
        }
        idPresentable::LocalStopFX(this: presentable, condition: FX_ZIPLINE_SPEED_SLOW);
        v85 = this->presentable;
        if ( v85 == nullptr )
        {
          idEntity::InitPresentableInternal(this);
          v85 = this->presentable;
        }
        idPresentable::LocalStopFX(this: v85, condition: FX_VEH_STOP_MONSTERBASHER);
        v86 = this->aiEditable.behaviors.decl;
        if ( v86 != nullptr && idAI2::GetControllingPlayer(this) != nullptr && damageDecl != v86->controlSplashDamage )
          idAI2::RelinquishControl(this);
      }
      v87 = this->GetScriptObject_2(this);
      if ( idScriptObject::HasObject(this: v87) && idScriptObject::GetFunction(this: v87, name: "onDamage") != nullptr )
      {
        idScriptFunction::idScriptFunction(this: &v151);
        idScriptFunction::SetFunction(
          this: &v151,
          ent: this,
          functionName: "onDamage",
          returnType: ev_void,
          numParms: 5,
          8,
          "attacker",
          4);
        if ( idScriptFunction::GetFunction(this: &v151) != nullptr )
        {
          idScriptFunction::SetArg_Entity(this: &v151, argNum: 0, ent: attacker);
          v88 = ((double (__fastcall *)(idAIHealth *))p_aiHealth->GetCurBaseHealth_Impl)(a1: &this->aiHealth);
          idScriptFunction::SetArg_Float(this: &v151, argNum: 1, value: v88);
          idScriptFunction::SetArg_Decl(this: &v151, argNum: 2, decl: damageDecl);
          idScriptFunction::SetArg_Float(this: &v151, argNum: 3, value: v137);
          v89 = !v58 && (this->IsDying(this) || this->IsDead(this));
          idScriptFunction::SetArg_Int(this: &v151, argNum: 4, value: v89);
          idScriptFunction::CallFunction(this: &v151, defer: true);
        }
      }
      if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.onDamageTrigger) != nullptr )
      {
        v90 = this;
        if ( attacker != nullptr )
          v90 = attacker;
        v91 = idEventArg::idEventArg(this: v150, data: v90);
        v92 = &v146;
        v93 = (_DWORD *)&v91[-1].value.q[3];
        for ( i = 5; i != 0; --i )
          *++v92 = *(float *)++v93;
        v95 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.onDamageTrigger);
        idEventReceiver::PostEventMS(this: v95, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)HIDWORD(v147));
      }
      v96 = idGameLocal::GetSpawnId(this: (idGameLocal *)v144, result: (idSpawnId *)gameLocal, ent: attacker);
      idEntity::SendNotify_OnDamage(this, attacker: v96->value, scaledBodyDamage: (float)(v137 * (float)damageScale));
      if ( g_EnableGore.valueInteger == 1 )
      {
        v97 = 0;
        if ( DamageGroup == nullptr || DamageGroup->locationArmor <= 0.0 )
          v97 = 1;
        if ( common->IsServer(this: common) && v97 != 0 && (damageDecl->damageTypes & 0x4000) != 0 )
        {
          v98 = this->presentable;
          if ( v98 == nullptr )
          {
            idEntity::InitPresentableInternal(this);
            v98 = this->presentable;
          }
          eventTime = v98->GetAIInterface(this: v98)->bloodSplatterEventInfo.eventTime;
          if ( eventTime == 0
            || (ServerGameTime = idClientGame::GetServerGameTime(this: clientGame),
                v101 = 0,
                ServerGameTime - eventTime > eventTimeDelay) )
          {
            v101 = 1;
          }
          v97 = v101;
        }
        if ( v97 != 0 && this->aiEditable.death.goreDef != nullptr && damageScale > 0.0 )
        {
          v102 = this->presentable;
          if ( v102 == nullptr )
          {
            idEntity::InitPresentableInternal(this);
            v102 = this->presentable;
          }
          if ( v102->GetAIInterface(this: v102) != nullptr )
          {
            v103 = this->presentable;
            if ( v103 == nullptr )
            {
              idEntity::InitPresentableInternal(this);
              v103 = this->presentable;
            }
            v103->GetAIInterface(this: v103);
            if ( (unsigned __int8)idPlayer::IsTypeOf(c: attacker) != 0 )
            {
              v104 = idPlayer::CastTo(c: (idPlayer *)attacker);
              if ( v104 != nullptr && v104->presentable == nullptr )
                idEntity::InitPresentableInternal(this: v104);
            }
            idPresentableAI::SplatterBlood(
              this: (idPresentableAI *)LODWORD(v139.x),
              impactPoint_: (idVec3 *)LODWORD(v139.y),
              impactDir_: (idVec3 *)LODWORD(trace->x),
              playerIndex: LODWORD(trace->y));
          }
        }
      }
      if ( !v58 )
      {
        v105 = idActor::GetDamageGroup(this, joint: v18);
        if ( v105 != nullptr )
          v106 = v105 - this->actorEditable.damageGroups.list;
        else
          v106 = -1;
        this->damageGroup = v106;
      }
      v107 = 1664525 * clientGame->random.seed + 1013904223;
      clientGame->random.seed = v107;
      if ( (signed int)(((v107 >> 10) & 0x7FFF) % 0x64) < this->aiEditable.behaviors.decl->rageBehaviors.angryRageAfterHurtChance )
      {
        v108 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        idAIMemory::SetWantAngryRageTime(this: &this->aiVolatile.memory, t: v108, debugReason: "hurt");
      }
      if ( common->IsMultiplayer(this: common)
        && attacker != nullptr
        && (unsigned __int8)idPlayer::IsTypeOf(c: attacker) != 0 )
      {
        entityNumber = attacker->entityNumber;
        if ( entityNumber < 0 || (v110 = 1, entityNumber >= 6) )
          v110 = 0;
        if ( v110 != 0 )
          this->aiVolatile.playerDamageTaken.ptr[entityNumber] = this->aiVolatile.playerDamageTaken.ptr[entityNumber]
                                                               + v137;
      }
      soonestTauntRageTime = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
                           + 3000;
      if ( this->aiVolatile.memory.soonestTauntRageTime > soonestTauntRageTime )
        soonestTauntRageTime = this->aiVolatile.memory.soonestTauntRageTime;
      this->aiVolatile.memory.soonestTauntRageTime = soonestTauntRageTime;
      if ( ai_enableInjuredRuns.valueInteger != 0 && (*((_BYTE *)&this->aiEditable.death + 84) & 0x20) != 0 )
      {
        injuredRunMode = this->aiEditable.behaviors.decl->damageBehaviors.injuredRunMode;
        if ( injuredRunMode != AIINJUREDRUNMODE_MOSTDAMAGED )
        {
          if ( injuredRunMode == AIINJUREDRUNMODE_RECENTLYDAMAGED && DamageGroup != nullptr )
          {
            forwardRunIndex = DamageGroup->forwardRunIndex;
            if ( forwardRunIndex != 0.0 )
              idAnimWebAI::SetForwardRunIndex(
                this: this->aiVolatile.animation.animWebAnimator.ptr,
                newRunIndex: forwardRunIndex,
                newIdleIndex: DamageGroup->injuredIdleIndex,
                t: v113,
                blend: v112);
          }
        }
        else if ( ((double (__fastcall *)(idAIHealth *))p_aiHealth->GetBaseHealthRatio_Impl)(a1: &this->aiHealth) < this->aiEditable.behaviors.decl->damageBehaviors.injuredRunThreshold
               && this->aiVolatile.animation.animWebAnimator.ptr[0].runIndexType != ANIMWEBAI_RUNINDEXTYPE_INJURED )
        {
          p_damageGroups = &this->actorEditable.damageGroups;
          v118 = 0.0;
          v119 = 0;
          v120 = 0;
          if ( this->actorEditable.damageGroups.num > 0 )
          {
            v121 = 0;
            do
            {
              v122 = &p_damageGroups->list[v121];
              if ( (float)(v122->maxHealth - v122->health) > v118
                || (float)(v122->maxHealth - v122->health) == v118
                && (v116 = 1664525 * clientGame->random.seed + 1013904223,
                    clientGame->random.seed = v116,
                    v123 = ((unsigned int)v116 >> 10) & 0x7FFF,
                    v124 = 2 * (v123 >> 1),
                    v115 = ((unsigned int)v116 >> 10) - v124,
                    v123 == v124) )
              {
                v119 = v120;
                v118 = (float)(p_damageGroups->list[v121].maxHealth - p_damageGroups->list[v121].health);
              }
              ++v120;
              ++v121;
            }
            while ( v120 < this->actorEditable.damageGroups.num );
            if ( v118 > 0.0 )
            {
              v125 = (int)&p_damageGroups->list[v119];
              v126 = *(float *)(v125 + 72);
              if ( v126 != 0.0 )
              {
                idAnimWebAI::SetForwardRunIndex(
                  this: this->aiVolatile.animation.animWebAnimator.ptr,
                  newRunIndex: v126,
                  newIdleIndex: *(float *)(v125 + 76),
                  t: v116,
                  blend: v115);
                this->aiVolatile.pain.damageInfo.mostDamagedIndex = v119;
              }
            }
          }
        }
      }
      if ( a8 != 0 && (*((_BYTE *)&this->aiEditable.death + 84) & 1) != 0 && (v15 = v140[0], v140[0] > (double)v137) )
      {
        *(_DWORD *)(a8 + 96) = 19;
      }
      else
      {
        if ( this->IsDead(this) && !this->IsDying(this) )
        {
          v128 = this->presentable;
          if ( v128 == nullptr )
          {
            idEntity::InitPresentableInternal(this);
            v128 = this->presentable;
          }
          v128->clipModelInfo.type = CLIPMODEL_NONE;
          idAnimatedEntity::StopFX(this, condition: FX_PROP_STOP_USE);
          v129 = this->presentable;
          if ( v129 != nullptr && ai_enableInfluenceTrails.valueInteger != 0 )
            idInfluenceTrailManager::FreeInfluenceTrail(this: &clientGame->influenceTrailManager, presentable: v129);
        }
        if ( !damageDecl->noSound )
          idEntity::StartSoundShader(
            this,
            channel: SND_CHANNEL_DAMAGE,
            shader: damageDecl->damageSound,
            soundShaderFlags: 0,
            peerMask: 0xFFu);
        v15 = v137;
      }
    }
    else
    {
      if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.onIgnoredDamageTrigger) != nullptr )
      {
        v46 = this;
        if ( attacker != nullptr )
          v46 = attacker;
        v47 = idEventArg::idEventArg(this: v150, data: v46);
        v48 = &v146;
        v49 = (_DWORD *)&v47[-1].value.q[3];
        for ( j = 5; j != 0; --j )
          *++v48 = *(float *)++v49;
        v51 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.onIgnoredDamageTrigger);
        idEventReceiver::PostEventMS(this: v51, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)HIDWORD(v147));
      }
      idAI2::ShowDebugDamageText(
        this,
        baseDamage: v32,
        difficultyScale: v31,
        bodyDamage: 0.0,
        limbDamage: 0.0,
        armorDamage: 0.0,
        shieldDamage: 0.0,
        armorDamageScale: 1.0,
        armoredHealthDamageScale: 1.0,
        bleedThroughDamage: *(const float *)&v131,
        excessDamage: *(const float *)&v133,
        attitudeDamageScale: *(const float *)&v135,
        damageGroup: v45,
        impactPoint: v44);
      v15 = 0.0;
    }
  }
  return *((float *)&v15 + 1);
}


// ========================================================================
// ?ModifyCrosshairInfo@idAI2@@UBA_NPBVidEntity@@ABVidFocusTrace@@W4usableState_t@@AAVidCrosshairInfo@@@Z
// EA  : 0x82A0DFB0
// RVA : 0x00A0DFB0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::ModifyCrosshairInfo(
        idAI2 *this,
        idPlayer *activator,
        const idFocusTrace *ft,
        usableState_t usable,
        idCrosshairInfo *info)
{
  BOOL v10; // r25
  idEntity *AttachedLoot; // r3
  idPlayer *v12; // r28
  idSmartLootComponent *v13; // r3
  idSmartLootComponent *v14; // r30
  bfx::Planner3D *v15; // r3
  bfx::Space *TypeDef; // r30
  idInventoryCollection *v17; // r3
  idInventoryItem *InventoryItem; // r3
  int num; // r28
  int v20; // r11
  idStaticList<idCrosshairCustomIcon,3> *p_icons; // r30
  int v22; // ctr
  int v23; // r11
  int v24; // r10
  idCrosshairCustomIcon *v25; // r9
  bool canPickup; // r8
  idPickupHudInfo v28[3]; // [sp+50h] [-A0h] BYREF

  info->text.index = this->npcName.index;
  if ( usable == USABLE_LOOT )
  {
    v10 = false;
    AttachedLoot = idActor::GetAttachedLoot(this);
    if ( AttachedLoot != nullptr )
      v10 = AttachedLoot->ModifyCrosshairInfo(this: AttachedLoot, a2: activator, a3: ft, a4: USABLE_LOOT, a5: info);
    v28[0].items.num = 0;
    v28[0].items.size = 3;
    v28[0].items.granularity = 1;
    v12 = idPlayer::CastTo(c: activator);
    v28[0].items.list = v28[0].items.staticList;
    v28[0].items.memTag = 5;
    v28[0].items.listStatic = 1;
    v28[0].items.staticList[0].icon = nullptr;
    v28[0].items.staticList[0].count = 0;
    v28[0].items.staticList[0].canPickup = true;
    v28[0].items.staticList[1].icon = nullptr;
    v28[0].items.staticList[1].count = 0;
    v28[0].items.staticList[1].canPickup = true;
    v28[0].items.staticList[2].icon = nullptr;
    v28[0].items.staticList[2].count = 0;
    v28[0].items.staticList[2].canPickup = true;
    v13 = this->GetSmartLootComponent_2(this);
    v14 = v13;
    if ( v13 != nullptr )
    {
      v13->Update(this: v13, a2: this, a3: v12);
      idSmartLootComponent::GetPickupHudInfo(this: v14, user: v12, info: v28, weaponStuffOnly: false);
    }
    else
    {
      v15 = (bfx::Planner3D *)this->GetInventory(this);
      TypeDef = idScriptObject::GetTypeDef(this: v15);
      if ( (int)TypeDef > 0 )
      {
        v17 = (idInventoryCollection *)this->GetInventory(this);
        InventoryItem = idInventoryCollection::GetInventoryItem(
                          this: v17,
                          index: (int)&TypeDef[-1].m_components.m_tag + 3);
        InventoryItem->GetPickupHudInfo(this: InventoryItem, a2: v12, a3: v28);
      }
    }
    num = v28[0].items.num;
    v20 = v28[0].items.num + v10;
    if ( v28[0].items.num + v10 < 1 )
      v20 = 1;
    p_icons = &info->icons;
    idList<idCrosshairCustomIcon,5>::SetNum(this: &info->icons, newNum: v20);
    if ( num > 0 )
    {
      v22 = num;
      v23 = 0;
      v24 = v10;
      do
      {
        p_icons->list[v24].material = v28[0].items.list[v23].icon;
        p_icons->list[v24].itemCount = v28[0].items.list[v23].count;
        v25 = &p_icons->list[v24];
        canPickup = v28[0].items.list[v23++].canPickup;
        ++v24;
        v25->usable = canPickup;
        --v22;
      }
      while ( v22 != 0 );
    }
    if ( v28[0].items.listStatic == 0 || v28[0].items.listStatic == 2 )
    {
      if ( v28[0].items.list != nullptr )
        idMem::Free(this: &mem, ptr: v28[0].items.list, align: ALIGN_16);
      v28[0].items.list = nullptr;
      v28[0].items.size = 0;
    }
    v28[0].items.num = 0;
  }
  return idEntity::ModifyCrosshairInfo(this, activator, ft, usable, info);
}


// ========================================================================
// __unwind$552182
// EA  : 0x82A0E210
// RVA : 0x00A0E210
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_552182()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 240 + 80));
}


// ========================================================================
// ?GetKnownEnemiesAsCoverTargets@idAI2@@QBAXAAV?$idList@UcoverTarget_t@idCoverQuery@@$04@@W4aiAwareness_t@@@Z
// EA  : 0x82A0E240
// RVA : 0x00A0E240
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::GetKnownEnemiesAsCoverTargets(
        idAI2 *this,
        idList<idVehicleState *,5> *targets,
        aiAwareness_t minAwareness)
{
  int v6; // r27
  int num; // r10
  int v8; // r26
  idTargetInfo *list; // r30
  int v10; // r29
  idEnemyTargetFilter v11; // [sp+50h] [-F0h] BYREF
  idAvoidTargetFilter v12; // [sp+58h] [-E8h] BYREF
  idTargetList v13; // [sp+60h] [-E0h] BYREF
  idCoverQuery::coverTarget_t v14; // [sp+A0h] [-A0h] BYREF

  idList<idThread *,58>::Clear(this: targets);
  idTargetList::idTargetList(this: &v13, targetCache_: &this->aiVolatile.world.worldState.targetCache);
  if ( ai_useAvoidForCoverFilter.valueInteger != 0 )
  {
    idAvoidTargetFilter::idAvoidTargetFilter(this: &v12, minAwareness_: minAwareness);
    idTargetList::Filter(this: &v13, owner: this, filter: &v12);
    v12.__vftable = (idAvoidTargetFilter_vtbl *)&idTargetFilter::`vftable';
  }
  else
  {
    idEnemyTargetFilter::idEnemyTargetFilter(this: &v11, minAwareness_: minAwareness);
    idTargetList::Filter(this: &v13, owner: this, filter: &v11);
    v11.__vftable = (idEnemyTargetFilter_vtbl *)&idTargetFilter::`vftable';
  }
  if ( v13.viableTargets.num > targets->size )
    idList<idCoverQuery::coverTarget_t,5>::Resize(
      this: (idList<idCoverQuery::coverTarget_t,5> *)targets,
      newsize: v13.viableTargets.num);
  if ( targets->size < 0 )
    idList<idThread *,58>::Clear(this: targets);
  v6 = 0;
  num = v13.viableTargets.num;
  v8 = 0;
  targets->num = __CFADD__(-targets->size, targets->size ^ 0x80000000) ? 0 : targets->size;
  if ( num > 0 )
  {
    do
    {
      list = v13.targetCache->targets.list;
      v10 = v13.viableTargets.list[v6];
      if ( idAIEntityState::GetEntity(this: (idAIEntityState *)v13.targetCache->targets.list[v10].es) != nullptr )
      {
        idCoverQuery::coverTarget_t::coverTarget_t(this: &v14);
        v14.spawnId.value = list[v10].es->spawnId.value;
        idList<idCoverQuery::coverTarget_t,5>::Append(this: (idList<idCoverQuery::coverTarget_t,5> *)targets, obj: &v14);
      }
      ++v8;
      ++v6;
    }
    while ( v8 < v13.viableTargets.num );
  }
  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v13);
}


// ========================================================================
// __unwind$552361
// EA  : 0x82A0E39C
// RVA : 0x00A0E39C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_552361()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 320 + 96));
}


// ========================================================================
// __unwind$552362
// EA  : 0x82A0E3C4
// RVA : 0x00A0E3C4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_552362()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 320 + 88));
}


// ========================================================================
// __unwind$552363
// EA  : 0x82A0E3EC
// RVA : 0x00A0E3EC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_552363()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 320 + 80));
}


// ========================================================================
// ?ForceEntranceAnimationToCombat@idAI2@@QAAXXZ
// EA  : 0x82A0E420
// RVA : 0x00A0E420
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceEntranceAnimationToCombat(idAI2 *this)
{
  unsigned int v2; // r4
  double v3; // fp0
  idFSMManager::idFSMStack v4; // [sp+50h] [-40h] BYREF

  idAI2::GiveAwarenessOfNearestPlayer(this, alertCycle: ALERTCYCLE_COMBAT);
  if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 196) & 0x20) != 0 )
  {
    vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v4);
    idFSMManager::idFSMStack::Add(this: &v4, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Combat::Type);
    idFSMManager::idFSMStack::Add(this: &v4, fsmType: &idCombatFSM::Type, stateType: &idCombat_Advance::Type);
    idFSMManager::idFSMStack::Add(this: &v4, fsmType: &idAdvanceFSM::Type, stateType: &idAdvance_PlayOverrideAnim::Type);
    idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v4);
  }
  else
  {
    if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 196) & 8) == 0 )
      goto LABEL_6;
    vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v4);
    idFSMManager::idFSMStack::Add(this: &v4, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Combat::Type);
    idFSMManager::idFSMStack::Add(this: &v4, fsmType: &idCombatFSM::Type, stateType: &idCombat_OpenCombat::Type);
    idFSMManager::idFSMStack::Add(
      this: &v4,
      fsmType: &idOpenCombatFSM::Type,
      stateType: &idOpenCombat_PlayOverrideAnim::Type);
    idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v4);
  }
  idPLog::~idPLog(this: &v4);
LABEL_6:
  v2 = 1664525 * clientGame->random.seed + 1013904223;
  clientGame->random.seed = v2;
  if ( ((v2 >> 10) & 0x7FFF) == 2 * ((int)((v2 >> 10) & 0x7FFF) >> 1) )
    v3 = 0.0;
  else
    v3 = 1.0;
  this->aiVolatile.animation.animWebAnimator.ptr[0].select01 = v3;
}


// ========================================================================
// __unwind$552592
// EA  : 0x82A0E5A4
// RVA : 0x00A0E5A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_552592()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 144 + 80));
}


// ========================================================================
// __unwind$552593
// EA  : 0x82A0E5CC
// RVA : 0x00A0E5CC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_552593()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 144 + 80));
}


// ========================================================================
// ?ForceSearchToEntity@idAI2@@QAAXPAVidEntity@@@Z
// EA  : 0x82A0E5F8
// RVA : 0x00A0E5F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceSearchToEntity(idAI2 *this, idEntity *ent)
{
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r30
  idEncounterGroup *v4; // r3

  p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
  idAI2::GiveAwarenessOfEntity(this, ent, alertCycle: ALERTCYCLE_SEARCH);
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF
    && idEncounterGroupManager::GroupForHandle(
         this: &gameLocal->encounterGroupManager,
         handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
  {
    if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
      v4 = nullptr;
    else
      v4 = idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &this->aiVolatile.encounterGroupHandle);
    idEncounterGroup::SetAnyMemberHasSeenDeadBody(this: v4, seen: true);
  }
  idAI2::ResetAnimState(this, web: AIANIMWEB_BODY, subWeb: AISUBWEB_SEARCH, stateName: "idle");
}


// ========================================================================
// ?ForceAwarenessOfNearestPlayer@idAI2@@QAAXXZ
// EA  : 0x82A0E698
// RVA : 0x00A0E698
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceAwarenessOfNearestPlayer(idAI2 *this)
{
  idAI2::GiveAwarenessOfNearestPlayer(this, alertCycle: ALERTCYCLE_COMBAT);
  idAI2::ResetAnimState(this, web: AIANIMWEB_BODY, subWeb: AISUBWEB_COMBAT, stateName: "idle");
}


// ========================================================================
// ?ForceSearchToNearestPlayer@idAI2@@QAAXXZ
// EA  : 0x82A0E6E0
// RVA : 0x00A0E6E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceSearchToNearestPlayer(idAI2 *this)
{
  idAI2::GiveAwarenessOfNearestPlayer(this, alertCycle: ALERTCYCLE_SEARCH);
  idAI2::ResetAnimState(this, web: AIANIMWEB_BODY, subWeb: AISUBWEB_SEARCH, stateName: "idle");
}


// ========================================================================
// ?InternalCallEvent@idAIScriptProxy@@MAA?AVidEventArg@@ABVidEventDef@@PBV2@@Z
// EA  : 0x82A0E728
// RVA : 0x00A0E728
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIScriptProxy *__fastcall idAIScriptProxy::InternalCallEvent(
        idAIScriptProxy *this,
        idAIScriptProxy *result,
        const idEventDef *event,
        const idEventArg *args)
{
  idThread *currentThread; // r29
  int v9; // r3
  idEventReceiver v11[5]; // [sp+50h] [-40h] BYREF

  if ( result->blocking )
  {
    if ( result->owner->IsDying(this: result->owner) || result->owner->IsDead(this: result->owner) )
      goto LABEL_9;
    idAIScriptProxy::ForceFSMIntoExecutingScript(this: result);
  }
  result->owner->aiVolatile.fsms.actionManager.actionEventTransCode = 6;
  idEventReceiver::ProcessEventArgPtr(
    this: v11,
    result: (idEventArg *)&result->owner->aiVolatile.fsms.actionManager,
    ev: event,
    args);
  if ( result->blocking )
  {
    currentThread = gameLocal->program.threadManager.currentThread;
    v9 = gameLocal->superScript.GetCurrentThreadId(this: &gameLocal->superScript);
    if ( currentThread != nullptr )
    {
      idAIScriptProxy::PauseCurrentThreadTillActionCompletes(this: result);
    }
    else if ( v9 > 0 )
    {
      idAIScriptProxy::PauseCurrentFiberTillActionCompletes(this: result);
    }
  }
LABEL_9:
  HIBYTE(this->__vftable) = 0;
  this->listenerList = nullptr;
  return this;
}


// ========================================================================
// ?AIStats_f@@YAXABVidCmdArgs@@@Z
// EA  : 0x82A0E938
// RVA : 0x00A0E938
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall AIStats_f(const idCmdArgs *args)
{
  idGame *v1; // r3
  int v2; // r3
  __int64 v3; // r6
  __int64 v4; // r10
  __int64 v5; // r8
  va *v6; // r3
  idLinkList<idActor> *next; // r11
  idAI2 *owner; // r14
  idAI2 *v9; // r30
  idAIHealth *p_aiHealth; // r30
  __int64 v11; // r6
  __int64 v12; // r10
  __int64 v13; // r8
  va *v14; // r3
  __int64 v15; // r6
  __int64 v16; // r10
  __int64 v17; // r8
  va *v18; // r3
  __int64 v19; // r10
  __int64 v20; // r6
  __int64 v21; // r8
  idList<idDamageGroup,5> *p_damageGroups; // r30
  int v23; // r28
  int v24; // r29
  va *v25; // r26
  __int64 v26; // r6
  __int64 v27; // r10
  __int64 v28; // r8
  va *v29; // r3
  __int64 v30; // r10
  __int64 v31; // r8
  __int64 v32; // r6
  int v33; // r28
  int v34; // r29
  va *v35; // r26
  __int64 v36; // r6
  __int64 v37; // r10
  __int64 v38; // r8
  va *v39; // r3
  idInventoryCollection *v40; // r28
  int v41; // r26
  int v42; // r29
  idStrId *DisplayName; // r3
  const char *Key; // r30
  idAmmoItem *v45; // r30
  idDeclInventory_vtbl *v46; // r10
  __int64 v47; // r6
  __int64 v48; // r10
  __int64 v49; // r8
  va *v50; // r21
  __int64 v51; // r10
  __int64 v52; // r8
  __int64 v53; // r6
  va *v54; // r21
  __int64 v55; // r8
  __int64 v56; // r6
  __int64 v57; // r10
  va *v58; // r21
  const idDeclInventory *v59; // r11
  idDeclInventory_vtbl *v60; // r10
  __int64 v61; // r6
  __int64 v62; // r10
  __int64 v63; // r8
  va *v64; // r21
  __int64 v65; // r10
  __int64 v66; // r8
  __int64 v67; // r6
  va *v68; // r21
  __int64 v69; // r8
  __int64 v70; // r6
  __int64 v71; // r10
  va *v72; // r30
  __int64 v73; // r10
  __int64 v74; // r8
  __int64 v75; // r6
  idThrowableItem *v76; // r30
  const idDeclProjectile *ProjectileDef; // r3
  __int64 v78; // r6
  __int64 v79; // r10
  __int64 v80; // r8
  va *v81; // r21
  __int64 v82; // r6
  __int64 v83; // r10
  __int64 v84; // r8
  va *v85; // r21
  __int64 v86; // r10
  __int64 v87; // r6
  __int64 v88; // r8
  va *v89; // r30
  va *v90; // r30
  __int64 v91; // r6
  __int64 v92; // r10
  __int64 v93; // r8
  va *v94; // r3
  idLinkList<idActor> *v95; // r11
  idAI2 *v96; // r11
  int v97; // [sp+8h] [-3408h]
  int v98; // [sp+8h] [-3408h]
  int v99; // [sp+8h] [-3408h]
  int v100; // [sp+8h] [-3408h]
  int v101; // [sp+8h] [-3408h]
  int v102; // [sp+8h] [-3408h]
  int v103; // [sp+8h] [-3408h]
  int v104; // [sp+8h] [-3408h]
  int v105; // [sp+8h] [-3408h]
  int v106; // [sp+8h] [-3408h]
  int v107; // [sp+8h] [-3408h]
  int v108; // [sp+8h] [-3408h]
  int v109; // [sp+Ch] [-3404h]
  int v110; // [sp+Ch] [-3404h]
  int v111; // [sp+Ch] [-3404h]
  int v112; // [sp+Ch] [-3404h]
  int v113; // [sp+Ch] [-3404h]
  int v114; // [sp+Ch] [-3404h]
  int v115; // [sp+Ch] [-3404h]
  int v116; // [sp+Ch] [-3404h]
  int v117; // [sp+Ch] [-3404h]
  int v118; // [sp+Ch] [-3404h]
  int v119; // [sp+Ch] [-3404h]
  int v120; // [sp+Ch] [-3404h]
  int v121; // [sp+10h] [-3400h]
  int v122; // [sp+10h] [-3400h]
  int v123; // [sp+10h] [-3400h]
  int v124; // [sp+10h] [-3400h]
  int v125; // [sp+10h] [-3400h]
  int v126; // [sp+10h] [-3400h]
  int v127; // [sp+10h] [-3400h]
  int v128; // [sp+10h] [-3400h]
  int v129; // [sp+10h] [-3400h]
  int v130; // [sp+10h] [-3400h]
  int v131; // [sp+10h] [-3400h]
  int v132; // [sp+10h] [-3400h]
  int v133; // [sp+14h] [-33FCh]
  int v134; // [sp+14h] [-33FCh]
  int v135; // [sp+14h] [-33FCh]
  int v136; // [sp+14h] [-33FCh]
  int v137; // [sp+14h] [-33FCh]
  int v138; // [sp+14h] [-33FCh]
  int v139; // [sp+14h] [-33FCh]
  int v140; // [sp+14h] [-33FCh]
  int v141; // [sp+14h] [-33FCh]
  int v142; // [sp+14h] [-33FCh]
  int v143; // [sp+14h] [-33FCh]
  int v144; // [sp+14h] [-33FCh]
  int v145; // [sp+18h] [-33F8h]
  int v146; // [sp+18h] [-33F8h]
  int v147; // [sp+18h] [-33F8h]
  int v148; // [sp+18h] [-33F8h]
  int v149; // [sp+18h] [-33F8h]
  int v150; // [sp+18h] [-33F8h]
  int v151; // [sp+18h] [-33F8h]
  int v152; // [sp+18h] [-33F8h]
  int v153; // [sp+18h] [-33F8h]
  int v154; // [sp+18h] [-33F8h]
  int v155; // [sp+18h] [-33F8h]
  int v156; // [sp+18h] [-33F8h]
  int v157; // [sp+1Ch] [-33F4h]
  int v158; // [sp+1Ch] [-33F4h]
  int v159; // [sp+1Ch] [-33F4h]
  int v160; // [sp+1Ch] [-33F4h]
  int v161; // [sp+1Ch] [-33F4h]
  int v162; // [sp+1Ch] [-33F4h]
  int v163; // [sp+1Ch] [-33F4h]
  int v164; // [sp+1Ch] [-33F4h]
  int v165; // [sp+1Ch] [-33F4h]
  int v166; // [sp+1Ch] [-33F4h]
  int v167; // [sp+1Ch] [-33F4h]
  int v168; // [sp+1Ch] [-33F4h]
  double locationArmor; // [sp+20h] [-33F0h]
  double damageScale; // [sp+20h] [-33F0h]
  double v171; // [sp+20h] [-33F0h]
  double v172; // [sp+20h] [-33F0h]
  double v173; // [sp+20h] [-33F0h]
  double v174; // [sp+20h] [-33F0h]
  double v175; // [sp+20h] [-33F0h]
  double v176; // [sp+20h] [-33F0h]
  double v177; // [sp+20h] [-33F0h]
  double maxDamage; // [sp+20h] [-33F0h]
  double v179; // [sp+20h] [-33F0h]
  idList<idXMLAttribute,44> v180; // [sp+50h] [-33C0h] BYREF
  const idDeclInventory *decl; // [sp+60h] [-33B0h]
  idXMLWriter v182; // [sp+70h] [-33A0h] BYREF
  const char *v183; // [sp+84h] [-338Ch]
  const char *v184; // [sp+88h] [-3388h]
  const char *v185; // [sp+8Ch] [-3384h]
  const char *v186; // [sp+90h] [-3380h]
  const char *v187; // [sp+94h] [-337Ch]
  const char *v188; // [sp+98h] [-3378h]
  const char *v189; // [sp+9Ch] [-3374h]
  const char *v190; // [sp+A0h] [-3370h]
  const char *v191; // [sp+A4h] [-336Ch]
  idInventoryItem v192; // [sp+A8h] [-3368h] BYREF
  idStr v193; // [sp+D0h] [-3340h] BYREF
  idXMLAttribute v194; // [sp+F0h] [-3320h] BYREF
  idXMLAttribute v195; // [sp+130h] [-32E0h] BYREF
  idXMLAttribute v196; // [sp+170h] [-32A0h] BYREF
  idXMLAttribute v197; // [sp+1B0h] [-3260h] BYREF
  idXMLAttribute v198; // [sp+1F0h] [-3220h] BYREF
  idXMLAttribute v199; // [sp+230h] [-31E0h] BYREF
  idXMLAttribute v200; // [sp+270h] [-31A0h] BYREF
  idXMLAttribute v201; // [sp+2B0h] [-3160h] BYREF
  idXMLAttribute v202; // [sp+2F0h] [-3120h] BYREF
  idXMLAttribute v203; // [sp+330h] [-30E0h] BYREF
  va v204; // [sp+370h] [-30A0h] BYREF
  va v205; // [sp+1370h] [-20A0h] BYREF
  va v206; // [sp+2370h] [-10A0h] BYREF

  idXMLWriter::idXMLWriter(this: &v182);
  v1 = common->Game(this: common);
  v2 = (int)v1->GetMapName(this: v1);
  LODWORD(v3) = &unk_821D0000;
  HIDWORD(v3) = v2;
  v6 = va::va(
         this: &v205,
         fmt: "%s.xml",
         a3: v3,
         a4: v5,
         a5: v4,
         a6: v97,
         a7: v109,
         a8: v121,
         a9: v133,
         a10: v145,
         a11: v157);
  if ( idXMLWriter::OpenFile(this: &v182, relativePath: v6->buffer, overwrite: true, savepath: true) )
  {
    *(_WORD *)&v180.memTag = 1280;
    memset(&v180, 0, 14);
    idXMLWriter::OpenElement(this: &v182, name: "Active_Actors");
    next = gameLocal->actorEntities.next;
    if ( next != nullptr && next != gameLocal->actorEntities.head )
    {
      owner = (idAI2 *)next->owner;
      if ( owner != nullptr )
      {
        v184 = "Inventory_%i";
        v188 = "%s";
        v183 = "MinDamage";
        v186 = "MaxDamage";
        v185 = "DamageAmount";
        v190 = "display_name";
        v191 = "Inventory";
        v189 = "samage_scale";
        v187 = "Armor";
        do
        {
          v9 = idAI2::CastTo(c: owner);
          if ( v9 != nullptr )
          {
            idXMLAttribute::idXMLAttribute(this: &v203, name: "name", value: owner->name.data);
            idList<idXMLAttribute,44>::Append(this: &v180, obj: &v203);
            idXMLWriter::OpenElement(this: &v182, name: "AI", attributes: &v180);
            if ( v180.listStatic == 0 || v180.listStatic == 2 )
            {
              if ( v180.list != nullptr )
                idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
              v180.list = nullptr;
              v180.size = 0;
            }
            v180.num = 0;
            p_aiHealth = &v9->aiHealth;
            HIDWORD(v11) = COERCE_UNSIGNED_INT64(((double (__fastcall *)(idAIHealth *))p_aiHealth->GetCurBaseHealth_Impl)(a1: p_aiHealth));
            v14 = va::va(
                    this: &v205,
                    fmt: "%f",
                    a3: v11,
                    a4: v13,
                    a5: v12,
                    a6: v98,
                    a7: v110,
                    a8: v122,
                    a9: v134,
                    a10: v146,
                    a11: v158);
            idXMLWriter::WriteElement(this: &v182, name: "Health", value: v14->buffer);
            HIDWORD(v15) = COERCE_UNSIGNED_INT64(((double (__fastcall *)(idAIHealth *))p_aiHealth->GetMaxBaseHealth_Impl)(a1: p_aiHealth));
            v18 = va::va(
                    this: &v205,
                    fmt: "%f",
                    a3: v15,
                    a4: v17,
                    a5: v16,
                    a6: v99,
                    a7: v111,
                    a8: v123,
                    a9: v135,
                    a10: v147,
                    a11: v159);
            idXMLWriter::WriteElement(this: &v182, name: "Max_Health", value: v18->buffer);
            idXMLWriter::OpenElement(this: &v182, name: v187);
            HIDWORD(v21) = owner->actorEditable.damageGroups.num;
            p_damageGroups = &owner->actorEditable.damageGroups;
            v23 = 0;
            if ( SHIDWORD(v21) > 0 )
            {
              v24 = 0;
              do
              {
                if ( v180.listStatic == 0 || v180.listStatic == 2 )
                {
                  if ( v180.list != nullptr )
                    idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
                  v180.list = nullptr;
                  v180.size = 0;
                }
                v180.num = 0;
                locationArmor = p_damageGroups->list[v24].locationArmor;
                HIDWORD(v20) = LODWORD(locationArmor);
                v25 = va::va(
                        this: &v205,
                        fmt: (const char *)HIDWORD(locationArmor),
                        a3: v20,
                        a4: v21,
                        a5: v19,
                        a6: v98,
                        a7: v110,
                        a8: v122,
                        a9: v134,
                        a10: v146,
                        a11: v158);
                HIDWORD(v26) = p_damageGroups->list[v24].groupName.data;
                v29 = va::va(
                        this: &v204,
                        fmt: "Armor_%s",
                        a3: v26,
                        a4: v28,
                        a5: v27,
                        a6: v100,
                        a7: v112,
                        a8: v124,
                        a9: v136,
                        a10: v148,
                        a11: v160);
                idXMLWriter::WriteElement(this: &v182, name: v29->buffer, value: v25->buffer);
                LODWORD(v19) = owner->actorEditable.damageGroups.num;
                ++v23;
                ++v24;
              }
              while ( v23 < (int)v19 );
            }
            idXMLWriter::CloseElement(this: &v182);
            idXMLWriter::OpenElement(this: &v182, name: v189);
            v33 = 0;
            if ( owner->actorEditable.damageGroups.num > 0 )
            {
              v34 = 0;
              do
              {
                if ( v180.listStatic == 0 || v180.listStatic == 2 )
                {
                  if ( v180.list != nullptr )
                    idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
                  v180.list = nullptr;
                  v180.size = 0;
                }
                v180.num = 0;
                damageScale = p_damageGroups->list[v34].damageScale;
                HIDWORD(v32) = LODWORD(damageScale);
                v35 = va::va(
                        this: &v204,
                        fmt: (const char *)HIDWORD(damageScale),
                        a3: v32,
                        a4: v31,
                        a5: v30,
                        a6: v98,
                        a7: v110,
                        a8: v122,
                        a9: v134,
                        a10: v146,
                        a11: v158);
                HIDWORD(v36) = p_damageGroups->list[v34].groupName.data;
                v39 = va::va(
                        this: &v205,
                        fmt: "area_%s",
                        a3: v36,
                        a4: v38,
                        a5: v37,
                        a6: v101,
                        a7: v113,
                        a8: v125,
                        a9: v137,
                        a10: v149,
                        a11: v161);
                idXMLWriter::WriteElement(this: &v182, name: v39->buffer, value: v35->buffer);
                LODWORD(v30) = owner->actorEditable.damageGroups.num;
                ++v33;
                ++v34;
              }
              while ( v33 < (int)v30 );
            }
            idXMLWriter::CloseElement(this: &v182);
            idXMLWriter::OpenElement(this: &v182, name: v191);
            v40 = owner->GetInventory_2(this: owner);
            v41 = 0;
            if ( v40->inventory.num > 0 )
            {
              v42 = 0;
              do
              {
                if ( v180.listStatic == 0 || v180.listStatic == 2 )
                {
                  if ( v180.list != nullptr )
                    idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
                  v180.list = nullptr;
                  v180.size = 0;
                }
                v180.num = 0;
                DisplayName = idInventoryItem::GetDisplayName(this: &v192, result: (idStrId *)v40->inventory.list[v42]);
                Key = idStrId::GetKey(this: DisplayName);
                idStr::idStr(this: &v198.name, text: v190);
                idStr::idStr(this: &v198.value, text: Key);
                idStr::StripLeadingWhiteSpace(this: &v198.name);
                idStr::StripTrailingWhitespace(this: &v198.name);
                idList<idXMLAttribute,44>::Append(this: &v180, obj: &v198);
                if ( (unsigned __int8)idAmmoItem::IsTypeOf(c: v40->inventory.list[v42]) != 0 )
                {
                  v45 = idAmmoItem::CastTo(c: (idAmmoItem *)v40->inventory.list[v42]);
                  decl = v45->decl;
                  if ( decl != nullptr )
                  {
                    v46 = decl[1].__vftable;
                    if ( v46 != nullptr )
                    {
                      if ( v46[6].Size != nullptr )
                      {
                        v171 = idDeclDamage::DamageAmount(this: (idDeclDamage *)decl[1].__vftable[6].Size);
                        HIDWORD(v47) = LODWORD(v171);
                        v50 = va::va(
                                this: &v204,
                                fmt: "%f",
                                a3: v47,
                                a4: v49,
                                a5: v48,
                                a6: v98,
                                a7: v110,
                                a8: v122,
                                a9: v134,
                                a10: v146,
                                a11: v158);
                        idStr::idStr(this: &v201.name, text: v185);
                        idStr::idStr(this: &v201.value, text: v50->buffer);
                        idStr::StripLeadingWhiteSpace(this: &v201.name);
                        idStr::StripTrailingWhitespace(this: &v201.name);
                        idList<idXMLAttribute,44>::Append(this: &v180, obj: &v201);
                        LODWORD(v51) = v45->decl;
                        HIDWORD(v51) = *(_DWORD *)(v51 + 504);
                        LODWORD(v52) = *(_DWORD *)(HIDWORD(v51) + 444);
                        v172 = *(float *)(v52 + 132);
                        HIDWORD(v53) = LODWORD(v172);
                        v54 = va::va(
                                this: &v205,
                                fmt: (const char *)HIDWORD(v172),
                                a3: v53,
                                a4: v52,
                                a5: v51,
                                a6: v102,
                                a7: v114,
                                a8: v126,
                                a9: v138,
                                a10: v150,
                                a11: v162);
                        idStr::idStr(this: &v195.name, text: v186);
                        idStr::idStr(this: &v195.value, text: v54->buffer);
                        idStr::StripLeadingWhiteSpace(this: &v195.name);
                        idStr::StripTrailingWhitespace(this: &v195.name);
                        idList<idXMLAttribute,44>::Append(this: &v180, obj: &v195);
                        HIDWORD(v55) = v45->decl;
                        LODWORD(v56) = *(_DWORD *)(HIDWORD(v55) + 504);
                        v173 = *(float *)(*(_DWORD *)(v56 + 444) + 128);
                        HIDWORD(v56) = LODWORD(v173);
                        v58 = va::va(
                                this: &v206,
                                fmt: (const char *)HIDWORD(v173),
                                a3: v56,
                                a4: v55,
                                a5: v57,
                                a6: v103,
                                a7: v115,
                                a8: v127,
                                a9: v139,
                                a10: v151,
                                a11: v163);
                        idStr::idStr(this: (idStr *)&v192.listeningToList, text: v183);
                        idStr::idStr(this: &v193, text: v58->buffer);
                        idStr::StripLeadingWhiteSpace(this: (idStr *)&v192.listeningToList);
                        idStr::StripTrailingWhitespace(this: (idStr *)&v192.listeningToList);
                        idList<idXMLAttribute,44>::Append(
                          this: &v180,
                          obj: (const idXMLAttribute *)&v192.listeningToList);
                        idStr::FreeData(this: &v193);
                        idStr::FreeData(this: (idStr *)&v192.listeningToList);
                        idStr::FreeData(this: &v195.value);
                        idStr::FreeData(this: &v195.name);
                        idStr::FreeData(this: &v201.value);
                        idStr::FreeData(this: &v201.name);
                      }
                      v59 = v45->decl;
                      v60 = v59[1].__vftable;
                      decl = v59;
                      if ( v60[7].LoadResource != nullptr )
                      {
                        decl = v59;
                        v174 = idDeclDamage::DamageAmount(this: (idDeclDamage *)v60[7].LoadResource);
                        HIDWORD(v61) = LODWORD(v174);
                        v64 = va::va(
                                this: &v206,
                                fmt: "%f",
                                a3: v61,
                                a4: v63,
                                a5: v62,
                                a6: v98,
                                a7: v110,
                                a8: v122,
                                a9: v134,
                                a10: v146,
                                a11: v158);
                        idStr::idStr(this: &v199.name, text: "Splash_DamageAmount");
                        idStr::idStr(this: &v199.value, text: v64->buffer);
                        idStr::StripLeadingWhiteSpace(this: &v199.name);
                        idStr::StripTrailingWhitespace(this: &v199.name);
                        idList<idXMLAttribute,44>::Append(this: &v180, obj: &v199);
                        LODWORD(v65) = v45->decl;
                        HIDWORD(v65) = *(_DWORD *)(v65 + 504);
                        LODWORD(v66) = *(_DWORD *)(HIDWORD(v65) + 452);
                        v175 = *(float *)(v66 + 132);
                        HIDWORD(v67) = LODWORD(v175);
                        v68 = va::va(
                                this: &v204,
                                fmt: (const char *)HIDWORD(v175),
                                a3: v67,
                                a4: v66,
                                a5: v65,
                                a6: v104,
                                a7: v116,
                                a8: v128,
                                a9: v140,
                                a10: v152,
                                a11: v164);
                        idStr::idStr(this: &v200.name, text: "Splash_MaxDamage");
                        idStr::idStr(this: &v200.value, text: v68->buffer);
                        idStr::StripLeadingWhiteSpace(this: &v200.name);
                        idStr::StripTrailingWhitespace(this: &v200.name);
                        idList<idXMLAttribute,44>::Append(this: &v180, obj: &v200);
                        HIDWORD(v69) = v45->decl;
                        LODWORD(v70) = *(_DWORD *)(HIDWORD(v69) + 504);
                        v176 = *(float *)(*(_DWORD *)(v70 + 452) + 128);
                        HIDWORD(v70) = LODWORD(v176);
                        v72 = va::va(
                                this: &v205,
                                fmt: (const char *)HIDWORD(v176),
                                a3: v70,
                                a4: v69,
                                a5: v71,
                                a6: v105,
                                a7: v117,
                                a8: v129,
                                a9: v141,
                                a10: v153,
                                a11: v165);
                        idStr::idStr(this: &v197.name, text: "Splash_MinDamage");
                        idStr::idStr(this: &v197.value, text: v72->buffer);
                        idStr::StripLeadingWhiteSpace(this: &v197.name);
                        idStr::StripTrailingWhitespace(this: &v197.name);
                        idList<idXMLAttribute,44>::Append(this: &v180, obj: &v197);
                        idStr::FreeData(this: &v197.value);
                        idStr::FreeData(this: &v197.name);
                        idStr::FreeData(this: &v200.value);
                        idStr::FreeData(this: &v200.name);
                        idStr::FreeData(this: &v199.value);
                        idStr::FreeData(this: &v199.name);
                      }
                    }
                  }
                }
                if ( (unsigned __int8)idThrowableItem::IsTypeOf(c: v40->inventory.list[v42]) != 0 )
                {
                  v76 = idThrowableItem::CastTo(c: (idThrowableItem *)v40->inventory.list[v42]);
                  if ( idThrowableItem::GetProjectileDef(this: v76) != nullptr
                    && idThrowableItem::GetProjectileDef(this: v76)->splashDamageDecl != nullptr )
                  {
                    ProjectileDef = idThrowableItem::GetProjectileDef(this: v76);
                    v177 = idDeclDamage::DamageAmount(this: ProjectileDef->splashDamageDecl);
                    HIDWORD(v78) = LODWORD(v177);
                    v81 = va::va(
                            this: &v206,
                            fmt: (const char *)HIDWORD(v177),
                            a3: v78,
                            a4: v80,
                            a5: v79,
                            a6: v98,
                            a7: v110,
                            a8: v122,
                            a9: v134,
                            a10: v146,
                            a11: v158);
                    idStr::idStr(this: &v196.name, text: "Splash_DamageAmount");
                    idStr::idStr(this: &v196.value, text: v81->buffer);
                    idStr::StripLeadingWhiteSpace(this: &v196.name);
                    idStr::StripTrailingWhitespace(this: &v196.name);
                    idList<idXMLAttribute,44>::Append(this: &v180, obj: &v196);
                    maxDamage = idThrowableItem::GetProjectileDef(this: v76)->splashDamageDecl->maxDamage;
                    HIDWORD(v82) = LODWORD(maxDamage);
                    v85 = va::va(
                            this: &v204,
                            fmt: (const char *)HIDWORD(maxDamage),
                            a3: v82,
                            a4: v84,
                            a5: v83,
                            a6: v106,
                            a7: v118,
                            a8: v130,
                            a9: v142,
                            a10: v154,
                            a11: v166);
                    idStr::idStr(this: &v194.name, text: "Splash_MaxDamage");
                    idStr::idStr(this: &v194.value, text: v85->buffer);
                    idStr::StripLeadingWhiteSpace(this: &v194.name);
                    idStr::StripTrailingWhitespace(this: &v194.name);
                    idList<idXMLAttribute,44>::Append(this: &v180, obj: &v194);
                    LODWORD(v86) = idThrowableItem::GetProjectileDef(this: v76)->splashDamageDecl;
                    v179 = *(float *)(v86 + 128);
                    HIDWORD(v87) = LODWORD(v179);
                    v89 = va::va(
                            this: &v205,
                            fmt: (const char *)HIDWORD(v179),
                            a3: v87,
                            a4: v88,
                            a5: v86,
                            a6: v107,
                            a7: v119,
                            a8: v131,
                            a9: v143,
                            a10: v155,
                            a11: v167);
                    idStr::idStr(this: &v202.name, text: "Splash_MinDamage");
                    idStr::idStr(this: &v202.value, text: v89->buffer);
                    idStr::StripLeadingWhiteSpace(this: &v202.name);
                    idStr::StripTrailingWhitespace(this: &v202.name);
                    idList<idXMLAttribute,44>::Append(this: &v180, obj: &v202);
                    idStr::FreeData(this: &v202.value);
                    idStr::FreeData(this: &v202.name);
                    idStr::FreeData(this: &v194.value);
                    idStr::FreeData(this: &v194.name);
                    idStr::FreeData(this: &v196.value);
                    idStr::FreeData(this: &v196.name);
                  }
                }
                LODWORD(v73) = v40->inventory.list[v42]->decl;
                HIDWORD(v75) = *(_DWORD *)(v73 + 8);
                v90 = va::va(
                        this: &v206,
                        fmt: v188,
                        a3: v75,
                        a4: v74,
                        a5: v73,
                        a6: v98,
                        a7: v110,
                        a8: v122,
                        a9: v134,
                        a10: v146,
                        a11: v158);
                HIDWORD(v91) = v41;
                v94 = va::va(
                        this: &v204,
                        fmt: v184,
                        a3: v91,
                        a4: v93,
                        a5: v92,
                        a6: v108,
                        a7: v120,
                        a8: v132,
                        a9: v144,
                        a10: v156,
                        a11: v168);
                idXMLWriter::WriteElement(this: &v182, name: v94->buffer, value: v90->buffer, attributes: &v180);
                idStr::FreeData(this: &v198.value);
                idStr::FreeData(this: &v198.name);
                ++v41;
                ++v42;
              }
              while ( v41 < v40->inventory.num );
            }
            if ( v180.listStatic == 0 || v180.listStatic == 2 )
            {
              if ( v180.list != nullptr )
                idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
              v180.list = nullptr;
              v180.size = 0;
            }
            v180.num = 0;
            idXMLWriter::CloseElement(this: &v182);
            idXMLWriter::CloseElement(this: &v182);
            if ( v180.listStatic == 0 || v180.listStatic == 2 )
            {
              if ( v180.list != nullptr )
                idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
              v180.list = nullptr;
              v180.size = 0;
            }
            v180.num = 0;
            idStr::FreeData(this: &v203.value);
            idStr::FreeData(this: &v203.name);
          }
          v95 = owner->actorNode.next;
          if ( v95 == nullptr || v95 == owner->actorNode.head )
            v96 = nullptr;
          else
            v96 = (idAI2 *)v95->owner;
          owner = v96;
        }
        while ( v96 != nullptr );
      }
    }
    idXMLWriter::CloseElement(this: &v182);
    idXMLWriter::CloseFile(this: &v182);
    if ( (v180.listStatic == 0 || v180.listStatic == 2) && v180.list != nullptr )
      idListArrayDelete<idTarget_Cvar::keyVal_t>(ptr: &v180.list->name, num: v180.size);
  }
}


// ========================================================================
// __unwind$553179
// EA  : 0x82A0F3E0
// RVA : 0x00A0F3E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553179()
{
  int v0; // r12

  idList<idKeyValue,5>::~idList<idKeyValue,5>(this: (idList<idLoadScreenInfo,5> *)(v0 - 13328 + 80));
}


// ========================================================================
// __unwind$553180
// EA  : 0x82A0F408
// RVA : 0x00A0F408
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553180()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 816));
}


// ========================================================================
// __unwind$553348
// EA  : 0x82A0F430
// RVA : 0x00A0F430
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553348()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 496));
}


// ========================================================================
// __unwind$553349
// EA  : 0x82A0F458
// RVA : 0x00A0F458
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553349()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 528));
}


// ========================================================================
// __unwind$553181
// EA  : 0x82A0F484
// RVA : 0x00A0F484
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553181()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 496));
}


// ========================================================================
// __unwind$553382
// EA  : 0x82A0F4AC
// RVA : 0x00A0F4AC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553382()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 688));
}


// ========================================================================
// __unwind$553383
// EA  : 0x82A0F4D4
// RVA : 0x00A0F4D4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553383()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 720));
}


// ========================================================================
// __unwind$553182
// EA  : 0x82A0F500
// RVA : 0x00A0F500
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553182()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 688));
}


// ========================================================================
// __unwind$553399
// EA  : 0x82A0F528
// RVA : 0x00A0F528
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553399()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 304));
}


// ========================================================================
// __unwind$553400
// EA  : 0x82A0F550
// RVA : 0x00A0F550
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553400()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 336));
}


// ========================================================================
// __unwind$553183
// EA  : 0x82A0F57C
// RVA : 0x00A0F57C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553183()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 304));
}


// ========================================================================
// __unwind$553416
// EA  : 0x82A0F5A4
// RVA : 0x00A0F5A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553416()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 176));
}


// ========================================================================
// __unwind$553417
// EA  : 0x82A0F5CC
// RVA : 0x00A0F5CC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553417()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 208));
}


// ========================================================================
// __unwind$553184
// EA  : 0x82A0F5F8
// RVA : 0x00A0F5F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553184()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 176));
}


// ========================================================================
// __unwind$553421
// EA  : 0x82A0F620
// RVA : 0x00A0F620
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553421()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 176));
}


// ========================================================================
// __unwind$553436
// EA  : 0x82A0F648
// RVA : 0x00A0F648
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553436()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 304));
}


// ========================================================================
// __unwind$553451
// EA  : 0x82A0F670
// RVA : 0x00A0F670
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553451()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 688));
}


// ========================================================================
// __unwind$553478
// EA  : 0x82A0F698
// RVA : 0x00A0F698
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553478()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 560));
}


// ========================================================================
// __unwind$553479
// EA  : 0x82A0F6C0
// RVA : 0x00A0F6C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553479()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 592));
}


// ========================================================================
// __unwind$553185
// EA  : 0x82A0F6EC
// RVA : 0x00A0F6EC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553185()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 560));
}


// ========================================================================
// __unwind$553495
// EA  : 0x82A0F714
// RVA : 0x00A0F714
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553495()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 624));
}


// ========================================================================
// __unwind$553496
// EA  : 0x82A0F73C
// RVA : 0x00A0F73C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553496()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 656));
}


// ========================================================================
// __unwind$553186
// EA  : 0x82A0F768
// RVA : 0x00A0F768
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553186()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 624));
}


// ========================================================================
// __unwind$553512
// EA  : 0x82A0F790
// RVA : 0x00A0F790
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553512()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 432));
}


// ========================================================================
// __unwind$553513_0
// EA  : 0x82A0F7B8
// RVA : 0x00A0F7B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553513_0()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 464));
}


// ========================================================================
// __unwind$553187
// EA  : 0x82A0F7E4
// RVA : 0x00A0F7E4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553187()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 432));
}


// ========================================================================
// __unwind$553517
// EA  : 0x82A0F80C
// RVA : 0x00A0F80C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553517()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 432));
}


// ========================================================================
// __unwind$553532
// EA  : 0x82A0F834
// RVA : 0x00A0F834
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553532()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 624));
}


// ========================================================================
// __unwind$553547
// EA  : 0x82A0F85C
// RVA : 0x00A0F85C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553547()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 560));
}


// ========================================================================
// __unwind$553574
// EA  : 0x82A0F884
// RVA : 0x00A0F884
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553574()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 368));
}


// ========================================================================
// __unwind$553575
// EA  : 0x82A0F8AC
// RVA : 0x00A0F8AC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553575()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 400));
}


// ========================================================================
// __unwind$553188
// EA  : 0x82A0F8D8
// RVA : 0x00A0F8D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553188()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 368));
}


// ========================================================================
// __unwind$553588
// EA  : 0x82A0F900
// RVA : 0x00A0F900
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553588()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 240));
}


// ========================================================================
// __unwind$553589
// EA  : 0x82A0F928
// RVA : 0x00A0F928
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553589()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 272));
}


// ========================================================================
// __unwind$553189
// EA  : 0x82A0F954
// RVA : 0x00A0F954
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553189()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 240));
}


// ========================================================================
// __unwind$553602
// EA  : 0x82A0F97C
// RVA : 0x00A0F97C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553602()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 752));
}


// ========================================================================
// __unwind$553603
// EA  : 0x82A0F9A4
// RVA : 0x00A0F9A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553603()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 784));
}


// ========================================================================
// __unwind$553190
// EA  : 0x82A0F9D0
// RVA : 0x00A0F9D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553190()
{
  int v0; // r12

  idKeyValue::~idKeyValue(this: (idXMLAttribute *)(v0 - 13328 + 752));
}


// ========================================================================
// __unwind$553607
// EA  : 0x82A0F9F8
// RVA : 0x00A0F9F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553607()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 752));
}


// ========================================================================
// __unwind$553622
// EA  : 0x82A0FA20
// RVA : 0x00A0FA20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553622()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 240));
}


// ========================================================================
// __unwind$553637
// EA  : 0x82A0FA48
// RVA : 0x00A0FA48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553637()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 368));
}


// ========================================================================
// __unwind$553680
// EA  : 0x82A0FA70
// RVA : 0x00A0FA70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553680()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 496));
}


// ========================================================================
// __unwind$553707
// EA  : 0x82A0FA98
// RVA : 0x00A0FA98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553707()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 13328 + 816));
}


// ========================================================================
// ?UpdateGroupStatusConditions@idAI2@@AAAXXZ
// EA  : 0x82A0FAC8
// RVA : 0x00A0FAC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateGroupStatusConditions(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  const idDeclAIBehavior *decl; // r29
  char v5; // r11
  idAI2::idAIVolatile::idAIGroupStatus *p_groupStatus; // r26
  bool v7; // cr58
  idAI2::aiCondition_t condition; // r11
  idAI2::aiCondition_t v9; // r10
  int GameMs; // r3
  idAI2::aiCondition_t v11; // r11
  idAI2::aiCondition_t v12; // r10
  idPhysics *Physics; // r3
  float *v14; // r28
  const idVec3 *Origin; // r3
  double v16; // fp10
  unsigned __int8 v17; // r11
  double v18; // fp6
  int v19; // r27
  int v20; // r3
  char v21; // r28
  char v22; // r11
  bool v23; // cr58
  idAI2::aiCondition_t v24; // r11
  idAI2::aiCondition_t v25; // r10
  bool v26; // r3
  idAI2::aiCondition_t v27; // r11
  idAI2::aiCondition_t v28; // r10
  bool v29; // r28
  aiSenseState_t *EnemySenseState; // r27
  int value; // r8
  idEntity *v32; // r3
  idEntity *v33; // r3
  idPhysics *v34; // r30
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r29
  float *v36; // r3
  double v37; // fp10
  double v38; // fp6
  idAI2::aiCondition_t v39; // r11
  unsigned int v40; // r10
  idPLogScope v41[10]; // [sp+50h] [-50h] BYREF

  RD_EventBegin(name: "idAI2::UpdateGroupStatusConditions");
  LODWORD(v2) = "idAI2::UpdateGroupStatusConditions";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v41, pl: &pLog, gMask: v2, label: v3);
  decl = this->aiEditable.behaviors.decl;
  if ( this->aiVolatile.animation.animWebAnimator.ptr[0].runIndexType != ANIMWEBAI_RUNINDEXTYPE_INJURED
    || (v5 = 1, decl->damageBehaviors.injuredRunMode == AIINJUREDRUNMODE_RECENTLYDAMAGED) )
  {
    v5 = 0;
  }
  p_groupStatus = &this->aiVolatile.groupStatus;
  v7 = v5 == 0;
  condition = this->aiVolatile.groupStatus.condition;
  v9 = condition | 8;
  if ( v7 )
    v9 = condition & 0xFFFFFFF7;
  this->aiVolatile.groupStatus.condition = v9;
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  v11 = this->aiVolatile.groupStatus.condition;
  v12 = v11 | 0x10;
  if ( decl->intimidation.minIntimidationTime < GameMs - this->aiVolatile.memory.lastIntimidationTime )
    v12 = v11 & 0xFFFFFFEF;
  this->aiVolatile.groupStatus.condition = v12;
  if ( !idAICover::IsValid(this: &this->aiVolatile.memory.currentCover)
    || (Physics = idEntity::GetPhysics(this),
        v14 = (float *)Physics->GetOrigin(this: Physics, a2: 0),
        Origin = idAICover::GetOrigin(this: &this->aiVolatile.memory.currentCover),
        v16 = (float)(Origin->y - v14[1]),
        v17 = 1,
        (float)((float)((float)(v18 = (float)(Origin->z - v14[2])) * (float)v18)
              + (float)((float)((float)(Origin->x - *v14) * (float)(Origin->x - *v14)) + (float)((float)v16 * (float)v16))) >= 4096.0) )
  {
    v17 = 0;
  }
  v19 = v17;
  v20 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
  v21 = ((v20 - this->aiVolatile.memory.lastFiredAtTime >= 0)
       + ((unsigned int)(v20 - this->aiVolatile.memory.lastFiredAtTime) >= 0x7D0))
      & 1;
  gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
  if ( v19 == 0 || (v22 = 1, v21 == 0) )
    v22 = 0;
  v23 = v22 == 0;
  v24 = this->aiVolatile.groupStatus.condition;
  v25 = v24 | 2;
  if ( v23 )
    v25 = v24 & 0xFFFFFFFD;
  this->aiVolatile.groupStatus.condition = v25;
  v26 = idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this);
  v27 = this->aiVolatile.groupStatus.condition;
  v28 = v27 | 1;
  if ( !v26 )
    v28 = v27 & 0xFFFFFFFE;
  this->aiVolatile.groupStatus.condition = v28;
  v29 = false;
  EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
  if ( EnemySenseState != nullptr
    && gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - EnemySenseState->lastConfirmedStimTime >= 5000 )
  {
    value = this->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
      && (v32 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
    {
      v33 = idEntity::CastTo(c: v32);
    }
    else
    {
      v33 = nullptr;
    }
    v34 = idEntity::GetPhysics(this: v33);
    ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: EnemySenseState);
    v36 = (float *)v34->GetOrigin(this: v34, a2: 0);
    v37 = (float)(v36[1] - ConfirmedPhysicalSafe->origin.y);
    v38 = (float)(v36[2] - ConfirmedPhysicalSafe->origin.z);
    v29 = (float)((float)((float)v38 * (float)v38)
                + (float)((float)((float)(*v36 - ConfirmedPhysicalSafe->origin.x)
                                * (float)(*v36 - ConfirmedPhysicalSafe->origin.x))
                        + (float)((float)v37 * (float)v37))) > 16384.0;
  }
  v39 = p_groupStatus->condition;
  v40 = v39 | 4;
  if ( !v29 )
    v40 = v39 & 0xFFFFFFFB;
  p_groupStatus->condition = v40;
  idPLogScope::~idPLogScope(this: v41);
  RD_EventEnd();
}


// ========================================================================
// __unwind$553998
// EA  : 0x82A0FE3C
// RVA : 0x00A0FE3C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553998()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 160 + 88));
}


// ========================================================================
// __unwind$553999
// EA  : 0x82A0FE64
// RVA : 0x00A0FE64
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_553999()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 160 + 80));
}


// ========================================================================
// ?InitMemory@idAI2@@AAAXXZ
// EA  : 0x82A10298
// RVA : 0x00A10298
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitMemory(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  int GameMs; // r3
  const idDeclAIBehavior *decl; // r11
  idPLogScope v6[6]; // [sp+50h] [-30h] BYREF

  RD_EventBegin(name: "idAI2::InitMemory");
  LODWORD(v2) = "idAI2::InitMemory";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v6, pl: &pLog, gMask: v2, label: v3);
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  decl = this->aiEditable.behaviors.decl;
  this->aiVolatile.memory.spawnTime = GameMs;
  if ( decl != nullptr )
    this->aiVolatile.memory.confidenceLevel = decl->intimidation.maxConfidenceLevel;
  else
    idLib::Warning(fmt: "idAI2::InitMemory '%s' doesn't have a behavior def set.", this->name.data);
  idPLogScope::~idPLogScope(this: v6);
  RD_EventEnd();
}


// ========================================================================
// __unwind$554392
// EA  : 0x82A10344
// RVA : 0x00A10344
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554392()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 128 + 88));
}


// ========================================================================
// __unwind$554393
// EA  : 0x82A1036C
// RVA : 0x00A1036C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554393()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 128 + 80));
}


// ========================================================================
// ?InitScriptObjects@idAI2@@AAAXXZ
// EA  : 0x82A103A0
// RVA : 0x00A103A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitScriptObjects(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idScriptObject *v4; // r3
  const idHandle<int,enum invalidThreadHandle_t,0> **v5; // r3
  idThread *Thread; // r3
  int v7; // [sp+50h] [-40h] BYREF
  idPLogScope v8[7]; // [sp+58h] [-38h] BYREF

  RD_EventBegin(name: "idAI2::InitScriptObjects");
  LODWORD(v2) = "idAI2::InitScriptObjects";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v8, pl: &pLog, gMask: v2, label: v3);
  v4 = this->GetScriptObject_2(this);
  if ( !idScriptObject::HasObject(this: v4) )
  {
LABEL_6:
    idPLogScope::~idPLogScope(this: v8);
    goto LABEL_7;
  }
  if ( this->NumThreads(this) != 0 )
  {
    v5 = (const idHandle<int,enum invalidThreadHandle_t,0> **)this->GetThread(this: &v7, result: this, a3: 0);
    Thread = idThreadManager::GetThread(this: &gameLocal->program.threadManager, threadHandle: *v5);
    this->aiVolatile.script.thread = Thread;
    if ( Thread != nullptr )
      idThread::ManualDelete(this: Thread);
    goto LABEL_6;
  }
  idLib::Warning(
    fmt: "AI %s has a script object but no thread. Make sure the script object has a constructor (init) defined.",
    this->name.data);
  idPLogScope::~idPLogScope(this: v8);
LABEL_7:
  RD_EventEnd();
}


// ========================================================================
// __unwind$554454_0
// EA  : 0x82A104A4
// RVA : 0x00A104A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554454_0()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 144 + 96));
}


// ========================================================================
// __unwind$554455
// EA  : 0x82A104CC
// RVA : 0x00A104CC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554455()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 144 + 88));
}


// ========================================================================
// ?InitFSMs@idAI2@@AAAXXZ
// EA  : 0x82A10500
// RVA : 0x00A10500
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitFSMs(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  int v4; // r10
  int v5; // r11
  idAIFSM *v6; // r7
  idPLog *pLog; // r29
  idPLog::logEntry_t *v8; // r30
  int v9; // r3
  __int64 totalTicks; // r11
  __int64 v11; // r9
  idPLogScope v12; // [sp+50h] [-30h] BYREF

  RD_EventBegin(name: "idAI2::InitFSMs");
  LODWORD(v2) = "idAI2::InitFSMs";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: &v12, pl: &::pLog, gMask: v2, label: v3);
  idAIActionManager::Init(this: &this->aiVolatile.fsms.actionManager, entity: this);
  idAIFSMManager::Init(this: &this->aiVolatile.fsms.fsmManager, owner: this);
  idAIFSMLite::Init(this: &this->aiVolatile.animation.animFSM, ai: this);
  v4 = 0;
  if ( this->aiVolatile.fsms.fsmManager.fsms.num > 0 )
  {
    v5 = 0;
    do
    {
      ++v4;
      v6 = this->aiVolatile.fsms.fsmManager.fsms.list[v5++];
      v6->callback = &this->fsmCallback;
    }
    while ( v4 < this->aiVolatile.fsms.fsmManager.fsms.num );
  }
  if ( v12.logIndex >= 0 )
  {
    pLog = v12.pLog;
    v8 = &v12.pLog->logEntries.list[v12.logIndex];
    v9 = (unsigned __int64)Sys_GetClockTicks() >> 32;
    totalTicks = v8->totalTicks;
    HIDWORD(totalTicks) = v8->parent;
    LODWORD(v11) = v9 - totalTicks;
    v8->totalTicks = v11;
    pLog->lastEntry = HIDWORD(totalTicks);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$554509
// EA  : 0x82A105E0
// RVA : 0x00A105E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554509()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 128 + 88));
}


// ========================================================================
// __unwind$554510
// EA  : 0x82A10608
// RVA : 0x00A10608
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554510()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 128 + 80));
}


// ========================================================================
// ?InitActionSettings@idAI2@@AAAXXZ
// EA  : 0x82A10638
// RVA : 0x00A10638
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitActionSettings(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  long double v4; // fp2
  idPLogScope v5[6]; // [sp+50h] [-30h] BYREF

  RD_EventBegin(name: "idAI2::InitActionSettings");
  LODWORD(v2) = "idAI2::InitActionSettings";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v5, pl: &pLog, gMask: v2, label: v3);
  idAIEditable::idAIActionSettings::Init(this: &this->aiEditable.actionSettings, a2: v4);
  idPLogScope::~idPLogScope(this: v5);
  RD_EventEnd();
}


// ========================================================================
// __unwind$554579_0
// EA  : 0x82A10690
// RVA : 0x00A10690
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554579_0()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 128 + 88));
}


// ========================================================================
// ?InitFireControl@idAI2@@AAAXXZ
// EA  : 0x82A106C0
// RVA : 0x00A106C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitFireControl(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idAIFireControl_Human *v4; // r3
  idAIFireControl_Human *v5; // r3
  idPLogScope v6[7]; // [sp+58h] [-38h] BYREF

  RD_EventBegin(name: "idAI2::InitFireControl");
  LODWORD(v2) = "idAI2::InitFireControl";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v6, pl: &pLog, gMask: v2, label: v3);
  v4 = (idAIFireControl_Human *)idMem::AllocWithLocation(
                                  this: &mem,
                                  location: "w:\\tech5\\shared\\idlib\\Heap.h(28) : TAG_NEW",
                                  size: 0x24u,
                                  tag: TAG_NEW,
                                  zeroBuffer: false,
                                  align: ALIGN_16,
                                  heap: HEAP_DEFAULTHEAP);
  if ( v4 != nullptr )
    v5 = idAIFireControl_Human::idAIFireControl_Human(this: v4);
  else
    v5 = nullptr;
  this->aiVolatile.fireControl = v5;
  idPLogScope::~idPLogScope(this: v6);
  RD_EventEnd();
}


// ========================================================================
// __unwind$554608
// EA  : 0x82A1075C
// RVA : 0x00A1075C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554608()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 144 + 96));
}


// ========================================================================
// __unwind$554609
// EA  : 0x82A10784
// RVA : 0x00A10784
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554609()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 144 + 88));
}


// ========================================================================
// __unwind$554610_0
// EA  : 0x82A107AC
// RVA : 0x00A107AC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall _unwind_554610_0(int a1, memTag_t a2)
{
  int v2; // r12

  operator delete(p: *(void **)(v2 - 144 + 80), tag: a2);
}


// ========================================================================
// ?UpdateMeleeCapabilities@idAI2@@AAAXXZ
// EA  : 0x82A107E0
// RVA : 0x00A107E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateMeleeCapabilities(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  int *p_meleeFlags; // r26
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *decl; // r28
  int v6; // r29
  const char **v7; // r30
  idPLog *pLog; // r29
  idPLog::logEntry_t *v9; // r30
  int v10; // r3
  __int64 totalTicks; // r11
  __int64 v12; // r9
  __int16 v13; // [sp+50h] [-70h] BYREF
  unsigned __int16 v14; // [sp+52h] [-6Eh] BYREF
  __int16 v15; // [sp+54h] [-6Ch] BYREF
  idPLogScope v16; // [sp+58h] [-68h] BYREF
  idStr v17[3]; // [sp+60h] [-60h] BYREF

  RD_EventBegin(name: "idAI2::UpdateMeleeCapabilities");
  LODWORD(v2) = "idAI2::UpdateMeleeCapabilities";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: &v16, pl: &::pLog, gMask: v2, label: v3);
  p_meleeFlags = &this->aiVolatile.animation.meleeFlags;
  this->aiVolatile.animation.meleeFlags = 0;
  decl = (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl;
  if ( decl != nullptr )
  {
    v17[0].len = 0;
    v17[0].baseBuffer[0] = 0;
    v17[0].allocedAndFlag = 20;
    v17[0].data = v17[0].baseBuffer;
    idAI2::GetSubWebPrefix(this, swt: AISUBWEB_MELEE, subWebPrefix: v17);
    idDeclAnimWeb::GetSubWebIndexForName(this: (idDeclAnimWeb *)&v13, result: decl, subWebName: v17[0].data);
    if ( v13 >= 0 )
    {
      v6 = 1;
      v7 = aiMeleeAnimNodeNames;
      do
      {
        idDeclAnimWeb::GetStateIndexForName(
          this: (idDeclAnimWeb *)&v14,
          result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)decl,
          name: *v7);
        if ( (v14 & 0x8000u) == 0 )
        {
          idDeclAnimWeb::FindNodeIndex(
            this: (idDeclAnimWeb *)&v15,
            result: (idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *)decl,
            subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v13,
            stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v14);
          if ( v15 >= 0 )
            *p_meleeFlags |= v6;
        }
        ++v7;
        v6 = __ROL4__(v6, 1);
      }
      while ( (int)v7 < (int)&aiMeleeAnimNodeNames[16] );
      idStr::FreeData(this: v17);
      if ( v16.logIndex >= 0 )
      {
        pLog = v16.pLog;
        v9 = &v16.pLog->logEntries.list[v16.logIndex];
        v10 = (unsigned __int64)Sys_GetClockTicks() >> 32;
        totalTicks = v9->totalTicks;
        HIDWORD(totalTicks) = v9->parent;
        LODWORD(v12) = v10 - totalTicks;
        v9->totalTicks = v12;
        pLog->lastEntry = HIDWORD(totalTicks);
      }
    }
    else
    {
      idStr::FreeData(this: v17);
      idPLogScope::~idPLogScope(this: &v16);
    }
  }
  else
  {
    idPLogScope::~idPLogScope(this: &v16);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$554648
// EA  : 0x82A10960
// RVA : 0x00A10960
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554648()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 192 + 128));
}


// ========================================================================
// __unwind$554649
// EA  : 0x82A10988
// RVA : 0x00A10988
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554649()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 192 + 88));
}


// ========================================================================
// __unwind$554650
// EA  : 0x82A109B0
// RVA : 0x00A109B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554650()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 192 + 96));
}


// ========================================================================
// ?EquipItem@idAI2@@UAA_NPAVidInventoryItem@@W4equipSlot_t@@@Z
// EA  : 0x82A109D8
// RVA : 0x00A109D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::EquipItem(idAI2 *this, idWeapon *item, equipSlot_t equipSlot)
{
  BOOL v5; // r30

  v5 = idActor::EquipItem(this, item, equipSlot);
  if ( idWeapon::CastTo(c: item) != nullptr )
    idAI2::UpdateMeleeCapabilities(this);
  return v5;
}


// ========================================================================
// ?UnequipItem@idAI2@@UAA_NPAVidInventoryItem@@@Z
// EA  : 0x82A10A18
// RVA : 0x00A10A18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idAI2::UnequipItem(idAI2 *this, idWeapon *item)
{
  BOOL v4; // r30

  v4 = idActor::UnequipItem(this, item);
  if ( idWeapon::CastTo(c: item) != nullptr )
    idAI2::UpdateMeleeCapabilities(this);
  return v4;
}


// ========================================================================
// ?InitHeadTracking@idAI2@@AAAXXZ
// EA  : 0x82A10A60
// RVA : 0x00A10A60
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitHeadTracking(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  aiAccuracy_t EffectiveAccuracy; // r3
  idDeclMD6 *decl; // r27
  const idVarArgs<6> *UserProp; // r3
  const idVarArgs<6> *v7; // r3
  int HeadTrackGroupIndex; // r3
  int v9; // r3
  idPLogScope v10[2]; // [sp+50h] [-90h] BYREF
  __int128 v11; // [sp+60h] [-80h]
  idRotationTrackerRange v12; // [sp+70h] [-70h] BYREF
  idRotationTrackerRange v13; // [sp+80h] [-60h] BYREF
  idRotationTrackerRange v14; // [sp+90h] [-50h] BYREF

  RD_EventBegin(name: "idAI2::InitHeadTracking");
  LODWORD(v2) = "idAI2::InitHeadTracking";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v10, pl: &pLog, gMask: v2, label: v3);
  idFocusInfo::SetDeclTrackingParms(
    this: this->aiVolatile.focus.foci.ptr,
    decl: this->aiEditable.behaviors.aimTrackingParms);
  EffectiveAccuracy = idAI2::GetEffectiveAccuracy(this);
  idFocusInfo::SetTrackingParmsIndex(this: this->aiVolatile.focus.foci.ptr, idx: EffectiveAccuracy);
  idFocusInfo::SetDeclTrackingParms(
    this: &this->aiVolatile.focus.foci.ptr[1],
    decl: this->aiEditable.behaviors.lookTrackingParms);
  idFocusInfo::SetTrackingParmsIndex(this: &this->aiVolatile.focus.foci.ptr[1], idx: this->aiEditable.skill.lookRate);
  v12.minYaw = -90.0;
  v12.maxYaw = 90.0;
  v12.minPitch = -80.0;
  v12.maxPitch = 80.0;
  idFocusInfo::SetConstraints(this: this->aiVolatile.focus.foci.ptr, constraints: &v12);
  idFocusInfo::SetConstraints(this: &this->aiVolatile.focus.foci.ptr[1], constraints: &v12);
  decl = idAnimatedEntity::GetTreeAnimatorFromPresentable(this)->decl;
  UserProp = idDeclMD6::FindUserProp(this: decl, name: "lookLimits");
  if ( UserProp != nullptr )
  {
    if ( UserProp->numArgs > 1u && UserProp->argTypes[1] == 12 )
      v11 = *(_OWORD *)&UserProp->args[UserProp->argOffsets[1]];
    v13.minYaw = *(float *)&v11;
    v13.maxYaw = *((float *)&v11 + 1);
    v13.minPitch = *((float *)&v11 + 2);
    v13.maxPitch = *((float *)&v11 + 3);
    idFocusInfo::SetConstraints(this: &this->aiVolatile.focus.foci.ptr[1], constraints: &v13);
  }
  v7 = idDeclMD6::FindUserProp(this: decl, name: "aimLimits");
  if ( v7 != nullptr )
  {
    if ( v7->numArgs > 1u && v7->argTypes[1] == 12 )
      v11 = *(_OWORD *)&v7->args[v7->argOffsets[1]];
    v14.minYaw = *(float *)&v11;
    v14.maxYaw = *((float *)&v11 + 1);
    v14.minPitch = *((float *)&v11 + 2);
    v14.maxPitch = *((float *)&v11 + 3);
    idFocusInfo::SetConstraints(this: this->aiVolatile.focus.foci.ptr, constraints: &v14);
  }
  HeadTrackGroupIndex = idDeclMD6::GetHeadTrackGroupIndex(this: decl, name: "look");
  this->aiVolatile.focus.foci.ptr[1].defaultHeadTrackGroup = HeadTrackGroupIndex;
  idFocusInfo::SetCurHeadTrackGroup(
    this: &this->aiVolatile.focus.foci.ptr[1],
    owner: this,
    trackGroupIndex: HeadTrackGroupIndex);
  v9 = idDeclMD6::GetHeadTrackGroupIndex(this: decl, name: "aim");
  this->aiVolatile.focus.foci.ptr[0].defaultHeadTrackGroup = v9;
  idFocusInfo::SetCurHeadTrackGroup(this: this->aiVolatile.focus.foci.ptr, owner: this, trackGroupIndex: v9);
  idPLogScope::~idPLogScope(this: v10);
  RD_EventEnd();
}


// ========================================================================
// __unwind$554783
// EA  : 0x82A10C94
// RVA : 0x00A10C94
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554783()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 224 + 160));
}


// ========================================================================
// __unwind$554784
// EA  : 0x82A10CBC
// RVA : 0x00A10CBC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554784()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 224 + 80));
}


// ========================================================================
// ?InitPhysics@idAI2@@AAAXXZ
// EA  : 0x82A10CF0
// RVA : 0x00A10CF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitPhysics(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idAI2::idAIVolatile *p_aiVolatile; // r29
  bool canSetCrouchPhysics; // r11
  const idClipModel *v6; // r27
  idClipModel *v7; // r3
  idClipModel *v8; // r4
  double y; // fp12
  double z; // fp9
  float *p_z; // r10
  int v12; // ctr
  idSysMutex *p_viewNoteMutex; // r11
  idClipModel *v14; // r3
  idClipModel *v15; // r4
  float *v16; // r3
  double v17; // fp0
  double v18; // fp13
  double v19; // fp12
  idAI2 *ai; // r4
  float x; // [sp+50h] [-6A0h]
  idVec3 v22; // [sp+58h] [-698h] BYREF
  idBounds v23; // [sp+70h] [-680h] BYREF
  idPLogScope v24; // [sp+88h] [-668h] BYREF
  idTraceModel v25; // [sp+90h] [-660h] BYREF

  RD_EventBegin(name: "idAI2::InitPhysics");
  LODWORD(v2) = "idAI2::InitPhysics";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: &v24, pl: &pLog, gMask: v2, label: v3);
  p_aiVolatile = &this->aiVolatile;
  idPhysics::InitPhysics(
    this: &this->aiVolatile.physics.object,
    clip_: &clientGame->clip,
    callbacks_: &this->physicsCallbacks,
    entityNumber_: this->entityNumber);
  this->aiVolatile.physics.object.SetGravity(
    this: (struct idPhysics_AI *)&this->aiVolatile,
    a2: &gameLocal->clientGame.gravity);
  ((void (__fastcall *)(idAI2::idAIVolatile *, double))this->aiVolatile.physics.object.SetMass)(
    a1: &this->aiVolatile,
    a2: this->mass);
  canSetCrouchPhysics = this->aiEditable.movement.canSetCrouchPhysics;
  this->aiVolatile.physics.object.heightCrouched = this->aiConstants.physics.heightCrouched;
  this->aiVolatile.physics.object.canSetCrouchedPhysics = canSetCrouchPhysics;
  v6 = this->defaultPhysicsObj.GetClipModel(this: &this->defaultPhysicsObj, a2: 0);
  v7 = (idClipModel *)idMem::AllocWithLocation(
                        this: &mem,
                        location: "w:\\tech5\\shared\\idlib\\Heap.h(64) : tag",
                        size: 0xD8u,
                        tag: TAG_CLIPMODEL,
                        zeroBuffer: false,
                        align: ALIGN_16,
                        heap: HEAP_DEFAULTHEAP);
  if ( v7 != nullptr )
    v8 = idClipModel::idClipModel(this: v7, clip: &clientGame->clip, model: v6);
  else
    v8 = nullptr;
  ((void (__fastcall *)(idAI2::idAIVolatile *, idClipModel *, double))p_aiVolatile->physics.object.SetClipModel)(
    a1: &this->aiVolatile,
    a2: v8,
    a3: 1.0);
  y = this->aiConstants.physics.playerCollisionSize.y;
  z = this->aiConstants.physics.playerCollisionSize.z;
  p_z = &v25.offset.z;
  v12 = 6;
  x = this->aiConstants.physics.playerCollisionSize.x;
  v23.b[0].z = 0.0;
  memset(&v25.type, 0, 20);
  v25.offset.x = 0.0;
  v25.offset.y = 0.0;
  v25.offset.z = 0.0;
  v23.b[0].x = x * (float)-1.0;
  v23.b[1].x = x;
  p_viewNoteMutex = &analysisClient.viewNoteMutex;
  v23.b[1].y = y;
  v23.b[1].z = z;
  v23.b[0].y = (float)y * (float)-1.0;
  do
  {
    ++p_viewNoteMutex;
    *++p_z = *(float *)&p_viewNoteMutex->handle;
    --v12;
  }
  while ( v12 != 0 );
  v25.radius = 0.0;
  v25.isConvex = false;
  v25.pad[2] = 0;
  v25.pad[1] = 0;
  v25.pad[0] = 0;
  idTraceModel::SetupCylinder(this: &v25, cylBounds: &v23, numSides: 8);
  v14 = (idClipModel *)idMem::AllocWithLocation(
                         this: &mem,
                         location: "w:\\tech5\\shared\\idlib\\Heap.h(64) : tag",
                         size: 0xD8u,
                         tag: TAG_CLIPMODEL,
                         zeroBuffer: false,
                         align: ALIGN_16,
                         heap: HEAP_DEFAULTHEAP);
  if ( v14 != nullptr )
    v15 = idClipModel::idClipModel(this: v14, clip: &clientGame->clip, trm: &v25, numTraceModels: 1, material: nullptr);
  else
    v15 = nullptr;
  ((void (__fastcall *)(idAI2::idAIVolatile *, idClipModel *, double))p_aiVolatile->physics.object.SetClipModel)(
    a1: &this->aiVolatile,
    a2: v15,
    a3: 1.0);
  v16 = (float *)p_aiVolatile->physics.object.GetGravityAxis(this: &this->aiVolatile.physics.object);
  v17 = this->actorVolatile.modelInfo.modelAxis.mat[0].z;
  v18 = this->actorVolatile.modelInfo.modelAxis.mat[0].y;
  v19 = this->actorVolatile.modelInfo.modelAxis.mat[0].x;
  ai = this->aiVolatile.physics.moveState.ai;
  v22.x = (float)(this->actorVolatile.modelInfo.modelAxis.mat[0].x * *v16)
        + (float)((float)(v16[1] * this->actorVolatile.modelInfo.modelAxis.mat[0].y)
                + (float)(v16[2] * this->actorVolatile.modelInfo.modelAxis.mat[0].z));
  v22.y = (float)(v16[3] * (float)v19) + (float)((float)(v16[4] * (float)v18) + (float)(v16[5] * (float)v17));
  v22.z = (float)((float)v19 * v16[6]) + (float)((float)(v16[7] * (float)v18) + (float)(v16[8] * (float)v17));
  idAIOrientation::SetIdealDir(this: &this->aiVolatile.physics.moveState.moveOrientation, ai, dir: &v22);
  p_aiVolatile->physics.object.SetOrigin(this: &this->aiVolatile.physics.object, a2: &this->spawnPosition, a3: -1);
  idEntity::SetPhysics(this, phys: &this->aiVolatile.physics.object);
  idAI2::SetSolid(this, isSolid: true);
  idAI2::SetWorldCollision(this, collideWithWorld: true);
  this->aiVolatile.animation.animFSM.InitTransform(
    this: &this->aiVolatile.animation.animFSM,
    a2: &this->spawnPosition,
    a3: &this->spawnOrientation);
  idPLogScope::~idPLogScope(this: &v24);
  RD_EventEnd();
}


// ========================================================================
// __unwind$554926
// EA  : 0x82A1107C
// RVA : 0x00A1107C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554926()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 1776 + 1680));
}


// ========================================================================
// __unwind$554927
// EA  : 0x82A110A4
// RVA : 0x00A110A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554927()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 1776 + 136));
}


// ========================================================================
// __unwind$554928
// EA  : 0x82A110CC
// RVA : 0x00A110CC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554928()
{
  int v0; // r12

  operator delete(p: *(void **)(v0 - 1776 + 80), tag: TAG_CLIPMODEL);
}


// ========================================================================
// __unwind$554929
// EA  : 0x82A110F8
// RVA : 0x00A110F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_554929()
{
  int v0; // r12

  operator delete(p: *(void **)(v0 - 1776 + 80), tag: TAG_CLIPMODEL);
}


// ========================================================================
// ?InitAAS@idAI2@@AAAXXZ
// EA  : 0x82A11130
// RVA : 0x00A11130
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::InitAAS(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  const idAAS2 *AAS; // r3
  idAAS2Settings *v5; // r29
  idPhysics *Physics; // r3
  const idBounds *v7; // r3
  BOOL v8; // r9
  char *data; // r5
  char *v10; // r4
  int v11; // r9
  char *v12; // r4
  idPLogScope v13[6]; // [sp+50h] [-30h] BYREF

  RD_EventBegin(name: "idAI2::InitAAS");
  LODWORD(v2) = "idAI2::InitAAS";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v13, pl: &pLog, gMask: v2, label: v3);
  AAS = idGameLocal::GetAAS(this: gameLocal, typeName: this->aiConstants.movement.aasName.data, load: true);
  this->aiVolatile.aas.aas = AAS;
  if ( AAS != nullptr )
  {
    v5 = AAS->GetSettings(this: AAS);
    if ( v5 != nullptr )
    {
      if ( this->clipModelInfo.type != CLIPMODEL_NONE )
      {
        Physics = idEntity::GetPhysics(this);
        v7 = Physics->GetBounds(this: Physics, a2: 0);
        if ( (unsigned __int8)idAAS2Settings::ValidForBounds(this: v5, bounds: v7) == 0 )
        {
          v8 = this->aiVolatile.aas.aas->IsDefault(this: (idAAS2 *)this->aiVolatile.aas.aas);
          data = this->aiConstants.movement.aasName.data;
          v10 = this->name.data;
          if ( v8 )
            idLib::Warning(fmt: "'%s' is too large for AAS '%s' - using anyway. (default aas was used)", v10, data);
          else
            idLib::Warning(fmt: "'%s' is too large for AAS '%s' - using anyway.", v10, data);
        }
      }
      this->aiVolatile.physics.object.maxStepHeight = v5->maxStepHeight;
    }
    if ( this->aiVolatile.aas.aas->IsDefault(this: (idAAS2 *)this->aiVolatile.aas.aas) )
      idLib::Printf(fmt: "'%s' is using the default AAS.\n", this->name.data);
    idPLogScope::~idPLogScope(this: v13);
  }
  else
  {
    v11 = gameLocal->GetGameFlags(this: gameLocal) & 2;
    v12 = this->name.data;
    if ( v11 != 0 )
      idLib::Warning(fmt: "'%s' has no AAS file or was not loaded.", v12);
    else
      idLib::Warning(fmt: "'%s' has no AAS file.", v12);
    this->aiVolatile.debugging.errorFlags |= 1u;
    idPLogScope::~idPLogScope(this: v13);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$555082
// EA  : 0x82A112D0
// RVA : 0x00A112D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555082()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 128 + 88));
}


// ========================================================================
// __unwind$555083
// EA  : 0x82A112F8
// RVA : 0x00A112F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555083()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 128 + 80));
}


// ========================================================================
// ?InitAnimation@idAI2@@AAA_NXZ
// EA  : 0x82A11328
// RVA : 0x00A11328
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::InitAnimation(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  idPresentable *presentable; // r11
  idTreeAnimator *v6; // r20
  unsigned __int64 v8; // r6
  const char *v9; // r7
  idDeclTwitchPain *declTwitchPain; // r3
  idPresentable *v11; // r3
  const idDeclTwitchPain *v12; // r28
  idEyeInfoCollection *decl; // r11
  idEyeInfoCollection *v14; // r4
  idEyeInfoCollection *EyeInfoHandle; // r3
  const idDeclAnimWeb *v16; // r10
  unsigned __int64 v17; // r6
  const char *v18; // r7
  const idDeclAnimWeb *v19; // r28
  int GameMs; // r3
  const char *allocedAndFlag; // r26
  int v22; // r25
  const char *textLength; // r22
  const char *v24; // r27
  idAnimStack *v25; // r3
  const idDeclAnimWeb *v26; // r10
  idGameTimeManager *v27; // r3
  idAnimStack *v28; // r3
  idPLog *pLog; // r27
  idPLog::logEntry_t *v30; // r28
  int v31; // r3
  __int64 totalTicks; // r11
  __int64 v33; // r9
  unsigned __int64 v34; // r6
  const char *v35; // r7
  idAnimStack *v36; // r28
  idGameTimeManager *v37; // r3
  unsigned __int64 v38; // r6
  const char *v39; // r7
  idGameTimeManager *v40; // r3
  char v41; // r5
  idPLog *v42; // r27
  idPLog::logEntry_t *v43; // r28
  int v44; // r3
  __int64 v45; // r11
  __int64 v46; // r9
  unsigned __int64 v47; // r6
  const char *v48; // r7
  const idDeclRollBones *rollBonesDecl; // r28
  idGameTimeManager *v50; // r3
  char v51; // r9
  idPropsCollection *v52; // r28
  char v53; // r11
  char v54; // r10
  char v55; // r11
  char v56; // r11
  char v57; // r10
  char v58; // r11
  char v59; // r11
  char v60; // r10
  char v61; // r11
  unsigned __int64 v62; // r6
  const char *v63; // r7
  char *str; // r10
  char v65; // r10
  bool v66; // zf
  const tagData_t *Tag; // r3
  double x; // fp0
  idGameTimeManager *v69; // r3
  unsigned __int64 v70; // r6
  const char *v71; // r7
  const idDeclDragJoints *dragJointsDecl; // r28
  idGameTimeManager *v73; // r3
  unsigned __int64 v74; // r6
  const char *v75; // r7
  aiFoci_t v76; // r28
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r27
  idPLog *v78; // r27
  idPLog::logEntry_t *v79; // r28
  int v80; // r3
  __int64 v81; // r11
  __int64 v82; // r9
  int v83; // r26
  idPLog::logEntry_t *v84; // r28
  __int64 v85; // r3
  int v86; // r27
  int v87; // r28
  idPLog::logEntry_t *v88; // r28
  int v89; // r3
  int parent; // r11
  __int64 v91; // r9
  int v92; // r28
  idPLog::logEntry_t *v93; // r27
  __int64 v94; // r3
  idPhysics *Physics; // r27
  idPhysics *v96; // r26
  idPhysics *v97; // r25
  float *v98; // r3
  idJointGroup **entityNumber; // r17
  const idDeclWalkIK *walkIKDecl; // r16
  idAnimStack *(__fastcall *GetAnimStack_2)(struct idAI2 *); // r7
  double v102; // fp13
  double v103; // fp12
  idDeclMD6::includeDecl_t *v104; // r27
  int v105; // r26
  int v106; // r3
  int v107; // r25
  idClip *p_clip; // r27
  idGameTimeManager *v109; // r3
  idPLog::logEntry_t *v110; // r28
  int v111; // r3
  int v112; // r11
  __int64 v113; // r9
  idAnimWebCmdCtx *v114; // r3
  int v115; // r29
  int v116; // r30
  int v117; // r3
  __int64 v118; // r11
  __int64 v119; // r9
  const char *v120; // [sp+8h] [-378h]
  const char *v121; // [sp+Ch] [-374h]
  int v122; // [sp+10h] [-370h]
  int v123; // [sp+14h] [-36Ch]
  int v124; // [sp+18h] [-368h]
  int v125; // [sp+1Ch] [-364h]
  int v126; // [sp+20h] [-360h]
  int v127; // [sp+24h] [-35Ch]
  int v128; // [sp+28h] [-358h]
  int v129; // [sp+2Ch] [-354h]
  int v130; // [sp+30h] [-350h]
  int v131; // [sp+34h] [-34Ch]
  int v132; // [sp+38h] [-348h]
  int v133; // [sp+3Ch] [-344h]
  int v134; // [sp+40h] [-340h]
  int v135; // [sp+44h] [-33Ch]
  int v136; // [sp+48h] [-338h]
  int v137; // [sp+4Ch] [-334h]
  int v138; // [sp+50h] [-330h]
  int v139; // [sp+58h] [-328h]
  int v140; // [sp+60h] [-320h]
  int v141; // [sp+68h] [-318h]
  idPLogScope v142; // [sp+70h] [-310h] BYREF
  idEyeInfoCollection v143; // [sp+78h] [-308h] BYREF
  idDeclMD6 v144; // [sp+8Ch] [-2F4h] BYREF

  RD_EventBegin(name: "idAI2::InitAnimation");
  LODWORD(v2) = "idAI2::InitAnimation";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: (idPLogScope *)&v144.staleCount, pl: &::pLog, gMask: v2, label: v3);
  TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
  presentable = this->presentable;
  v6 = TreeAnimatorFromPresentable;
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
  }
  idPresentable::UpdateModelTransform(this: presentable);
  if ( v6 != nullptr )
  {
    RD_EventBegin(name: "idAI2::InitAnimation - twitch pain");
    LODWORD(v8) = "idAI2::InitAnimation - twitch pain";
    HIDWORD(v8) = 2;
    idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v8, label: v9);
    declTwitchPain = this->aiEditable.death.declTwitchPain;
    if ( declTwitchPain != nullptr )
      idDeclTwitchPain::StrongLoadAliasesForModelDef(this: declTwitchPain, decl: v6->decl);
    v11 = this->presentable;
    if ( v11 == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      v11 = this->presentable;
    }
    v12 = this->aiEditable.death.declTwitchPain;
    v11->GetAIInterface(this: v11)->painAnimationEventInfo.declTwitchPain = v12;
    idPLogScope::~idPLogScope(this: &v142);
    RD_EventEnd();
    decl = (idEyeInfoCollection *)v6->decl;
    v14 = decl + 21;
    if ( decl == nullptr )
      v14 = nullptr;
    EyeInfoHandle = idEyeInfoCollection::FindEyeInfoHandle(
                      this: &v143,
                      result: v14,
                      name: this->aiConstants.animation.eyeInfoName.data);
    v16 = this->aiConstants.animation.animWebs[0];
    this->aiVolatile.eyeTracking.eyeInfoHandle.value = EyeInfoHandle->curHandle;
    if ( v16 == nullptr )
      idLib::Error(fmt: "AI '%s' has no body anim-web defined.", this->name.data);
    RD_EventBegin(name: "idAI2::InitAnimation - init anim webs");
    LODWORD(v17) = "idAI2::InitAnimation - init anim webs";
    HIDWORD(v17) = 2;
    idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v17, label: v18);
    v19 = this->aiConstants.animation.animWebs[0];
    if ( v19 != nullptr )
    {
      v144.textSource = nullptr;
      v144.programaticallyDefined = false;
      v144.md5Checksum = 20;
      *(_DWORD *)&v143.curHandle = this->aiConstants.animation.animWebDefaults;
      v144.textLength = (int)&v144.programaticallyDefined;
      *(_DWORD *)v144.parent.baseBuffer = 20;
      v144.parent.allocedAndFlag = (int)&v144.parent.baseBuffer[4];
      v144.parent.data = nullptr;
      v144.parent.baseBuffer[4] = 0;
      idAI2::GetSubWebAndStateFromAnimWebPath(
        this,
        animWebPath: this->aiConstants.animation.animWebDefaults[0].webPath.data,
        subWebName: (idStr *)&v144.textSource,
        stateName: (idStr *)&v144.parent.data);
      this->aiVolatile.animation.animWebAnimator.ptr[0].ai = this;
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      allocedAndFlag = (const char *)v144.parent.allocedAndFlag;
      v22 = GameMs;
      textLength = (const char *)v144.textLength;
      v24 = aiAnimWebNames[0];
      v25 = this->GetAnimStack_2(this);
      idAnimatorParms_AnimWeb::idAnimatorParms_AnimWeb(
        this: (idAnimatorParms_AnimWeb *)&v144.userProps.granularity,
        animStack_: v25,
        name_: v24,
        blendOp_: BOP_LERP,
        originBlend_: ORIGINBLEND_BRANCH,
        weightGroup_: MD6_WEIGHTGROUP_ALL,
        filterGroup_: MD6_WEIGHTGROUP_ALL,
        alpha_: 1.0,
        webDecl_: v26,
        initialSubWebName_: v120,
        initialStateName_: v121,
        curTime_: v122,
        a13: v123,
        a14: v124,
        a15: v125,
        a16: v126,
        a17: v127,
        a18: v128,
        a19: v129,
        a20: v130,
        a21: v131,
        a22: v132,
        a23: v133,
        a24: v134,
        a25: v135,
        a26: v136,
        a27: v137,
        a28: v138,
        a29: v19,
        a30: v139,
        a31: textLength,
        a32: v140,
        a33: allocedAndFlag,
        a34: v141,
        a35: v22);
      idList<idAtomicString,109>::operator=(
        this: (idList<idAtomicString,109> *)&v144.meshKitDefault[0].allocedAndFlag,
        other: (const idList<idAtomicString,109> *)&this->aiConstants.animation.animWebDefaults[0].activeLayers);
      v27 = gameLocal->GetGameTimeManager(this: gameLocal);
      idAnimator_Base::Init(
        this: (idAnimator_Base *)&this->aiVolatile.animation,
        gametimeManager: v27,
        parms: (const idAnimatorParms_Base *)&v144.userProps.granularity);
      LOBYTE(v24) = this->aiConstants.animation.animWebDefaults[0].enabled;
      v28 = this->GetAnimStack_2(this);
      idAnimator_Base::SetEnabled(
        this: (idAnimator_Base *)&this->aiVolatile.animation,
        animStack: v28,
        enabled: (const bool)v24);
      idAnimatorParms_AnimWeb::~idAnimatorParms_AnimWeb(this: (idAnimatorParms_AnimWeb *)&v144.userProps.granularity);
      idStr::FreeData(this: (idStr *)&v144.parent.data);
      idStr::FreeData(this: (idStr *)&v144.textSource);
    }
    if ( v142.logIndex >= 0 )
    {
      pLog = v142.pLog;
      v30 = &v142.pLog->logEntries.list[v142.logIndex];
      v31 = (unsigned __int64)Sys_GetClockTicks() >> 32;
      totalTicks = v30->totalTicks;
      HIDWORD(totalTicks) = v30->parent;
      LODWORD(v33) = v31 - totalTicks;
      v30->totalTicks = v33;
      pLog->lastEntry = HIDWORD(totalTicks);
    }
    RD_EventEnd();
    if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 197) & 0x80) != 0
      || (this->aiEditable.actionSettings.cover.scenePointSelectionFlags & 0x20) != 0 )
    {
      RD_EventBegin(name: "idAI2::InitAnimation - turret ta");
      LODWORD(v34) = "idAI2::InitAnimation - turret ta";
      HIDWORD(v34) = 2;
      idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v34, label: v35);
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)&v143.eyeInfos.num,
        result: v6->decl,
        aliasName: "unarmed/combat/turret_nw");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)((char *)&v143.eyeInfos.num + 2),
        result: v6->decl,
        aliasName: "unarmed/combat/turret_n");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)&v143.eyeInfos.size,
        result: v6->decl,
        aliasName: "unarmed/combat/turret_ne");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)((char *)&v143.eyeInfos.size + 2),
        result: v6->decl,
        aliasName: "unarmed/combat/turret_w");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)&v143.eyeInfos.granularity,
        result: v6->decl,
        aliasName: "unarmed/combat/turret_c");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)&v143.eyeInfos.memTag,
        result: v6->decl,
        aliasName: "unarmed/combat/turret_e");
      idDeclMD6::StrongLoadAlias(this: &v144, result: v6->decl, aliasName: "unarmed/combat/turret_sw");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)((char *)&v144.__vftable + 2),
        result: v6->decl,
        aliasName: "unarmed/combat/turret_s");
      idDeclMD6::StrongLoadAlias(
        this: (idDeclMD6 *)&v144.trackedMemory,
        result: v6->decl,
        aliasName: "unarmed/combat/turret_se");
      v36 = this->GetAnimStack_2(this);
      v37 = gameLocal->GetGameTimeManager(this: gameLocal);
      idAnimator_TurretNxN<3>::SetParameters(
        this: &this->aiVolatile.animation.turretAnimator,
        gametimeManager: v37,
        animStack: v36,
        _vertexAliasHandles: (const idHandle<unsigned short,enum invalidAliasHandle_t,65535> *)&v143.eyeInfos.num,
        additive: false);
      idPLogScope::~idPLogScope(this: &v142);
      RD_EventEnd();
    }
    RD_EventBegin(name: "idAI2::InitAnimation - pain ta");
    LODWORD(v38) = "idAI2::InitAnimation - pain ta";
    HIDWORD(v38) = 2;
    idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v38, label: v39);
    v144.animEvents.hashIndex.hash = (int *)this->GetAnimStack_2(this);
    idStr::idStr(this: (idStr *)&v144.animEvents.hashIndex.indexChain, text: "pain");
    *(float *)&v144.userProps.list = 1.0;
    memset(&v144.eyeInfoCollection.eyeInfos.num, 0, 12);
    v144.eyeInfoCollection.eyeInfos.list = (idEyeInfo *)4;
    v40 = gameLocal->GetGameTimeManager(this: gameLocal);
    idAnimator_Base::Init(
      this: &this->aiVolatile.animation.painAnimator,
      gametimeManager: v40,
      parms: (const idAnimatorParms_Base *)&v144.animEvents.hashIndex);
    v41 = *((_BYTE *)&this->aiVolatile.animation.painAnimator.idAnimator_Channel + 94);
    *(_DWORD *)&v143.curHandle = &this->aiVolatile.animation.painAnimator;
    *((_BYTE *)&this->aiVolatile.animation.painAnimator.idAnimator_Channel + 94) = v41 | 0x40;
    idStr::FreeData(this: (idStr *)&v144.animEvents.hashIndex.indexChain);
    if ( v142.logIndex >= 0 )
    {
      v42 = v142.pLog;
      v43 = &v142.pLog->logEntries.list[v142.logIndex];
      v44 = (unsigned __int64)Sys_GetClockTicks() >> 32;
      v45 = v43->totalTicks;
      HIDWORD(v45) = v43->parent;
      LODWORD(v46) = v44 - v45;
      v43->totalTicks = v46;
      v42->lastEntry = HIDWORD(v45);
    }
    RD_EventEnd();
    if ( this->aiEditable.rollBonesDecl != nullptr )
    {
      RD_EventBegin(name: "idAI2::InitAnimation - rollbones animator");
      LODWORD(v47) = "idAI2::InitAnimation - rollbones animator";
      HIDWORD(v47) = 2;
      idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v47, label: v48);
      v144.jointGroupCollection.jointGroupsByType[2].num = (int)this->GetAnimStack_2(this);
      rollBonesDecl = this->aiEditable.rollBonesDecl;
      idStr::idStr(this: (idStr *)&v144.jointGroupCollection.jointGroupsByType[2].size, text: "rollBones");
      *(float *)&v144.jointGroupCollection.jointGroupsByType[5].size = 1.0;
      v144.jointGroupCollection.jointGroupsByType[4].size = 2;
      *(_DWORD *)&v144.jointGroupCollection.jointGroupsByType[4].granularity = 0;
      v144.jointGroupCollection.jointGroupsByType[5].list = (idJointGroup **)2;
      v144.jointGroupCollection.jointGroupsByType[5].num = 0;
      *(_DWORD *)&v144.jointGroupCollection.jointGroupsByType[5].granularity = rollBonesDecl;
      v50 = gameLocal->GetGameTimeManager(this: gameLocal);
      idAnimator_Base::Init(
        this: &this->aiVolatile.animation.rollBonesAnimator,
        gametimeManager: v50,
        parms: (const idAnimatorParms_Base *)&v144.jointGroupCollection.jointGroupsByType[2].num);
      idStr::FreeData(this: (idStr *)&v144.jointGroupCollection.jointGroupsByType[2].size);
      idPLogScope::~idPLogScope(this: &v142);
      RD_EventEnd();
    }
    v51 = *((_BYTE *)&this->aiConstants.animation + 92);
    v52 = (idPropsCollection *)v6->decl;
    if ( (v51 & 0x80) == 0 || (v53 = 1, (v52[44].props.size & 4) == 0) )
      v53 = 0;
    v54 = (v53 << 6) & 0x40 | *((_BYTE *)&this->aiConstants.animation + 93) & 0xBF;
    *((_BYTE *)&this->aiConstants.animation + 93) = v54;
    if ( (v51 & 0x40) == 0 || (v55 = 1, (v52[44].props.size & 1) == 0) )
      v55 = 0;
    v56 = (32 * v55) & 0x20 | v54 & 0xDF;
    *((_BYTE *)&this->aiConstants.animation + 93) = v56;
    if ( (v51 & 0x20) == 0 || (v57 = 1, (v52[44].props.size & 8) == 0) )
      v57 = 0;
    v58 = (16 * v57) & 0x10 | v56 & 0xEF;
    *((_BYTE *)&this->aiConstants.animation + 93) = v58;
    if ( (v58 & 0x80) == 0 || (v59 = 1, (v52[44].props.size & 2) == 0) )
      v59 = 0;
    v60 = (8 * v59) & 8 | *((_BYTE *)&this->aiConstants.animation + 93) & 0xF7;
    *((_BYTE *)&this->aiConstants.animation + 93) = v60;
    if ( (v51 & 8) == 0 || (v61 = 1, (v52[44].props.size & 2) == 0) )
      v61 = 0;
    *((_BYTE *)&this->aiConstants.animation + 93) = (4 * v61) & 4 | v60 & 0xFB;
    if ( (v51 & 1) != 0 )
    {
      RD_EventBegin(name: "idAI2::InitAnimation - face manager");
      LODWORD(v62) = "idAI2::InitAnimation - face manager";
      HIDWORD(v62) = 2;
      idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v62, label: v63);
      *((_BYTE *)&this->aiConstants.animation + 92) = (idFaceMgr::Init(
                                                         this: &this->aiVolatile.faceMgr,
                                                         owner: this,
                                                         ta: v6,
                                                         mood: MOOD_NONE,
                                                         voiceChannel: SND_CHANNEL_VOICE,
                                                         enableMoodAnimation: (*((_BYTE *)&this->aiConstants.animation + 93) & 0x40) != 0,
                                                         enableLipSyncAnimation: (*((_BYTE *)&this->aiConstants.animation + 93) & 0x20) != 0,
                                                         enableGestureAnimation: (*((_BYTE *)&this->aiConstants.animation + 93) & 0x10) != 0,
                                                         enableEyeTracking: (const bool)v120,
                                                         useFaceSetupEyeTracking_: (const bool)v121,
                                                         enableBlinking: v122,
                                                         enableLidDeformation: v123) << 7)
                                                    | *((_BYTE *)&this->aiConstants.animation + 92) & 0x7F;
      idPLogScope::~idPLogScope(this: &v142);
      RD_EventEnd();
    }
    if ( v52 != nullptr )
    {
      str = (char *)this->aiConstants.animation.viewTagName.str;
      *(_DWORD *)&v143.curHandle = &this->aiConstants.animation.viewTagName;
      if ( str == &byte_8200D768 || (v66 = *str != 0, v65 = 0, !v66) )
        v65 = 1;
      if ( v65 == 0 )
      {
        Tag = idPropsCollection::GetTag(
                this: v52 + 22,
                propName: idPropInfo::INFO_PROP_NAME,
                tagName: this->aiConstants.animation.viewTagName.str);
        x = Tag->trans.x;
        *(_DWORD *)&v143.curHandle = &this->aiVolatile.animation.viewTagData.rot;
        this->aiVolatile.animation.viewTagData.trans.x = x;
        this->aiVolatile.animation.viewTagData.trans.y = Tag->trans.y;
        this->aiVolatile.animation.viewTagData.trans.z = Tag->trans.z;
        this->aiVolatile.animation.viewTagData.rot = Tag->rot;
        this->aiVolatile.animation.viewTagData.parentJoint.value = Tag->parentJoint.value;
      }
    }
    if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 8) != 0 )
    {
      v144.jointGroupCollection.jointGroupsByType[10].num = (int)this->GetAnimStack_2(this);
      idStr::idStr(this: (idStr *)&v144.jointGroupCollection.jointGroupsByType[10].size, text: "facetracks");
      *(float *)&v144.animEvents.list.num = 1.0;
      v144.props.props.size = 4;
      *(_DWORD *)&v144.props.props.granularity = 0;
      v144.animEvents.__vftable = (idAnimEvents_vtbl *)4;
      v144.animEvents.list.list = (idAnimEvents::animEventInfo_t *)4;
      v69 = gameLocal->GetGameTimeManager(this: gameLocal);
      idAnimator_Base::Init(
        this: &this->aiVolatile.animation.faceAnimator,
        gametimeManager: v69,
        parms: (const idAnimatorParms_Base *)&v144.jointGroupCollection.jointGroupsByType[10].num);
      idStr::FreeData(this: (idStr *)&v144.jointGroupCollection.jointGroupsByType[10].size);
    }
    if ( this->aiEditable.dragJointsDecl != nullptr )
    {
      RD_EventBegin(name: "idAI2::InitAnimation - draggedjoints animator");
      LODWORD(v70) = "idAI2::InitAnimation - draggedjoints animator";
      HIDWORD(v70) = 2;
      idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v70, label: v71);
      v144.jointGroupCollection.jointGroupsByType[6].num = (int)this->GetAnimStack_2(this);
      dragJointsDecl = this->aiEditable.dragJointsDecl;
      idStr::idStr(this: (idStr *)&v144.jointGroupCollection.jointGroupsByType[6].size, text: "dragJoints");
      *(float *)&v144.jointGroupCollection.jointGroupsByType[9].size = 1.0;
      v144.jointGroupCollection.jointGroupsByType[8].size = 2;
      *(_DWORD *)&v144.jointGroupCollection.jointGroupsByType[8].granularity = 0;
      v144.jointGroupCollection.jointGroupsByType[9].list = (idJointGroup **)2;
      v144.jointGroupCollection.jointGroupsByType[9].num = 0;
      *(_DWORD *)&v144.jointGroupCollection.jointGroupsByType[9].granularity = dragJointsDecl;
      idCurve_BSpline<idAngles>::SetOrder(
        this: &this->aiVolatile.animation.dragJointsAnimator,
        web: (idAnimator_AnimWeb *)&this->aiVolatile.animation);
      v73 = gameLocal->GetGameTimeManager(this: gameLocal);
      idAnimator_Base::Init(
        this: &this->aiVolatile.animation.dragJointsAnimator,
        gametimeManager: v73,
        parms: (const idAnimatorParms_Base *)&v144.jointGroupCollection.jointGroupsByType[6].num);
      idStr::FreeData(this: (idStr *)&v144.jointGroupCollection.jointGroupsByType[6].size);
      idPLogScope::~idPLogScope(this: &v142);
      RD_EventEnd();
    }
    RD_EventBegin(name: "idAI2::InitAnimation - init foci");
    LODWORD(v74) = "idAI2::InitAnimation - init foci";
    HIDWORD(v74) = 2;
    idPLogScope::idPLogScope(this: &v142, pl: &::pLog, gMask: v74, label: v75);
    v76 = AIFOCI_AIM;
    p_focus = &this->aiVolatile.focus;
    do
    {
      idFocusInfo::Init(this: p_focus->foci.ptr, owner: this, fociType_: v76++);
      p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)p_focus + 272);
    }
    while ( v76 < AIFOCI_MAX );
    if ( v142.logIndex >= 0 )
    {
      v78 = v142.pLog;
      v79 = &v142.pLog->logEntries.list[v142.logIndex];
      v80 = (unsigned __int64)Sys_GetClockTicks() >> 32;
      v81 = v79->totalTicks;
      HIDWORD(v81) = v79->parent;
      LODWORD(v82) = v80 - v81;
      v79->totalTicks = v82;
      v78->lastEntry = HIDWORD(v81);
    }
    RD_EventEnd();
    RD_EventBegin(name: "idAI2::InitAnimation - ponytail animators");
    v142.pLog = &::pLog;
    v83 = -1;
    v142.logIndex = -1;
    if ( (::pLog.groupMask & 2) != 0 )
    {
      idMem::PushHeap(this: &mem, heapType: HEAP_SYSTEMHEAP);
      idList<idPLog::logEntry_t,44>::PreAllocateWithGranularity(
        this: &::pLog.logEntries,
        newSize: ::pLog.logEntries.num + 1);
      if ( ::pLog.logEntries.num >= ::pLog.logEntries.size )
        v84 = &::pLog.logEntries.list[::pLog.logEntries.size - 1];
      else
        v84 = &::pLog.logEntries.list[::pLog.logEntries.num++];
      idMem::PopHeap(this: &mem);
      v84->label = "idAI2::InitAnimation - ponytail animators";
      v84->parent = ::pLog.lastEntry;
      v83 = ::pLog.logEntries.num - 1;
      ::pLog.lastEntry = ::pLog.logEntries.num - 1;
      v142.logIndex = ::pLog.logEntries.num - 1;
      LODWORD(v85) = (unsigned __int64)Sys_GetClockTicks() >> 32;
      v84->totalTicks = v85;
    }
    v86 = 0;
    if ( this->aiEditable.ponytails.num > 0 )
    {
      v87 = 0;
      do
      {
        idPonytail::Init(this: &this->aiEditable.ponytails.list[v87], parent_: this);
        ++v86;
        ++v87;
      }
      while ( v86 < this->aiEditable.ponytails.num );
    }
    if ( v83 >= 0 )
    {
      v88 = &::pLog.logEntries.list[v83];
      v89 = (unsigned __int64)Sys_GetClockTicks() >> 32;
      parent = v88->parent;
      LODWORD(v91) = v89 - LODWORD(v88->totalTicks);
      v88->totalTicks = v91;
      ::pLog.lastEntry = parent;
    }
    RD_EventEnd();
    RD_EventBegin(name: "idAI2::InitAnimation - IK ta");
    v92 = -1;
    v142.pLog = &::pLog;
    v142.logIndex = -1;
    if ( (::pLog.groupMask & 2) != 0 )
    {
      idMem::PushHeap(this: &mem, heapType: HEAP_SYSTEMHEAP);
      idList<idPLog::logEntry_t,44>::PreAllocateWithGranularity(
        this: &::pLog.logEntries,
        newSize: ::pLog.logEntries.num + 1);
      if ( ::pLog.logEntries.num >= ::pLog.logEntries.size )
        v93 = &::pLog.logEntries.list[::pLog.logEntries.size - 1];
      else
        v93 = &::pLog.logEntries.list[::pLog.logEntries.num++];
      idMem::PopHeap(this: &mem);
      v93->label = "idAI2::InitAnimation - IK ta";
      v93->parent = ::pLog.lastEntry;
      v92 = ::pLog.logEntries.num - 1;
      ::pLog.lastEntry = ::pLog.logEntries.num - 1;
      v142.logIndex = ::pLog.logEntries.num - 1;
      LODWORD(v94) = (unsigned __int64)Sys_GetClockTicks() >> 32;
      v93->totalTicks = v94;
    }
    Physics = idEntity::GetPhysics(this);
    v96 = idEntity::GetPhysics(this);
    v97 = idEntity::GetPhysics(this);
    v98 = (float *)Physics->GetGravityNormal(this: Physics);
    entityNumber = (idJointGroup **)this->entityNumber;
    walkIKDecl = this->walkIKDecl;
    GetAnimStack_2 = this->GetAnimStack_2;
    v102 = v98[1];
    v103 = -v98[2];
    *(float *)&v144.nextOnHashChain = -*v98;
    *(float *)&v144.resourceError = v103;
    *(float *)&v144.resourceListPtr = -v102;
    v104 = (idDeclMD6::includeDecl_t *)GetAnimStack_2(this);
    v105 = v96->GetClipMask(this: v96, a2: -1);
    v106 = (int)v97->GetClipModel(this: v97, a2: 0);
    v144.declsToIncludeAnimDataFrom.list = v104;
    v107 = v106;
    p_clip = &clientGame->clip;
    idStr::idStr(this: (idStr *)&v144.declsToIncludeAnimDataFrom.num, text: "walkIK");
    *(float *)&v144.jointGroupCollection.jointGroups.size = 1.0;
    LODWORD(v144.referenceBounds.b[1].z) = 2;
    memset(&v144.numLoadErrors, 0, 12);
    *(_DWORD *)&v144.jointGroupCollection.jointGroups.granularity = walkIKDecl;
    v144.jointGroupCollection.jointGroupsByType[0].list = entityNumber;
    v144.jointGroupCollection.jointGroupsByType[0].num = v105;
    v144.jointGroupCollection.jointGroupsByType[0].size = (int)p_clip;
    *(_DWORD *)&v144.jointGroupCollection.jointGroupsByType[0].granularity = v107;
    v144.jointGroupCollection.jointGroupsByType[1].list = (idJointGroup **)v144.nextOnHashChain;
    v144.jointGroupCollection.jointGroupsByType[1].num = (int)v144.resourceListPtr;
    v144.jointGroupCollection.jointGroupsByType[1].size = (int)v144.resourceError;
    v109 = gameLocal->GetGameTimeManager(this: gameLocal);
    idAnimator_Base::Init(
      this: &this->walkIK,
      gametimeManager: v109,
      parms: (const idAnimatorParms_Base *)&v144.declsToIncludeAnimDataFrom);
    idStr::FreeData(this: (idStr *)&v144.declsToIncludeAnimDataFrom.num);
    if ( v92 >= 0 )
    {
      v110 = &::pLog.logEntries.list[v92];
      v111 = (unsigned __int64)Sys_GetClockTicks() >> 32;
      v112 = v110->parent;
      LODWORD(v113) = v111 - LODWORD(v110->totalTicks);
      v110->totalTicks = v113;
      ::pLog.lastEntry = v112;
    }
    RD_EventEnd();
    *((_BYTE *)v6 + 2164) |= 0x10u;
    if ( this->actorConstants.actorClass == ACTORCLASS_MUTANT )
    {
      idFaceMgr::SetEnableMoodAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      idFaceMgr::SetEnableLipSyncAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      idFaceMgr::SetEnableGestureAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      idFaceMgr::SetEnableEyeTracking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      idFaceMgr::SetEnableLidDeformation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
    }
    v114 = this->GetAnimWebCmdCtx(this);
    v114->animWeb = (idAnimator_AnimWeb *)&this->aiVolatile.animation;
    v114->entity = this;
    this->GetAnimWebCmdCtx(this)->defaultAnimWebCmdGroupFilter = 0x80000000;
    if ( v144.staleCount >= 0 )
    {
      v115 = *((_DWORD *)&v144.idResource + 8);
      v116 = *(_DWORD *)(*((_DWORD *)&v144.idResource + 8) + 16) + 16 * v144.staleCount;
      v117 = (unsigned __int64)Sys_GetClockTicks() >> 32;
      v118 = *(_QWORD *)(v116 + 8);
      HIDWORD(v118) = *(_DWORD *)(v116 + 4);
      LODWORD(v119) = v117 - v118;
      *(_QWORD *)(v116 + 8) = v119;
      *(_DWORD *)(v115 + 32) = HIDWORD(v118);
    }
    RD_EventEnd();
    return 1;
  }
  else
  {
    idPLogScope::~idPLogScope(this: (idPLogScope *)&v144.staleCount);
    RD_EventEnd();
    return 0;
  }
}


// ========================================================================
// $LN370
// EA  : 0x82A12198
// RVA : 0x00A12198
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _LN370()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 736));
}


// ========================================================================
// __unwind$555216
// EA  : 0x82A121C0
// RVA : 0x00A121C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555216()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 168));
}


// ========================================================================
// __unwind$555217
// EA  : 0x82A121E8
// RVA : 0x00A121E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555217()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 737));
}


// ========================================================================
// __unwind$555218
// EA  : 0x82A12210
// RVA : 0x00A12210
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555218()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555219
// EA  : 0x82A12238
// RVA : 0x00A12238
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555219()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 738));
}


// ========================================================================
// __unwind$555220
// EA  : 0x82A12260
// RVA : 0x00A12260
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555220()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555221
// EA  : 0x82A12288
// RVA : 0x00A12288
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555221()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 896 + 176));
}


// ========================================================================
// __unwind$555222
// EA  : 0x82A122B0
// RVA : 0x00A122B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555222()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 896 + 208));
}


// ========================================================================
// __unwind$555223
// EA  : 0x82A122D8
// RVA : 0x00A122D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555223()
{
  int v0; // r12

  idAnimatorParms_AnimWeb::~idAnimatorParms_AnimWeb(this: (idAnimatorParms_AnimWeb *)(v0 - 896 + 592));
}


// ========================================================================
// __unwind$555224
// EA  : 0x82A12300
// RVA : 0x00A12300
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555224()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 739));
}


// ========================================================================
// __unwind$555225
// EA  : 0x82A12328
// RVA : 0x00A12328
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555225()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555226
// EA  : 0x82A12350
// RVA : 0x00A12350
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555226()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 740));
}


// ========================================================================
// __unwind$555227
// EA  : 0x82A12378
// RVA : 0x00A12378
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555227()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555228
// EA  : 0x82A123A0
// RVA : 0x00A123A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555228()
{
  int v0; // r12

  idAnimatorParms_EndAdditiveChannels::~idAnimatorParms_EndAdditiveChannels(this: (vaiAction_t::vehicleCam_t *)(v0 - 896 + 528));
}


// ========================================================================
// __unwind$555229
// EA  : 0x82A123C8
// RVA : 0x00A123C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555229()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 741));
}


// ========================================================================
// __unwind$555230
// EA  : 0x82A123F0
// RVA : 0x00A123F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555230()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555231
// EA  : 0x82A12418
// RVA : 0x00A12418
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555231()
{
  int v0; // r12

  idAnimatorParms_EndAdditiveChannels::~idAnimatorParms_EndAdditiveChannels(this: (vaiAction_t::vehicleCam_t *)(v0 - 896 + 336));
}


// ========================================================================
// __unwind$555232
// EA  : 0x82A12440
// RVA : 0x00A12440
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555232()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 742));
}


// ========================================================================
// __unwind$555233
// EA  : 0x82A12468
// RVA : 0x00A12468
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555233()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555234
// EA  : 0x82A12490
// RVA : 0x00A12490
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555234()
{
  int v0; // r12

  idAnimatorParms_EndAdditiveChannels::~idAnimatorParms_EndAdditiveChannels(this: (vaiAction_t::vehicleCam_t *)(v0 - 896 + 464));
}


// ========================================================================
// __unwind$555235
// EA  : 0x82A124B8
// RVA : 0x00A124B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555235()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 743));
}


// ========================================================================
// __unwind$555236
// EA  : 0x82A124E0
// RVA : 0x00A124E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555236()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555237
// EA  : 0x82A12508
// RVA : 0x00A12508
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555237()
{
  int v0; // r12

  idAnimatorParms_EndAdditiveChannels::~idAnimatorParms_EndAdditiveChannels(this: (vaiAction_t::vehicleCam_t *)(v0 - 896 + 400));
}


// ========================================================================
// __unwind$555238
// EA  : 0x82A12530
// RVA : 0x00A12530
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555238()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 744));
}


// ========================================================================
// __unwind$555239
// EA  : 0x82A12558
// RVA : 0x00A12558
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555239()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555240
// EA  : 0x82A12580
// RVA : 0x00A12580
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555240()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 745));
}


// ========================================================================
// __unwind$555241
// EA  : 0x82A125A8
// RVA : 0x00A125A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555241()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555242
// EA  : 0x82A125D0
// RVA : 0x00A125D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555242()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 896 + 746));
}


// ========================================================================
// __unwind$555243
// EA  : 0x82A125F8
// RVA : 0x00A125F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555243()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 896 + 112));
}


// ========================================================================
// __unwind$555244
// EA  : 0x82A12620
// RVA : 0x00A12620
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_555244()
{
  int v0; // r12

  idAnimatorParms_EndAdditiveChannels::~idAnimatorParms_EndAdditiveChannels(this: (vaiAction_t::vehicleCam_t *)(v0 - 896 + 240));
}


// ========================================================================
// ?UpdateTravelFlags@idAI2@@QAAXXZ
// EA  : 0x82A12650
// RVA : 0x00A12650
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateTravelFlags(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  const idDeclAIBehavior *decl; // r28
  unsigned int v5; // r7
  int v6; // r23
  idVec3 *v7; // r4
  aiSenseState_t *EnemySenseState; // r3
  idPhysics *Physics; // r3
  float *v10; // r3
  double v11; // fp10
  double v12; // fp0
  double v13; // fp7
  double v14; // fp31
  idPhysics *v15; // r3
  idAIMoveState *MoveInterface; // r3
  int v17; // r3
  char v18; // r11
  bool v19; // r25
  idRenderModel *RenderModelFromPresentable; // r3
  float *p_deferredAxis; // r11
  bool v22; // r27
  int lastAimedAtTime; // r29
  char v24; // r11
  char v25; // r29
  int lastFiredAtTime; // r20
  char v27; // r11
  int lastAvoidTime; // r29
  int valueInteger; // r28
  idPhysics *v30; // r3
  char *data; // r27
  idRenderWorld_vtbl *v32; // r29
  int v33; // r3
  idPLogScope v34; // [sp+68h] [-D8h] BYREF
  idVec3 v35; // [sp+70h] [-D0h] BYREF
  idVec3 v36; // [sp+80h] [-C0h] BYREF
  float v37; // [sp+90h] [-B0h]
  float v38; // [sp+94h] [-ACh]
  float v39; // [sp+98h] [-A8h]
  idStr v40; // [sp+A0h] [-A0h] BYREF

  RD_EventBegin(name: "idAI2::UpdateTravelFlags");
  LODWORD(v2) = "idAI2::UpdateTravelFlags";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: &v34, pl: &pLog, gMask: v2, label: v3);
  decl = this->aiEditable.behaviors.decl;
  v5 = *((unsigned __int8 *)decl + 84);
  v6 = (16
      * ((4
        * ((2
          * ((2 * ((4 * ((4 * ((2 * (v5 >> 1)) & 2 | v5 & 0xFD)) & 0xC | ((v5 & 4) != 0))) | ((v5 & 8) != 0)))
           | ((v5 & 0x10) != 0)))
         | ((v5 & 0x40) != 0)))
       | ((*((_BYTE *)decl + 85) & 0x40) != 0)))
     | ((*((_BYTE *)decl + 85) & 0x80) == 0 ? 0 : 0x200)
     | 0x4000028;
  if ( (*((_BYTE *)decl + 85) & 0x20) != 0 && (this->aiVolatile.groupStatus.condition & 8) == 0 )
    v6 |= (!this->aiEditable.movement.useTraversalClassE ? 0 : 0x1000000)
        | (!this->aiEditable.movement.useTraversalClassD ? 0 : 0x800000)
        | (!this->aiEditable.movement.useTraversalClassC ? 0 : 0x40000)
        | (!this->aiEditable.movement.useTraversalClassB ? 0 : 0x20000)
        | (!this->aiEditable.movement.useTraversalClassA ? 0 : 0x10000);
  if ( (*((_BYTE *)decl + 85) & 0x10) != 0
    && (idAI2::IsPlayerControlled(this) || this->aiVolatile.fsms.alertCycle == ALERTCYCLE_COMBAT) )
  {
    EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
    if ( EnemySenseState != nullptr )
    {
      aiSenseState_t::ExtrapolatePosition(this: EnemySenseState, seconds: 0.25, futurePos: v7);
      Physics = idEntity::GetPhysics(this);
      v10 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
      v11 = (float)(v38 - v10[1]);
      v12 = (float)(v37 - *v10);
      v13 = (float)(v39 - v10[2]);
      v35.x = v37 - *v10;
      v35.y = v11;
      v35.z = v13;
      v14 = (float)((float)((float)v13 * (float)v13)
                  + (float)((float)((float)v12 * (float)v12) + (float)((float)v11 * (float)v11)));
      idVec3::NormalizeFast(this: &v35);
      v15 = idEntity::GetPhysics(this);
      v15->GetLinearVelocity(this: (idPhysics *)&v36, result: (idVec3 *)v15, a3: 0);
      if ( (float)((float)(v36.x * v36.x) + (float)((float)(v36.y * v36.y) + (float)(v36.z * v36.z))) > 1.0 )
        idVec3::NormalizeFast(this: &v36);
      MoveInterface = idAI2::GetMoveInterface(this);
      v17 = (int)MoveInterface->GetDestinationTraversal(this: MoveInterface);
      if ( v17 == 0 || (v18 = 1, (*(_DWORD *)(v17 + 52) & 2) == 0) )
        v18 = 0;
      if ( v18 != 0 )
        goto LABEL_26;
      v19 = (this->aiVolatile.groupStatus.condition & 8) != 0;
      RenderModelFromPresentable = idEntity::GetRenderModelFromPresentable(this);
      p_deferredAxis = (float *)&RenderModelFromPresentable->deferredAxis;
      if ( !RenderModelFromPresentable->useDeferredPosition )
        p_deferredAxis = (float *)&RenderModelFromPresentable->g.axis;
      v22 = (float)((float)(*p_deferredAxis * v35.x)
                  + (float)((float)(p_deferredAxis[2] * v35.z) + (float)(p_deferredAxis[1] * v35.y))) > 0.866;
      lastAimedAtTime = this->aiVolatile.memory.lastAimedAtTime;
      if ( gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - lastAimedAtTime >= decl->traversalAimEvasionDuration
        || (v24 = 1, v14 >= (float)(decl->traversalEvasionAimDist * decl->traversalEvasionAimDist)) )
      {
        v24 = 0;
      }
      v25 = v24;
      lastFiredAtTime = this->aiVolatile.memory.lastFiredAtTime;
      if ( gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - lastFiredAtTime >= decl->traversalGunfireEvasionDuration
        || (v27 = 1, v14 >= (float)(decl->traversalEvasionGunfireDist * decl->traversalEvasionGunfireDist)) )
      {
        v27 = 0;
      }
      if ( (v25 != 0 || v27 != 0) && !v19 && v22 )
LABEL_26:
        v6 |= 0x80000u;
    }
    if ( (unsigned __int8)idAI2::IsInAvoidFSM(this) != 0
      || (lastAvoidTime = this->aiVolatile.memory.lastAvoidTime) >= 0
      && (valueInteger = ai_scrambleTime.valueInteger,
          gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - lastAvoidTime < valueInteger)
      || (this->aiVolatile.groupStatus.condition & 0x10) != 0 )
    {
      v6 |= 0x400000u;
    }
  }
  if ( idAI2::IsPlayerControlled(this) || this->aiVolatile.fsms.alertCycle == ALERTCYCLE_COMBAT )
    v6 |= 0x2000000u;
  if ( ai_debugTraversals.valueInteger != 0 && ai_debugLevel.valueInteger > 0 )
  {
    v40.len = 0;
    v40.baseBuffer[0] = 0;
    v40.allocedAndFlag = 20;
    v40.data = v40.baseBuffer;
    if ( (v6 & 0x10000) != 0 )
      idStr::Append(this: &v40, text: "a ");
    if ( (v6 & 0x20000) != 0 )
      idStr::Append(this: &v40, text: "b ");
    if ( (v6 & 0x40000) != 0 )
      idStr::Append(this: &v40, text: "c ");
    if ( (v6 & 0x800000) != 0 )
      idStr::Append(this: &v40, text: "d ");
    if ( (v6 & 0x1000000) != 0 )
      idStr::Append(this: &v40, text: "e ");
    if ( (v6 & 0x80000) != 0 )
      idStr::Append(this: &v40, text: "evasion ");
    if ( (v6 & 0x400000) != 0 )
      idStr::Append(this: &v40, text: "emergency ");
    if ( (v6 & 0x2000000) != 0 )
      idStr::Append(this: &v40, text: "combat ");
    v30 = idEntity::GetPhysics(this);
    data = v40.data;
    v32 = clientGame->renderWorld->__vftable;
    v33 = (int)v30->GetOrigin(this: v30, a2: 0);
    ((void (__fastcall *)(idRenderWorld *, char *, int, enum idAIStateTransition::aiTransCode_t (__fastcall **)(COMBAT_AtPlugAnim *__hidden, struct idAI2 *, struct idAIFSM *, struct idAIState *, int), idColor *, int, _DWORD, _DWORD, double))v32->DebugText)(
      a1: clientGame->renderWorld,
      a2: data,
      a3: v33,
      a4: &off_82040000,
      a5: &idColor::colorGreen,
      a6: 1,
      a7: 0,
      a8: 0,
      a9: 0.2);
    idStr::FreeData(this: &v40);
  }
  this->aiVolatile.aas.travelFlags = v6;
  idPLogScope::~idPLogScope(this: &v34);
  RD_EventEnd();
}


// ========================================================================
// __unwind$556062
// EA  : 0x82A12C84
// RVA : 0x00A12C84
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556062()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 320 + 192));
}


// ========================================================================
// __unwind$556063
// EA  : 0x82A12CAC
// RVA : 0x00A12CAC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556063()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 320 + 104));
}


// ========================================================================
// __unwind$556064
// EA  : 0x82A12CD4
// RVA : 0x00A12CD4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556064()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 320 + 160));
}


// ========================================================================
// ?PlayAmbientSound@idAI2@@QAAXPBVidSoundShader@@@Z
// EA  : 0x82A12D08
// RVA : 0x00A12D08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::PlayAmbientSound(idAI2 *this, const idSoundShader *snd)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  idPLogScope v6[8]; // [sp+50h] [-40h] BYREF

  RD_EventBegin(name: "idAI2::PlayAmbientSound");
  LODWORD(v4) = "idAI2::PlayAmbientSound";
  HIDWORD(v4) = 2;
  idPLogScope::idPLogScope(this: v6, pl: &pLog, gMask: v4, label: v5);
  if ( snd != nullptr )
    idEntity::StartSoundShader(
      this,
      channel: SND_CHANNEL_AMBIENT,
      shader: this->aiEditable.sounds.sndAmbient,
      soundShaderFlags: 0,
      peerMask: 0xFFu);
  this->aiEditable.sounds.sndAmbient = snd;
  idPLogScope::~idPLogScope(this: v6);
  RD_EventEnd();
}


// ========================================================================
// __unwind$556277
// EA  : 0x82A12D80
// RVA : 0x00A12D80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556277()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 144 + 88));
}


// ========================================================================
// __unwind$556278
// EA  : 0x82A12DA8
// RVA : 0x00A12DA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556278()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 144 + 80));
}


// ========================================================================
// ?UpdateEffects@idAI2@@AAAXXZ
// EA  : 0x82A12DD0
// RVA : 0x00A12DD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateEffects(idAI2 *this)
{
  double fadeOutTime; // fp31
  idAnimator_AF *v3; // r3
  char v4; // r29
  int valueInteger; // r30
  int v6; // r28
  idAnimator_AF *v7; // r3
  char v8; // r11
  signed int GameMsPerFrame; // r3
  signed int v10; // r29
  int v11; // r3
  unsigned int v12; // r8
  idGameTimeManager *p_gameTimeManager; // r3
  idPhysics *v14; // r30
  idPhysics *v15; // r29
  int GameMs; // r28
  idPresentable *v17; // r27
  const idMat3 *v18; // r30
  const idVec3 *v19; // r3
  char v20; // r27
  idPhysics *Physics; // r30
  idPhysics *v22; // r29
  idPhysics *v23; // r3
  idPhysics_vtbl *v24; // r30
  int (__fastcall *GetClipMask)(idPhysics *, int); // ctr
  int v26; // r3
  idPhysics_AF *p_physicsObj; // r30
  idPhysics_AF *v28; // r29
  idPhysics_AF *v29; // r3
  idPhysics_AF_vtbl *v30; // r30
  int (__fastcall *v31)(struct idPhysics_AF *, int); // ctr
  int v32; // r3
  __int64 v33; // r7
  idPresentable *presentable; // r3
  int v35; // r3
  idPresentable *v36; // r3
  int v37; // r3
  int v38; // r11
  idPresentable *v39; // r3
  int v40; // r30
  int v41; // r3
  idClipModel *v42; // r3
  const idSoundShader *sndDeath; // r10
  int started; // r3
  __int64 v45; // r7
  double v46; // fp31
  idPresentable *v47; // r11
  idAttachmentCollection *v48; // r3
  idAttachment *v49; // r3
  idEntityPtr<idEntity> *p_entity; // r30
  idAttachment *v51; // r29
  idEntity *v52; // r3
  idProjectile *v53; // r3
  idProjectile *v54; // r29
  const idEntity *v55; // r30
  idAttachmentCollection *v56; // r3
  idPhysics *v57; // r30
  idPhysics *v58; // r29
  unsigned int v59; // r28
  idPresentable *v60; // r31
  const idMat3 *v61; // r30
  const idVec3 *v62; // r3
  int v63; // r7
  idPhysics *v64; // r30
  idPhysics *v65; // r29

  fadeOutTime = this->aiEditable.death.fadeOutTime;
  v3 = this->GetAF_2(this);
  v4 = v3->physicsObj.IsAtRest(this: &v3->physicsObj);
  valueInteger = ai_FadeDelay.valueInteger;
  v6 = 0;
  if ( common->IsMultiplayer(this: common) )
  {
    fadeOutTime = ai_CoopFadeOutTime.valueFloat;
    if ( v4 != 0
      || this->aiVolatile.death.deathTime != -1
      && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) > this->aiVolatile.death.deathTime
                                                                                                 + ai_CoopFadeDelay.valueInteger )
    {
      valueInteger = 0;
      v4 = 1;
    }
  }
  if ( fadeOutTime > 0.0 && !idAI2::IsPlayerControlled(this) && this->aiVolatile.fsms.alertCycle == ALERTCYCLE_DEAD )
  {
    v7 = this->GetAF_2(this);
    if ( v7->isActive || (v8 = 0, v7->isClientAuthoritativeActive) )
      v8 = 1;
    if ( v8 != 0 && v4 != 0 )
    {
      GameMsPerFrame = idGameTimeManager::GetGameMsPerFrame(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      __twllei(GameMsPerFrame, 0);
      __twlgei(GameMsPerFrame & ~(__ROL4__(valueInteger, 1) - 1), 0xFFFFFFFF);
      if ( valueInteger % GameMsPerFrame != 0 )
      {
        v10 = idGameTimeManager::GetGameMsPerFrame(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        v11 = idGameTimeManager::GetGameMsPerFrame(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        __twllei(v10, 0);
        v12 = v10 & ~(__ROL4__(valueInteger, 1) - 1);
        valueInteger = v11 * (valueInteger / v10);
        __twlgei(v12, 0xFFFFFFFF);
      }
      p_gameTimeManager = &clientGame->gameTimeManager;
      if ( this->aiVolatile.death.ragdollAtRestTime >= 0 )
      {
        if ( idGameTimeManager::GetGameMs(this: p_gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.death.ragdollAtRestTime )
        {
          v20 = 0;
          Physics = idEntity::GetPhysics(this);
          v22 = idEntity::GetPhysics(this);
          v23 = Physics;
          GetClipMask = Physics->GetClipMask;
          v24 = v22->__vftable;
          v26 = GetClipMask(this: v23, a2: -1);
          v24->SetClipMask(this: v22, a2: v26 & 0xFFFFFF7F, a3: -1);
          p_physicsObj = &this->GetAF_2(this)->physicsObj;
          v28 = &this->GetAF_2(this)->physicsObj;
          v29 = p_physicsObj;
          v31 = p_physicsObj->GetClipMask;
          v30 = v28->__vftable;
          v32 = v31(this: v29, a2: -1);
          v30->SetClipMask(this: v28, a2: v32 & 0xFFFFFF7F, a3: -1);
          presentable = this->presentable;
          if ( presentable != nullptr )
            v35 = (int)presentable->GetAnimatedEntityInterface(this: presentable);
          else
            v35 = 0;
          if ( *(_BYTE *)(v35 + 1240) != 0 && *(_DWORD *)(v35 + 1208) != 0 )
          {
            v36 = this->presentable;
            if ( v36 != nullptr )
              v37 = (int)v36->GetAnimatedEntityInterface(this: v36);
            else
              v37 = 0;
            if ( *(_BYTE *)(v37 + 1240) != 0 )
              v38 = *(_DWORD *)(v37 + 1208);
            else
              v38 = 0;
            v39 = this->presentable;
            v40 = *(_DWORD *)(v38 + 128);
            if ( v39 != nullptr )
              v41 = (int)v39->GetAnimatedEntityInterface(this: v39);
            else
              v41 = 0;
            if ( *(_BYTE *)(v41 + 1240) != 0 )
              v42 = *(idClipModel **)(v41 + 1208);
            else
              v42 = nullptr;
            idClipModel::SetContents(this: v42, newContents: v40 & 0xFFFFFF7F);
          }
          sndDeath = this->aiEditable.sounds.sndDeath;
          this->lootable = false;
          this->dropRandomLoot = false;
          if ( sndDeath != nullptr && !idEntity::IsPlayingSound(this, channel: SND_CHANNEL_DAMAGE) )
          {
            started = idEntity::StartSoundShader(
                        this,
                        channel: SND_CHANNEL_DAMAGE,
                        shader: this->aiEditable.sounds.sndDeath,
                        soundShaderFlags: 0,
                        peerMask: 0xFFu);
            if ( started > 0 && (*((_BYTE *)&this->aiVolatile.death + 1761) & 0x80) == 0 )
            {
              idEventReceiver::PostEventMS(this, ev: &EV_Remove, time: started + 2000);
              v20 = 1;
              *((_BYTE *)&this->aiVolatile.death + 1761) |= 0x80u;
            }
          }
          if ( v20 == 0 )
          {
            if ( (*((_BYTE *)&this->aiVolatile.death + 1761) & 0x80) == 0 )
            {
              idEventReceiver::PostEventMS(
                this,
                ev: &EV_Remove,
                time: 2000 - (int)(float)((float)(1000.0 * (float)fadeOutTime) * (float)-1.25));
              *((_BYTE *)&this->aiVolatile.death + 1761) |= 0x80u;
            }
            if ( (*((_BYTE *)&this->aiVolatile.death + 1760) & 1) == 0 )
            {
              *((_BYTE *)&this->aiVolatile.death + 1760) = *((_BYTE *)&this->aiVolatile.death + 1760) & 0xFE | 1;
              LODWORD(v33) = 2000 - (int)(float)((float)(1000.0 * (float)fadeOutTime) * (float)-1.25);
              idEventReceiver::PostEventMS(this, ev: &EV_SpawnLootBox, time: (int)(float)((float)v33 * (float)0.75));
            }
          }
          LODWORD(v45) = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
                       - this->aiVolatile.death.ragdollAtRestTime;
          v46 = (float)((float)((float)((float)fadeOutTime * (float)1000.0) - (float)v45)
                      / (float)((float)fadeOutTime * (float)1000.0));
          if ( v46 < 0.0 )
          {
            if ( common->IsMultiplayer(this: common) )
              this->StopRagdoll(this);
          }
          else
          {
            v47 = this->presentable;
            if ( v47 == nullptr )
            {
              idEntity::InitPresentableInternal(this);
              v47 = this->presentable;
            }
            idRenderModel::SetModelFade(this: v47->model, v: v46);
          }
          if ( v46 < 0.5 && (*((_BYTE *)&this->aiVolatile.death + 1760) & 1) == 0 )
          {
            *((_BYTE *)&this->aiVolatile.death + 1760) = *((_BYTE *)&this->aiVolatile.death + 1760) & 0xFE | 1;
            idEventReceiver::PostEventMS(this, ev: &EV_SpawnLootBox, time: 0);
          }
          if ( this->GetAttachments_2(this)->attachments.num > 0 )
          {
            do
            {
              v48 = this->GetAttachments_2(this);
              v49 = idAttachmentCollection::ForIndex(this: v48, index: v6);
              p_entity = &v49->entity;
              v51 = v49;
              if ( idEntityPtr<idEntity const>::operator->(this: &v49->entity) != nullptr )
              {
                v52 = idEntityPtr<idEntity const>::operator->(this: p_entity);
                if ( (unsigned __int8)idProjectile::IsTypeOf(c: v52) != 0 )
                {
                  v53 = (idProjectile *)idEntityPtr<idEntity const>::operator->(this: p_entity);
                  v54 = idProjectile::CastTo(c: v53);
                  v55 = idEntityPtr<idEntity const>::operator->(this: p_entity);
                  v56 = this->GetAttachments_2(this);
                  idAttachmentCollection::RemoveAttachment(this: v56, ent: v55);
                  v54->BecomeUnstuck(this: v54);
                }
              }
              else if ( v51->presentable != nullptr )
              {
                idRenderModel::SetModelFade(this: v51->presentable->model, v: v46);
              }
              ++v6;
            }
            while ( v6 < this->GetAttachments_2(this)->attachments.num );
          }
        }
      }
      else
      {
        this->aiVolatile.death.ragdollAtRestTime = idGameTimeManager::GetGameMs(
                                                     this: p_gameTimeManager,
                                                     type: GAMETIME_SCALED)
                                                 + valueInteger;
        v14 = idEntity::GetPhysics(this);
        v15 = idEntity::GetPhysics(this);
        GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        if ( this->presentable == nullptr )
          idEntity::InitPresentableInternal(this);
        v17 = this->presentable;
        v18 = v14->GetAxis(this: v14, a2: 0);
        v19 = v15->GetOrigin(this: v15, a2: 0);
        idFXManager::StartFX(this: &v17->fxManager, org: v19, axis: v18, time: GameMs, startCondition: 133);
      }
    }
  }
  this->UpdateFX(this);
  if ( idGoreComponent::UpdateGore(this: &this->aiVolatile.death.goreComponent)
    && (this->IsDying(this) || this->IsDead(this)) )
  {
    this->SetEyeAxis(this, a2: &mat3_identity);
  }
  idAI2::UpdateGroupStatusConditions(this);
  if ( ((double (__fastcall *)(idAIHealth *))this->aiHealth.GetBaseHealthRatio_Impl)(a1: &this->aiHealth) < 0.33000001 )
  {
    if ( !this->IsDead(this) || (*((_BYTE *)&this->aiVolatile.death + 1760) & 0x40) != 0 )
    {
      if ( (*((_BYTE *)&this->aiVolatile.death + 1760) & 0x40) != 0 )
        return;
      v64 = idEntity::GetPhysics(this);
      v65 = idEntity::GetPhysics(this);
      v59 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      if ( this->presentable == nullptr )
        idEntity::InitPresentableInternal(this);
      v60 = this->presentable;
      v61 = v64->GetAxis(this: v64, a2: 0);
      v62 = v65->GetOrigin(this: v65, a2: 0);
      v63 = 105;
    }
    else
    {
      v57 = idEntity::GetPhysics(this);
      v58 = idEntity::GetPhysics(this);
      v59 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      if ( this->presentable == nullptr )
        idEntity::InitPresentableInternal(this);
      v60 = this->presentable;
      v61 = v57->GetAxis(this: v57, a2: 0);
      v62 = v58->GetOrigin(this: v58, a2: 0);
      v63 = 134;
    }
    idFXManager::LocalStartFX(this: &v60->fxManager, org: v62, axis: v61, time: v59, start: v63);
  }
}


// ========================================================================
// ?UpdateMovement@idAI2@@IAAXXZ
// EA  : 0x82A13750
// RVA : 0x00A13750
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateMovement(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  int v4; // r3
  idPLogScope v5[6]; // [sp+50h] [-30h] BYREF

  RD_EventBegin(name: "idAI2::UpdateMovement");
  LODWORD(v2) = "idAI2::UpdateMovement";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: v5, pl: &pLog, gMask: v2, label: v3);
  if ( this->aiVolatile.physics.restoreSolidCollisionTime != 0
    && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.physics.restoreSolidCollisionTime )
  {
    idAI2::SetSolid(this, isSolid: true);
    this->aiVolatile.physics.restoreSolidCollisionTime = 0;
  }
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
  {
    idBehaviorState::InternalProcessEvent(this: &this->aiVolatile.animation.animFSM);
  }
  else
  {
    v4 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
    idAIMoveState::UpdateMovement(this: &this->aiVolatile.physics.moveState, timeMS: v4);
  }
  idAI2::UpdateExtendedClipModel(this);
  idPLogScope::~idPLogScope(this: v5);
  RD_EventEnd();
}


// ========================================================================
// __unwind$556596
// EA  : 0x82A13838
// RVA : 0x00A13838
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556596()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 128 + 88));
}


// ========================================================================
// __unwind$556597
// EA  : 0x82A13860
// RVA : 0x00A13860
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556597()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 128 + 80));
}


// ========================================================================
// ?UpdateConfidenceLevel@idAI2@@AAAXXZ
// EA  : 0x82A13890
// RVA : 0x00A13890
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

// local variable allocation has failed, the output may be wrong!
void __fastcall idAI2::UpdateConfidenceLevel(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  const idDeclAIBehavior *decl; // r21
  double firedAtFactor; // fp23
  double v6; // fp24
  double heavyFiredAtFactor; // fp21
  double v8; // fp28
  double v9; // fp27
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r23
  double v11; // fp25
  double v12; // fp22
  idEncounterGroup *v13; // r3
  double deadGroupMemberCap; // fp0
  double recentlyKilledGroupMemberFactor; // fp7
  double recentHeavilyKilledGroupMemberFactor; // fp6
  double recentlyKilledHeaviesFactor; // fp5
  int v24; // r29
  int v25; // r30
  double injured; // fp20
  idAI2::aiCondition_t *p_condition; // r19
  double avoidFactor; // fp26
  int lastAvoidTime; // r30
  double v30; // fp29
  double v31; // fp31
  int *list; // r11
  int num; // ctr
  idTargetInfo *v34; // r9
  int v35; // r10
  int minConfidenceLevel; // r10
  int maxConfidenceLevel; // r9
  aiConfidenceLevel_t v38; // r28
  int v39; // r7
  int GameMs; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r10
  idPhysics *Physics; // r30
  int v43; // r17
  idPhysics *v44; // r3
  const idDeclAIBehaviorEvents *v45; // r16
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r30
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  const idVec3 *v48; // r3
  idEncounterGroup *v49; // r3
  int curCombatStage; // r11
  int v51; // r11
  int v52; // r9
  int v53; // r10
  int v54; // r8
  int v55; // r11
  idEncounterGroup *v56; // r3
  idEncounterGroup *v57; // r3
  __int64 v58; // r10
  __int64 v59; // r8
  __int64 v60; // r6
  bool v61; // cr58
  va *v62; // r3
  __int64 v63; // r10
  __int64 v64; // r8
  __int64 v65; // r6 OVERLAPPED
  va *v66; // r3
  va *v67; // r3
  va *v68; // r3
  va *v69; // r3
  va *v70; // r3
  va *v71; // r3
  va *v72; // r3
  va *v73; // r3
  va *v74; // r3
  va *v75; // r3
  const char *v76; // r4
  va *v77; // r3
  int v78; // r3
  __int64 v79; // r10
  int v80; // r8 OVERLAPPED
  __int128 v81; // r7 OVERLAPPED
  va *v82; // r3
  idRenderWorld *v83; // r29
  idPhysics *v84; // r3
  int v85; // r3
  idRenderWorld *v86; // r3
  idRenderWorld *v87; // r30
  idPhysics *v88; // r3
  int v89; // r3
  int v90; // r29
  int v91; // r30
  int v92; // r3
  __int64 v93; // r11
  __int64 v94; // r9
  int v95; // [sp+8h] [-2308h]
  int v96; // [sp+8h] [-2308h]
  int v97; // [sp+8h] [-2308h]
  int v98; // [sp+Ch] [-2304h]
  int v99; // [sp+Ch] [-2304h]
  int v100; // [sp+Ch] [-2304h]
  int v101; // [sp+10h] [-2300h]
  int v102; // [sp+10h] [-2300h]
  int v103; // [sp+10h] [-2300h]
  int v104; // [sp+14h] [-22FCh]
  int v105; // [sp+14h] [-22FCh]
  int v106; // [sp+14h] [-22FCh]
  int v107; // [sp+18h] [-22F8h]
  int v108; // [sp+18h] [-22F8h]
  int v109; // [sp+18h] [-22F8h]
  int v110; // [sp+1Ch] [-22F4h]
  int v111; // [sp+1Ch] [-22F4h]
  int v112; // [sp+1Ch] [-22F4h]
  double v113; // [sp+28h] [-22E8h]
  idAIEventManager v114; // [sp+60h] [-22B0h] BYREF
  float v115; // [sp+B0h] [-2260h]
  idTargetList v116; // [sp+C0h] [-2250h] BYREF
  idStaticList<idAI2 *,64> v117; // [sp+100h] [-2210h] BYREF
  va v118; // [sp+210h] [-2100h] BYREF
  va v119; // [sp+1210h] [-1100h] BYREF

  RD_EventBegin(name: "idAI2::UpdateConfidenceLevel");
  LODWORD(v2) = "idAI2::UpdateConfidenceLevel";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: (idPLogScope *)&v114.eventList.size, pl: &pLog, gMask: v2, label: v3);
  decl = this->aiEditable.behaviors.decl;
  if ( (*((_BYTE *)decl + 196) & 0x80) == 0 )
  {
    idPLogScope::~idPLogScope(this: (idPLogScope *)&v114.eventList.size);
    goto LABEL_113;
  }
  if ( ai_enableConfidence.valueInteger == 0 || decl->intimidation.minConfidenceLevel == AICONFIDENCE_FEARLESS )
  {
    this->aiVolatile.memory.confidenceLevel = AICONFIDENCE_FEARLESS;
    idPLogScope::~idPLogScope(this: (idPLogScope *)&v114.eventList.size);
    goto LABEL_113;
  }
  firedAtFactor = 0.0;
  v6 = (float)((float)((float)1.0 - this->aiHealth.GetBaseHealthRatio_Impl(this: &this->aiHealth))
             * decl->intimidation.healthFactor);
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.lastFiredAtTime < 4000 )
    firedAtFactor = decl->intimidation.firedAtFactor;
  heavyFiredAtFactor = 0.0;
  if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
     - this->aiVolatile.memory.lastHeavyFiredAtTime < 4000 )
    heavyFiredAtFactor = decl->intimidation.heavyFiredAtFactor;
  v8 = 0.0;
  v9 = 0.0;
  p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
  v11 = 0.0;
  v12 = 0.0;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF )
  {
    v13 = idEncounterGroupManager::GroupForHandle(
            this: &gameLocal->encounterGroupManager,
            handle: &this->aiVolatile.encounterGroupHandle);
    if ( v13 != nullptr )
    {
      deadGroupMemberCap = decl->intimidation.deadGroupMemberCap;
      _FP11 = (float)(v13->recentlyKilledMembers - decl->intimidation.deadGroupMemberCap);
      _FP9 = (float)(v13->recentHeavilyKilledMembers - decl->intimidation.deadGroupMemberCap);
      _FP8 = (float)(v13->recentlyKilledHeavies - decl->intimidation.deadGroupMemberCap);
      recentlyKilledGroupMemberFactor = decl->intimidation.recentlyKilledGroupMemberFactor;
      recentHeavilyKilledGroupMemberFactor = decl->intimidation.recentHeavilyKilledGroupMemberFactor;
      recentlyKilledHeaviesFactor = decl->intimidation.recentlyKilledHeaviesFactor;
      v117.size = 64;
      v117.num = 0;
      v117.granularity = 1;
      *(float *)&v114.eventList.list = deadGroupMemberCap;
      v117.list = v117.staticList;
      v117.memTag = 5;
      __asm { fsel      f4, f11, f0, f13 }
      v117.listStatic = 1;
      __asm
      {
        fsel      f3, f9, f0, f12
        fsel      f2, f8, f0, f10
      }
      v8 = (float)((float)_FP4 * (float)recentlyKilledGroupMemberFactor);
      v9 = (float)((float)_FP3 * (float)recentHeavilyKilledGroupMemberFactor);
      v11 = (float)((float)_FP2 * (float)recentlyKilledHeaviesFactor);
      idEncounterGroup::GetLivingMembers(this: v13, list: &v117);
      v24 = 0;
      if ( v117.num > 0 )
      {
        v25 = 0;
        do
        {
          if ( ((double (__fastcall *)(idAIHealth *))v117.list[v25]->aiHealth.GetTotalMaxHealth_Impl)(a1: &v117.list[v25]->aiHealth) > 200.0 )
            v12 = (float)(decl->intimidation.heavyConfidenceBoost + (float)v12);
          ++v24;
          ++v25;
        }
        while ( v24 < v117.num );
      }
      idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)&v117);
    }
  }
  injured = 0.0;
  p_condition = &this->aiVolatile.groupStatus.condition;
  if ( (this->aiVolatile.groupStatus.condition & 8) != 0 )
    injured = decl->intimidation.injured;
  avoidFactor = 0.0;
  lastAvoidTime = this->aiVolatile.memory.lastAvoidTime;
  if ( gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - lastAvoidTime < 5000 )
    avoidFactor = decl->intimidation.avoidFactor;
  v30 = 0.0;
  if ( decl->intimidation.closeEnemyFactor > 0.0 )
  {
    v31 = 0.0;
    idEnemyTargetFilter::idEnemyTargetFilter(
      this: (idEnemyTargetFilter *)&v114.eventPools,
      minAwareness_: AIAWARE_CONFIRMED);
    idTargetList::idTargetList(this: &v116, targetCache_: &this->aiVolatile.world.worldState.targetCache);
    idTargetList::Filter(this: &v116, owner: this, filter: (const idTargetFilter *)&v114.eventPools);
    if ( v116.viableTargets.num > 0 )
    {
      list = v116.viableTargets.list;
      num = v116.viableTargets.num;
      v34 = v116.targetCache->targets.list;
      do
      {
        v35 = *list;
        if ( v34[v35].distTo < (double)decl->intimidation.closeEnemyDist )
          v31 = (float)((float)((float)1.0 - (float)(v34[v35].distTo / decl->intimidation.closeEnemyDist)) + (float)v31);
        ++list;
        --num;
      }
      while ( num != 0 );
    }
    v30 = (float)(decl->intimidation.closeEnemyFactor * (float)v31);
    idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v116);
    v114.eventPools.list = (idAIEventPool **)&idTargetFilter::`vftable';
  }
  minConfidenceLevel = decl->intimidation.minConfidenceLevel;
  maxConfidenceLevel = decl->intimidation.maxConfidenceLevel;
  v114.eventList.num = (int)(float)((float)((float)((float)((float)((float)((float)((float)((float)((float)((float)4.0 - (float)v6)
                                                                                                  - (float)firedAtFactor)
                                                                                          - (float)heavyFiredAtFactor)
                                                                                  - (float)v8)
                                                                          - (float)v9)
                                                                  - (float)v11)
                                                          + (float)v12)
                                                  - (float)v30)
                                          - (float)avoidFactor)
                                  - (float)injured);
  if ( v114.eventList.num >= minConfidenceLevel )
  {
    v38 = maxConfidenceLevel;
    if ( (int)(float)((float)((float)((float)((float)((float)((float)((float)((float)((float)((float)4.0 - (float)v6)
                                                                                    - (float)firedAtFactor)
                                                                            - (float)heavyFiredAtFactor)
                                                                    - (float)v8)
                                                            - (float)v9)
                                                    - (float)v11)
                                            + (float)v12)
                                    - (float)v30)
                            - (float)avoidFactor)
                    - (float)injured) <= maxConfidenceLevel )
      v38 = v114.eventList.num;
  }
  else
  {
    v38 = minConfidenceLevel;
  }
  v39 = *((_BYTE *)&this->aiEditable.death + 84) & 8;
  this->aiVolatile.memory.confidenceLevel = v38;
  if ( v39 != 0 && v38 <= decl->intimidation.intimidationConfidence )
  {
    if ( (*p_condition & 0x10) == 0 )
    {
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
      this->aiVolatile.memory.startIntimidationTime = GameMs;
      if ( declBehaviorEvents != nullptr )
      {
        Physics = idEntity::GetPhysics(this);
        v43 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        v44 = Physics;
        v45 = this->aiEditable.behaviors.declBehaviorEvents;
        GetOrigin = Physics->GetOrigin;
        p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
        v48 = GetOrigin(this: v44, a2: 0);
        idAIEventManager::AddEvent(
          this: &v114,
          result: p_aiEventManager,
          eventDecl: v45->intimidatedVOEventDecl,
          curTime: v43,
          originator: nullptr,
          instigator: this,
          origin: v48,
          delay: 1000);
      }
      v114.eventList.list = (idAIEvent **)this->aiVolatile.groupStatus.currentRole;
      if ( (v114.eventList.list == (idAIEvent **)2
         || v114.eventList.list == (idAIEvent **)3
         || v114.eventList.list == (idAIEvent **)4)
        && idAI2::GetCurrentCombatStage(this) != nullptr )
      {
        v49 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
            ? nullptr
            : idEncounterGroupManager::GroupForHandle(
                this: &gameLocal->encounterGroupManager,
                handle: &this->aiVolatile.encounterGroupHandle);
        curCombatStage = v49->curCombatStage;
        if ( curCombatStage < 0 || curCombatStage >= v49->combatStages.num )
          v51 = 0;
        else
          v51 = (int)&v49->combatStages.list[curCombatStage];
        v52 = *(_DWORD *)(v51 + 44);
        v53 = 0;
        if ( v52 > 0 )
        {
          v54 = *(_DWORD *)(v51 + 40);
          v55 = 0;
          while ( *(_DWORD *)(v55 + v54) != 1 )
          {
            ++v53;
            v55 += 4;
            if ( v53 >= v52 )
              goto LABEL_55;
          }
          if ( v53 != -1 )
          {
            this->aiVolatile.groupStatus.roleChangeResponseRequired = true;
            this->aiVolatile.groupStatus.pendingRole = ROLE_NONE;
            this->aiVolatile.groupStatus.currentRole = ROLE_DEFEND;
          }
        }
      }
    }
LABEL_55:
    this->aiVolatile.memory.lastIntimidationTime = idGameTimeManager::GetGameMs(
                                                     this: &clientGame->gameTimeManager,
                                                     type: GAMETIME_SCALED);
  }
  if ( (idAI2::IsPlayerControlled(this) || this->aiVolatile.fsms.alertCycle == ALERTCYCLE_COMBAT)
    && (*p_condition & 0x10) != 0 )
  {
    idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  }
  if ( (idAI2::IsPlayerControlled(this) || this->aiVolatile.fsms.alertCycle == ALERTCYCLE_COMBAT)
    && (unsigned __int16)p_encounterGroupHandle->value != 0xFFFF
    && idEncounterGroupManager::GroupForHandle(
         this: &gameLocal->encounterGroupManager,
         handle: &this->aiVolatile.encounterGroupHandle) != nullptr )
  {
    v56 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
        ? nullptr
        : idEncounterGroupManager::GroupForHandle(
            this: &gameLocal->encounterGroupManager,
            handle: &this->aiVolatile.encounterGroupHandle);
    if ( idEncounterGroup::NumDeadMembers(this: v56) >= 3 )
    {
      v57 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
          ? nullptr
          : idEncounterGroupManager::GroupForHandle(
              this: &gameLocal->encounterGroupManager,
              handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::NumLivingMembers(this: v57) == 1 )
      {
        idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        this->aiVolatile.fsms.fsmManager.FindFSM_3(
          this: (struct idAIFSMManager *)&this->aiVolatile.fsms,
          a2: &idAlertCycleFSM::Type);
      }
    }
  }
  if ( ai_debugConfidence.valueInteger != 0 && ai_debugLevel.valueInteger != 0 )
  {
    SLODWORD(v58) = *p_condition;
    HIDWORD(v58) = &v114.eventHash;
    LODWORD(v59) = &idColor::colorWhite;
    HIDWORD(v59) = (*p_condition & 0x10) != 0;
    LODWORD(v60) = LODWORD(idColor::colorWhite.r);
    v61 = (*p_condition & 0x10) == 0;
    v114.eventHash.hash = (int *)LODWORD(idColor::colorWhite.r);
    v114.eventHash.indexChain = (int *)LODWORD(idColor::colorWhite.g);
    v114.eventHash.hashSize = LODWORD(idColor::colorWhite.b);
    v114.eventHash.indexSize = LODWORD(idColor::colorWhite.a);
    if ( v61 )
    {
      switch ( v38 )
      {
        case AICONFIDENCE_SURE:
          HIDWORD(v58) = &idColor::colorGreen;
          LODWORD(v59) = LODWORD(idColor::colorGreen.r);
          break;
        case AICONFIDENCE_NEUTRAL:
          HIDWORD(v58) = &idColor::colorYellow;
          LODWORD(v59) = LODWORD(idColor::colorYellow.r);
          break;
        case AICONFIDENCE_HESITANT:
          HIDWORD(v58) = &idColor::colorOrange;
          LODWORD(v59) = LODWORD(idColor::colorOrange.r);
          break;
        case AICONFIDENCE_SCARED:
          HIDWORD(v58) = &idColor::colorBrown;
          LODWORD(v59) = LODWORD(idColor::colorBrown.r);
          break;
        default:
LABEL_86:
          HIDWORD(v60) = 4;
          v62 = va::va(
                  this: &v119,
                  fmt: "%d\n",
                  a3: v60,
                  a4: v59,
                  a5: v58,
                  a6: v95,
                  a7: v98,
                  a8: v101,
                  a9: v104,
                  a10: v107,
                  a11: v110);
          idStr::idStr(this: (idStr *)&v114.eventHash.granularity, text: v62);
          if ( v6 > 0.0 )
          {
            HIDWORD(v65) = LODWORD(v6);
            v66 = va::va(
                    this: &v118,
                    fmt: "- health: %4.2f\n",
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    v6);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v66);
          }
          if ( firedAtFactor > 0.0 )
          {
            HIDWORD(v65) = LODWORD(firedAtFactor);
            v67 = va::va(
                    this: &v118,
                    fmt: "- fire: %4.2f\n",
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    firedAtFactor);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v67);
          }
          if ( heavyFiredAtFactor > 0.0 )
          {
            HIDWORD(v65) = LODWORD(heavyFiredAtFactor);
            v68 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(heavyFiredAtFactor),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    heavyFiredAtFactor);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v68);
          }
          if ( v8 > 0.0 )
          {
            HIDWORD(v65) = LODWORD(v8);
            v69 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(v8),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    v8);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v69);
          }
          if ( v9 > 0.0 )
          {
            HIDWORD(v65) = LODWORD(v9);
            v70 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(v9),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    v9);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v70);
          }
          if ( v11 > 0.0 )
          {
            HIDWORD(v65) = LODWORD(v11);
            v71 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(v11),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    v11);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v71);
          }
          if ( v12 > 0.0 )
          {
            HIDWORD(v65) = LODWORD(v12);
            v72 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(v12),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    v12);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v72);
          }
          if ( avoidFactor > 0.0 )
          {
            HIDWORD(v65) = LODWORD(avoidFactor);
            v73 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(avoidFactor),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    avoidFactor);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v73);
          }
          if ( v30 > 0.0 )
          {
            HIDWORD(v65) = LODWORD(v30);
            v74 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(v30),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    v30);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v74);
          }
          if ( injured > 0.0 )
          {
            HIDWORD(v65) = LODWORD(injured);
            v75 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(injured),
                    a3: v65,
                    a4: v64,
                    a5: v63,
                    a6: v96,
                    a7: v99,
                    a8: v102,
                    a9: v105,
                    a10: v108,
                    a11: v111,
                    injured);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v75);
          }
          *(double *)((char *)&v65 + 4) = (float)((float)((float)((float)((float)((float)((float)((float)((float)((float)((float)4.0 - (float)v6) - (float)firedAtFactor) - (float)heavyFiredAtFactor)
                                                                                                - (float)v8)
                                                                                        - (float)v9)
                                                                                - (float)v11)
                                                                        + (float)v12)
                                                                - (float)v30)
                                                        - (float)avoidFactor)
                                                - (float)injured);
          v77 = va::va(
                  this: &v118,
                  fmt: v76,
                  a3: v65,
                  a4: v64,
                  a5: v63,
                  a6: v96,
                  a7: v99,
                  a8: v102,
                  a9: v105,
                  a10: v108,
                  a11: v111,
                  *(double *)((char *)&v65 + 4));
          idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v77);
          idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: (char *)aiConfidenceLevelNames[v38]);
          if ( (*p_condition & 0x10) != 0 )
          {
            v78 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
            LODWORD(v79) = decl->intimidation.minIntimidationTime;
            HIDWORD(v79) = &off_82040000;
            v80 = v78 - this->aiVolatile.memory.lastIntimidationTime;
            *((_QWORD *)&v81 + 1) = __PAIR64__(v80, v79);
            *(_QWORD *)&v114.eventList.list = *(_QWORD *)((char *)&v81 + 4);
            v113 = (float)((float)__SPAIR64__(v80, v79) * (float)0.001);
            *(double *)&v81 = (float)((float)*(__int64 *)((char *)&v81 + 4) * (float)0.001);
            DWORD2(v81) = LODWORD(v113);
            v82 = va::va(
                    this: &v118,
                    fmt: (const char *)HIDWORD(v81),
                    a3: *(__int64 *)((char *)&v81 + 4),
                    a4: *(__int64 *)&v80,
                    a5: v79,
                    a6: v97,
                    a7: v100,
                    a8: v103,
                    a9: v106,
                    a10: v109,
                    a11: v112);
            idStr::Append(this: (idStr *)&v114.eventHash.granularity, text: v82);
          }
          v83 = common->RW(this: common);
          v84 = idEntity::GetPhysics(this);
          v85 = (int)v84->GetOrigin(this: v84, a2: 0);
          ((void (__fastcall *)(idRenderWorld *, int, int, enum idAIStateTransition::aiTransCode_t (__fastcall **)(COMBAT_AtPlugAnim *__hidden, struct idAI2 *, struct idAIFSM *, struct idAIState *, int), idHashIndex *, int, _DWORD, _DWORD, double))v83->DebugText)(
            a1: v83,
            a2: v114.eventHash.hashMask,
            a3: v85,
            a4: &off_82040000,
            a5: &v114.eventHash,
            a6: 1,
            a7: 0,
            a8: 0,
            a9: 0.2);
          v86 = common->RW(this: common);
          *(float *)&v114.eventPools.size = 0.0;
          v87 = v86;
          *(float *)&v114.eventPools.granularity = 0.0;
          v115 = 1.0;
          v88 = idEntity::GetPhysics(this);
          v89 = (int)v88->GetOrigin(this: v88, a2: 0);
          ((void (__fastcall *)(idRenderWorld *, idHashIndex *, int, int *, double))v87->DebugCircle)(
            a1: v87,
            a2: &v114.eventHash,
            a3: v89,
            a4: &v114.eventPools.size,
            a5: decl->intimidation.closeEnemyDist);
          idStr::FreeData(this: (idStr *)&v114.eventHash.granularity);
          goto LABEL_109;
      }
    }
    else
    {
      HIDWORD(v58) = &idColor::colorRed;
      LODWORD(v59) = LODWORD(idColor::colorRed.r);
    }
    LODWORD(v58) = &v114.eventHash;
    HIDWORD(v59) = *(_DWORD *)(HIDWORD(v58) + 4);
    LODWORD(v60) = *(_DWORD *)(HIDWORD(v58) + 8);
    HIDWORD(v60) = *(_DWORD *)(HIDWORD(v58) + 12);
    v114.eventHash.indexChain = (int *)HIDWORD(v59);
    v114.eventHash.hash = (int *)v59;
    v114.eventHash.indexSize = HIDWORD(v60);
    v114.eventHash.hashSize = v60;
    goto LABEL_86;
  }
LABEL_109:
  if ( v114.eventList.size >= 0 )
  {
    v90 = *(_DWORD *)&v114.eventList.granularity;
    v91 = *(_DWORD *)(*(_DWORD *)&v114.eventList.granularity + 16) + 16 * v114.eventList.size;
    v92 = (unsigned __int64)Sys_GetClockTicks() >> 32;
    v93 = *(_QWORD *)(v91 + 8);
    HIDWORD(v93) = *(_DWORD *)(v91 + 4);
    LODWORD(v94) = v92 - v93;
    *(_QWORD *)(v91 + 8) = v94;
    *(_DWORD *)(v90 + 32) = HIDWORD(v93);
  }
LABEL_113:
  RD_EventEnd();
}


// ========================================================================
// __unwind$556656
// EA  : 0x82A14434
// RVA : 0x00A14434
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556656()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 8976 + 8720));
}


// ========================================================================
// __unwind$556657
// EA  : 0x82A1445C
// RVA : 0x00A1445C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556657()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 8976 + 104));
}


// ========================================================================
// __unwind$556658
// EA  : 0x82A14484
// RVA : 0x00A14484
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556658()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 8976 + 256));
}


// ========================================================================
// __unwind$556659
// EA  : 0x82A144AC
// RVA : 0x00A144AC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556659()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 8976 + 160));
}


// ========================================================================
// __unwind$556660
// EA  : 0x82A144D4
// RVA : 0x00A144D4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556660()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 8976 + 192));
}


// ========================================================================
// __unwind$556661
// EA  : 0x82A144FC
// RVA : 0x00A144FC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_556661()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 8976 + 128));
}


// ========================================================================
// ?UpdatePathToEnemy@idAI2@@AAAX_N@Z
// EA  : 0x82A14530
// RVA : 0x00A14530
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdatePathToEnemy(idAI2 *this, const bool force)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  int value; // r7
  idEntity *v7; // r3
  bool v8; // r26
  const idAAS2 *v9; // r3
  idPhysics *Physics; // r3
  idPhysics *v11; // r26
  const idEntity *Enemy; // r25
  const idVec3 *v13; // r3
  idAIMoveState *MoveInterface; // r3
  idEntity *v15; // r3
  idPhysics *v16; // r28
  idPhysics *v17; // r27
  idRenderWorld *v18; // r25
  idRenderWorld_vtbl *v19; // r30
  int v20; // r28
  int v21; // r3
  int v22; // r10
  double v23; // fp13
  double v24; // fp12
  idPhysics *v25; // r25
  idRenderWorld *v26; // r24
  idRenderWorld_vtbl *v27; // r28
  int v28; // r3
  idEntity *v29; // r3
  idPhysics *v30; // r27
  idRenderWorld *v31; // r24
  idRenderWorld_vtbl *v32; // r28
  int v33; // r3
  idRenderWorld *v34; // r3
  __int64 v35; // r8
  idRenderWorld *v36; // r28
  __int64 v37; // r6
  __int64 v38; // r10
  va *v39; // r27
  idRenderWorld_vtbl *v40; // r30
  int v41; // r3
  int v42; // r6
  posture_t v43; // [sp+8h] [-1188h]
  int v44; // [sp+8h] [-1188h]
  int v45; // [sp+Ch] [-1184h]
  int v46; // [sp+Ch] [-1184h]
  const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *v47; // [sp+10h] [-1180h]
  int v48; // [sp+10h] [-1180h]
  const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *v49; // [sp+14h] [-117Ch]
  int v50; // [sp+14h] [-117Ch]
  const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *v51; // [sp+18h] [-1178h]
  int v52; // [sp+18h] [-1178h]
  const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *v53; // [sp+1Ch] [-1174h]
  int v54; // [sp+1Ch] [-1174h]
  _WORD v55[4]; // [sp+90h] [-1100h] BYREF
  int v56; // [sp+98h] [-10F8h] BYREF
  float v57[4]; // [sp+A0h] [-10F0h] BYREF
  idPLogScope v58; // [sp+B0h] [-10E0h] BYREF
  int v59; // [sp+B8h] [-10D8h] BYREF
  idAIMoveParms v60; // [sp+D0h] [-10C0h] BYREF
  va v61; // [sp+120h] [-1070h] BYREF

  RD_EventBegin(name: "idAI2::UpdatePathToEnemy");
  LODWORD(v4) = "idAI2::UpdatePathToEnemy";
  HIDWORD(v4) = 6;
  idPLogScope::idPLogScope(this: &v58, pl: &pLog, gMask: v4, label: v5);
  value = this->aiVolatile.memory.currentEnemy.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
  {
    v7 = gameLocal->entities.ptr[value & 0x1FFF];
    if ( v7 != nullptr
      && idEntity::CastTo(c: v7) != nullptr
      && (force || (this->entityNumber + idAccolade::Count(this: &clientGame->gameTimeManager)) % 60 == 0) )
    {
      v8 = false;
      if ( idEntity::GetPhysics(this)->type == PHYSICS_AI && BYTE2(idEntity::GetPhysics(this)[9].clip) != 0 )
      {
        v9 = this->GetAAS(this);
        if ( idActor::GetAASPosition(this, aas: v9)->valid )
        {
          idAIMoveParms::idAIMoveParms(this: &v60);
          Physics = idEntity::GetPhysics(this);
          v55[3] = -1;
          v55[1] = -1;
          v55[0] = -1;
          v55[2] = -1;
          v11 = Physics;
          Enemy = idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
          v13 = v11->GetOrigin(this: v11, a2: 0);
          v8 = true;
          idAIMoveParms::Init(
            this: &v60,
            moveReason_: AIMOVEREASON_TEST,
            startOrigin_: v13,
            goalOrigin_: &vec3_origin,
            goalEntity_: Enemy,
            goalOrientation_: &quat_identity,
            goalScenePoint_: nullptr,
            goalTolerance_: 0.1,
            intermediateTolerance_: 0.1,
            arrivalAction_: (const aiArrivalAction_t)v55,
            arrivalPosture_: v43,
            flags_: v45,
            sourceSubWeb_: v47,
            sourceState_: v49,
            destSubWeb_: v51,
            destState_: v53);
          MoveInterface = idAI2::GetMoveInterface(this);
          if ( (unsigned int)MoveInterface->TestMove(
                               this: MoveInterface,
                               a2: &v60,
                               a3: (idVec3 *)&v59,
                               a4: (idVec3 *)v57,
                               a5: &v56) < AIMOVESTATUS_ERROR )
          {
            v22 = v56;
            v23 = v57[1];
            v24 = v57[2];
            v8 = false;
            this->aiVolatile.memory.enemyApproachPoint.x = v57[0];
            this->aiVolatile.memory.enemyApproachPoint.y = v23;
            this->aiVolatile.memory.enemyApproachPoint.z = v24;
            this->aiVolatile.memory.enemyTravelTime = v22;
            if ( ai_debugPathToEnemy.valueInteger != 0 )
            {
              v25 = idEntity::GetPhysics(this);
              v26 = gameLocal->GetRenderWorld(this: gameLocal);
              v27 = v26->__vftable;
              gameLocal->GetGameHz(this: gameLocal, a2: GAMETIME_SCALED);
              v28 = (int)v25->GetOrigin(this: v25, a2: 0);
              ((void (__fastcall *)(idRenderWorld *, idColor *, int, float *, double))v27->DebugArrow)(
                a1: v26,
                a2: &idColor::colorGreen,
                a3: v28,
                a4: v57,
                a5: 2.0);
              v29 = (idEntity *)idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
              v30 = idEntity::GetPhysics(this: v29);
              v31 = gameLocal->GetRenderWorld(this: gameLocal);
              v32 = v31->__vftable;
              gameLocal->GetGameHz(this: gameLocal, a2: GAMETIME_SCALED);
              v33 = (int)v30->GetOrigin(this: v30, a2: 0);
              ((void (__fastcall *)(idRenderWorld *, idColor *, float *, int, double))v32->DebugArrow)(
                a1: v31,
                a2: &idColor::colorGreen,
                a3: v57,
                a4: v33,
                a5: 2.0);
              v34 = gameLocal->GetRenderWorld(this: gameLocal);
              HIDWORD(v35) = 0x82000000;
              v36 = v34;
              HIDWORD(v37) = v56;
              v39 = va::va(
                      this: &v61,
                      fmt: "%d",
                      a3: v37,
                      a4: v35,
                      a5: v38,
                      a6: v44,
                      a7: v46,
                      a8: v48,
                      a9: v50,
                      a10: v52,
                      a11: v54);
              v40 = v36->__vftable;
              v41 = gameLocal->GetGameHz(this: gameLocal, a2: GAMETIME_SCALED);
              ((void (__fastcall *)(idRenderWorld *, va *, float *, int, idColor *, int, int, double))v40->DebugText)(
                a1: v36,
                a2: v39,
                a3: v57,
                a4: v42,
                a5: &idColor::colorGreen,
                a6: 1,
                a7: 60 * v41,
                a8: 0.2);
            }
          }
          else if ( ai_debugPathToEnemy.valueInteger != 0 )
          {
            v15 = (idEntity *)idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
            v16 = idEntity::GetPhysics(this: v15);
            v17 = idEntity::GetPhysics(this);
            v18 = gameLocal->GetRenderWorld(this: gameLocal);
            v19 = v18->__vftable;
            gameLocal->GetGameHz(this: gameLocal, a2: GAMETIME_SCALED);
            v20 = (int)v16->GetOrigin(this: v16, a2: 0);
            v21 = (int)v17->GetOrigin(this: v17, a2: 0);
            ((void (__fastcall *)(idRenderWorld *, idColor *, int, int, double))v19->DebugArrow)(
              a1: v18,
              a2: &idColor::colorRed,
              a3: v21,
              a4: v20,
              a5: 2.0);
          }
        }
      }
      this->aiVolatile.memory.enemyPathBlocked = v8;
    }
  }
  idPLogScope::~idPLogScope(this: &v58);
  RD_EventEnd();
}


// ========================================================================
// __unwind$557312
// EA  : 0x82A14A94
// RVA : 0x00A14A94
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557312()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 4496 + 4384));
}


// ========================================================================
// __unwind$557313
// EA  : 0x82A14ABC
// RVA : 0x00A14ABC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557313()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 4496 + 176));
}


// ========================================================================
// ?CheckForGore@idAI2@@QAA_NXZ
// EA  : 0x82A14AF0
// RVA : 0x00A14AF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::CheckForGore(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idAnimStack *v5; // r3
  idTreeAnimator *TreeAnimatorFromPresentable; // r14
  int v7; // r16
  int v8; // r21
  idMD6Skel *skeleton; // r22
  idAttachmentCollection *v10; // r3
  idAttachmentCollection *v11; // r25
  int num; // r29
  int v13; // r30
  int v14; // r28
  int *list; // r27
  idAttachment *v16; // r3
  int v17; // r27
  int v18; // r30
  int v19; // r9
  idEntity *v20; // r3
  idProjectile *v21; // r3
  idProjectile *v22; // r28
  int v23; // r9
  idEntity *v24; // r3
  idEntity *v25; // r4
  int v26; // r11
  int v27; // r9
  idPonytail *v28; // r8
  int v29; // r11
  int v30; // [sp+50h] [-100h]
  idPLogScope v31; // [sp+58h] [-F8h] BYREF
  idList<int,37> v32; // [sp+60h] [-F0h] BYREF
  int v33; // [sp+70h] [-E0h] BYREF

  RD_EventBegin(name: "idAI2::CheckForGore");
  LODWORD(v2) = "idAI2::CheckForGore";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: &v31, pl: &pLog, gMask: v2, label: v3);
  if ( this->IsDead(this)
    && canCheckForGore
    && idGoreComponent::CheckForGore(this: &this->aiVolatile.death.goreComponent) )
  {
    v5 = this->GetAnimStack_2(this);
    idAnimator_Base::SetEnabled(this: &this->walkIK, animStack: v5, enabled: false);
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    v7 = 0;
    if ( this->aiVolatile.death.goreComponent.jointsGoredThisFrame.num > 0 )
    {
      v8 = 0;
      do
      {
        skeleton = TreeAnimatorFromPresentable->decl->model->skeleton;
        v10 = this->GetAttachments_2(this);
        v11 = v10;
        if ( v10 != nullptr )
        {
          num = v10->attachments.num;
          v32.size = 16;
          v32.num = 0;
          v32.granularity = 1;
          v32.list = &v33;
          v32.memTag = 5;
          v32.listStatic = 1;
          idList<idObstacleBuffers *,5>::SetNum(this: &v32, newNum: num);
          v13 = 0;
          if ( num > 0 )
          {
            v14 = 0;
            do
            {
              list = v32.list;
              v16 = idAttachmentCollection::ForIndex(this: v11, index: v13++);
              list[v14++] = (int)v16;
            }
            while ( v13 < num );
            v17 = 0;
            do
            {
              v18 = v32.list[v17];
              v19 = *(_DWORD *)(v18 + 88);
              if ( gameLocal->spawnIds.ptr[v19 & 0x1FFF] == v19 >> 13
                && (v20 = gameLocal->entities.ptr[v19 & 0x1FFF]) != nullptr )
              {
                v21 = (idProjectile *)idEntity::CastTo(c: v20);
              }
              else
              {
                v21 = nullptr;
              }
              v22 = idProjectile::CastTo(c: v21);
              if ( v22 != nullptr )
              {
                v23 = *(_DWORD *)(v18 + 88);
                if ( gameLocal->spawnIds.ptr[v23 & 0x1FFF] == v23 >> 13
                  && (v24 = gameLocal->entities.ptr[v23 & 0x1FFF]) != nullptr )
                {
                  v25 = idEntity::CastTo(c: v24);
                }
                else
                {
                  v25 = nullptr;
                }
                idAttachmentCollection::RemoveAttachment(this: v11, ent: v25);
                v22->Explode(this: v22, a2: nullptr, a3: nullptr);
              }
              else if ( *(unsigned __int16 *)(v18 + 92) == (unsigned __int16)this->aiVolatile.death.goreComponent.jointsGoredThisFrame.list[v8].value
                     || (unsigned __int8)idMD6Skel::IsJointChildOf(
                                           this: skeleton,
                                           joint: (idIndex<short,enum invalidJointIndex_t> *)*(unsigned __int16 *)(v18 + 92),
                                           parent: (idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)this->aiVolatile.death.goreComponent.jointsGoredThisFrame.list[v8].value) != 0 )
              {
                v26 = *(_DWORD *)(v18 + 4);
                if ( v26 != 0 )
                {
                  this->DropAttachment(this, a2: *(const equipSlot_t *)(*(_DWORD *)(v26 + 12) + 352));
                }
                else
                {
                  v27 = 0;
                  v30 = this->aiEditable.ponytails.num;
                  if ( v30 > 0 )
                  {
                    v28 = this->aiEditable.ponytails.list;
                    v29 = 0;
                    while ( v28[v29].attachmentHandle.value != *(_DWORD *)(v18 + 100) )
                    {
                      ++v27;
                      ++v29;
                      if ( v27 >= v30 )
                        goto LABEL_33;
                    }
                    idPonytail::Shutdown(this: &v28[v27]);
                  }
                }
              }
LABEL_33:
              --num;
              ++v17;
            }
            while ( num != 0 );
          }
          if ( v32.listStatic == 0 || v32.listStatic == 2 )
          {
            if ( v32.list != nullptr )
              idMem::Free(this: &mem, ptr: v32.list, align: ALIGN_16);
            v32.list = nullptr;
            v32.size = 0;
          }
          v32.num = 0;
        }
        ++v7;
        ++v8;
      }
      while ( v7 < this->aiVolatile.death.goreComponent.jointsGoredThisFrame.num );
    }
    idPLogScope::~idPLogScope(this: &v31);
    RD_EventEnd();
    return 1;
  }
  else
  {
    idPLogScope::~idPLogScope(this: &v31);
    RD_EventEnd();
    return 0;
  }
}


// ========================================================================
// __unwind$557518
// EA  : 0x82A14E90
// RVA : 0x00A14E90
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557518()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 336 + 176));
}


// ========================================================================
// __unwind$557519
// EA  : 0x82A14EB8
// RVA : 0x00A14EB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557519()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 336 + 88));
}


// ========================================================================
// __unwind$557520
// EA  : 0x82A14EE0
// RVA : 0x00A14EE0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557520()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 336 + 96));
}


// ========================================================================
// ?UpdateWorldState@idAI2@@IAAXXZ
// EA  : 0x82A14F10
// RVA : 0x00A14F10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateWorldState(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  const trackingParms_t *v4; // r29
  idFaction *v5; // r3
  unsigned __int64 v6; // r6
  const char *v7; // r7
  idAIGameState *p_aiGameState; // r27
  const idAILogic *v9; // r3
  idEncounterGroup *v10; // r29
  int value; // r9
  idEntity *v12; // r3
  idEntity *v13; // r28
  idTarget_FakeEnemy *v14; // r15
  unsigned __int64 v15; // r6
  const char *v16; // r7
  int curCombatStage; // r11
  int v18; // r11
  int v19; // r9
  idEntityPtr<idTarget_FakeEnemy> *v20; // r29
  idTarget_FakeEnemy *v21; // r3
  idTarget_FakeEnemy *v22; // r3
  idTarget_FakeEnemy *v23; // r3
  unsigned __int64 v24; // r6
  const char *v25; // r7
  idEntityPtr<idEntity const > *p_currentFriendly; // r28
  idEntityPtr<idEntity const > *p_currentNeutral; // r25
  unsigned __int64 v28; // r6
  const char *v29; // r7
  idTargetInfo *v30; // r11
  idEntity *Entity; // r3
  idEntity *v32; // r29
  idPhysics *Physics; // r3
  const idVec3 *v34; // r28
  idPhysics *v35; // r3
  idVec3 *v36; // r3
  unsigned __int64 v37; // r6
  const char *v38; // r7
  idTargetInfo *v39; // r11
  idEntity *v40; // r3
  const idEntity *Enemy; // r25
  unsigned __int64 v42; // r6
  const char *v43; // r7
  idTargetInfo *v44; // r26
  idEntity *v45; // r3
  idEntity *v46; // r28
  idEntityPtr<idEntity const > *p_currentEnemy; // r9
  int GameMs; // r3
  char v49; // r11
  idPhysics *v50; // r3
  idPhysics *v51; // r3
  const idVec3 *v52; // r29
  int v53; // r3
  aiSenseState_t *EnemySenseState; // r3
  aiSenseState_t *v55; // r29
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  double z; // fp12
  int v58; // r3
  idPhysics *v59; // r3
  const aiPhysicalState_t *v60; // r3
  int v61; // r3
  idScenePoint *curScenePoint; // r11
  int v63; // r10
  char v64; // r11
  idEntityPtr<idEntity> *p_onSpotEnemyTrigger; // r29
  idEntityPtr<idEntity const > *p_spottedEnemyTrigger; // r8
  idEventArg *v67; // r3
  int *v68; // r10
  _DWORD *v69; // r11
  int i; // ctr
  idEntityPtr<idEntity const > *p_detectedEnemyTrigger; // r8
  idEventArg *v72; // r3
  int *v73; // r10
  _DWORD *v74; // r11
  int j; // ctr
  idEntity *v76; // r3
  idAI2 *FriendlyBlocker; // r3
  idAI2 *v78; // r29
  idPhysics *v79; // r3
  int *v80; // r3
  idPLog *v81; // r7
  float v82; // r6
  idPhysics *v83; // r3
  float *v84; // r3
  double v85; // fp31
  double v86; // fp30
  double v87; // fp29
  double v88; // fp28
  idPhysics *v89; // r3
  float *v90; // r3
  double v91; // fp5
  double v92; // fp1
  int v93; // r3
  idAIGameState *v94; // r29
  const idSpawnId *v95; // r27
  const idAILogic *v96; // r3
  const idSpawnId *v97; // r8
  idEntity *v98; // r3
  idPhysics *v99; // r29
  idPhysics *v100; // r28
  idRenderWorld *v101; // r27
  float *v102; // r3
  double v103; // fp0
  double v104; // fp13
  float *v105; // r3
  double v106; // fp9
  double v107; // fp8
  int valueInteger; // r11
  idSpawnId v109; // [sp+50h] [-290h] BYREF
  int v110; // [sp+5Ch] [-284h] BYREF
  idPLogScope v111; // [sp+60h] [-280h] BYREF
  float v112; // [sp+68h] [-278h]
  idAI2::idAIVolatile::idAIWorldStateInfo *p_world; // [sp+74h] [-26Ch]
  idFriendlyTargetFilter v114; // [sp+78h] [-268h] BYREF
  idEnemyTargetFilter v115; // [sp+80h] [-260h] BYREF
  idEnemyTargetFilter v116; // [sp+88h] [-258h] BYREF
  idNonEnemyTargetFilter v117; // [sp+90h] [-250h] BYREF
  float v118[4]; // [sp+98h] [-248h] BYREF
  float v119[4]; // [sp+A8h] [-238h] BYREF
  idPLogScope v120; // [sp+B8h] [-228h] BYREF
  idPLogScope v121; // [sp+C0h] [-220h] BYREF
  idPLogScope v122; // [sp+C8h] [-218h] BYREF
  idTargetSelector v123; // [sp+D0h] [-210h] BYREF
  idTargetSelector v124; // [sp+E0h] [-200h] BYREF
  idTargetSelector v125; // [sp+F0h] [-1F0h] BYREF
  idAILogic v126; // [sp+100h] [-1E0h] BYREF
  idTargetList v127; // [sp+120h] [-1C0h] BYREF
  idTargetList v128; // [sp+160h] [-180h] BYREF
  idTargetList v129; // [sp+1A0h] [-140h] BYREF
  idTargetList v130; // [sp+1E0h] [-100h] BYREF

  RD_EventBegin(name: "idAI2::UpdateWorldState");
  LODWORD(v2) = "idAI2::UpdateWorldState";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: &v120, pl: &pLog, gMask: v2, label: v3);
  v4 = &this->aiEditable.behaviors.lookTrackingParms->parms.list[this->aiEditable.skill.lookRate];
  if ( (unsigned __int8)idFocusInfo::HasFocus(this: this->aiVolatile.focus.foci.ptr) != 0 )
    v4 = &this->aiEditable.behaviors.aimTrackingParms->parms.list[idAI2::GetEffectiveAccuracy(this)];
  v5 = this->GetFaction(this);
  idFaction::CullEntityRelationships(this: v5);
  this->aiVolatile.world.worldState.bOwnerAiInCover = idAICover::IsValid(this: &this->aiVolatile.memory.currentCover);
  RD_EventBegin(name: "idAI2::UpdateWorldState - Update");
  LODWORD(v6) = "idAI2::UpdateWorldState - Update";
  HIDWORD(v6) = 6;
  idPLogScope::idPLogScope(this: &v111, pl: &pLog, gMask: v6, label: v7);
  p_world = &this->aiVolatile.world;
  p_aiGameState = &gameLocal->aiGameState;
  v9 = idAILogic::idAILogic(this: &v126, ai: this);
  idAIWorldState::Update(
    this: &this->aiVolatile.world.worldState,
    gameState: p_aiGameState,
    aiOwner: v9,
    trackingParms: v4);
  idPLogScope::~idPLogScope(this: &v111);
  RD_EventEnd();
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
    v10 = nullptr;
  else
    v10 = idEncounterGroupManager::GroupForHandle(
            this: &gameLocal->encounterGroupManager,
            handle: &this->aiVolatile.encounterGroupHandle);
  value = this->aiVolatile.world.fakeEnemy.spawnId.value;
  v109.value = (int)&this->aiVolatile.world.fakeEnemy;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
    && (v12 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
  {
    v13 = idEntity::CastTo(c: v12);
  }
  else
  {
    v13 = nullptr;
  }
  v14 = (idTarget_FakeEnemy *)v13;
  if ( v10 != nullptr )
  {
    RD_EventBegin(name: "idAI2::UpdateWorldState - encounter group");
    LODWORD(v15) = "idAI2::UpdateWorldState - encounter group";
    HIDWORD(v15) = 6;
    idPLogScope::idPLogScope(this: &v111, pl: &pLog, gMask: v15, label: v16);
    idEnemyTargetFilter::idEnemyTargetFilter(this: &v116, minAwareness_: AIAWARE_CONFIRMED);
    idTargetList::idTargetList(this: &v130, targetCache_: &this->aiVolatile.world.worldState.targetCache);
    idTargetList::Filter(this: &v130, owner: this, filter: &v116);
    idEncounterGroup::UpdateTargetList(this: v10, targets: &v130);
    curCombatStage = v10->curCombatStage;
    if ( curCombatStage >= 0 && curCombatStage < v10->combatStages.num )
    {
      v18 = (int)&v10->combatStages.list[curCombatStage];
      if ( v18 != 0 )
      {
        v19 = *(_DWORD *)(v18 + 88);
        v20 = (idEntityPtr<idTarget_FakeEnemy> *)(v18 + 88);
        if ( gameLocal->spawnIds.ptr[v19 & 0x1FFF] == v19 >> 13
          && (v21 = (idTarget_FakeEnemy *)gameLocal->entities.ptr[v19 & 0x1FFF]) != nullptr )
        {
          v22 = idTarget_FakeEnemy::CastTo(c: v21);
        }
        else
        {
          v22 = nullptr;
        }
        if ( v13 != v22 )
        {
          if ( idEntityPtr<idTarget_FakeEnemy>::operator idTarget_FakeEnemy *(this: v20) != nullptr )
          {
            v23 = idEntityPtr<idTarget_FakeEnemy>::operator idTarget_FakeEnemy *(this: v20);
            idAI2::SetFakeEnemy(this, entity: v23);
          }
          else if ( v13 != nullptr && v13->targets.num == 0 )
          {
            idAI2::ClearFakeEnemy(this);
            v14 = idEntityPtr<idTarget_FakeEnemy>::operator idTarget_FakeEnemy *(this: v20);
          }
        }
      }
    }
    idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v130);
    v116.__vftable = (idEnemyTargetFilter_vtbl *)&idTargetFilter::`vftable';
    idPLogScope::~idPLogScope(this: &v111);
    RD_EventEnd();
  }
  if ( (this->aiVolatile.perception.flags & 1) == 0
    && !idAI2::ActionScriptFlagIsSet(this, flags: 16)
    && !idAI2::IsExecutingScript(this) )
  {
    RD_EventBegin(name: "idAI2::UpdateWorldState - filter targets");
    LODWORD(v24) = "idAI2::UpdateWorldState - filter targets";
    HIDWORD(v24) = 6;
    idPLogScope::idPLogScope(this: &v121, pl: &pLog, gMask: v24, label: v25);
    p_currentFriendly = &this->aiVolatile.memory.currentFriendly;
    p_currentNeutral = &this->aiVolatile.memory.currentNeutral;
    this->aiVolatile.memory.currentFriendly.spawnId.value = 0x1FFF;
    this->aiVolatile.memory.currentNeutral.spawnId.value = 0x1FFF;
    this->aiVolatile.memory.currentFriendlyBlocker.spawnId.value = 0x1FFF;
    RD_EventBegin(name: "idAI2::UpdateWorldState - friendly");
    LODWORD(v28) = "idAI2::UpdateWorldState - friendly";
    HIDWORD(v28) = 6;
    idPLogScope::idPLogScope(this: &v111, pl: &pLog, gMask: v28, label: v29);
    idFriendlyTargetFilter::idFriendlyTargetFilter(this: &v114, minAwareness_: AIAWARE_LOST);
    v124.__vftable = (idTargetSelector_vtbl *)&idFriendlyTargetSelector::`vftable';
    idTargetList::idTargetList(this: &v127, targetCache_: &this->aiVolatile.world.worldState.targetCache);
    if ( idTargetList::FindBestTarget(this: &v127, owner: this, filter: &v114, selector: &v124) >= 0
      && v127.bestTargetIndex >= 0 )
    {
      v30 = &v127.targetCache->targets.list[v127.viableTargets.list[v127.bestTargetIndex]];
      if ( v30 != nullptr )
      {
        Entity = idAIEntityState::GetEntity(this: (idAIEntityState *)v30->es);
        v32 = Entity;
        if ( Entity != nullptr )
        {
          v109.value = Entity->entityNumber;
          p_currentFriendly->spawnId.value = (gameLocal->spawnIds.ptr[v109.value] << 13) | v109.value;
          Physics = idEntity::GetPhysics(this: Entity);
          v34 = Physics->GetOrigin(this: Physics, a2: 0);
          v35 = idEntity::GetPhysics(this);
          v36 = (idVec3 *)v35->GetOrigin(this: v35, a2: 0);
          if ( idVec3::DistanceFast(this: v36, v: v34) <= 96.0 )
          {
            v109.value = v32->entityNumber;
            this->aiVolatile.memory.currentFriendlyBlocker.spawnId.value = (gameLocal->spawnIds.ptr[v109.value] << 13)
                                                                         | v109.value;
          }
        }
        else
        {
          p_currentFriendly->spawnId.value = 0x1FFF;
        }
      }
    }
    idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v127);
    v124.__vftable = (idTargetSelector_vtbl *)&idTargetSelector::`vftable';
    v114.__vftable = (idFriendlyTargetFilter_vtbl *)&idTargetFilter::`vftable';
    idPLogScope::~idPLogScope(this: &v111);
    RD_EventEnd();
    RD_EventBegin(name: "idAI2::UpdateWorldState - neutral");
    LODWORD(v37) = "idAI2::UpdateWorldState - neutral";
    HIDWORD(v37) = 6;
    idPLogScope::idPLogScope(this: &v111, pl: &pLog, gMask: v37, label: v38);
    idNonEnemyTargetFilter::idNonEnemyTargetFilter(this: &v117, minAwareness_: AIAWARE_LOST);
    v125.__vftable = (idTargetSelector_vtbl *)&idNeutralTargetSelector::`vftable';
    idTargetList::idTargetList(this: &v129, targetCache_: &this->aiVolatile.world.worldState.targetCache);
    if ( idTargetList::FindBestTarget(this: &v129, owner: this, filter: &v117, selector: &v125) >= 0
      && v129.bestTargetIndex >= 0 )
    {
      v39 = &v129.targetCache->targets.list[v129.viableTargets.list[v129.bestTargetIndex]];
      if ( v39 != nullptr )
      {
        v40 = idAIEntityState::GetEntity(this: (idAIEntityState *)v39->es);
        if ( v40 != nullptr )
        {
          v109.value = v40->entityNumber;
          p_currentNeutral->spawnId.value = (gameLocal->spawnIds.ptr[v109.value] << 13) | v109.value;
        }
        else
        {
          p_currentNeutral->spawnId.value = 0x1FFF;
        }
      }
    }
    idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v129);
    v125.__vftable = (idTargetSelector_vtbl *)&idTargetSelector::`vftable';
    v117.__vftable = (idNonEnemyTargetFilter_vtbl *)&idTargetFilter::`vftable';
    idPLogScope::~idPLogScope(this: &v111);
    RD_EventEnd();
    Enemy = idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
    RD_EventBegin(name: "idAI2::UpdateWorldState - enemy");
    LODWORD(v42) = "idAI2::UpdateWorldState - enemy";
    HIDWORD(v42) = 6;
    idPLogScope::idPLogScope(this: &v122, pl: &pLog, gMask: v42, label: v43);
    idEnemyTargetFilter::idEnemyTargetFilter(this: &v115, minAwareness_: AIAWARE_LOST);
    v123.__vftable = (idTargetSelector_vtbl *)&idEnemyTargetSelector::`vftable';
    idTargetList::idTargetList(this: &v128, targetCache_: &this->aiVolatile.world.worldState.targetCache);
    if ( idTargetList::FindBestTarget(this: &v128, owner: this, filter: &v115, selector: &v123) < 0 )
    {
      this->aiVolatile.memory.currentEnemy.spawnId.value = 0x1FFF;
      this->aiVolatile.memory.currentEnemySuspectedPos.bValid = false;
    }
    else if ( v128.bestTargetIndex >= 0 )
    {
      v44 = &v128.targetCache->targets.list[v128.viableTargets.list[v128.bestTargetIndex]];
      if ( v44 != nullptr )
      {
        v45 = idAIEntityState::GetEntity(this: (idAIEntityState *)v44->es);
        v46 = v45;
        p_currentEnemy = &this->aiVolatile.memory.currentEnemy;
        if ( v45 != nullptr )
        {
          v109.value = v45->entityNumber;
          p_currentEnemy->spawnId.value = (gameLocal->spawnIds.ptr[v109.value] << 13) | v109.value;
        }
        else
        {
          p_currentEnemy->spawnId.value = 0x1FFF;
        }
        GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        if ( this->aiVolatile.memory.enemyTrailUpdatePeriod < 0
          || (v49 = 1, GameMs < this->aiVolatile.memory.nextEnemyTrailTime) )
        {
          v49 = 0;
        }
        if ( v49 != 0 )
        {
          v50 = idEntity::GetPhysics(this: v46);
          if ( v50->HasGroundContacts(this: v50) )
          {
            v51 = idEntity::GetPhysics(this: v46);
            v52 = v51->GetOrigin(this: v51, a2: 0);
            v53 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
            idAIMemory::UpdateEnemyTrailPos(this: &this->aiVolatile.memory, _curTime: v53, _EnemyPos: v52);
          }
        }
        EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
        v55 = EnemySenseState;
        if ( EnemySenseState != nullptr )
        {
          ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: EnemySenseState);
          this->aiVolatile.memory.currentEnemySuspectedPos.pos.x = ConfirmedPhysicalSafe->origin.x;
          this->aiVolatile.memory.currentEnemySuspectedPos.pos.y = ConfirmedPhysicalSafe->origin.y;
          z = ConfirmedPhysicalSafe->origin.z;
          this->aiVolatile.memory.currentEnemySuspectedPos.bValid = true;
          this->aiVolatile.memory.currentEnemySuspectedPos.pos.z = z;
          if ( idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED)
             - v55->lastConfirmedStimTime >= 1000 )
          {
            if ( (v55->senseFlags & 4) != 0
              || (v59 = idEntity::GetPhysics(this),
                  v109.value = (int)v59->GetOrigin(this: v59, a2: 0),
                  v60 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v55),
                  idVec3::DistanceFast(this: (idVec3 *)v109.value, v: &v60->origin) <= 96.0) )
            {
              v61 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
              idAI2::CheckForSuspectedToTrailUpdate(this, curTime: v61);
            }
          }
          else
          {
            v58 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
            idAIMemory::TouchEnemyTrail(this: &this->aiVolatile.memory, _curTime: v58);
          }
        }
        else
        {
          this->aiVolatile.memory.currentEnemySuspectedPos.bValid = false;
        }
        if ( idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this) )
          goto LABEL_90;
        if ( Enemy != v46 )
        {
          if ( idAI2::GetAlertCycle(this) == ALERTCYCLE_COMBAT )
          {
            curScenePoint = this->aiVolatile.memory.curScenePoint;
            if ( curScenePoint == nullptr
              || (*(_BYTE *)&curScenePoint->flags & 8) == 0
              || (v63 = curScenePoint->scriptFlags & 1, v64 = 1, v63 == 0) )
            {
              v64 = 0;
            }
            if ( v64 == 0 )
              idFocusInfo::SetFocusEntity(
                this: this->aiVolatile.focus.foci.ptr,
                owner: this,
                _ent: v46,
                _keepFocusInView: true,
                _aimPoint: AIMPOINT_BEST,
                duration: -1);
          }
          idWanderingAim::Diverge(this: (idWanderingAim *)&this->aiVolatile.focus, ai: this);
        }
        if ( idAIEntityState::IsVisible(this: (idAIEntityState *)v44->es) )
        {
          p_onSpotEnemyTrigger = &this->aiEditable.onSpotEnemyTrigger;
          if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.onSpotEnemyTrigger) != nullptr
            && idAIMemory::GetSpottedEnemyTrigger(this: &this->aiVolatile.memory) != v46 )
          {
            p_spottedEnemyTrigger = &this->aiVolatile.memory.spottedEnemyTrigger;
            if ( v46 != nullptr )
            {
              v109.value = v46->entityNumber;
              p_spottedEnemyTrigger->spawnId.value = (gameLocal->spawnIds.ptr[v109.value] << 13) | v109.value;
            }
            else
            {
              p_spottedEnemyTrigger->spawnId.value = 0x1FFF;
            }
            v67 = idEventArg::idEventArg(this: (idEventArg *)&v126, data: this);
            v68 = &v110;
            v69 = (_DWORD *)&v67[-1].value.q[3];
            for ( i = 5; i != 0; --i )
              *++v68 = *++v69;
LABEL_89:
            v76 = idEntityPtr<idEntity const>::operator->(this: p_onSpotEnemyTrigger);
            idEventReceiver::PostEventMS(this: v76, ev: &EV_Activate, time: 0, arg1: (const idEventArg *)v111.pLog);
          }
        }
        else
        {
          p_onSpotEnemyTrigger = &this->aiEditable.onDetectEnemyTrigger;
          if ( idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.onDetectEnemyTrigger) != nullptr
            && idAIMemory::GetDetectedEnemyTrigger(this: &this->aiVolatile.memory) != v46 )
          {
            p_detectedEnemyTrigger = &this->aiVolatile.memory.detectedEnemyTrigger;
            if ( v46 != nullptr )
            {
              v109.value = v46->entityNumber;
              p_detectedEnemyTrigger->spawnId.value = (gameLocal->spawnIds.ptr[v109.value] << 13) | v109.value;
            }
            else
            {
              p_detectedEnemyTrigger->spawnId.value = 0x1FFF;
            }
            v72 = idEventArg::idEventArg(this: (idEventArg *)&v126, data: this);
            v73 = &v110;
            v74 = (_DWORD *)&v72[-1].value.q[3];
            for ( j = 5; j != 0; --j )
              *++v73 = *++v74;
            goto LABEL_89;
          }
        }
LABEL_90:
        FriendlyBlocker = (idAI2 *)idAIMemory::GetFriendlyBlocker(this: &this->aiVolatile.memory);
        v78 = idAI2::CastTo(c: FriendlyBlocker);
        if ( v78 != nullptr && v46 != nullptr )
        {
          v79 = idEntity::GetPhysics(this: v46);
          v80 = (int *)v79->GetOrigin(this: v79, a2: 0);
          v81 = (idPLog *)v80[1];
          v82 = *((float *)v80 + 2);
          v111.logIndex = *v80;
          v111.pLog = v81;
          v112 = v82;
          v83 = idEntity::GetPhysics(this: v78);
          v84 = (float *)v83->GetOrigin(this: v83, a2: 0);
          v85 = *(float *)&v111.pLog;
          v86 = *(float *)&v111.logIndex;
          v87 = v112;
          v88 = (float)((float)((float)(v84[2] - v112) * (float)(v84[2] - v112))
                      + (float)((float)((float)(*v84 - *(float *)&v111.logIndex)
                                      * (float)(*v84 - *(float *)&v111.logIndex))
                              + (float)((float)(v84[1] - *(float *)&v111.pLog) * (float)(v84[1] - *(float *)&v111.pLog))));
          v89 = idEntity::GetPhysics(this);
          v90 = (float *)v89->GetOrigin(this: v89, a2: 0);
          v91 = (float)(v90[1] - (float)v85);
          v92 = (float)(v90[2] - (float)v87);
          if ( v88 < (float)((float)((float)v92 * (float)v92)
                           + (float)((float)((float)(*v90 - (float)v86) * (float)(*v90 - (float)v86))
                                   + (float)((float)v91 * (float)v91))) )
          {
            v93 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
            v111.pLog = (idPLog *)(int)1000.0;
            v78->aiVolatile.memory.currentFriendlyBlockerTime = (int)1000.0 + v93;
          }
        }
      }
    }
    if ( v14 != nullptr
      && idAIMemory::GetEnemy(this: &this->aiVolatile.memory) != v14
      && (*(_BYTE *)&v14->flags & 8) != 0 )
    {
      v94 = &gameLocal->aiGameState;
      idSpawnId::idSpawnId(this: &v109, ent: this);
      v95 = idSpawnId::idSpawnId(this: (idSpawnId *)&v111, ent: v14);
      v96 = idAILogic::idAILogic(this: &v126, ai: this);
      idAIWorldState::AddEntityState(
        this: &p_world->worldState,
        gameState: v94,
        owner: v96,
        entId: v95,
        stimulusType: AISTIMULUS_TRIGGER,
        stimulusAmount: 1.0,
        sourceId: v97);
    }
    idAI2::UpdateAvoidCharacter(this);
    if ( ai_debugLevel.valueInteger > 0
      && (ai_debugEnemyTargetSelector.valueInteger == -1
       || ai_debugEnemyTargetSelector.valueInteger == this->entityNumber)
      && idAIMemory::GetEnemy(this: &this->aiVolatile.memory) != nullptr )
    {
      v98 = (idEntity *)idAIMemory::GetEnemy(this: &this->aiVolatile.memory);
      v99 = idEntity::GetPhysics(this: v98);
      v100 = idEntity::GetPhysics(this);
      v101 = common->RW(this: common);
      v102 = (float *)v99->GetOrigin(this: v99, a2: 0);
      v103 = v102[2];
      v104 = v102[1];
      v119[0] = *v102;
      v119[1] = v104;
      v119[2] = (float)v103 + (float)8.0;
      v105 = (float *)v100->GetOrigin(this: v100, a2: 0);
      v106 = v105[1];
      v107 = (float)(v105[2] + (float)8.0);
      v118[0] = *v105;
      v118[1] = v106;
      v118[2] = v107;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v101->DebugArrow)(
        a1: v101,
        a2: &idColor::colorYellow,
        a3: v118,
        a4: v119,
        a5: 8.0);
    }
    idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v128);
    v123.__vftable = (idTargetSelector_vtbl *)&idTargetSelector::`vftable';
    v115.__vftable = (idEnemyTargetFilter_vtbl *)&idTargetFilter::`vftable';
    idPLogScope::~idPLogScope(this: &v122);
    RD_EventEnd();
    idPLogScope::~idPLogScope(this: &v121);
    RD_EventEnd();
  }
  valueInteger = ai_debugLevel.valueInteger;
  if ( ai_debugLevel.valueInteger > 0 )
  {
    if ( ai_debugPerception.valueInteger > 0 )
    {
      idAI2::Debug_Perception(this);
      valueInteger = ai_debugLevel.valueInteger;
    }
    if ( valueInteger > 0 && ai_debugScenePoints.valueInteger != 0 )
      idAI2::Debug_ScenePoints(this);
  }
  idPLogScope::~idPLogScope(this: &v120);
  RD_EventEnd();
}


// ========================================================================
// __unwind$557829
// EA  : 0x82A15D28
// RVA : 0x00A15D28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557829()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 536));
}


// ========================================================================
// __unwind$557830
// EA  : 0x82A15D50
// RVA : 0x00A15D50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557830()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 184));
}


// ========================================================================
// __unwind$557831
// EA  : 0x82A15D78
// RVA : 0x00A15D78
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557831()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 537));
}


// ========================================================================
// __unwind$557832
// EA  : 0x82A15DA0
// RVA : 0x00A15DA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557832()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 96));
}


// ========================================================================
// __unwind$557833
// EA  : 0x82A15DC8
// RVA : 0x00A15DC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557833()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 538));
}


// ========================================================================
// __unwind$557834
// EA  : 0x82A15DF0
// RVA : 0x00A15DF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557834()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 96));
}


// ========================================================================
// __unwind$557835
// EA  : 0x82A15E18
// RVA : 0x00A15E18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557835()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 736 + 136));
}


// ========================================================================
// __unwind$557836
// EA  : 0x82A15E40
// RVA : 0x00A15E40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557836()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 736 + 480));
}


// ========================================================================
// __unwind$557837
// EA  : 0x82A15E68
// RVA : 0x00A15E68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557837()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 539));
}


// ========================================================================
// __unwind$557838
// EA  : 0x82A15E90
// RVA : 0x00A15E90
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557838()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 192));
}


// ========================================================================
// __unwind$557839
// EA  : 0x82A15EB8
// RVA : 0x00A15EB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557839()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 540));
}


// ========================================================================
// __unwind$557840
// EA  : 0x82A15EE0
// RVA : 0x00A15EE0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557840()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 96));
}


// ========================================================================
// __unwind$557841
// EA  : 0x82A15F08
// RVA : 0x00A15F08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557841()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 736 + 120));
}


// ========================================================================
// __unwind$557842
// EA  : 0x82A15F30
// RVA : 0x00A15F30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557842()
{
  int v0; // r12

  idEnemyTargetSelector::~idEnemyTargetSelector(this: (idNeutralTargetSelector *)(v0 - 736 + 224));
}


// ========================================================================
// __unwind$557843
// EA  : 0x82A15F58
// RVA : 0x00A15F58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557843()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 736 + 288));
}


// ========================================================================
// __unwind$557844
// EA  : 0x82A15F80
// RVA : 0x00A15F80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557844()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 541));
}


// ========================================================================
// __unwind$557845
// EA  : 0x82A15FA8
// RVA : 0x00A15FA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557845()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 96));
}


// ========================================================================
// __unwind$557846
// EA  : 0x82A15FD0
// RVA : 0x00A15FD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557846()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 736 + 144));
}


// ========================================================================
// __unwind$557847
// EA  : 0x82A15FF8
// RVA : 0x00A15FF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557847()
{
  int v0; // r12

  idEnemyTargetSelector::~idEnemyTargetSelector(this: (idNeutralTargetSelector *)(v0 - 736 + 240));
}


// ========================================================================
// __unwind$557848
// EA  : 0x82A16020
// RVA : 0x00A16020
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557848()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 736 + 416));
}


// ========================================================================
// __unwind$557849
// EA  : 0x82A16048
// RVA : 0x00A16048
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557849()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 736 + 542));
}


// ========================================================================
// __unwind$557850
// EA  : 0x82A16070
// RVA : 0x00A16070
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557850()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 736 + 200));
}


// ========================================================================
// __unwind$557851
// EA  : 0x82A16098
// RVA : 0x00A16098
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557851()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 736 + 128));
}


// ========================================================================
// __unwind$557852
// EA  : 0x82A160C0
// RVA : 0x00A160C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557852()
{
  int v0; // r12

  idEnemyTargetSelector::~idEnemyTargetSelector(this: (idNeutralTargetSelector *)(v0 - 736 + 208));
}


// ========================================================================
// __unwind$557853_0
// EA  : 0x82A160E8
// RVA : 0x00A160E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_557853_0()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 736 + 352));
}


// ========================================================================
// ?OnAIEvent@idAI2@@UAAXPBVidAIEvent@@@Z
// EA  : 0x82A16118
// RVA : 0x00A16118
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::OnAIEvent(idAI2 *this, const idAIEvent *event)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  bool v6; // r11
  idStaticList<idHandle<int,enum invalidAIEvent_t,-1>,4> *p_pendingAIEvents; // r30
  char v8; // r25
  int v9; // r26
  bool v10; // r23
  int v11; // r28
  idAIEvent *v12; // r3
  int Priority; // r21
  int size; // r10
  idAIEvent *v15; // r3
  char *v16; // r30
  char *data; // r29
  char *v18; // r28
  int GameMs; // r27
  const char *Classname; // r3
  idStrId v21[2]; // [sp+50h] [-80h] BYREF
  idPLogScope v22[15]; // [sp+58h] [-78h] BYREF

  RD_EventBegin(name: "idAI2::OnAIEvent");
  LODWORD(v4) = "idAI2::OnAIEvent";
  HIDWORD(v4) = 2;
  idPLogScope::idPLogScope(this: v22, pl: &pLog, gMask: v4, label: v5);
  v6 = idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
    && (this->aiVolatile.script.flags & 4) != 0;
  if ( !v6 && ai_ignoreEvents.valueInteger == 0 && event != nullptr )
  {
    p_pendingAIEvents = &this->aiVolatile.aiEvents.pendingAIEvents;
    v8 = 0;
    v9 = 0;
    v10 = ai_debugEvents.valueInteger != 0;
    if ( this->aiVolatile.aiEvents.pendingAIEvents.num > 0 )
    {
      v11 = 0;
      while ( 1 )
      {
        v12 = idAIEventManager::GetEvent(this: &gameLocal->aiEventManager, handle: &p_pendingAIEvents->list[v11]);
        if ( v12 != nullptr )
        {
          Priority = idAIEvent::GetPriority(this: v12);
          if ( Priority <= idAIEvent::GetPriority(this: event) )
            break;
        }
        ++v9;
        ++v11;
        if ( v9 >= this->aiVolatile.aiEvents.pendingAIEvents.num )
          goto LABEL_20;
      }
      size = this->aiVolatile.aiEvents.pendingAIEvents.size;
      v21[0] = (idStrId)this->aiVolatile.aiEvents.pendingAIEvents.num;
      if ( v21[0].index >= size )
      {
        v15 = idAIEventManager::GetEvent(
                this: &gameLocal->aiEventManager,
                handle: &p_pendingAIEvents->list[v21[0].index - 1]);
        if ( v15 != nullptr && v10 )
        {
          idAIEvent::GetPriority(this: v15);
          idAIEvent::GetPriority(this: event);
        }
        idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(
          this: (idList<idEntityPtr<idEntity>,58> *)&this->aiVolatile.aiEvents.pendingAIEvents,
          index: this->aiVolatile.aiEvents.pendingAIEvents.num - 1);
      }
      v21[0] = (idStrId)event->handle.value;
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::Insert(
        this: &this->aiVolatile.aiEvents.pendingAIEvents,
        obj: (const idHandle<int,enum invalidAIEvent_t,-1> *)v21,
        index: v9);
      v8 = 1;
    }
LABEL_20:
    if ( v8 == 0 && this->aiVolatile.aiEvents.pendingAIEvents.num < this->aiVolatile.aiEvents.pendingAIEvents.size )
    {
      v21[0] = (idStrId)event->handle.value;
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::Append(
        this: (idList<idStrId,5> *)&this->aiVolatile.aiEvents.pendingAIEvents,
        obj: v21);
    }
    if ( v10 && v8 != 0 )
    {
      v16 = "< none >";
      if ( idAIEvent::GetInstigator(this: event) != nullptr )
        data = idAIEvent::GetInstigator(this: event)->name.data;
      else
        data = "< none >";
      if ( idAIEvent::GetOriginator(this: event) != nullptr )
        v16 = idAIEvent::GetOriginator(this: event)->name.data;
      v18 = this->name.data;
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      Classname = idClass::GetClassname(this: &event->idClass);
      idLib::Printf(fmt: "(%d) - '%s' received %s from '%s', instigator '%s'\n", GameMs, v18, Classname, v16, data);
    }
  }
  idPLogScope::~idPLogScope(this: v22);
  RD_EventEnd();
}


// ========================================================================
// __unwind$559697
// EA  : 0x82A163C0
// RVA : 0x00A163C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559697()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 208 + 96));
}


// ========================================================================
// __unwind$559698
// EA  : 0x82A163E8
// RVA : 0x00A163E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559698()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 208 + 88));
}


// ========================================================================
// ?HandlePendingAIEvents@idAI2@@IAAXXZ
// EA  : 0x82A16418
// RVA : 0x00A16418
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::HandlePendingAIEvents(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  int v4; // r22
  idAIEventVoice *Event; // r29
  int GameMs; // r28
  int GameMsPerFrame; // r3
  idThread *thread; // r4
  int i; // r28
  idThread *v10; // r30
  idAIEvent::aiEventClass_t EventClass; // r3
  idGameLocal *v12; // r10
  int value; // r8
  idEntity *v14; // r3
  idEntity *v15; // r3
  idEntityPtr<idEntity> *p_lastAIEventOriginator; // r9
  int v17; // r9
  idGameLocal *v18; // r10
  idEntity *v19; // r3
  idEntity *v20; // r3
  idEntityPtr<idEntity> *p_lastAIEventInstigator; // r9
  idEncounterGroup *v22; // r30
  idAIEvent::aiEventClass_t v23; // r3
  char v24; // r11
  unsigned int v25; // r30
  const char *v26; // r7
  idAIEventSound *v27; // r3
  char v28; // r11
  unsigned __int64 v29; // r6
  const char *v30; // r7
  idAIEventSound *v31; // r3
  idAIEventProjectedSphere *v32; // r30
  unsigned int v33; // r29
  const char *v34; // r7
  idAIEventSound *v35; // r3
  idAIEventSound *v36; // r30
  unsigned __int64 v37; // r6
  const char *v38; // r7
  idAIEventSphere *v39; // r30
  unsigned int v40; // r29
  const char *v41; // r7
  idAIEvent_PlayerAim *v42; // r30
  unsigned int v43; // r29
  const char *v44; // r7
  idAIEvent_Vehicle *v45; // r30
  unsigned int v46; // r29
  const char *v47; // r7
  char v48; // r11
  unsigned int v49; // r30
  const char *v50; // r7
  idAIEventVoice *v51; // r3
  char v52; // r11
  unsigned __int64 v53; // r6
  const char *v54; // r7
  idAIEventSound *v55; // r3
  idAIEventProjectile *v56; // r30
  unsigned __int64 v57; // r6
  const char *v58; // r7
  char v59; // r11
  unsigned int v60; // r30
  const char *v61; // r7
  idAIEventSound *v62; // r3
  const idEntity *Originator; // r3
  idEntityPtr<idEntity const > *p_nearbyPossessed; // r10
  char v65; // r11
  unsigned int v66; // r30
  const char *v67; // r7
  idAIEventSound *v68; // r3
  char v69; // r11
  unsigned __int64 v70; // r6
  const char *v71; // r7
  idAIEventSound *v72; // r3
  char v73; // r11
  unsigned __int64 v74; // r6
  const char *v75; // r7
  idAIEventSound *v76; // r3
  idAIEvent_DelayedVO *v77; // r30
  unsigned __int64 v78; // r6
  const char *v79; // r7
  voiceMsg_t Message; // r3
  idAIEventSound *v81; // r30
  unsigned __int64 v82; // r6
  const char *v83; // r7
  idAIEventSphere *v84; // r30
  unsigned __int64 v85; // r6
  const char *v86; // r7
  idStaticList<idHandle<int,enum invalidAIEvent_t,-1>,4> *v87; // r30
  idPLog *pLog; // r29
  idPLog::logEntry_t *v89; // r30
  int v90; // r3
  __int64 totalTicks; // r11
  __int64 v92; // r9
  char v93; // [sp+50h] [-180h]
  int v94; // [sp+58h] [-178h]
  idHandle<int,enum invalidAIEvent_t,-1> v95; // [sp+5Ch] [-174h] BYREF
  const char *v96; // [sp+60h] [-170h]
  const char *v97; // [sp+64h] [-16Ch]
  const char *v98; // [sp+68h] [-168h]
  const char *v99; // [sp+6Ch] [-164h]
  idStaticList<idHandle<int,enum invalidAIEvent_t,-1>,4> *p_pendingAIEvents; // [sp+70h] [-160h]
  const char *v101; // [sp+74h] [-15Ch]
  const char *v102; // [sp+78h] [-158h]
  int *p_num; // [sp+7Ch] [-154h]
  const char *v104; // [sp+80h] [-150h]
  const idHandle<int,enum invalidThreadHandle_t,0> *v105; // [sp+84h] [-14Ch] BYREF
  const char *v106; // [sp+88h] [-148h]
  idPLogScope v107; // [sp+90h] [-140h] BYREF
  idPLogScope v108; // [sp+98h] [-138h] BYREF
  idPLogScope v109; // [sp+A0h] [-130h] BYREF
  idPLogScope v110; // [sp+A8h] [-128h] BYREF
  idPLogScope v111; // [sp+B0h] [-120h] BYREF
  idPLogScope v112; // [sp+B8h] [-118h] BYREF
  idPLogScope v113; // [sp+C0h] [-110h] BYREF
  idPLogScope v114; // [sp+C8h] [-108h] BYREF
  idPLogScope v115; // [sp+D0h] [-100h] BYREF
  idPLogScope v116; // [sp+D8h] [-F8h] BYREF
  idPLogScope v117; // [sp+E0h] [-F0h] BYREF
  idPLogScope v118; // [sp+E8h] [-E8h] BYREF
  idPLogScope v119; // [sp+F0h] [-E0h] BYREF
  idPLogScope v120; // [sp+F8h] [-D8h] BYREF
  idPLogScope v121; // [sp+100h] [-D0h] BYREF
  idPLogScope v122; // [sp+108h] [-C8h] BYREF
  idPLogScope v123; // [sp+110h] [-C0h] BYREF
  idPLogScope v124[23]; // [sp+118h] [-B8h] BYREF

  RD_EventBegin(name: "idAI2::HandlePendingAIEvents");
  LODWORD(v2) = "idAI2::HandlePendingAIEvents";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: &v107, pl: &::pLog, gMask: v2, label: v3);
  v93 = 0;
  v94 = 0;
  p_num = &this->aiVolatile.aiEvents.pendingAIEvents.num;
  if ( this->aiVolatile.aiEvents.pendingAIEvents.num > 0 )
  {
    v96 = "OnAIEvent_Body";
    v4 = 0;
    p_pendingAIEvents = &this->aiVolatile.aiEvents.pendingAIEvents;
    v106 = "OnAIEvent_Grenade";
    v104 = "OnAIEvent_PlayerAim";
    v102 = "OnAIEvent_Vehicle";
    v99 = "OnAIEvent_DoorMotion";
    v101 = "OnAIEvent_DeadBodyLand";
    v98 = "OnAIEvent_Footstep";
    v97 = "OnAIEvent_Voice";
    do
    {
      v95.value = p_pendingAIEvents->list[v4].value;
      Event = (idAIEventVoice *)idAIEventManager::GetEvent(this: &gameLocal->aiEventManager, handle: &v95);
      if ( Event == nullptr )
        goto LABEL_127;
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      GameMsPerFrame = idGameTimeManager::GetGameMsPerFrame(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      thread = this->aiVolatile.script.thread;
      this->aiVolatile.aiEvents.nextAIEventTime = GameMsPerFrame + GameMs;
      if ( thread != nullptr )
      {
        for ( i = 0; i < this->NumThreads(this); ++i )
        {
          this->GetThread(
            this: (struct idAI2 *)&v105,
            result: (idHandle<int,enum invalidThreadHandle_t,0> *)this,
            a3: i);
          v10 = idThreadManager::GetThread(this: &gameLocal->program.threadManager, threadHandle: v105);
          if ( v10 != nullptr )
          {
            EventClass = idAIEvent::GetEventClass(this: Event);
            if ( idThread::IsWaitingForFlags(this: v10, flags: EventClass) )
            {
              this->aiVolatile.script.lastAIEventClass = idAIEvent::GetEventClass(this: Event);
              v12 = gameLocal;
              value = Event->originator.spawnId.value;
              if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13
                && (v14 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
              {
                v15 = idEntity::CastTo(c: v14);
                v12 = gameLocal;
              }
              else
              {
                v15 = nullptr;
              }
              p_lastAIEventOriginator = &this->aiVolatile.script.lastAIEventOriginator;
              if ( v15 != nullptr )
                p_lastAIEventOriginator->spawnId.value = (v12->spawnIds.ptr[v15->entityNumber] << 13)
                                                       | v15->entityNumber;
              else
                p_lastAIEventOriginator->spawnId.value = 0x1FFF;
              v17 = Event->instigator.spawnId.value;
              v18 = gameLocal;
              if ( gameLocal->spawnIds.ptr[v17 & 0x1FFF] == v17 >> 13
                && (v19 = gameLocal->entities.ptr[v17 & 0x1FFF]) != nullptr )
              {
                v20 = idEntity::CastTo(c: v19);
                v18 = gameLocal;
              }
              else
              {
                v20 = nullptr;
              }
              p_lastAIEventInstigator = &this->aiVolatile.script.lastAIEventInstigator;
              if ( v20 != nullptr )
                p_lastAIEventInstigator->spawnId.value = (v18->spawnIds.ptr[v20->entityNumber] << 13)
                                                       | v20->entityNumber;
              else
                p_lastAIEventInstigator->spawnId.value = 0x1FFF;
              this->aiVolatile.script.lastAIEventOrigin.x = Event->origin.x;
              this->aiVolatile.script.lastAIEventOrigin.y = Event->origin.y;
              this->aiVolatile.script.lastAIEventOrigin.z = Event->origin.z;
              this->ExecuteThread(this, a2: v10);
            }
          }
        }
      }
      if ( (this->aiVolatile.perception.flags & 1) != 0 )
        goto LABEL_127;
      if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
        v22 = nullptr;
      else
        v22 = idEncounterGroupManager::GroupForHandle(
                this: &gameLocal->encounterGroupManager,
                handle: &this->aiVolatile.encounterGroupHandle);
      v23 = idAIEvent::GetEventClass(this: Event);
      if ( v23 > AIEVENT_PROJECTILE )
      {
        if ( v23 <= AIEVENT_VEHICLE_SOUND )
        {
          if ( v23 == AIEVENT_VEHICLE_SOUND )
          {
            if ( v22 == nullptr )
              goto _M560548;
            if ( v22->active || (v73 = 0, v22->enabled) )
              v73 = 1;
            if ( v73 == 0 )
              goto _M560548;
            RD_EventBegin(name: "OnAIEvent_VehicleSound");
            LODWORD(v74) = "OnAIEvent_VehicleSound";
            HIDWORD(v74) = 6;
            idPLogScope::idPLogScope(this: &v118, pl: &::pLog, gMask: v74, label: v75);
            v76 = idAIEventSound::CastTo(c: Event);
            idAI2::OnAIEvent_VehicleSound(this, ev: v76);
            idPLogScope::~idPLogScope(this: &v118);
          }
          else if ( v23 > AIEVENT_DEAD_BODY_LAND )
          {
            if ( v23 != AIEVENT_DEPLOY_SOUND || v22 == nullptr )
              goto _M560548;
            if ( v22->active || (v69 = 0, v22->enabled) )
              v69 = 1;
            if ( v69 == 0 )
              goto _M560548;
            RD_EventBegin(name: "OnAIEvent_DeploySound");
            LODWORD(v70) = "OnAIEvent_DeploySound";
            HIDWORD(v70) = 6;
            idPLogScope::idPLogScope(this: &v116, pl: &::pLog, gMask: v70, label: v71);
            v72 = idAIEventSound::CastTo(c: Event);
            idAI2::OnAIEvent_DoorMotion(this, ev: v72);
            idPLogScope::~idPLogScope(this: &v116);
          }
          else if ( v23 == AIEVENT_DEAD_BODY_LAND )
          {
            if ( v22 == nullptr )
              goto _M560548;
            if ( v22->active || (v65 = 0, v22->enabled) )
              v65 = 1;
            if ( v65 == 0 )
              goto _M560548;
            v66 = (unsigned int)v101;
            RD_EventBegin(name: v101);
            idPLogScope::idPLogScope(this: &v114, pl: &::pLog, gMask: v66 | 0x600000000LL, label: v67);
            v68 = idAIEventSound::CastTo(c: Event);
            idAI2::OnAIEvent_DeadBodyLand(this, ev: v68);
            idPLogScope::~idPLogScope(this: &v114);
          }
          else
          {
            if ( v23 == AIEVENT_POSSESSION )
            {
              Originator = idAIEvent::GetOriginator(this: Event);
              p_nearbyPossessed = &this->aiVolatile.memory.nearbyPossessed;
              if ( Originator != nullptr )
                p_nearbyPossessed->spawnId.value = (gameLocal->spawnIds.ptr[Originator->entityNumber] << 13)
                                                 | Originator->entityNumber;
              else
                p_nearbyPossessed->spawnId.value = 0x1FFF;
              goto _M560548;
            }
            if ( v23 != AIEVENT_DOOR_MOTION || v22 == nullptr )
              goto _M560548;
            if ( v22->active || (v59 = 0, v22->enabled) )
              v59 = 1;
            if ( v59 == 0 )
              goto _M560548;
            v60 = (unsigned int)v99;
            RD_EventBegin(name: v99);
            idPLogScope::idPLogScope(this: &v112, pl: &::pLog, gMask: v60 | 0x600000000LL, label: v61);
            v62 = idAIEventSound::CastTo(c: Event);
            idAI2::OnAIEvent_DoorMotion(this, ev: v62);
            idPLogScope::~idPLogScope(this: &v112);
          }
          goto LABEL_125;
        }
        switch ( v23 )
        {
          case AIEVENT_PLAYER_INTERACTION:
            v84 = idAIEventSphere::CastTo(c: Event);
            if ( v84 != nullptr )
            {
              RD_EventBegin(name: "OnAIEvent_PlayerInteraction");
              LODWORD(v85) = "OnAIEvent_PlayerInteraction";
              HIDWORD(v85) = 6;
              idPLogScope::idPLogScope(this: v124, pl: &::pLog, gMask: v85, label: v86);
              v93 = 1;
              idAI2::OnAIEvent_PlayerInteraction(this, ev: v84);
              idPLogScope::~idPLogScope(this: v124);
              goto LABEL_125;
            }
            break;
          case AIEVENT_PROJECTILE_IMPACT:
            v81 = idAIEventSound::CastTo(c: Event);
            if ( v81 != nullptr )
            {
              RD_EventBegin(name: "OnAIEvent_ProjectileImpact");
              LODWORD(v82) = "OnAIEvent_ProjectileImpact";
              HIDWORD(v82) = 6;
              idPLogScope::idPLogScope(this: &v122, pl: &::pLog, gMask: v82, label: v83);
              idAI2::OnAIEvent_ProjectileImpact(this, ev: v81);
              idPLogScope::~idPLogScope(this: &v122);
              goto LABEL_125;
            }
            break;
          case AIEVENT_DELAYED_VO:
            v77 = idAIEvent_DelayedVO::CastTo(c: (idAIEvent_DelayedVO *)Event);
            if ( v77 == nullptr )
              break;
            RD_EventBegin(name: "OnAIEvent_DelayedVO");
            LODWORD(v78) = "OnAIEvent_DelayedVO";
            HIDWORD(v78) = 6;
            idPLogScope::idPLogScope(this: &v120, pl: &::pLog, gMask: v78, label: v79);
            Message = idAIEvent_DelayedVO::GetMessage(this: v77);
            idAIVoiceController::PlayVoice(this: &this->aiVolatile.voiceController, ai: this, msg: Message);
            idPLogScope::~idPLogScope(this: &v120);
            goto LABEL_125;
          default:
            break;
        }
      }
      else if ( v23 == AIEVENT_PROJECTILE )
      {
        v56 = idAIEventProjectile::CastTo(c: (idAIEventProjectile *)Event);
        if ( v56 != nullptr )
        {
          RD_EventBegin(name: "OnAIEvent_Projectile");
          LODWORD(v57) = "OnAIEvent_Projectile";
          HIDWORD(v57) = 6;
          idPLogScope::idPLogScope(this: &v110, pl: &::pLog, gMask: v57, label: v58);
          idAI2::OnAIEvent_Projectile(this, ev: v56);
          idPLogScope::~idPLogScope(this: &v110);
          goto LABEL_125;
        }
      }
      else if ( v23 > AIEVENT_BODY )
      {
        if ( v23 > AIEVENT_VOICE )
        {
          if ( v23 != AIEVENT_INVESTIGATE || v22 == nullptr )
            goto _M560548;
          if ( v22->active || (v52 = 0, v22->enabled) )
            v52 = 1;
          if ( v52 == 0 )
            goto _M560548;
          RD_EventBegin(name: "OnAIEvent_Investigate");
          LODWORD(v53) = "OnAIEvent_Investigate";
          HIDWORD(v53) = 6;
          idPLogScope::idPLogScope(this: &v109, pl: &::pLog, gMask: v53, label: v54);
          v55 = idAIEventSound::CastTo(c: Event);
          idAI2::OnAIEvent_Investigate(this, ev: v55);
          idPLogScope::~idPLogScope(this: &v109);
          goto LABEL_125;
        }
        if ( v23 == AIEVENT_VOICE )
        {
          if ( v22 == nullptr )
            goto _M560548;
          if ( v22->active || (v48 = 0, v22->enabled) )
            v48 = 1;
          if ( v48 == 0 )
            goto _M560548;
          v49 = (unsigned int)v97;
          RD_EventBegin(name: v97);
          idPLogScope::idPLogScope(this: &v123, pl: &::pLog, gMask: v49 | 0x600000000LL, label: v50);
          v51 = idAIEventVoice::CastTo(c: Event);
          idAI2::OnAIEvent_Voice(this, ev: v51);
          idPLogScope::~idPLogScope(this: &v123);
          goto LABEL_125;
        }
        if ( v23 != AIEVENT_VEHICLE )
        {
          if ( v23 != AIEVENT_AIM )
            goto _M560548;
          v42 = idAIEvent_PlayerAim::CastTo(c: (idAIEvent_PlayerAim *)Event);
          if ( v42 == nullptr )
            goto _M560548;
          v43 = (unsigned int)v104;
          RD_EventBegin(name: v104);
          idPLogScope::idPLogScope(this: &v119, pl: &::pLog, gMask: v43 | 0x600000000LL, label: v44);
          idAI2::OnAIEvent_PlayerAim(this, ev: v42);
          idPLogScope::~idPLogScope(this: &v119);
          goto LABEL_125;
        }
        v45 = idAIEvent_Vehicle::CastTo(c: (idAIEvent_Vehicle *)Event);
        if ( v45 != nullptr )
        {
          v46 = (unsigned int)v102;
          RD_EventBegin(name: v102);
          idPLogScope::idPLogScope(this: &v115, pl: &::pLog, gMask: v46 | 0x600000000LL, label: v47);
          idAI2::OnAIEvent_Vehicle(this, ev: v45);
          idPLogScope::~idPLogScope(this: &v115);
          goto LABEL_125;
        }
      }
      else if ( v23 == AIEVENT_BODY )
      {
        v39 = idAIEventSphere::CastTo(c: Event);
        if ( v39 != nullptr )
        {
          v40 = (unsigned int)v96;
          RD_EventBegin(name: v96);
          idPLogScope::idPLogScope(this: &v113, pl: &::pLog, gMask: v40 | 0x600000000LL, label: v41);
          idAI2::OnAIEvent_Body(this, ev: v39);
          idPLogScope::~idPLogScope(this: &v113);
          goto LABEL_125;
        }
      }
      else if ( (unsigned int)(v23 - 1) <= 7 )
      {
        if ( v23 == AIEVENT_GUNFIRE )
        {
          if ( v22 == nullptr )
            goto _M560548;
          if ( v22->active || (v28 = 0, v22->enabled) )
            v28 = 1;
          if ( v28 == 0 )
            goto _M560548;
          RD_EventBegin(name: "OnAIEvent_Gunfire");
          LODWORD(v29) = "OnAIEvent_Gunfire";
          HIDWORD(v29) = 6;
          idPLogScope::idPLogScope(this: &v117, pl: &::pLog, gMask: v29, label: v30);
          v31 = idAIEventSound::CastTo(c: Event);
          idAI2::OnAIEvent_Gunfire(this, ev: v31);
          idPLogScope::~idPLogScope(this: &v117);
          goto LABEL_125;
        }
        if ( v23 != (AIEVENT_GUNFIRE|AIEVENT_FOOTSTEP) )
        {
          switch ( v23 )
          {
            case AIEVENT_EXPLOSION:
              v35 = idAIEventSound::CastTo(c: Event);
              v36 = v35;
              if ( v35 == nullptr )
                goto _M560548;
              RD_EventBegin(name: "OnAIEvent_Explosion");
              LODWORD(v37) = "OnAIEvent_Explosion";
              HIDWORD(v37) = 6;
              idPLogScope::idPLogScope(this: &v121, pl: &::pLog, gMask: v37, label: v38);
              idAI2::OnAIEvent_Explosion(this, ev: v36);
              idPLogScope::~idPLogScope(this: &v121);
              goto LABEL_125;
            case AIEVENT_EXPLOSION|AIEVENT_FOOTSTEP:
            case AIEVENT_EXPLOSION|AIEVENT_GUNFIRE:
            case AIEVENT_EXPLOSION|AIEVENT_GUNFIRE|AIEVENT_FOOTSTEP:
              goto _M560548;
            case AIEVENT_FOOTSTEP:
              if ( v22 == nullptr )
                goto _M560548;
              if ( v22->active || (v24 = 0, v22->enabled) )
                v24 = 1;
              if ( v24 == 0 )
                goto _M560548;
              v25 = (unsigned int)v98;
              RD_EventBegin(name: v98);
              idPLogScope::idPLogScope(this: &v108, pl: &::pLog, gMask: v25 | 0x600000000LL, label: v26);
              v27 = idAIEventSound::CastTo(c: Event);
              idAI2::OnAIEvent_Footstep(this, ev: v27);
              idPLogScope::~idPLogScope(this: &v108);
              goto LABEL_125;
            default:
              break;
          }
          v32 = idAIEventProjectedSphere::CastTo(c: (idAIEventProjectedSphere *)Event);
          if ( v32 != nullptr )
          {
            v33 = (unsigned int)v106;
            RD_EventBegin(name: v106);
            idPLogScope::idPLogScope(this: &v111, pl: &::pLog, gMask: v33 | 0x600000000LL, label: v34);
            idAI2::OnAIEvent_Grenade(this, ev: v32);
            idPLogScope::~idPLogScope(this: &v111);
LABEL_125:
            RD_EventEnd();
          }
        }
      }
_M560548:
      v95.value = -1;
LABEL_127:
      v4 = ++v94;
    }
    while ( v94 < *p_num );
  }
  v87 = &this->aiVolatile.aiEvents.pendingAIEvents;
  if ( this->aiVolatile.aiEvents.pendingAIEvents.listStatic == 0
    || this->aiVolatile.aiEvents.pendingAIEvents.listStatic == 2 )
  {
    if ( v87->list != nullptr )
      idMem::Free(this: &mem, ptr: v87->list, align: ALIGN_16);
    v87->list = nullptr;
    this->aiVolatile.aiEvents.pendingAIEvents.size = 0;
  }
  this->aiVolatile.aiEvents.pendingAIEvents.num = 0;
  if ( v93 == 0 && (*((_BYTE *)&this->aiVolatile + 49704) & 4) != 0 )
    *((_BYTE *)&this->aiVolatile + 49704) |= 2u;
  *((_BYTE *)&this->aiVolatile + 49704) = (4 * v93) & 4 | *((_BYTE *)&this->aiVolatile + 49704) & 0xFB;
  if ( v107.logIndex >= 0 )
  {
    pLog = v107.pLog;
    v89 = &v107.pLog->logEntries.list[v107.logIndex];
    v90 = (unsigned __int64)Sys_GetClockTicks() >> 32;
    totalTicks = v89->totalTicks;
    HIDWORD(totalTicks) = v89->parent;
    LODWORD(v92) = v90 - totalTicks;
    v89->totalTicks = v92;
    pLog->lastEntry = HIDWORD(totalTicks);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$559859
// EA  : 0x82A17078
// RVA : 0x00A17078
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559859()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 288));
}


// ========================================================================
// __unwind$559860
// EA  : 0x82A170A0
// RVA : 0x00A170A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559860()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 144));
}


// ========================================================================
// __unwind$559863
// EA  : 0x82A170C8
// RVA : 0x00A170C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559863()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 289));
}


// ========================================================================
// __unwind$559864
// EA  : 0x82A170F0
// RVA : 0x00A170F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559864()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 152));
}


// ========================================================================
// __unwind$559875
// EA  : 0x82A17118
// RVA : 0x00A17118
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559875()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 290));
}


// ========================================================================
// __unwind$559876
// EA  : 0x82A17140
// RVA : 0x00A17140
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559876()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 224));
}


// ========================================================================
// __unwind$559879
// EA  : 0x82A17168
// RVA : 0x00A17168
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559879()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 291));
}


// ========================================================================
// __unwind$559880
// EA  : 0x82A17190
// RVA : 0x00A17190
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559880()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 176));
}


// ========================================================================
// __unwind$559889
// EA  : 0x82A171B8
// RVA : 0x00A171B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559889()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 292));
}


// ========================================================================
// __unwind$559890_0
// EA  : 0x82A171E0
// RVA : 0x00A171E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559890_0()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 256));
}


// ========================================================================
// __unwind$559887
// EA  : 0x82A17208
// RVA : 0x00A17208
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559887()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 293));
}


// ========================================================================
// __unwind$559888
// EA  : 0x82A17230
// RVA : 0x00A17230
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559888()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 192));
}


// ========================================================================
// __unwind$559883
// EA  : 0x82A17258
// RVA : 0x00A17258
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559883()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 294));
}


// ========================================================================
// __unwind$559884
// EA  : 0x82A17280
// RVA : 0x00A17280
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559884()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 240));
}


// ========================================================================
// __unwind$559881
// EA  : 0x82A172A8
// RVA : 0x00A172A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559881()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 295));
}


// ========================================================================
// __unwind$559882
// EA  : 0x82A172D0
// RVA : 0x00A172D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559882()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 208));
}


// ========================================================================
// __unwind$559861
// EA  : 0x82A172F8
// RVA : 0x00A172F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559861()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 296));
}


// ========================================================================
// __unwind$559862
// EA  : 0x82A17320
// RVA : 0x00A17320
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559862()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 272));
}


// ========================================================================
// __unwind$559873
// EA  : 0x82A17348
// RVA : 0x00A17348
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559873()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 297));
}


// ========================================================================
// __unwind$559874
// EA  : 0x82A17370
// RVA : 0x00A17370
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559874()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 160));
}


// ========================================================================
// __unwind$559877
// EA  : 0x82A17398
// RVA : 0x00A17398
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559877()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 298));
}


// ========================================================================
// __unwind$559878
// EA  : 0x82A173C0
// RVA : 0x00A173C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559878()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 168));
}


// ========================================================================
// __unwind$559867
// EA  : 0x82A173E8
// RVA : 0x00A173E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559867()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 299));
}


// ========================================================================
// __unwind$559868
// EA  : 0x82A17410
// RVA : 0x00A17410
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559868()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 184));
}


// ========================================================================
// __unwind$559865
// EA  : 0x82A17438
// RVA : 0x00A17438
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559865()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 300));
}


// ========================================================================
// __unwind$559866
// EA  : 0x82A17460
// RVA : 0x00A17460
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559866()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 200));
}


// ========================================================================
// __unwind$559871
// EA  : 0x82A17488
// RVA : 0x00A17488
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559871()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 301));
}


// ========================================================================
// __unwind$559872
// EA  : 0x82A174B0
// RVA : 0x00A174B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559872()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 216));
}


// ========================================================================
// __unwind$559869
// EA  : 0x82A174D8
// RVA : 0x00A174D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559869()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 302));
}


// ========================================================================
// __unwind$559870
// EA  : 0x82A17500
// RVA : 0x00A17500
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559870()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 232));
}


// ========================================================================
// __unwind$559893
// EA  : 0x82A17528
// RVA : 0x00A17528
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559893()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 303));
}


// ========================================================================
// __unwind$559894
// EA  : 0x82A17550
// RVA : 0x00A17550
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559894()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 248));
}


// ========================================================================
// __unwind$559891
// EA  : 0x82A17578
// RVA : 0x00A17578
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559891()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 304));
}


// ========================================================================
// __unwind$559892
// EA  : 0x82A175A0
// RVA : 0x00A175A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559892()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 264));
}


// ========================================================================
// __unwind$559885_0
// EA  : 0x82A175C8
// RVA : 0x00A175C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559885_0()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 464 + 305));
}


// ========================================================================
// __unwind$559886
// EA  : 0x82A175F0
// RVA : 0x00A175F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_559886()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 464 + 280));
}


// ========================================================================
// ?UpdateAnimationControllers@idAI2@@UAA_NXZ
// EA  : 0x82A17620
// RVA : 0x00A17620
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::UpdateAnimationControllers(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idVec3 *BodyOrientation; // r3
  double z; // fp9
  double actorPerceptionRadius; // fp28
  idPhysics *Physics; // r3
  int v9; // r3
  float v10; // r7
  float v11; // r6
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  float *p_deferredAxis; // r11
  float v14; // r8
  float v15; // r6
  int valueInteger; // r11
  idRenderWorld *v17; // r26
  idAIOrientation *v18; // r3
  double v19; // fp7
  double v20; // fp6
  idRenderWorld *v21; // r26
  idAIOrientation *v22; // r3
  double v23; // fp8
  double v24; // fp7
  idRenderWorld *v25; // r3
  idRenderWorld *v26; // r3
  idRenderWorld *v27; // r26
  double v28; // fp26
  double v29; // fp25
  double v30; // fp24
  idAIOrientation *v31; // r3
  double v32; // fp7
  double v33; // fp6
  idRenderWorld *v34; // r26
  double v35; // fp29
  double v36; // fp26
  double v37; // fp25
  idAIOrientation *v38; // r3
  double v39; // fp11
  double v40; // fp13
  idRenderWorld *v41; // r26
  idAIOrientation *MoveOrientation; // r3
  double v43; // fp7
  double v44; // fp6
  idRenderWorld *v45; // r26
  idAIOrientation *v46; // r3
  double v47; // fp8
  double v48; // fp7
  idRenderWorld *v49; // r3
  idRenderWorld *v50; // r3
  idRenderWorld *v51; // r26
  double v52; // fp26
  double v53; // fp25
  double v54; // fp24
  idAIOrientation *v55; // r3
  double v56; // fp7
  double v57; // fp6
  idRenderWorld *v58; // r26
  double v59; // fp26
  double v60; // fp25
  double v61; // fp31
  idAIOrientation *v62; // r3
  double v63; // fp11
  double v64; // fp13
  idPhysics *v65; // r29
  idRenderWorld *v66; // r28
  float *v67; // r3
  double v68; // fp7
  double v69; // fp6
  double value; // fp29
  const idVec3 *v71; // r3
  idRotation *v72; // r3
  double v73; // fp29
  const idVec3 *v74; // r3
  idRotation *v75; // r3
  bool v76; // r5
  const idAnimator_TrackerBase *v77; // r29
  bool v78; // r5
  idTreeAnimator *v79; // r3
  float v80; // [sp+70h] [-210h] BYREF
  float v81; // [sp+74h] [-20Ch]
  float v82; // [sp+78h] [-208h]
  float v83; // [sp+7Ch] [-204h]
  float v84; // [sp+80h] [-200h] BYREF
  float v85; // [sp+84h] [-1FCh]
  float v86; // [sp+88h] [-1F8h]
  idPLogScope v87; // [sp+90h] [-1F0h] BYREF
  float v88[4]; // [sp+98h] [-1E8h] BYREF
  float v89[4]; // [sp+A8h] [-1D8h] BYREF
  float v90[4]; // [sp+B8h] [-1C8h] BYREF
  float v91[4]; // [sp+C8h] [-1B8h] BYREF
  float v92[4]; // [sp+D8h] [-1A8h] BYREF
  float v93[4]; // [sp+E8h] [-198h] BYREF
  float v94[4]; // [sp+F8h] [-188h] BYREF
  float v95[4]; // [sp+108h] [-178h] BYREF
  float v96[4]; // [sp+118h] [-168h] BYREF
  float v97[4]; // [sp+128h] [-158h] BYREF
  float v98[6]; // [sp+138h] [-148h] BYREF
  float v99[4]; // [sp+150h] [-130h] BYREF
  float v100[4]; // [sp+160h] [-120h] BYREF
  idVec3 v101[3]; // [sp+170h] [-110h] BYREF
  idRotation v102[2]; // [sp+198h] [-E8h] BYREF

  RD_EventBegin(name: "idAI2::UpdateAnimationControllers");
  LODWORD(v2) = "idAI2::UpdateAnimationControllers";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: &v87, pl: &pLog, gMask: v2, label: v3);
  if ( (unsigned __int8)Get_idCombatStage_useRelaxedChatterVO(ptr: this) != 0
    || (unsigned __int8)idAI2::ShouldDeadThink(this) != 0 )
  {
    idPLogScope::~idPLogScope(this: &v87);
    RD_EventEnd();
    return 0;
  }
  idLobbyBackend360::StartArbitration(pexcept: (_exception *)this);
  BodyOrientation = (idVec3 *)idAI2::GetBodyOrientation(this);
  this->actorVolatile.modelInfo.modelAxis.mat[0] = BodyOrientation[1];
  this->actorVolatile.modelInfo.modelAxis.mat[1].x = BodyOrientation[2].x;
  this->actorVolatile.modelInfo.modelAxis.mat[1].y = BodyOrientation[2].y;
  z = BodyOrientation[2].z;
  LODWORD(v83) = &BodyOrientation[1];
  this->actorVolatile.modelInfo.modelAxis.mat[1].z = z;
  this->actorVolatile.modelInfo.modelAxis.mat[2].x = BodyOrientation[3].x;
  LODWORD(v83) = &this->actorVolatile.modelInfo.modelAxis.mat[1];
  this->actorVolatile.modelInfo.modelAxis.mat[2].y = BodyOrientation[3].y;
  LODWORD(v83) = &this->actorVolatile.modelInfo.modelAxis.mat[2];
  this->actorVolatile.modelInfo.modelAxis.mat[2].z = BodyOrientation[3].z;
  actorPerceptionRadius = 64.0;
  if ( ai_debugOrientation.valueInteger > 0 )
  {
    Physics = idEntity::GetPhysics(this);
    v9 = (int)Physics->GetOrigin(this: Physics, a2: 0);
    v10 = *(float *)(v9 + 4);
    v11 = *(float *)(v9 + 8);
    v80 = *(float *)v9;
    v81 = v10;
    v82 = v11;
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    p_deferredAxis = (float *)&TreeAnimatorFromPresentable->deferredAxis;
    if ( !TreeAnimatorFromPresentable->useDeferredPosition )
      p_deferredAxis = (float *)&TreeAnimatorFromPresentable->g.axis;
    v14 = p_deferredAxis[7];
    v15 = p_deferredAxis[8];
    v84 = p_deferredAxis[6];
    valueInteger = ai_debugOrientation.valueInteger;
    v85 = v14;
    v86 = v15;
    if ( ai_debugOrientation.valueInteger == 1 || ai_debugOrientation.valueInteger >= 3 )
    {
      v17 = gameLocal->GetRenderWorld(this: gameLocal);
      v18 = idAI2::GetBodyOrientation(this);
      v19 = (float)(v18->axis.mat[0].y * (float)48.0);
      v20 = (float)(v18->axis.mat[0].x * (float)48.0);
      v94[2] = v82 + (float)(v18->axis.mat[0].z * (float)48.0);
      LODWORD(v83) = &v18->axis;
      v94[1] = v81 + (float)v19;
      v94[0] = v80 + (float)v20;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v17->DebugArrow)(
        a1: v17,
        a2: &idColor::colorYellow,
        a3: &v80,
        a4: v94,
        a5: 8.0);
      v21 = gameLocal->GetRenderWorld(this: gameLocal);
      v22 = idAI2::GetBodyOrientation(this);
      v23 = (float)(v22->idealDir.y * (float)64.0);
      v24 = (float)(v22->idealDir.x * (float)64.0);
      v96[2] = v82 + (float)(v22->idealDir.z * (float)64.0);
      v96[1] = v81 + (float)v23;
      v96[0] = (float)v24 + v80;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v21->DebugArrow)(
        a1: v21,
        a2: &idColor::colorGreen,
        a3: &v80,
        a4: v96,
        a5: 8.0);
      v25 = gameLocal->GetRenderWorld(this: gameLocal);
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v25->DebugCircle)(
        a1: v25,
        a2: &idColor::colorYellow,
        a3: &v80,
        a4: &v84,
        a5: 48.0);
      v26 = gameLocal->GetRenderWorld(this: gameLocal);
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v26->DebugCircle)(
        a1: v26,
        a2: &idColor::colorGreen,
        a3: &v80,
        a4: &v84,
        a5: 64.0);
      v27 = gameLocal->GetRenderWorld(this: gameLocal);
      v28 = (float)(v86 * (float)8.0);
      v29 = (float)(v85 * (float)8.0);
      v30 = (float)(v84 * (float)8.0);
      v31 = idAI2::GetBodyOrientation(this);
      v32 = (float)(v31->axis.mat[0].y * (float)48.0);
      v33 = (float)(v31->axis.mat[0].x * (float)48.0);
      v92[2] = (float)(v82 + (float)(v31->axis.mat[0].z * (float)48.0)) + (float)v28;
      LODWORD(v83) = &v31->axis;
      v92[1] = (float)(v81 + (float)v32) + (float)v29;
      v92[0] = (float)((float)v33 + v80) + (float)v30;
      ((void (__fastcall *)(idRenderWorld *, const char *, float *, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, _DWORD, _DWORD, double))v27->DebugText)(
        a1: v27,
        a2: "body::curr",
        a3: v92,
        a4: v27->DebugText,
        a5: &idColor::colorYellow,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 0.125);
      v34 = gameLocal->GetRenderWorld(this: gameLocal);
      v35 = (float)(v86 * (float)16.0);
      v36 = (float)(v85 * (float)16.0);
      v37 = (float)(v84 * (float)16.0);
      v38 = idAI2::GetBodyOrientation(this);
      v39 = (float)((float)(v38->idealDir.x * (float)64.0) + v80);
      v40 = (float)(v82 + (float)(v38->idealDir.z * (float)64.0));
      v98[1] = (float)(v81 + (float)(v38->idealDir.y * (float)64.0)) + (float)v36;
      v98[0] = (float)v39 + (float)v37;
      v98[2] = (float)v40 + (float)v35;
      ((void (__fastcall *)(idRenderWorld *, const char *, float *, idRenderWorld_vtbl *, idColor *, int, _DWORD, _DWORD, double))v34->DebugText)(
        a1: v34,
        a2: "body::ideal",
        a3: v98,
        a4: v34->__vftable,
        a5: &idColor::colorGreen,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 0.125);
      valueInteger = ai_debugOrientation.valueInteger;
    }
    if ( valueInteger >= 2 )
    {
      v41 = gameLocal->GetRenderWorld(this: gameLocal);
      MoveOrientation = idAI2::GetMoveOrientation(this);
      v43 = (float)(MoveOrientation->axis.mat[0].y * (float)16.0);
      v44 = (float)(MoveOrientation->axis.mat[0].x * (float)16.0);
      v89[2] = v82 + (float)(MoveOrientation->axis.mat[0].z * (float)16.0);
      LODWORD(v83) = &MoveOrientation->axis;
      v89[1] = v81 + (float)v43;
      v89[0] = (float)v44 + v80;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v41->DebugArrow)(
        a1: v41,
        a2: &idColor::colorOrange,
        a3: &v80,
        a4: v89,
        a5: 8.0);
      v45 = gameLocal->GetRenderWorld(this: gameLocal);
      v46 = idAI2::GetMoveOrientation(this);
      v47 = (float)(v46->idealDir.y * (float)32.0);
      v48 = (float)(v46->idealDir.x * (float)32.0);
      v95[2] = v82 + (float)(v46->idealDir.z * (float)32.0);
      v95[1] = v81 + (float)v47;
      v95[0] = (float)v48 + v80;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v45->DebugArrow)(
        a1: v45,
        a2: &idColor::colorRed,
        a3: &v80,
        a4: v95,
        a5: 8.0);
      v49 = gameLocal->GetRenderWorld(this: gameLocal);
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v49->DebugCircle)(
        a1: v49,
        a2: &idColor::colorOrange,
        a3: &v80,
        a4: &v84,
        a5: 16.0);
      v50 = gameLocal->GetRenderWorld(this: gameLocal);
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))v50->DebugCircle)(
        a1: v50,
        a2: &idColor::colorRed,
        a3: &v80,
        a4: &v84,
        a5: 32.0);
      v51 = gameLocal->GetRenderWorld(this: gameLocal);
      v52 = (float)(v86 * (float)8.0);
      v53 = (float)(v85 * (float)8.0);
      v54 = (float)(v84 * (float)8.0);
      v55 = idAI2::GetMoveOrientation(this);
      v56 = (float)(v55->axis.mat[0].z * (float)16.0);
      v57 = (float)(v55->axis.mat[0].y * (float)16.0);
      v97[0] = (float)((float)(v55->axis.mat[0].x * (float)16.0) + v80) + (float)v54;
      LODWORD(v83) = &v55->axis;
      v97[2] = (float)(v82 + (float)v56) + (float)v52;
      v97[1] = (float)(v81 + (float)v57) + (float)v53;
      ((void (__fastcall *)(idRenderWorld *, const char *, float *, idMat3 *, idColor *, int, _DWORD, _DWORD, double))v51->DebugText)(
        a1: v51,
        a2: "move::curr",
        a3: v97,
        a4: &v55->axis,
        a5: &idColor::colorOrange,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 0.125);
      v58 = gameLocal->GetRenderWorld(this: gameLocal);
      v59 = (float)(v86 * (float)16.0);
      v60 = (float)(v85 * (float)16.0);
      v61 = (float)(v84 * (float)16.0);
      v62 = idAI2::GetMoveOrientation(this);
      v63 = (float)(v82 + (float)(v62->idealDir.z * (float)32.0));
      v64 = (float)((float)(v62->idealDir.x * (float)32.0) + v80);
      v90[1] = (float)(v81 + (float)(v62->idealDir.y * (float)32.0)) + (float)v60;
      v90[2] = (float)v63 + (float)v59;
      v90[0] = (float)v64 + (float)v61;
      ((void (__fastcall *)(idRenderWorld *, const char *, float *, idRenderWorld_vtbl *, idColor *, int, _DWORD, _DWORD, double))v58->DebugText)(
        a1: v58,
        a2: "move::ideal",
        a3: v90,
        a4: v58->__vftable,
        a5: &idColor::colorRed,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 0.125);
      valueInteger = ai_debugOrientation.valueInteger;
    }
    if ( valueInteger == 4 )
    {
      v65 = idEntity::GetPhysics(this);
      v66 = gameLocal->GetRenderWorld(this: gameLocal);
      v67 = (float *)v65->GetGravityNormal(this: v65);
      v68 = (float)(v67[2] * (float)32.0);
      v69 = (float)(v67[1] * (float)32.0);
      v91[0] = (float)(*v67 * (float)32.0) + v80;
      v91[2] = v82 + (float)v68;
      v91[1] = v81 + (float)v69;
      v66->DebugLine(
        this: v66,
        a2: (const idVec4 *)&idColor::colorMagenta,
        a3: (const idVec3 *)&v80,
        a4: (const idVec3 *)v91,
        a5: 3000,
        a6: false);
    }
  }
  if ( ai_showFOV.valueInteger > 0 && idAI2::GetDebugLevel() >= 0 )
  {
    if ( ai_showFOV.valueInteger > 1 )
      actorPerceptionRadius = this->aiEditable.perception.actorPerceptionRadius;
    this->GetEyePos(this, a2: (idVec3 *)v88);
    this->GetEyeAxis(this, a2: (idMat3 *)v101);
    value = this->aiEditable.perception.fieldOfView.value;
    v71 = this->aiVolatile.physics.object.GetGravityNormal(this: &this->aiVolatile);
    v72 = idRotation::idRotation(
            this: (idRotation *)&v102[0].angle,
            rotationOrigin: &vec3_origin,
            rotationVec: v71,
            rotationAngle: (float)((float)value * (float)0.5));
    idRotation::operator*(this: v102, result: v72, v: v101);
    v73 = this->aiEditable.perception.fieldOfView.value;
    v74 = this->aiVolatile.physics.object.GetGravityNormal(this: &this->aiVolatile);
    v75 = idRotation::idRotation(
            this: (idRotation *)&v102[0].angle,
            rotationOrigin: &vec3_origin,
            rotationVec: v74,
            rotationAngle: (float)((float)v73 * (float)-0.5));
    idRotation::operator*(this: v102, result: v75, v: v101);
    v100[1] = 0.5;
    v83 = this->aiEditable.perception.fieldOfView.value;
    v100[3] = 1.0;
    v100[0] = 0.0;
    v100[2] = 1.0;
    ((void (__fastcall *)(idRenderWorld *, float *, float *, idVec3 *, double, double, double, double))clientGame->renderWorld->DebugArc)(
      a1: clientGame->renderWorld,
      a2: v100,
      a3: v88,
      a4: v101,
      a5: actorPerceptionRadius,
      a6: (float)(v83 * (float)-0.5),
      a7: (float)(v83 * (float)0.5),
      a8: 10.0);
    v99[3] = 1.0;
    v99[0] = 0.0;
    v99[2] = 1.0;
    v99[1] = 0.5;
    v93[1] = v88[1] + (float)(v101[0].y * (float)actorPerceptionRadius);
    v93[2] = v88[2] + (float)(v101[0].z * (float)actorPerceptionRadius);
    v93[0] = v88[0] + (float)(v101[0].x * (float)actorPerceptionRadius);
    ((void (__fastcall *)(idRenderWorld *, float *, float *, float *, double))clientGame->renderWorld->DebugArrow)(
      a1: clientGame->renderWorld,
      a2: v99,
      a3: v88,
      a4: v93,
      a5: 8.0);
  }
  if ( (ai_useAimTracker.flags & 0x20000) != 0 )
  {
    ai_useAimTracker.flags &= ~0x20000u;
    if ( ai_useAimTracker.valueInteger != 0 )
    {
      if ( !this->aiVolatile.focus.enableHeadTracking )
        goto LABEL_25;
      v76 = true;
    }
    else
    {
      v76 = false;
    }
    idFocusInfo::SetEnableTracking(this: this->aiVolatile.focus.foci.ptr, owner: this, enable: v76);
  }
LABEL_25:
  LODWORD(v83) = &this->aiVolatile.focus;
  idFocusInfo::Update(this: this->aiVolatile.focus.foci.ptr, owner: this, parentTracker: nullptr);
  v77 = this->aiVolatile.focus.foci.ptr[0].animators[this->aiVolatile.focus.foci.ptr[0].curAnimatorIndex];
  if ( (ai_useLookTracker.flags & 0x20000) != 0 )
  {
    ai_useLookTracker.flags &= ~0x20000u;
    if ( ai_useLookTracker.valueInteger == 0 )
    {
      v78 = false;
LABEL_30:
      idFocusInfo::SetEnableTracking(this: &this->aiVolatile.focus.foci.ptr[1], owner: this, enable: v78);
      goto LABEL_31;
    }
    if ( this->aiVolatile.focus.enableHeadTracking )
    {
      v78 = true;
      goto LABEL_30;
    }
  }
LABEL_31:
  idFocusInfo::Update(this: &this->aiVolatile.focus.foci.ptr[1], owner: this, parentTracker: v77);
  if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 1) != 0 )
  {
    v79 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    idFaceMgr::Update(
      this: &this->aiVolatile.faceMgr,
      owner: this,
      ta: v79,
      focusPoint: &this->aiVolatile.focus.foci.ptr[1].idealFocusPoint);
  }
  idPLogScope::~idPLogScope(this: &v87);
  RD_EventEnd();
  return 1;
}


// ========================================================================
// __unwind$560744
// EA  : 0x82A1821C
// RVA : 0x00A1821C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_560744()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 640 + 500));
}


// ========================================================================
// __unwind$560745_0
// EA  : 0x82A18244
// RVA : 0x00A18244
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_560745_0()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 640 + 144));
}


// ========================================================================
// ?PathPassesNear@idAI2@@QBA_NABVidVec3@@0HH0HM_N@Z
// EA  : 0x82A18278
// RVA : 0x00A18278
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::PathPassesNear(
        idAI2 *this,
        const idVec3 *startPoint,
        const idVec3 *goalPoint,
        int startAreaNum,
        int goalAreaNum,
        const idVec3 *testPoint,
        const int testAreaNum,
        double nearDist,
        const bool debug)
{
  unsigned __int64 v14; // r6
  const char *v15; // r7
  int *v16; // r10
  int i; // ctr
  idPLogScope v19[4]; // [sp+68h] [-1CC8h] BYREF
  int v20; // [sp+88h] [-1CA8h] BYREF
  int v21; // [sp+90h] [-1CA0h] BYREF

  RD_EventBegin(name: "idAI2::PathPassesNear");
  LODWORD(v14) = "idAI2::PathPassesNear";
  HIDWORD(v14) = 2;
  idPLogScope::idPLogScope(this: v19, pl: &pLog, gMask: v14, label: v15);
  v16 = &v20;
  for ( i = 128; i != 0; --i )
  {
    v16 += 6;
    *(_WORD *)v16 = -1;
  }
  ((void (__fastcall *)(const idAAS2 *, const idVec3 *, const idVec3 *, int, int, int, int *, int))this->aiVolatile.aas.aas->GetPath)(
    a1: this->aiVolatile.aas.aas,
    a2: startPoint,
    a3: goalPoint,
    a4: startAreaNum,
    a5: goalAreaNum,
    a6: this->aiVolatile.aas.travelFlags,
    a7: &v21,
    a8: 128);
  idPLogScope::~idPLogScope(this: v19);
  RD_EventEnd();
  return 0;
}


// ========================================================================
// __unwind$561423
// EA  : 0x82A18548
// RVA : 0x00A18548
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_561423()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 7472 + 7312));
}


// ========================================================================
// __unwind$561424
// EA  : 0x82A18570
// RVA : 0x00A18570
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_561424()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 7472 + 104));
}


// ========================================================================
// ?Update@idVisibilityObscurity@idAI2@@QAAXPBV2@@Z
// EA  : 0x82A185A0
// RVA : 0x00A185A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::idVisibilityObscurity::Update(idAI2::idVisibilityObscurity *this, idAI2 *ai)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  const idDeclAIBehavior *decl; // r29
  aiSenseState_t *EnemySenseState; // r3
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  float x; // r4
  float y; // r11
  const idAAS2 *(__fastcall *GetAAS)(struct idAI2 *); // ctr
  const idAAS2 *v12; // r3
  idAASPosition *AASPosition; // r3
  idAI2_vtbl *v14; // r9
  idAASPosition *v15; // r17
  const idVec3 *(__fastcall *GetEyeOffset)(struct idAI2 *, const idVec3 *); // r8
  idWeapon *v17; // r4
  idPhysics *Physics; // r3
  float *v19; // r3
  double v20; // fp10
  double v21; // fp0
  double v22; // fp7
  double v23; // fp30
  double v24; // fp29
  double v25; // fp28
  double sidestepDistance; // fp31
  idPhysics *v27; // r3
  idPresentable *presentable; // r11
  idPhysics *v29; // r28
  idPhysics_vtbl *v30; // r10
  double v31; // fp26
  double v32; // fp25
  double v33; // fp31
  float *v34; // r3
  const idDeclAIBehavior *v35; // r6
  double v36; // fp7
  double v37; // fp6
  double diveDistance; // fp31
  idPhysics *v39; // r3
  idPresentable *v40; // r11
  idPhysics *v41; // r28
  idPhysics_vtbl *v42; // r10
  double v43; // fp26
  double v44; // fp25
  double v45; // fp31
  float *v46; // r3
  const idDeclAIBehavior *v47; // r6
  double v48; // fp3
  double v49; // fp1
  double v50; // fp0
  double v51; // fp31
  idPhysics *v52; // r3
  idPresentable *v53; // r11
  idPhysics *v54; // r28
  idPhysics_vtbl *v55; // r10
  double v56; // fp26
  double v57; // fp25
  double v58; // fp31
  float *v59; // r3
  const idDeclAIBehavior *v60; // r6
  double v61; // fp10
  double v62; // fp6
  double v63; // fp31
  idPhysics *v64; // r3
  idPresentable *v65; // r11
  idPhysics *v66; // r28
  idPhysics_vtbl *v67; // r10
  double v68; // fp26
  double v69; // fp25
  double v70; // fp31
  float *v71; // r3
  const idDeclAIBehavior *v72; // r5
  double v73; // fp3
  double v74; // fp0
  double v75; // fp12
  double v76; // fp31
  idPhysics *v77; // r3
  idPresentable *v78; // r11
  idPhysics *v79; // r28
  idPhysics_vtbl *v80; // r10
  double v81; // fp30
  double v82; // fp29
  double v83; // fp31
  float *v84; // r3
  const idDeclAIBehavior *v85; // r6
  double v86; // fp6
  double v87; // fp4
  double v88; // fp3
  double v89; // fp31
  idPhysics *v90; // r3
  idPresentable *v91; // r11
  idPhysics *v92; // r29
  idPhysics_vtbl *v93; // r10
  double v94; // fp30
  double v95; // fp29
  double v96; // fp31
  float *v97; // r3
  double v98; // fp6
  double v99; // fp4
  double v100; // fp3
  const idSpawnId **v101; // r3
  const idSpawnId **v102; // r3
  const idSpawnId **v103; // r3
  const idSpawnId **v104; // r3
  const idSpawnId **v105; // r3
  const idSpawnId **v106; // r3
  const idSpawnId **v107; // r3
  idArray<enum idAI2::idVisibilityObscurity::obscurity_t,7> *p_visibilityObscurity; // r19
  _DWORD *v109; // r11
  int i; // ctr
  idEntityPtr<idEntity const > *p_currentEnemy; // r24
  idGameLocal *v112; // r11
  int value; // r9
  idEntity *v114; // r3
  const idEntity *v115; // r4
  idEntity *v116; // r3
  const idAIGameState *p_aiGameState; // r29
  const idSpawnId **v118; // r3
  idPhysics *v119; // r3
  idAAS2 *aas; // r29
  idPhysics *v121; // r16
  idAAS2_vtbl *v122; // r14
  unsigned int v123; // r15
  int AreaNum; // r3
  idPhysics_vtbl *v125; // r10
  int v126; // r3
  int v127; // r9
  idGameLocal *v128; // r11
  int v129; // r10
  idEntity *v130; // r3
  idEntity *v131; // r3
  const idEntity *v132; // r4
  const idAIGameState *v133; // r16
  const idSpawnId **v134; // r3
  idPhysics *v135; // r3
  idAAS2 *v136; // r16
  idPhysics *v137; // r15
  idAASPosition *v138; // r3
  idAAS2_vtbl *v139; // r14
  unsigned int v140; // r17
  int v141; // r3
  idPhysics_vtbl *v142; // r10
  int v143; // r3
  idAIGameState *v144; // r17
  const idEntity *Enemy; // r3
  const idSpawnId **v146; // r3
  bool v147; // r3
  idPhysics *v148; // r3
  idAAS2 *v149; // r16
  idPhysics *v150; // r15
  int travelFlags; // r14
  idAASPosition *v152; // r3
  idAAS2_vtbl *v153; // r17
  int v154; // r3
  idPhysics_vtbl *v155; // r11
  int v156; // r3
  int v157; // r9
  idGameLocal *v158; // r11
  int v159; // r10
  idEntity *v160; // r3
  idEntity *v161; // r3
  const idEntity *v162; // r4
  const idAIGameState *v163; // r17
  const idSpawnId **v164; // r3
  idPhysics *v165; // r17
  const idAAS2 *v166; // r15
  unsigned int v167; // r16
  idAAS2_vtbl *v168; // r14
  int v169; // r3
  idPhysics_vtbl *v170; // r9
  int v171; // r3
  idAIGameState *v172; // r29
  const idEntity *v173; // r3
  const idSpawnId **v174; // r3
  idPhysics *v175; // r3
  idAASPosition *v176; // r29
  idPhysics *v177; // r17
  const idAAS2 *v178; // r15
  unsigned int v179; // r16
  idAAS2_vtbl *v180; // r14
  int v181; // r3
  idPhysics_vtbl *v182; // r10
  int v183; // r3
  int v184; // r9
  idGameLocal *v185; // r11
  int v186; // r10
  idEntity *v187; // r3
  idEntity *v188; // r3
  const idEntity *v189; // r4
  const idAIGameState *v190; // r17
  const idSpawnId **v191; // r3
  idPhysics *v192; // r3
  idAAS2 *v193; // r17
  idPhysics *v194; // r16
  idAASPosition *v195; // r3
  idAAS2_vtbl *v196; // r15
  unsigned int v197; // r29
  int v198; // r14
  int v199; // r3
  int v200; // r9
  idGameLocal *v201; // r11
  int v202; // r10
  idEntity *v203; // r3
  idEntity *v204; // r3
  const idEntity *v205; // r4
  const idAIGameState *v206; // r29
  const idSpawnId **v207; // r3
  idColor *v208; // r4
  idColor *v209; // r4
  idPhysics *v210; // r3
  idRenderWorld *v211; // r24
  idRenderWorld_vtbl *v212; // r23
  int v213; // r3
  idAI2::idVisibilityObscurity::obscurity_t v214; // r11
  idColor *v215; // r4
  idPhysics *v216; // r3
  idRenderWorld *renderWorld; // r24
  idRenderWorld_vtbl *v218; // r23
  int v219; // r3
  idColor *v220; // r4
  idPhysics *v221; // r3
  idColor *v222; // r4
  idPhysics *v223; // r3
  idRenderWorld *v224; // r24
  idRenderWorld_vtbl *v225; // r23
  int v226; // r3
  void (*v227)(void); // ctr
  idPhysics *v228; // r3
  idRenderWorld_vtbl *v229; // r24
  void (*DebugLine)(void); // r11
  idPhysics *v231; // r3
  idRenderWorld_vtbl *v232; // r27
  idPhysics *v233; // r3
  idRenderWorld *v234; // r28
  idRenderWorld_vtbl *v235; // r27
  int v236; // r3
  const idVec4 *v237; // r4
  idPhysics *v238; // r3
  idRenderWorld *v239; // r28
  idRenderWorld_vtbl *v240; // r27
  int v241; // r5
  idPhysics *v242; // r3
  idRenderWorld *v243; // r30
  idRenderWorld_vtbl *v244; // r28
  int v245; // r3
  const idVec4 *v246; // r4
  idPhysics *v247; // r3
  idRenderWorld *v248; // r30
  idRenderWorld_vtbl *v249; // r29
  int v250; // r5
  idSpawnId v251; // [sp+60h] [-2F0h] BYREF
  idAASPosition *v252; // [sp+64h] [-2ECh]
  float v253; // [sp+68h] [-2E8h] BYREF
  float v254; // [sp+6Ch] [-2E4h]
  float v255; // [sp+70h] [-2E0h]
  idVec3 v256; // [sp+78h] [-2D8h] BYREF
  idVec3 v257; // [sp+88h] [-2C8h] BYREF
  idVec3 v258; // [sp+98h] [-2B8h] BYREF
  idVec3 v259; // [sp+A8h] [-2A8h] BYREF
  idVec3 v260; // [sp+B8h] [-298h] BYREF
  idVec3 v261; // [sp+C8h] [-288h] BYREF
  idVec3 v262; // [sp+D8h] [-278h] BYREF
  idPLogScope v263; // [sp+E8h] [-268h] BYREF
  idVec3 v264; // [sp+F0h] [-260h] BYREF
  idVec3 v265; // [sp+100h] [-250h] BYREF
  idVec3 v266; // [sp+110h] [-240h] BYREF
  idVec3 v267; // [sp+120h] [-230h] BYREF
  idVec3 v268; // [sp+130h] [-220h] BYREF
  idVec3 v269; // [sp+140h] [-210h] BYREF
  float v270[22]; // [sp+150h] [-200h] BYREF
  idVec3 v271; // [sp+1A8h] [-1A8h] BYREF
  idAI2::idVisibilityObscurity v272; // [sp+1B8h] [-198h] BYREF
  idMat3 v273[2]; // [sp+250h] [-100h] BYREF

  RD_EventBegin(name: "idAI2::idVisibilityObscurity::Update");
  LODWORD(v4) = "idAI2::idVisibilityObscurity::Update";
  HIDWORD(v4) = 6;
  idPLogScope::idPLogScope(this: &v263, pl: &pLog, gMask: v4, label: v5);
  decl = ai->aiEditable.behaviors.decl;
  EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this: ai, senseType: AISENSE_MAX);
  if ( EnemySenseState == nullptr )
    goto LABEL_127;
  ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: EnemySenseState);
  x = ConfirmedPhysicalSafe->eyePos.x;
  y = ConfirmedPhysicalSafe->eyePos.y;
  GetAAS = ai->GetAAS;
  v256.z = ConfirmedPhysicalSafe->eyePos.z;
  v256.x = x;
  v256.y = y;
  v256.z = -(float)((float)((float)(UNITS_PER_INCH_2 * (float)0.5) * (float)12.0) - v256.z);
  v12 = GetAAS(this: ai);
  AASPosition = (idAASPosition *)idActor::GetAASPosition(this: ai, aas: v12);
  v14 = ai->__vftable;
  v15 = AASPosition;
  memset(&v270[4], 0, 12);
  v270[0] = 0.0;
  v270[10] = 0.0;
  v270[1] = 0.0;
  v270[11] = 0.0;
  v270[2] = 0.0;
  memset(&v270[15], 0, 24);
  v270[3] = 0.0;
  v270[7] = 0.0;
  v270[8] = 0.0;
  v270[9] = 0.0;
  v270[12] = 0.0;
  v270[13] = 0.0;
  GetEyeOffset = v14->GetEyeOffset;
  v270[14] = 0.0;
  v252 = AASPosition;
  GetEyeOffset(this: (struct idAI2 *)&v253, result: (const idVec3 *)ai);
  v17 = ai->GetEquippedWeapon(this: ai);
  if ( v17 != nullptr && idAI2::GetMuzzlePoint(this: ai, weapon: v17, muzzlePos: &v271, muzzleAxis: v273) )
  {
    Physics = idEntity::GetPhysics(this: ai);
    v19 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v20 = (float)(v271.z - v19[2]);
    v21 = (float)(v271.y - v19[1]);
    v22 = (float)(v271.x - *v19);
    v255 = v271.z - v19[2];
    v253 = v22;
    v254 = v21;
    v255 = decl->muzzleTraceClearOffset + (float)v20;
  }
  v23 = v255;
  v24 = v254;
  v25 = v253;
  idAI2::idVisibilityObscurity::GetDestination(
    this: &v272,
    result: (idVec3 *)this,
    (idVec3 *)ai,
    obscurityTest: OBSCURITYTEST_MUZZLE_POS);
  sidestepDistance = ai->aiEditable.behaviors.decl->dodging.sidestepDistance;
  v258 = vec3_origin;
  v27 = idEntity::GetPhysics(this: ai);
  presentable = ai->presentable;
  v29 = v27;
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this: ai);
    presentable = ai->presentable;
  }
  v30 = v29->__vftable;
  v31 = (float)(presentable->axis.mat[1].z * (float)sidestepDistance);
  v32 = (float)(presentable->axis.mat[1].y * (float)sidestepDistance);
  v33 = (float)((float)sidestepDistance * presentable->axis.mat[1].x);
  v251.value = (int)&presentable->axis.mat[1];
  v34 = (float *)v30->GetOrigin(this: v29, a2: 0);
  v35 = ai->aiEditable.behaviors.decl;
  v36 = (float)(v34[1] + (float)v32);
  v37 = (float)(*v34 + (float)v33);
  v258.z = v34[2] + (float)v31;
  v258.x = v37;
  v258.y = v36;
  diveDistance = v35->dodging.diveDistance;
  v262 = vec3_origin;
  v39 = idEntity::GetPhysics(this: ai);
  v40 = ai->presentable;
  v41 = v39;
  if ( v40 == nullptr )
  {
    idEntity::InitPresentableInternal(this: ai);
    v40 = ai->presentable;
  }
  v42 = v41->__vftable;
  v43 = (float)(v40->axis.mat[1].z * (float)diveDistance);
  v44 = (float)(v40->axis.mat[1].y * (float)diveDistance);
  v45 = (float)((float)diveDistance * v40->axis.mat[1].x);
  v251.value = (int)&v40->axis.mat[1];
  v46 = (float *)v42->GetOrigin(this: v41, a2: 0);
  v47 = ai->aiEditable.behaviors.decl;
  v48 = (float)(v46[2] + (float)v43);
  v49 = (float)(v46[1] + (float)v44);
  v50 = (float)(*v46 + (float)v45);
  v266.z = v258.z + v255;
  v266.x = v258.x + v253;
  v266.y = v258.y + v254;
  v262.y = v49;
  v262.z = v48;
  v262.x = v50;
  v269.z = (float)v23 + (float)v48;
  v269.y = (float)v24 + (float)v49;
  v269.x = (float)v25 + (float)v50;
  v51 = v47->dodging.sidestepDistance;
  v257 = vec3_origin;
  v52 = idEntity::GetPhysics(this: ai);
  v53 = ai->presentable;
  v54 = v52;
  if ( v53 == nullptr )
  {
    idEntity::InitPresentableInternal(this: ai);
    v53 = ai->presentable;
  }
  v55 = v54->__vftable;
  v56 = (float)(v53->axis.mat[1].z * (float)v51);
  v57 = (float)(v53->axis.mat[1].y * (float)v51);
  v58 = (float)(v53->axis.mat[1].x * (float)v51);
  v251.value = (int)&v53->axis.mat[1];
  v59 = (float *)v55->GetOrigin(this: v54, a2: 0);
  v60 = ai->aiEditable.behaviors.decl;
  v61 = v59[1];
  v62 = (float)(*v59 - (float)v58);
  v257.z = v59[2] - (float)v56;
  v257.x = v62;
  v257.y = (float)v61 - (float)v57;
  v63 = v60->dodging.diveDistance;
  v261 = vec3_origin;
  v64 = idEntity::GetPhysics(this: ai);
  v65 = ai->presentable;
  v66 = v64;
  if ( v65 == nullptr )
  {
    idEntity::InitPresentableInternal(this: ai);
    v65 = ai->presentable;
  }
  v67 = v66->__vftable;
  v68 = (float)(v65->axis.mat[1].z * (float)v63);
  v69 = (float)(v65->axis.mat[1].y * (float)v63);
  v70 = (float)((float)v63 * v65->axis.mat[1].x);
  v251.value = (int)&v65->axis.mat[1];
  v71 = (float *)v67->GetOrigin(this: v66, a2: 0);
  v72 = ai->aiEditable.behaviors.decl;
  v73 = (float)(v71[2] - (float)v68);
  v74 = (float)(v71[1] - (float)v69);
  v75 = (float)(*v71 - (float)v70);
  v268.z = v257.z + v255;
  v268.x = v253 + v257.x;
  v268.y = v257.y + v254;
  v261.y = v74;
  v261.z = v73;
  v261.x = v75;
  v267.z = (float)v23 + (float)v73;
  v267.y = (float)v24 + (float)v74;
  v267.x = (float)v25 + (float)v75;
  v76 = v72->dodging.diveDistance;
  v259 = vec3_origin;
  v77 = idEntity::GetPhysics(this: ai);
  v78 = ai->presentable;
  v79 = v77;
  if ( v78 == nullptr )
  {
    idEntity::InitPresentableInternal(this: ai);
    v78 = ai->presentable;
  }
  v80 = v79->__vftable;
  v81 = (float)(v78->axis.mat[0].z * (float)v76);
  v82 = (float)(v78->axis.mat[0].y * (float)v76);
  v83 = (float)(v78->axis.mat[0].x * (float)v76);
  v251.value = (int)&v78->axis;
  v84 = (float *)v80->GetOrigin(this: v79, a2: 0);
  v85 = ai->aiEditable.behaviors.decl;
  v86 = (float)(v84[2] + (float)v81);
  v87 = (float)(v84[1] + (float)v82);
  v88 = (float)((float)v83 + *v84);
  v259.y = v84[1] + (float)v82;
  v259.z = v86;
  v259.x = v88;
  v264.z = (float)v86 + v255;
  v264.y = (float)v87 + v254;
  v264.x = (float)v88 + v253;
  v89 = v85->dodging.diveDistance;
  v260 = vec3_origin;
  v90 = idEntity::GetPhysics(this: ai);
  v91 = ai->presentable;
  v92 = v90;
  if ( v91 == nullptr )
  {
    idEntity::InitPresentableInternal(this: ai);
    v91 = ai->presentable;
  }
  v93 = v92->__vftable;
  v94 = (float)(v91->axis.mat[0].z * (float)v89);
  v95 = (float)(v91->axis.mat[0].y * (float)v89);
  v96 = (float)((float)v89 * v91->axis.mat[0].x);
  v251.value = (int)&v91->axis;
  v97 = (float *)v93->GetOrigin(this: v92, a2: 0);
  v98 = (float)(v97[2] - (float)v94);
  v99 = (float)(v97[1] - (float)v95);
  v100 = (float)(*v97 - (float)v96);
  v260.y = v97[1] - (float)v95;
  v260.z = v98;
  v260.x = v100;
  v265.z = (float)v98 + v255;
  v265.y = v254 + (float)v99;
  v265.x = v253 + (float)v100;
  if ( this->lastSubmitFrame == idAccolade::Count(this: &clientGame->gameTimeManager) - 1 )
  {
    p_visibilityObscurity = &this->visibilityObscurity;
    v109 = (_DWORD *)&this->clipQuery[6].index + 1;
    for ( i = 7; i != 0; --i )
      *++v109 = 0;
    p_currentEnemy = &ai->aiVolatile.memory.currentEnemy;
    v251.value = (int)&ai->aiVolatile.memory.currentEnemy;
    v112 = gameLocal;
    value = ai->aiVolatile.memory.currentEnemy.spawnId.value;
    if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
    {
      v114 = gameLocal->entities.ptr[value & 0x1FFF];
      if ( v114 != nullptr )
      {
        v116 = idEntity::CastTo(c: v114);
        v112 = gameLocal;
        v115 = v116;
      }
      else
      {
        v115 = nullptr;
      }
    }
    else
    {
      v115 = nullptr;
    }
    p_aiGameState = &v112->aiGameState;
    v118 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: v115);
    if ( (_cntlzw(
            idAIVisibility::TraceVisible_Resolve(
              gameState: p_aiGameState,
              destId: *v118,
              clipQuery: this->clipQuery,
              tr: (trace_t *)&v272.clipQuery[3]))
        & 0x20) != 0 )
    {
      if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
        p_visibilityObscurity->ptr[0] = OBSCURITY_PATH_OPEN_WITH_COVER;
      else
        p_visibilityObscurity->ptr[0] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
    }
    else
    {
      p_visibilityObscurity->ptr[0] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
    }
    if ( v15->aas == nullptr )
      goto LABEL_91;
    v119 = idEntity::GetPhysics(this: ai);
    aas = (idAAS2 *)v15->aas;
    v121 = v119;
    v122 = aas->__vftable;
    v123 = ai->aiVolatile.aas.travelFlags & 0xFE78FFFF;
    AreaNum = idAASPosition::GetAreaNum(this: v15);
    v125 = v121->__vftable;
    v251.value = AreaNum;
    v126 = (int)v125->GetOrigin(this: v121, a2: 0);
    ((void (__fastcall *)(idAAS2 *, float *, int, int, idVec3 *, unsigned int, _DWORD, int))v122->TraceFloor)(
      a1: aas,
      a2: v270,
      a3: v126,
      a4: v251.value,
      a5: &v258,
      a6: v123,
      a7: 0,
      a8: 1);
    if ( v270[0] < 1.0 )
    {
      this->visibilityObscurity.ptr[3] = OBSCURITY_PATH_BLOCKED;
    }
    else
    {
      v127 = p_currentEnemy->spawnId.value;
      v128 = gameLocal;
      v129 = p_currentEnemy->spawnId.value & 0x1FFF;
      v251.value = (int)&ai->aiVolatile.memory.currentEnemy;
      if ( gameLocal->spawnIds.ptr[v129] == v127 >> 13 && (v130 = gameLocal->entities.ptr[v129]) != nullptr )
      {
        v131 = idEntity::CastTo(c: v130);
        v128 = gameLocal;
        v132 = v131;
      }
      else
      {
        v132 = nullptr;
      }
      v133 = &v128->aiGameState;
      v134 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: v132);
      if ( (_cntlzw(
              idAIVisibility::TraceVisible_Resolve(
                gameState: v133,
                destId: *v134,
                clipQuery: &this->clipQuery[1],
                tr: (trace_t *)&v272.clipQuery[3]))
          & 0x20) != 0 )
      {
        if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
          this->visibilityObscurity.ptr[3] = OBSCURITY_PATH_OPEN_WITH_COVER;
        else
          this->visibilityObscurity.ptr[3] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
      }
      else
      {
        this->visibilityObscurity.ptr[3] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
      }
      v135 = idEntity::GetPhysics(this: ai);
      v136 = (idAAS2 *)v15->aas;
      v137 = v135;
      v138 = v15;
      v139 = v136->__vftable;
      v140 = ai->aiVolatile.aas.travelFlags & 0xFE78FFFF;
      v141 = idAASPosition::GetAreaNum(this: v138);
      v142 = v137->__vftable;
      v251.value = v141;
      v143 = (int)v142->GetOrigin(this: v137, a2: 0);
      ((void (__fastcall *)(idAAS2 *, float *, int, int, idVec3 *, unsigned int, _DWORD, int))v139->TraceFloor)(
        a1: v136,
        a2: v270,
        a3: v143,
        a4: v251.value,
        a5: &v262,
        a6: v140,
        a7: 0,
        a8: 1);
      if ( v270[0] >= 1.0 )
      {
        v144 = &gameLocal->aiGameState;
        Enemy = idAIMemory::GetEnemy(this: &ai->aiVolatile.memory);
        v146 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: Enemy);
        v147 = idAIVisibility::TraceVisible_Resolve(
                 gameState: v144,
                 destId: *v146,
                 clipQuery: &this->clipQuery[2],
                 tr: (trace_t *)&v272.clipQuery[3]);
        v15 = v252;
        if ( (_cntlzw(v147) & 0x20) != 0 )
        {
          if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
            this->visibilityObscurity.ptr[1] = OBSCURITY_PATH_OPEN_WITH_COVER;
          else
            this->visibilityObscurity.ptr[1] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
        }
        else
        {
          this->visibilityObscurity.ptr[1] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
        }
LABEL_51:
        v148 = idEntity::GetPhysics(this: ai);
        v149 = (idAAS2 *)v15->aas;
        v150 = v148;
        travelFlags = ai->aiVolatile.aas.travelFlags;
        v152 = v15;
        v153 = v149->__vftable;
        v154 = idAASPosition::GetAreaNum(this: v152);
        v155 = v150->__vftable;
        v251.value = v154;
        v156 = (int)v155->GetOrigin(this: v150, a2: 0);
        ((void (__fastcall *)(idAAS2 *, float *, int, int, idVec3 *, int, _DWORD, int))v153->TraceFloor)(
          a1: v149,
          a2: v270,
          a3: v156,
          a4: v251.value,
          a5: &v257,
          a6: travelFlags,
          a7: 0,
          a8: 1);
        if ( v270[0] < 1.0 )
        {
          this->visibilityObscurity.ptr[4] = OBSCURITY_PATH_BLOCKED;
        }
        else
        {
          v157 = p_currentEnemy->spawnId.value;
          v158 = gameLocal;
          v159 = p_currentEnemy->spawnId.value & 0x1FFF;
          v251.value = (int)&ai->aiVolatile.memory.currentEnemy;
          if ( gameLocal->spawnIds.ptr[v159] == v157 >> 13 && (v160 = gameLocal->entities.ptr[v159]) != nullptr )
          {
            v161 = idEntity::CastTo(c: v160);
            v158 = gameLocal;
            v162 = v161;
          }
          else
          {
            v162 = nullptr;
          }
          v163 = &v158->aiGameState;
          v164 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: v162);
          if ( (_cntlzw(
                  idAIVisibility::TraceVisible_Resolve(
                    gameState: v163,
                    destId: *v164,
                    clipQuery: &this->clipQuery[3],
                    tr: (trace_t *)&v272.clipQuery[3]))
              & 0x20) != 0 )
          {
            if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
              this->visibilityObscurity.ptr[4] = OBSCURITY_PATH_OPEN_WITH_COVER;
            else
              this->visibilityObscurity.ptr[4] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
          }
          else
          {
            this->visibilityObscurity.ptr[4] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
          }
          v165 = idEntity::GetPhysics(this: ai);
          v166 = v252->aas;
          v167 = ai->aiVolatile.aas.travelFlags & 0xFE78FFFF;
          v168 = v166->__vftable;
          v169 = idAASPosition::GetAreaNum(this: v252);
          v170 = v165->__vftable;
          v251.value = v169;
          v171 = (int)v170->GetOrigin(this: v165, a2: 0);
          ((void (__fastcall *)(const idAAS2 *, float *, int, int, idVec3 *, unsigned int, _DWORD, int))v168->TraceFloor)(
            a1: v166,
            a2: v270,
            a3: v171,
            a4: v251.value,
            a5: &v261,
            a6: v167,
            a7: 0,
            a8: 1);
          if ( v270[0] >= 1.0 )
          {
            v172 = &gameLocal->aiGameState;
            v173 = idAIMemory::GetEnemy(this: &ai->aiVolatile.memory);
            v174 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: v173);
            if ( (_cntlzw(
                    idAIVisibility::TraceVisible_Resolve(
                      gameState: v172,
                      destId: *v174,
                      clipQuery: &this->clipQuery[4],
                      tr: (trace_t *)&v272.clipQuery[3]))
                & 0x20) != 0 )
            {
              if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
                this->visibilityObscurity.ptr[2] = OBSCURITY_PATH_OPEN_WITH_COVER;
              else
                this->visibilityObscurity.ptr[2] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
            }
            else
            {
              this->visibilityObscurity.ptr[2] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
            }
            goto LABEL_69;
          }
        }
        this->visibilityObscurity.ptr[2] = OBSCURITY_PATH_BLOCKED;
LABEL_69:
        v175 = idEntity::GetPhysics(this: ai);
        v176 = v252;
        v177 = v175;
        v178 = v252->aas;
        v179 = ai->aiVolatile.aas.travelFlags & 0xFE78FFFF;
        v180 = v178->__vftable;
        v181 = idAASPosition::GetAreaNum(this: v252);
        v182 = v177->__vftable;
        v251.value = v181;
        v183 = (int)v182->GetOrigin(this: v177, a2: 0);
        ((void (__fastcall *)(const idAAS2 *, float *, int, int, idVec3 *, unsigned int, _DWORD, int))v180->TraceFloor)(
          a1: v178,
          a2: v270,
          a3: v183,
          a4: v251.value,
          a5: &v259,
          a6: v179,
          a7: 0,
          a8: 1);
        if ( v270[0] < 1.0 )
        {
          this->visibilityObscurity.ptr[5] = OBSCURITY_PATH_BLOCKED;
        }
        else
        {
          v184 = p_currentEnemy->spawnId.value;
          v185 = gameLocal;
          v186 = p_currentEnemy->spawnId.value & 0x1FFF;
          v251.value = (int)&ai->aiVolatile.memory.currentEnemy;
          if ( gameLocal->spawnIds.ptr[v186] == v184 >> 13 && (v187 = gameLocal->entities.ptr[v186]) != nullptr )
          {
            v188 = idEntity::CastTo(c: v187);
            v185 = gameLocal;
            v189 = v188;
          }
          else
          {
            v189 = nullptr;
          }
          v190 = &v185->aiGameState;
          v191 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: v189);
          if ( (_cntlzw(
                  idAIVisibility::TraceVisible_Resolve(
                    gameState: v190,
                    destId: *v191,
                    clipQuery: &this->clipQuery[5],
                    tr: (trace_t *)&v272.clipQuery[3]))
              & 0x20) != 0 )
          {
            if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
              this->visibilityObscurity.ptr[5] = OBSCURITY_PATH_OPEN_WITH_COVER;
            else
              this->visibilityObscurity.ptr[5] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
          }
          else
          {
            this->visibilityObscurity.ptr[5] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
          }
        }
        v192 = idEntity::GetPhysics(this: ai);
        v193 = (idAAS2 *)v176->aas;
        v194 = v192;
        v195 = v176;
        v196 = v193->__vftable;
        v197 = ai->aiVolatile.aas.travelFlags & 0xFE78FFFF;
        v198 = idAASPosition::GetAreaNum(this: v195);
        v199 = (int)v194->GetOrigin(this: v194, a2: 0);
        ((void (__fastcall *)(idAAS2 *, float *, int, int, idVec3 *, unsigned int, _DWORD, int))v196->TraceFloor)(
          a1: v193,
          a2: v270,
          a3: v199,
          a4: v198,
          a5: &v260,
          a6: v197,
          a7: 0,
          a8: 1);
        if ( v270[0] < 1.0 )
        {
          this->visibilityObscurity.ptr[6] = OBSCURITY_PATH_BLOCKED;
        }
        else
        {
          v200 = p_currentEnemy->spawnId.value;
          v201 = gameLocal;
          v202 = p_currentEnemy->spawnId.value & 0x1FFF;
          v251.value = (int)&ai->aiVolatile.memory.currentEnemy;
          if ( gameLocal->spawnIds.ptr[v202] == v200 >> 13 && (v203 = gameLocal->entities.ptr[v202]) != nullptr )
          {
            v204 = idEntity::CastTo(c: v203);
            v201 = gameLocal;
            v205 = v204;
          }
          else
          {
            v205 = nullptr;
          }
          v206 = &v201->aiGameState;
          v207 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: v205);
          if ( (_cntlzw(
                  idAIVisibility::TraceVisible_Resolve(
                    gameState: v206,
                    destId: *v207,
                    clipQuery: &this->clipQuery[6],
                    tr: (trace_t *)&v272.clipQuery[3]))
              & 0x20) != 0 )
          {
            if ( *(float *)&v272.clipQuery[3].index <= 0.5 )
              this->visibilityObscurity.ptr[6] = OBSCURITY_PATH_OPEN_WITH_COVER;
            else
              this->visibilityObscurity.ptr[6] = OBSCURITY_PATH_OPEN_WITH_OBSCURITY;
          }
          else
          {
            this->visibilityObscurity.ptr[6] = OBSCURITY_PATH_OPEN_AND_ENEMY_VISIBLE;
          }
        }
LABEL_91:
        this->valid = true;
        if ( ai_debugDodge.valueInteger >= 2 && ai_debugLevel.valueInteger > 0 )
        {
          if ( p_visibilityObscurity->ptr[0] > OBSCURITY_PATH_OPEN_WITH_OBSCURITY )
          {
            v208 = &idColor::colorOrange;
            if ( p_visibilityObscurity->ptr[0] != OBSCURITY_PATH_OPEN_WITH_COVER )
              v208 = &idColor::colorGreen;
          }
          else
          {
            v208 = &idColor::colorYellow;
          }
          clientGame->renderWorld->DebugLine(
            this: clientGame->renderWorld,
            a2: (const idVec4 *)v208,
            a3: (const idVec3 *)&v272,
            a4: &v256,
            a5: 1500,
            a6: true);
          v251.value = this->visibilityObscurity.ptr[3];
          if ( v251.value <= 1 )
          {
            v221 = idEntity::GetPhysics(this: ai);
            renderWorld = clientGame->renderWorld;
            v218 = renderWorld->__vftable;
            v219 = (int)v221->GetOrigin(this: v221, a2: 0);
            v220 = &idColor::colorRed;
          }
          else
          {
            if ( v251.value > 2 )
            {
              v209 = &idColor::colorOrange;
              if ( v251.value != 3 )
                v209 = &idColor::colorGreen;
            }
            else
            {
              v209 = &idColor::colorYellow;
            }
            clientGame->renderWorld->DebugLine(
              this: clientGame->renderWorld,
              a2: (const idVec4 *)v209,
              a3: &v266,
              a4: &v256,
              a5: 1500,
              a6: true);
            if ( this->visibilityObscurity.ptr[1] > OBSCURITY_PATH_BLOCKED )
            {
              v210 = idEntity::GetPhysics(this: ai);
              v211 = clientGame->renderWorld;
              v212 = v211->__vftable;
              v213 = (int)v210->GetOrigin(this: v210, a2: 0);
              v212->DebugLine(
                this: v211,
                a2: (const idVec4 *)&idColor::colorGreen,
                a3: (const idVec3 *)v213,
                a4: &v262,
                a5: 1500,
                a6: true);
              v214 = this->visibilityObscurity.ptr[1];
              if ( v214 > OBSCURITY_PATH_OPEN_WITH_OBSCURITY )
              {
                v215 = &idColor::colorOrange;
                if ( v214 != OBSCURITY_PATH_OPEN_WITH_COVER )
                  v215 = &idColor::colorGreen;
              }
              else
              {
                v215 = &idColor::colorYellow;
              }
              clientGame->renderWorld->DebugLine(
                this: clientGame->renderWorld,
                a2: (const idVec4 *)v215,
                a3: &v269,
                a4: &v256,
                a5: 1500,
                a6: true);
LABEL_111:
              v251.value = this->visibilityObscurity.ptr[4];
              if ( v251.value <= 1 )
              {
                v231 = idEntity::GetPhysics(this: ai);
                v232 = clientGame->renderWorld->__vftable;
                v231->GetOrigin(this: v231, a2: 0);
                DebugLine = (void (*)(void))v232->DebugLine;
              }
              else
              {
                if ( v251.value > 2 )
                {
                  v222 = &idColor::colorOrange;
                  if ( v251.value != 3 )
                    v222 = &idColor::colorGreen;
                }
                else
                {
                  v222 = &idColor::colorYellow;
                }
                clientGame->renderWorld->DebugLine(
                  this: clientGame->renderWorld,
                  a2: (const idVec4 *)v222,
                  a3: &v268,
                  a4: &v256,
                  a5: 1500,
                  a6: true);
                if ( this->visibilityObscurity.ptr[2] > OBSCURITY_PATH_BLOCKED )
                {
                  v223 = idEntity::GetPhysics(this: ai);
                  v224 = clientGame->renderWorld;
                  v225 = v224->__vftable;
                  v226 = (int)v223->GetOrigin(this: v223, a2: 0);
                  v225->DebugLine(
                    this: v224,
                    a2: (const idVec4 *)&idColor::colorGreen,
                    a3: (const idVec3 *)v226,
                    a4: &v261,
                    a5: 1500,
                    a6: true);
                  v227 = (void (*)(void))clientGame->renderWorld->DebugLine;
LABEL_121:
                  v227();
                  if ( this->visibilityObscurity.ptr[5] <= OBSCURITY_PATH_BLOCKED )
                  {
                    v238 = idEntity::GetPhysics(this: ai);
                    v239 = clientGame->renderWorld;
                    v240 = v239->__vftable;
                    v241 = (int)v238->GetOrigin(this: v238, a2: 0);
                    v240->DebugLine(
                      this: v239,
                      a2: (const idVec4 *)&idColor::colorRed,
                      a3: (const idVec3 *)v241,
                      a4: &v259,
                      a5: 1500,
                      a6: true);
                  }
                  else
                  {
                    v233 = idEntity::GetPhysics(this: ai);
                    v234 = clientGame->renderWorld;
                    v235 = v234->__vftable;
                    v236 = (int)v233->GetOrigin(this: v233, a2: 0);
                    v235->DebugLine(
                      this: v234,
                      a2: (const idVec4 *)&idColor::colorGreen,
                      a3: (const idVec3 *)v236,
                      a4: &v259,
                      a5: 1500,
                      a6: true);
                    v237 = (const idVec4 *)idAI2::idVisibilityObscurity::DebugColor(
                                             this,
                                             test: OBSCURITYTEST_FULL_HEIGHT_FORWARD);
                    clientGame->renderWorld->DebugLine(
                      this: clientGame->renderWorld,
                      a2: v237,
                      a3: &v264,
                      a4: &v256,
                      a5: 1500,
                      a6: true);
                  }
                  if ( this->visibilityObscurity.ptr[6] <= OBSCURITY_PATH_BLOCKED )
                  {
                    v247 = idEntity::GetPhysics(this: ai);
                    v248 = clientGame->renderWorld;
                    v249 = v248->__vftable;
                    v250 = (int)v247->GetOrigin(this: v247, a2: 0);
                    v249->DebugLine(
                      this: v248,
                      a2: (const idVec4 *)&idColor::colorRed,
                      a3: (const idVec3 *)v250,
                      a4: &v260,
                      a5: 1500,
                      a6: true);
                  }
                  else
                  {
                    v242 = idEntity::GetPhysics(this: ai);
                    v243 = clientGame->renderWorld;
                    v244 = v243->__vftable;
                    v245 = (int)v242->GetOrigin(this: v242, a2: 0);
                    v244->DebugLine(
                      this: v243,
                      a2: (const idVec4 *)&idColor::colorGreen,
                      a3: (const idVec3 *)v245,
                      a4: &v260,
                      a5: 1500,
                      a6: true);
                    v246 = (const idVec4 *)idAI2::idVisibilityObscurity::DebugColor(
                                             this,
                                             test: OBSCURITYTEST_FULL_HEIGHT_BACK);
                    clientGame->renderWorld->DebugLine(
                      this: clientGame->renderWorld,
                      a2: v246,
                      a3: &v265,
                      a4: &v256,
                      a5: 1500,
                      a6: true);
                  }
                  goto LABEL_127;
                }
                v228 = idEntity::GetPhysics(this: ai);
                v229 = clientGame->renderWorld->__vftable;
                v228->GetOrigin(this: v228, a2: 0);
                DebugLine = (void (*)(void))v229->DebugLine;
              }
              v227 = DebugLine;
              goto LABEL_121;
            }
            v216 = idEntity::GetPhysics(this: ai);
            renderWorld = clientGame->renderWorld;
            v218 = renderWorld->__vftable;
            v219 = (int)v216->GetOrigin(this: v216, a2: 0);
            v220 = &idColor::colorYellow;
          }
          v218->DebugLine(
            this: renderWorld,
            a2: (const idVec4 *)v220,
            a3: (const idVec3 *)v219,
            a4: &v258,
            a5: 1500,
            a6: true);
          goto LABEL_111;
        }
LABEL_127:
        idPLogScope::~idPLogScope(this: &v263);
        goto LABEL_128;
      }
      v15 = v252;
    }
    this->visibilityObscurity.ptr[1] = OBSCURITY_PATH_BLOCKED;
    goto LABEL_51;
  }
  this->lastSubmitFrame = idAccolade::Count(this: &clientGame->gameTimeManager);
  v101 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: (const idVec3 *)&v272,
    toPoint: &v256,
    ignoreId: *v101,
    seeThroughBreakables: false,
    clipQuery: this->clipQuery);
  v102 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: &v266,
    toPoint: &v256,
    ignoreId: *v102,
    seeThroughBreakables: false,
    clipQuery: &this->clipQuery[1]);
  v103 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: &v269,
    toPoint: &v256,
    ignoreId: *v103,
    seeThroughBreakables: false,
    clipQuery: &this->clipQuery[2]);
  v104 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: &v268,
    toPoint: &v256,
    ignoreId: *v104,
    seeThroughBreakables: false,
    clipQuery: &this->clipQuery[3]);
  v105 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: &v267,
    toPoint: &v256,
    ignoreId: *v105,
    seeThroughBreakables: false,
    clipQuery: &this->clipQuery[4]);
  v106 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: &v264,
    toPoint: &v256,
    ignoreId: *v106,
    seeThroughBreakables: false,
    clipQuery: &this->clipQuery[5]);
  v107 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v251, ent: ai);
  idAIVisibility::TraceVisible_Submit(
    fromPoint: &v265,
    toPoint: &v256,
    ignoreId: *v107,
    seeThroughBreakables: false,
    clipQuery: &this->clipQuery[6]);
  idPLogScope::~idPLogScope(this: &v263);
LABEL_128:
  RD_EventEnd();
}


// ========================================================================
// __unwind$561591
// EA  : 0x82A19AC8
// RVA : 0x00A19AC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_561591()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 848 + 628));
}


// ========================================================================
// __unwind$561592
// EA  : 0x82A19AF0
// RVA : 0x00A19AF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_561592()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 848 + 232));
}


// ========================================================================
// ?TestFireWeapon@idAI2@@QAA_NPAVidWeapon@@AAVidFireParms@@AAVidTestFireResults@@ABUtestFireWeaponParms_t@@@Z
// EA  : 0x82A19B20
// RVA : 0x00A19B20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::TestFireWeapon(
        idAI2 *this,
        idWeapon *weapon,
        idFireParms *fp,
        idTestFireResults *tfr,
        const testFireWeaponParms_t *testParms)
{
  unsigned __int64 v10; // r6
  const char *v11; // r7
  int v12; // r29
  char v13; // r9
  unsigned __int64 v14; // r6
  const char *v15; // r7
  float y; // r9
  float z; // r8
  double v18; // fp24
  double aimDot; // fp25
  double v20; // fp31
  double v21; // fp30
  double v22; // fp29
  double v23; // fp28
  double v24; // fp27
  double x; // fp26
  double v26; // fp11
  double v27; // fp12
  idPhysics *Physics; // r3
  int v29; // r3
  aiAccuracy_t EffectiveAccuracy; // r3
  idPresentable *presentable; // r4
  idVec3 *v32; // r26
  idVec3 *v33; // r30
  const char *v35; // r4
  idAI2 *v36; // r3
  idVec3 *p_start; // r26
  idVec3 *p_endpos; // r30
  const char *v39; // [sp+8h] [-218h]
  int v40; // [sp+Ch] [-214h]
  int v41; // [sp+10h] [-210h]
  int v42; // [sp+14h] [-20Ch]
  int v43; // [sp+18h] [-208h]
  int v44; // [sp+1Ch] [-204h]
  int v45; // [sp+20h] [-200h]
  int v46; // [sp+24h] [-1FCh]
  int v47; // [sp+28h] [-1F8h]
  int v48; // [sp+2Ch] [-1F4h]
  int v49; // [sp+30h] [-1F0h]
  int v50; // [sp+34h] [-1ECh]
  int v51; // [sp+38h] [-1E8h]
  int v52; // [sp+3Ch] [-1E4h]
  int v53; // [sp+40h] [-1E0h]
  int v54; // [sp+44h] [-1DCh]
  int v55; // [sp+48h] [-1D8h]
  int v56; // [sp+4Ch] [-1D4h]
  int v57; // [sp+50h] [-1D0h]
  idPLogScope v58; // [sp+60h] [-1C0h] BYREF
  float v59; // [sp+68h] [-1B8h]
  idVec3 v60; // [sp+70h] [-1B0h] BYREF
  idPLogScope v61[2]; // [sp+80h] [-1A0h] BYREF
  idMat3 v62; // [sp+90h] [-190h] BYREF
  idVec3 v63[2]; // [sp+B8h] [-168h] BYREF
  idMat3 v64; // [sp+D0h] [-150h] BYREF
  trace_t v65; // [sp+100h] [-120h] BYREF

  RD_EventBegin(name: "idAI2::TestFireWeapon");
  LODWORD(v10) = "idAI2::TestFireWeapon";
  HIDWORD(v10) = 6;
  idPLogScope::idPLogScope(this: v61, pl: &pLog, gMask: v10, label: v11);
  idFireParms::Clear(this: fp);
  v12 = 0;
  tfr->numTraces = 0;
  v13 = (32 * testParms->freeAmmo) & 0x20 | *((_BYTE *)fp + 128) & 0xDF;
  fp->weapon = weapon;
  *((_BYTE *)fp + 128) = v13;
  if ( weapon->triggerState == TRIGGERSTATE_RELEASED )
  {
    idAI2::AimDebug(this, text: "TR", level: 1);
    idPLogScope::~idPLogScope(this: v61);
LABEL_40:
    RD_EventEnd();
    return 0;
  }
  if ( !idAI2::GetMuzzlePoint(this, weapon, muzzlePos: &v60, muzzleAxis: &v64) )
  {
    idLib::Warning(fmt: "idAI2::TestFireWeapon - could not determine weapon muzzle point.");
    idPLogScope::~idPLogScope(this: v61);
    goto LABEL_40;
  }
  v60.x = v60.x - (float)(v64.mat[0].x * (float)50.0);
  v60.z = v60.z - (float)(v64.mat[0].z * (float)50.0);
  v60.y = v60.y - (float)(v64.mat[0].y * (float)50.0);
  RD_EventBegin(name: "idAI2::TestFireWeapon - solid check");
  LODWORD(v14) = "idAI2::TestFireWeapon - solid check";
  HIDWORD(v14) = 6;
  idPLogScope::idPLogScope(this: &v58, pl: &pLog, gMask: v14, label: v15);
  idClip::Contents(
    this: (idClip *)v63,
    result: &clientGame->clip,
    a3: &v65,
    start: &v60,
    clipModel: nullptr,
    startAxis: &mat3_identity,
    clipMask: 1,
    passEntityNumber: 0x1FFF,
    userName: v39,
    a10: v40,
    a11: v41,
    a12: v42,
    a13: v43,
    a14: v44,
    a15: v45,
    a16: v46,
    a17: v47,
    a18: v48,
    a19: v49,
    a20: v50,
    a21: v51,
    a22: v52,
    a23: v53,
    a24: v54,
    a25: v55,
    a26: v56,
    a27: v57,
    a28: 0);
  if ( (v65.c.contentFlags & 1) != 0 )
  {
    idAI2::AimDebug(this, text: "muzzle in solid", level: 1);
    idPLogScope::~idPLogScope(this: &v58);
    RD_EventEnd();
    idPLogScope::~idPLogScope(this: v61);
    goto LABEL_40;
  }
  idPLogScope::~idPLogScope(this: &v58);
  RD_EventEnd();
  y = this->aiVolatile.focus.foci.ptr[0].curFocusPoint.y;
  z = this->aiVolatile.focus.foci.ptr[0].curFocusPoint.z;
  v58.logIndex = LODWORD(this->aiVolatile.focus.foci.ptr[0].curFocusPoint.x);
  *(float *)&v58.pLog = y;
  v59 = z;
  v18 = v64.mat[2].z;
  aimDot = this->aiEditable.actionSettings.fire.aimDot;
  if ( v64.mat[2].z < 0.0 )
    aimDot = this->aiEditable.actionSettings.fire.aimDotUpsideDown;
  if ( this->aiVolatile.memory.enableGangstaPose )
    aimDot = this->aiEditable.actionSettings.fire.gangstaAimDot;
  v20 = (float)(v59 - v60.z);
  v21 = (float)(*(float *)&v58.pLog - v60.y);
  v22 = (float)(*(float *)&v58.logIndex - v60.x);
  v63[0].z = v59 - v60.z;
  v63[0].y = *(float *)&v58.pLog - v60.y;
  v63[0].x = *(float *)&v58.logIndex - v60.x;
  *(float *)&v58.logIndex = v63[0].y;
  idVec3::NormalizeFast(this: v63);
  v23 = v63[0].y;
  v24 = v63[0].z;
  x = v63[0].x;
  v26 = (float)((float)(v64.mat[0].x * v63[0].x)
              + (float)((float)(v64.mat[0].z * v63[0].z) + (float)(v64.mat[0].y * v63[0].y)));
  if ( testParms->useMuzzleDirForFireAxis )
  {
    if ( v26 < aimDot )
    {
LABEL_13:
      idAI2::AimDebug(this, text: "muzzle direction", level: 1);
      idPLogScope::~idPLogScope(this: v61);
      goto LABEL_40;
    }
    v62.mat[0].x = v64.mat[0].x;
    v62.mat[0].y = v64.mat[0].y;
    v62.mat[0].z = v64.mat[0].z;
    v62.mat[1].x = v64.mat[1].x;
    v62.mat[1].y = v64.mat[1].y;
    v62.mat[1].z = v64.mat[1].z;
    v62.mat[2].x = v64.mat[2].x;
    v62.mat[2].y = v64.mat[2].y;
    v62.mat[2].z = v18;
  }
  else
  {
    v27 = (float)(testParms->alwaysAimingDistance * testParms->alwaysAimingDistance);
    *(float *)&v58.logIndex = v21;
    if ( (float)((float)((float)v20 * (float)v20)
               + (float)((float)((float)v22 * (float)v22) + (float)((float)v21 * (float)v21))) > v27
      && v26 < aimDot )
    {
      goto LABEL_13;
    }
    Physics = idEntity::GetPhysics(this);
    v29 = (int)Physics->GetAxis(this: Physics, a2: 0);
    v58.logIndex = v29 + 12;
    v62.mat[0].x = *(float *)v29;
    v58.logIndex = v29 + 24;
    v62.mat[0].y = *(float *)(v29 + 4);
    v62.mat[0].z = *(float *)(v29 + 8);
    v62.mat[1] = *(idVec3 *)(v29 + 12);
    v62.mat[2] = *(idVec3 *)(v29 + 24);
    v62.mat[0].x = x;
    v62.mat[0].y = v23;
    v62.mat[0].z = v24;
    idMat3::OrthoNormalizeSelf(this: &v62);
  }
  if ( testParms->useWeaponSpread )
  {
    EffectiveAccuracy = idAI2::GetEffectiveAccuracy(this);
    idWeapon::AddSpreadToFireAxis(this: weapon, inAxis: &v62, accuracy: EffectiveAccuracy, outAxis: &v62);
  }
  presentable = this->presentable;
  if ( ai_useDeferredFiring.valueInteger != 0 )
  {
    if ( presentable == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      presentable = this->presentable;
    }
    idWeapon::DeferredFire(
      this: weapon,
      attacker: presentable,
      target: nullptr,
      start: &v60,
      fireAxis: &v62,
      fp,
      secondaryAmmo: false);
    if ( ai_debugAim.valueInteger >= 3 && idAI2::GetDebugLevel() > 0 && tfr->numTraces > 0 )
    {
      p_start = &fp->start;
      p_endpos = &tfr->traces[0].endpos;
      do
      {
        clientGame->renderWorld->DebugLine(
          this: clientGame->renderWorld,
          a2: (const idVec4 *)&idColor::colorYellow,
          a3: p_start,
          a4: p_endpos,
          a5: 1000,
          a6: true);
        ++v12;
        p_endpos = (idVec3 *)((char *)p_endpos + 128);
      }
      while ( v12 < tfr->numTraces );
    }
    v35 = "TestFire passed deferred fire submitted";
    v36 = this;
    goto LABEL_39;
  }
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
  }
  if ( !idWeapon::TestFire(
          this: weapon,
          attacker: presentable,
          target: nullptr,
          start: &v60,
          fireAxis: &v62,
          fp,
          tfr,
          secondaryAmmo: false) )
  {
    v35 = "TestFire failed";
    v36 = this;
LABEL_39:
    idAI2::AimDebug(this: v36, text: v35, level: 1);
    idPLogScope::~idPLogScope(this: v61);
    goto LABEL_40;
  }
  if ( ai_debugAim.valueInteger >= 3 && idAI2::GetDebugLevel() > 0 && tfr->numTraces > 0 )
  {
    v32 = &fp->start;
    v33 = &tfr->traces[0].endpos;
    do
    {
      clientGame->renderWorld->DebugLine(
        this: clientGame->renderWorld,
        a2: (const idVec4 *)&idColor::colorYellow,
        a3: v32,
        a4: v33,
        a5: 1000,
        a6: true);
      ++v12;
      v33 = (idVec3 *)((char *)v33 + 128);
    }
    while ( v12 < tfr->numTraces );
  }
  idPLogScope::~idPLogScope(this: v61);
  RD_EventEnd();
  return 1;
}


// ========================================================================
// __unwind$565437
// EA  : 0x82A1A0E0
// RVA : 0x00A1A0E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565437()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 544 + 384));
}


// ========================================================================
// __unwind$565438
// EA  : 0x82A1A108
// RVA : 0x00A1A108
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565438()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 544 + 128));
}


// ========================================================================
// __unwind$565439
// EA  : 0x82A1A130
// RVA : 0x00A1A130
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565439()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 544 + 385));
}


// ========================================================================
// __unwind$565440
// EA  : 0x82A1A158
// RVA : 0x00A1A158
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565440()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 544 + 96));
}


// ========================================================================
// ?TestForBlockedTrace@idAI2@@QBAPBVidEntity@@ABVidFireParms@@ABVidTestFireResults@@AAHABUtestForBlockedTraceParms_t@@@Z
// EA  : 0x82A1A188
// RVA : 0x00A1A188
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idProp_Breakable *__fastcall idAI2::TestForBlockedTrace(
        idAI2 *this,
        const idFireParms *fp,
        const idTestFireResults *tfr,
        int *outNumBlocked,
        const testForBlockedTraceParms_t *testParms)
{
  unsigned __int64 v10; // r6
  const char *v11; // r7
  float z; // r8
  double y; // fp0
  float v14; // r7
  double x; // fp13
  double v16; // fp12
  idAI2_vtbl *v17; // r6
  const idDeclAIBehavior *decl; // r19
  double v19; // fp31
  idProp_Breakable *v20; // r17
  idFaction *v21; // r18
  int v22; // r22
  trace_t *traces; // r26
  int v24; // r8
  idProp_Breakable *v25; // r30
  idProp_Breakable *v26; // r29
  idDamageableEntity *v27; // r3
  idPlayer *v28; // r3
  idPlayer *v29; // r30
  int entityNumber; // r30
  double v31; // fp0
  idPLog *pLog; // r29
  idPLog::logEntry_t *v33; // r30
  int v34; // r3
  __int64 totalTicks; // r11
  __int64 v36; // r9
  idPLogScope v38; // [sp+50h] [-C0h] BYREF
  float v39; // [sp+58h] [-B8h]
  float v40; // [sp+5Ch] [-B4h]
  float v41; // [sp+60h] [-B0h]
  idVec3 v42; // [sp+68h] [-A8h] BYREF

  RD_EventBegin(name: "idAI2::TestForBlockedTrace");
  LODWORD(v10) = "idAI2::TestForBlockedTrace";
  HIDWORD(v10) = 6;
  idPLogScope::idPLogScope(this: &v38, pl: &::pLog, gMask: v10, label: v11);
  z = this->aiVolatile.focus.foci.ptr[0].curFocusPoint.z;
  y = fp->start.y;
  v14 = this->aiVolatile.focus.foci.ptr[0].curFocusPoint.y;
  x = fp->start.x;
  v16 = fp->start.z;
  v17 = this->__vftable;
  decl = this->aiEditable.behaviors.decl;
  v39 = this->aiVolatile.focus.foci.ptr[0].curFocusPoint.x;
  v41 = z;
  v40 = v14;
  v19 = __fsqrts((float)((float)((float)(z - (float)v16) * (float)(z - (float)v16))
                       + (float)((float)((float)(v39 - (float)x) * (float)(v39 - (float)x))
                               + (float)((float)(v14 - (float)y) * (float)(v14 - (float)y)))));
  v20 = nullptr;
  v21 = (idFaction *)v17->GetFaction_2(this);
  *outNumBlocked = 0;
  v22 = 0;
  if ( tfr->numTraces <= 0 )
    goto LABEL_23;
  traces = tfr->traces;
  while ( 1 )
  {
    if ( traces->fraction < 1.0 )
    {
      v24 = 4 * (traces->c.entityNum + 21563);
      v25 = *(idProp_Breakable **)((char *)&gameLocal->__vftable + v24);
      if ( v25 != nullptr )
        break;
    }
LABEL_19:
    ++v22;
    ++traces;
    if ( v22 >= tfr->numTraces )
      goto LABEL_23;
  }
  if ( idFaction::GetAttitudeTowards(this: v21, otherEnt: *(const idEntity **)((char *)&gameLocal->__vftable + v24)) < decl->friendlyFireThreshold )
  {
    v26 = idProp_Breakable::CastTo(c: v25);
    v27 = idDamageableEntity::CastTo(c: (idDamageableEntity *)v25);
    if ( (v26 == nullptr && v27 == nullptr || traces->fraction <= (double)testParms->blockOnBreakableFraction)
      && (idPresentablePtr<idPresentableProjectile>::operator->(this: &fp->target) == nullptr
       || idPresentablePtr<idPresentableProjectile>::operator->(this: &fp->target)->entityNumber != v25->entityNumber) )
    {
      v28 = idPlayer::CastTo(c: (idPlayer *)v25);
      v29 = v28;
      if ( v28 == nullptr
        || v28->GetVehicle_2(this: v28) == nullptr
        || idPresentablePtr<idPresentableProjectile>::operator->(this: &fp->target) == nullptr
        || (entityNumber = v29->GetVehicle_2(this: v29)->entityNumber) != idPresentablePtr<idPresentableProjectile>::operator->(this: &fp->target)->entityNumber )
      {
        idGeometry::ClosestPointOnLine(point: &traces->endpos, start: &fp->start, dir: fp->fireAxis.mat, closest: &v42);
        v31 = __fsqrts((float)((float)((float)(v42.z - fp->start.z) * (float)(v42.z - fp->start.z))
                             + (float)((float)((float)(v42.x - fp->start.x) * (float)(v42.x - fp->start.x))
                                     + (float)((float)(v42.y - fp->start.y) * (float)(v42.y - fp->start.y)))));
        if ( v31 < v19
          && ((float)((float)v19 - (float)v31) > (double)testParms->minImpactDelta
           || (float)((float)v31 / (float)v19) < (double)testParms->minTravelRatio) )
        {
          ++*outNumBlocked;
        }
      }
    }
    goto LABEL_19;
  }
  v20 = v25;
  if ( testParms->blockOnFriendly )
    ++*outNumBlocked;
LABEL_23:
  if ( v38.logIndex >= 0 )
  {
    pLog = v38.pLog;
    v33 = &v38.pLog->logEntries.list[v38.logIndex];
    v34 = (unsigned __int64)Sys_GetClockTicks() >> 32;
    totalTicks = v33->totalTicks;
    HIDWORD(totalTicks) = v33->parent;
    LODWORD(v36) = v34 - totalTicks;
    v33->totalTicks = v36;
    pLog->lastEntry = HIDWORD(totalTicks);
  }
  RD_EventEnd();
  return v20;
}


// ========================================================================
// __unwind$565702
// EA  : 0x82A1A47C
// RVA : 0x00A1A47C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565702()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 272 + 116));
}


// ========================================================================
// __unwind$565703
// EA  : 0x82A1A4A4
// RVA : 0x00A1A4A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565703()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 272 + 80));
}


// ========================================================================
// ?FinishFireWeapon@idAI2@@QAA_NPAVidWeapon@@ABVidFireParms@@AAVidTestFireResults@@AAVidFinishFireResults@@@Z
// EA  : 0x82A1A4D8
// RVA : 0x00A1A4D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::FinishFireWeapon(
        idAI2 *this,
        idWeapon *weapon,
        const idFireParms *fp,
        idTestFireResults *tfr,
        idFinishFireResults *ffr)
{
  unsigned __int64 v10; // r6
  const char *v11; // r7
  idWeapon_vtbl *v12; // r28
  idFXManager *v13; // r3
  float *decl; // r11
  double yaw; // fp11
  double roll; // fp8
  char *v17; // r11
  int v18; // r10
  int v19; // r8
  signed int v20; // r11
  int v21; // r11
  unsigned int seed; // r7
  unsigned int v23; // r3
  int v24; // r8
  unsigned int v25; // r4
  int v26; // r29
  idVec3 *p_endpos; // r30
  idPLogScope v29[11]; // [sp+58h] [-58h] BYREF

  RD_EventBegin(name: "idAI2::FinishFireWeapon");
  LODWORD(v10) = "idAI2::FinishFireWeapon";
  HIDWORD(v10) = 6;
  idPLogScope::idPLogScope(this: v29, pl: &pLog, gMask: v10, label: v11);
  v12 = weapon->__vftable;
  v13 = this->GetFXMgrForAttachment(this, a2: weapon);
  if ( v12->FinishFire(this: weapon, a2: fp, a3: tfr, a4: ffr, a5: v13, a6: false) )
  {
    decl = (float *)weapon->decl;
    if ( ai_weaponKick.valueInteger != 0 )
    {
      yaw = this->aiVolatile.headTracking.targetKickOffset.yaw;
      this->aiVolatile.headTracking.targetKickOffset.pitch = decl[141]
                                                           + this->aiVolatile.headTracking.targetKickOffset.pitch;
      roll = this->aiVolatile.headTracking.targetKickOffset.roll;
      this->aiVolatile.headTracking.targetKickOffset.yaw = decl[142] + (float)yaw;
      this->aiVolatile.headTracking.targetKickOffset.roll = decl[143] + (float)roll;
    }
    v17 = (char *)weapon->decl + 24 * idAI2::GetModifiedSkill(this);
    v18 = *((_DWORD *)v17 + 231);
    v19 = *((_DWORD *)v17 + 232);
    v20 = v19 - v18;
    if ( v19 == v18 )
    {
      v21 = 0;
    }
    else
    {
      seed = clientGame->random.seed;
      __twllei(v20, 0);
      v23 = 1664525 * seed + 1013904223;
      clientGame->random.seed = v23;
      v24 = (v23 >> 10) & 0x7FFF;
      v25 = v20 & ~(__ROL4__(v24, 1) - 1);
      v21 = v24 % v20;
      __twlgei(v25, 0xFFFFFFFF);
    }
    idWeapon::AddFireDelay(this: weapon, delayMS: v21 + v18);
    if ( ai_debugAim.valueInteger >= 3 && idAI2::GetDebugLevel() > 0 )
    {
      v26 = 0;
      if ( tfr->numTraces > 0 )
      {
        p_endpos = &tfr->traces[0].endpos;
        do
        {
          clientGame->renderWorld->DebugLine(
            this: clientGame->renderWorld,
            a2: (const idVec4 *)&idColor::colorRed,
            a3: &fp->start,
            a4: p_endpos,
            a5: 1000,
            a6: true);
          ++v26;
          p_endpos = (idVec3 *)((char *)p_endpos + 128);
        }
        while ( v26 < tfr->numTraces );
      }
    }
    idPLogScope::~idPLogScope(this: v29);
    RD_EventEnd();
    return 1;
  }
  else
  {
    idPLogScope::~idPLogScope(this: v29);
    RD_EventEnd();
    return 0;
  }
}


// ========================================================================
// __unwind$565853
// EA  : 0x82A1A700
// RVA : 0x00A1A700
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565853()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 176 + 96));
}


// ========================================================================
// __unwind$565854
// EA  : 0x82A1A728
// RVA : 0x00A1A728
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565854()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 176 + 88));
}


// ========================================================================
// ?UpdateAimFocus@idAI2@@AAAXXZ
// EA  : 0x82A1A758
// RVA : 0x00A1A758
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateAimFocus(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r30
  idVec3 *p_offset; // r23
  int value; // r10
  idEntity *v7; // r3
  idEntity *v8; // r3
  idEntity *v9; // r22
  idAIEntityState *v10; // r3
  idAIEntityState *v11; // r24
  idPhysics *Physics; // r3
  idPhysics *v13; // r28
  float *p_z; // r27
  aiSenseState_t *v15; // r26
  idPhysics *v16; // r3
  int v17; // r3
  float v18; // r7
  float v19; // r6
  aiSenseState_t *v20; // r28
  char v21; // r27
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r21
  const aiPhysicalState_t *v23; // r3
  idVec3 *p_eyePos; // r5
  aiFocus_t v25; // r6
  const idVec3 *p_aiOrigin; // r28
  const aiPhysicalState_t *v27; // r3
  const idVec3 *v28; // r3
  double v29; // fp12
  double v30; // fp11
  const aiPhysicalState_t *v31; // r28
  const aiPhysicalState_t *v32; // r3
  const aiPhysicalState_t *v33; // r3
  float v34; // r9
  float v35; // r8
  idPhysics *v36; // r28
  float *v37; // r27
  const aiPhysicalState_t *v38; // r3
  const aiPhysicalState_t *v39; // r3
  const idVec3 *v40; // r3
  double v41; // fp9
  double v42; // fp7
  const idDeclAIBehavior *decl; // r27
  aimPoint_t v44; // r5
  aimPoint_t v45; // r28
  double v46; // fp12
  double v47; // fp11
  double aimOffset; // fp13
  double v49; // fp12
  double v50; // fp0
  const aiPhysicalState_t *v51; // r3
  double x; // fp31
  double v53; // fp30
  idPhysics *v54; // r28
  float *v55; // r29
  double v56; // fp12
  idAIOrientation *BodyOrientation; // r3
  double z; // fp8
  double y; // fp7
  double v60; // fp11
  double v61; // fp10
  double v62; // fp12
  aimPoint_t aimPoint; // [sp+50h] [-110h]
  idPLogScope v64; // [sp+58h] [-108h] BYREF
  idVec3 v65; // [sp+60h] [-100h] BYREF
  float v66; // [sp+70h] [-F0h] BYREF
  float v67; // [sp+74h] [-ECh]
  float v68; // [sp+78h] [-E8h]
  idVec3 v69; // [sp+80h] [-E0h] BYREF
  float v70[4]; // [sp+90h] [-D0h] BYREF
  idVec3 v71; // [sp+A0h] [-C0h] BYREF
  idVec3 v72; // [sp+B0h] [-B0h] BYREF
  idVec3 v73; // [sp+C0h] [-A0h] BYREF
  idVec3 v74; // [sp+D0h] [-90h] BYREF
  _BYTE v75[16]; // [sp+E0h] [-80h] BYREF

  RD_EventBegin(name: "idAI2::UpdateAimFocus");
  LODWORD(v2) = "idAI2::UpdateAimFocus";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: &v64, pl: &pLog, gMask: v2, label: v3);
  p_focus = &this->aiVolatile.focus;
  p_offset = &this->aiVolatile.focus.foci.ptr[0].offset;
  this->aiVolatile.focus.foci.ptr[0].offset = vec3_origin;
  if ( this->aiVolatile.focus.foci.ptr[0].focusTimeout != -1
    && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.focus.foci.ptr[0].focusTimeout )
  {
    idFocusInfo::Clear(this: this->aiVolatile.focus.foci.ptr, owner: this);
  }
  value = this->aiVolatile.focus.foci.ptr[0].focusEntity.spawnId.value;
  if ( gameLocal->spawnIds.ptr[value & 0x1FFF] != value >> 13
    || (v7 = gameLocal->entities.ptr[value & 0x1FFF]) == nullptr
    || (v8 = idEntity::CastTo(c: v7), v9 = v8, v8 == nullptr) )
  {
    if ( (unsigned __int8)idFocusInfo::HasFocus(this: this->aiVolatile.focus.foci.ptr) == 0 )
    {
      this->GetEyePos(this, a2: (idVec3 *)&v66);
      BodyOrientation = idAI2::GetBodyOrientation(this);
      z = BodyOrientation->axis.mat[0].z;
      y = BodyOrientation->axis.mat[0].y;
      v60 = v68;
      v61 = v67;
      v62 = (float)((float)(BodyOrientation->axis.mat[0].x * (float)64.0) + v66);
      this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.x = (float)(BodyOrientation->axis.mat[0].x * (float)64.0) + v66;
      this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.y = (float)v61 + (float)((float)y * (float)64.0);
      v50 = (float)((float)v60 + (float)((float)z * (float)64.0));
      v68 = (float)v60 + (float)((float)z * (float)64.0);
      v66 = v62;
      v67 = (float)v61 + (float)((float)y * (float)64.0);
      goto LABEL_49;
    }
    goto LABEL_51;
  }
  this->aiVolatile.focus.foci.ptr[0].focusType = AIFOCUS_ENTITY;
  v10 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v8);
  v11 = v10;
  if ( v10 == nullptr )
  {
    aimPoint = this->aiVolatile.focus.foci.ptr[0].aimPoint;
    if ( aimPoint == AIMPOINT_EYELEVEL )
    {
      Physics = idEntity::GetPhysics(this: v9);
      v69 = *Physics->GetOrigin(this: Physics, a2: 0);
      v13 = idEntity::GetPhysics(this);
      p_z = &this->GetEyeOffset(this: &v65, result: this)->z;
      v69.z = v13->GetOrigin(this: v13, a2: 0)->z + *p_z;
      idFocusInfo::SetTempFocusPoint(
        this: this->aiVolatile.focus.foci.ptr,
        owner: this,
        focusPoint: &v69,
        _focusType: AIFOCUS_MISC);
    }
    else
    {
      v9->GetAimPoint(this: v9, a2: aimPoint, a3: &v74);
      idFocusInfo::SetTempFocusPoint(
        this: this->aiVolatile.focus.foci.ptr,
        owner: this,
        focusPoint: &v74,
        _focusType: AIFOCUS_MISC);
    }
    goto LABEL_50;
  }
  v15 = v10->senses.ptr[v10->lastSense];
  if ( v15->lastUnconfirmedStimTime < 0 || v15->lastConfirmedStimTime <= 0 )
  {
    idFocusInfo::Clear(this: this->aiVolatile.focus.foci.ptr, owner: this);
    goto LABEL_51;
  }
  v16 = idEntity::GetPhysics(this);
  v17 = (int)v16->GetOrigin(this: v16, a2: 0);
  v18 = *(float *)(v17 + 4);
  v19 = *(float *)(v17 + 8);
  v65.x = *(float *)v17;
  v65.y = v18;
  v65.z = v19;
  if ( !idAIEntityState::IsVisible(this: v11) )
  {
    v20 = v11->senses.ptr[1];
    v21 = 0;
    if ( v20->lastUnconfirmedStimTime >= 0 && v20->lastConfirmedStimTime >= 0 )
    {
      ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
      v23 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v20);
      if ( OkToFocus(to: &v23->eyePos, from: &v65, actualPos: &ConfirmedPhysicalSafe->origin) )
      {
        p_eyePos = &aiSenseState_t::GetConfirmedPhysicalSafe(this: v20)->eyePos;
        v25 = AIFOCUS_LAST_SEEN_POS;
      }
      else
      {
        p_aiOrigin = &v20->aiOrigin;
        v27 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
        if ( !OkToFocus(to: p_aiOrigin, from: &v65, actualPos: &v27->origin) )
          goto LABEL_21;
        v28 = this->GetEyeOffset(this: v75, result: this);
        v25 = AIFOCUS_POS_WHEN_LAST_SEEN;
        p_eyePos = (idVec3 *)v70;
        v29 = p_aiOrigin->y;
        v30 = (float)(p_aiOrigin->z + v28->z);
        v70[0] = p_aiOrigin->x;
        v70[1] = v29;
        v70[2] = v30;
      }
      idFocusInfo::SetTempFocusPoint(
        this: this->aiVolatile.focus.foci.ptr,
        owner: this,
        focusPoint: p_eyePos,
        _focusType: v25);
      v21 = 1;
    }
LABEL_21:
    if ( v21 == 0 )
    {
      v31 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
      v32 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
      if ( OkToFocus(to: &v32->origin, from: &v65, actualPos: &v31->origin) )
      {
        if ( this->aiVolatile.focus.foci.ptr[0].aimPoint == AIMPOINT_EYELEVEL )
        {
          v33 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
          v34 = v33->eyePos.y;
          v35 = v33->eyePos.z;
          v65.x = v33->eyePos.x;
          v65.y = v34;
          v65.z = v35;
          v36 = idEntity::GetPhysics(this);
          v37 = &this->GetEyeOffset(this: v75, result: this)->z;
          v65.z = v36->GetOrigin(this: v36, a2: 0)->z + *v37;
          idFocusInfo::SetTempFocusPoint(
            this: this->aiVolatile.focus.foci.ptr,
            owner: this,
            focusPoint: &v65,
            _focusType: AIFOCUS_LAST_SENSED_POS);
        }
        else
        {
          v38 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
          idFocusInfo::SetTempFocusPoint(
            this: this->aiVolatile.focus.foci.ptr,
            owner: this,
            focusPoint: &v38->eyePos,
            _focusType: AIFOCUS_LAST_SENSED_POS);
        }
      }
      else
      {
        v39 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
        if ( OkToFocus(to: &v15->aiOrigin, from: &v65, actualPos: &v39->origin) )
        {
          v40 = this->GetEyeOffset(this: v75, result: this);
          v41 = (float)(v15->aiOrigin.z + v40->z);
          v42 = (float)(v15->aiOrigin.y + v40->y);
          v71.x = v15->aiOrigin.x + v40->x;
          v71.z = v41;
          v71.y = v42;
          idFocusInfo::SetTempFocusPoint(
            this: this->aiVolatile.focus.foci.ptr,
            owner: this,
            focusPoint: &v71,
            _focusType: AIFOCUS_POS_WHEN_LAST_SENSED);
        }
        else
        {
          idFocusInfo::Clear(this: this->aiVolatile.focus.foci.ptr, owner: this);
        }
      }
    }
  }
  decl = this->aiEditable.behaviors.decl;
  if ( this->aiVolatile.focus.foci.ptr[0].focusType == AIFOCUS_ENTITY )
  {
    v44 = this->aiVolatile.focus.foci.ptr[0].aimPoint;
    if ( (unsigned int)v44 <= AIMPOINT_LOOKAHEAD )
    {
      if ( (unsigned int)v44 < AIMPOINT_BEST )
      {
LABEL_44:
        idAIEntityState::GetAimPoint(this: v11, sense: (const aiSense_t)v11->lastSense, aimPoint: v44, point: &v73);
        v49 = v73.y;
        v50 = v73.z;
        this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.x = v73.x;
        this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.y = v49;
LABEL_49:
        this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.z = v50;
        goto LABEL_50;
      }
      if ( v44 != AIMPOINT_BEST )
      {
        if ( v44 == AIMPOINT_EYELEVEL )
        {
          v51 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
          x = v51->origin.x;
          v53 = v51->origin.y;
          v54 = idEntity::GetPhysics(this);
          v55 = &this->GetEyeOffset(this: v75, result: this)->z;
          v56 = (float)(v54->GetOrigin(this: v54, a2: 0)->z + *v55);
          p_focus->foci.ptr[0].idealFocusPoint.x = x;
          p_focus->foci.ptr[0].idealFocusPoint.y = v53;
          p_focus->foci.ptr[0].idealFocusPoint.z = v56;
LABEL_50:
          *p_offset = vec3_origin;
          goto LABEL_51;
        }
        goto LABEL_44;
      }
      if ( v11->lastVisible == 3 || (v45 = AIMPOINT_TORSO, v9->IsDead(this: v9)) )
        v45 = AIMPOINT_HEAD;
      if ( this->GetEquippedWeapon(this) != nullptr && BYTE1(this->GetEquippedWeapon(this)->decl[1].thirdPersonMD6) != 0 )
        v45 = AIMPOINT_HEAD;
      idAIEntityState::GetAimPoint(this: v11, sense: (const aiSense_t)v11->lastSense, aimPoint: v45, point: &v72);
      v46 = v72.y;
      v47 = v72.z;
      this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.x = v72.x;
      this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.y = v46;
      this->aiVolatile.focus.foci.ptr[0].idealFocusPoint.z = v47;
      if ( v45 == AIMPOINT_TORSO )
      {
        aimOffset = decl->aimOffset;
        p_offset->x = 0.0;
        this->aiVolatile.focus.foci.ptr[0].offset.y = 0.0;
        this->aiVolatile.focus.foci.ptr[0].offset.z = aimOffset;
      }
      else
      {
        p_offset->x = 0.0;
        this->aiVolatile.focus.foci.ptr[0].offset.y = 0.0;
        this->aiVolatile.focus.foci.ptr[0].offset.z = 0.0;
      }
    }
  }
LABEL_51:
  idPLogScope::~idPLogScope(this: &v64);
  RD_EventEnd();
}


// ========================================================================
// __unwind$565960
// EA  : 0x82A1AEBC
// RVA : 0x00A1AEBC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565960()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 352 + 236));
}


// ========================================================================
// __unwind$565961
// EA  : 0x82A1AEE4
// RVA : 0x00A1AEE4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_565961()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 352 + 88));
}


// ========================================================================
// ?TraceVector@idCheckSurroundingsState@@ABA_NPBVidAI2@@ABVidVec3@@1@Z
// EA  : 0x82A1AF18
// RVA : 0x00A1AF18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

BOOL __fastcall idCheckSurroundingsState::TraceVector(
        idCheckSurroundingsState *this,
        const idAI2 *ai,
        const idVec3 *from,
        const idVec3 *to)
{
  unsigned __int64 v7; // r6
  const char *v8; // r7
  idSoundWorld *v9; // r3
  char v11; // r8
  BOOL v12; // r27
  idAIGameState *p_aiGameState; // r27
  const idSpawnId **v14; // r3
  idColor *v15; // r4
  idPLogScope v16; // [sp+50h] [-D0h] BYREF
  idSpawnId v17; // [sp+58h] [-C8h] BYREF
  trace_t v18; // [sp+60h] [-C0h] BYREF

  RD_EventBegin(name: "idCheckSurroundingsState::TraceVector");
  LODWORD(v7) = "idCheckSurroundingsState::TraceVector";
  HIDWORD(v7) = 6;
  idPLogScope::idPLogScope(this: &v16, pl: &pLog, gMask: v7, label: v8);
  v9 = gameLocal->GetSoundWorld(this: gameLocal);
  if ( v9 != nullptr )
  {
    v11 = _cntlzw(v9->Trace(this: v9, a2: from, a3: to));
    v12 = (v11 & 0x20) != 0;
    if ( (v11 & 0x20) != 0 )
    {
      p_aiGameState = &gameLocal->aiGameState;
      v14 = (const idSpawnId **)idSpawnId::idSpawnId(this: &v17, ent: ai);
      v12 = idAIVisibility::TraceVisible(
              gameState: p_aiGameState,
              fromPoint: from,
              toPoint: to,
              ignoreId: *v14,
              destId: nullptr,
              tr: &v18,
              seeThroughBreakables: false);
    }
    if ( ai_debugLook.valueInteger >= 3 && ai_debugLevel.valueInteger > 0 )
    {
      if ( v12 )
        v15 = &idColor::colorWhite;
      else
        v15 = &idColor::colorBlack;
      ((void (__fastcall *)(idRenderWorld *, idColor *, const idVec3 *, const idVec3 *, double))clientGame->renderWorld->DebugArrow)(
        a1: clientGame->renderWorld,
        a2: v15,
        a3: from,
        a4: to,
        a5: 5.0);
    }
    idPLogScope::~idPLogScope(this: &v16);
    RD_EventEnd();
    return v12;
  }
  else
  {
    idPLogScope::~idPLogScope(this: &v16);
    RD_EventEnd();
    return false;
  }
}


// ========================================================================
// __unwind$566354
// EA  : 0x82A1B090
// RVA : 0x00A1B090
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566354()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 288 + 224));
}


// ========================================================================
// __unwind$566355
// EA  : 0x82A1B0B8
// RVA : 0x00A1B0B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566355()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 288 + 80));
}


// ========================================================================
// ?UpdateDirectionDistanceExponent@idCheckSurroundingsState@@AAAHHPBVidAI2@@@Z
// EA  : 0x82A1B0E8
// RVA : 0x00A1B0E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

unsigned int __fastcall idCheckSurroundingsState::UpdateDirectionDistanceExponent(
        idCheckSurroundingsState *this,
        const int directionToTrace,
        idAI2 *ai)
{
  unsigned __int64 v6; // r6
  const char *v7; // r7
  int v8; // r24
  unsigned int v9; // r26
  float *v10; // r4
  unsigned int v11; // r28
  float *v12; // r29
  idPhysics *Physics; // r3
  float *v14; // r3
  double v15; // fp9
  double v16; // fp6
  long double v17; // fp4
  double v18; // fp2
  double v19; // fp1
  double v20; // fp1
  double v21; // fp11
  double v22; // fp10
  long double v23; // fp4
  double v24; // fp2
  double v25; // fp1
  unsigned int v26; // r25
  double v27; // fp1
  double v28; // fp7
  double v29; // fp6
  double v30; // fp1
  double v31; // fp7
  double v32; // fp6
  idPLogScope v34; // [sp+50h] [-B0h] BYREF
  idVec3 v35; // [sp+58h] [-A8h] BYREF
  idVec3 v36; // [sp+68h] [-98h] BYREF
  int v37; // [sp+78h] [-88h] BYREF
  float v38[28]; // [sp+90h] [-70h] BYREF

  RD_EventBegin(name: "idCheckSurroundingsState::UpdateDirectionDistanceExponent");
  LODWORD(v6) = "idCheckSurroundingsState::UpdateDirectionDistanceExponent";
  HIDWORD(v6) = 6;
  idPLogScope::idPLogScope(this: &v34, pl: &pLog, gMask: v6, label: v7);
  ai->GetEyeAxis(this: ai, a2: (idMat3 *)v38);
  v8 = 4 * (directionToTrace + 1);
  v9 = *(_DWORD *)((char *)&this->lookForwardInterest + v8);
  v10 = (float *)((char *)gameLocal + 12 * directionToTrace);
  v11 = v9 + 1;
  v12 = v10 + 437432;
  if ( (int)(v9 + 1) > 15 )
    v11 = 15;
  if ( (float)((float)(v10[437433] * v38[1]) + (float)((float)(v10[437432] * v38[0]) + (float)(v38[2] * v10[437434]))) < (double)CHECK_DOT_THRESHOLD )
  {
LABEL_10:
    v11 = v9;
    goto LABEL_12;
  }
  ai->GetEyePos(this: ai, a2: &v35);
  Physics = idEntity::GetPhysics(this: ai);
  v14 = (float *)Physics->GetLinearVelocity(this: (idPhysics *)&v37, result: (idVec3 *)Physics, a3: 0);
  v15 = (float)(v35.x + *v14);
  v16 = (float)(v35.y + v14[1]);
  v35.z = v14[2] + v35.z;
  v35.y = v16;
  v35.x = v15;
  v20 = idCheckSurroundingsState::DistanceExponentToDistance(this, distanceExponent: v11, a3: v19, a4: v18, a5: v17);
  v21 = (float)(v12[1] * (float)v20);
  v22 = (float)(*v12 * (float)v20);
  v36.z = (float)((float)v20 * v12[2]) + v35.z;
  v36.y = v35.y + (float)v21;
  v36.x = (float)v22 + v35.x;
  if ( !idCheckSurroundingsState::TraceVector(this, ai, from: &v35, to: &v36) )
  {
    v30 = idCheckSurroundingsState::DistanceExponentToDistance(this, distanceExponent: v9, a3: v25, a4: v24, a5: v23);
    v31 = (float)(v12[1] * (float)v30);
    v32 = (float)(*v12 * (float)v30);
    v36.z = (float)((float)v30 * v12[2]) + v35.z;
    v36.y = v35.y + (float)v31;
    v36.x = (float)v32 + v35.x;
    if ( !idCheckSurroundingsState::TraceVector(this, ai, from: &v35, to: &v36) )
    {
      v11 = ((v9 == 1) + ((v9 - 1) >> 31) - 1) & (v9 - 1);
      goto LABEL_12;
    }
    goto LABEL_10;
  }
  v26 = v11 + 1;
  if ( (int)(v11 + 1) > 15 )
    v26 = 15;
  v27 = idCheckSurroundingsState::DistanceExponentToDistance(this, distanceExponent: v26, a3: v25, a4: v24, a5: v23);
  v28 = (float)(v12[1] * (float)v27);
  v29 = (float)(*v12 * (float)v27);
  v36.z = (float)((float)v27 * v12[2]) + v35.z;
  v36.y = v35.y + (float)v28;
  v36.x = (float)v29 + v35.x;
  if ( idCheckSurroundingsState::TraceVector(this, ai, from: &v35, to: &v36) )
    v11 = v26;
LABEL_12:
  *(_DWORD *)((char *)&this->lookForwardInterest + v8) = v11;
  idPLogScope::~idPLogScope(this: &v34);
  RD_EventEnd();
  return v11 - v9;
}


// ========================================================================
// __unwind$566430
// EA  : 0x82A1B3B4
// RVA : 0x00A1B3B4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566430()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 256 + 180));
}


// ========================================================================
// __unwind$566431
// EA  : 0x82A1B3DC
// RVA : 0x00A1B3DC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566431()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 256 + 80));
}


// ========================================================================
// ?UpdateLookInterests@idCheckSurroundingsState@@AAAXPBVidAI2@@@Z
// EA  : 0x82A1B410
// RVA : 0x00A1B410
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idCheckSurroundingsState::UpdateLookInterests(idCheckSurroundingsState *this, idAI2 *ai)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  idPhysics *Physics; // r3
  double v7; // fp31
  float *v8; // r3
  double v9; // fp29
  double v10; // fp30
  double v11; // fp28
  double v12; // fp0
  double v15; // fp2
  double v16; // fp1
  double v17; // fp6
  double v18; // fp5
  double v19; // fp12
  int v20; // r22
  idArray<float,8> *p_lookInterest; // r28
  float *v22; // r11
  idVec3 *v23; // r30
  double v24; // fp0
  double v25; // fp31
  idPhysics *v28; // r19
  const idVec3 *v29; // r18
  float *v30; // r3
  double v31; // fp0
  double v32; // fp4
  double v33; // fp3
  double v34; // fp5
  double v35; // fp4
  idPLog *pLog; // r29
  idPLog::logEntry_t *v37; // r30
  int v38; // r3
  __int64 totalTicks; // r11
  __int64 v40; // r9
  idPLogScope v41; // [sp+58h] [-128h] BYREF
  float v42; // [sp+60h] [-120h] BYREF
  float v43; // [sp+64h] [-11Ch]
  float v44; // [sp+68h] [-118h]
  float v45[4]; // [sp+70h] [-110h] BYREF
  float v46[4]; // [sp+80h] [-100h] BYREF
  float v47[30]; // [sp+90h] [-F0h] BYREF

  RD_EventBegin(name: "idCheckSurroundingsState::UpdateLookInterests");
  LODWORD(v4) = "idCheckSurroundingsState::UpdateLookInterests";
  HIDWORD(v4) = 6;
  idPLogScope::idPLogScope(this: &v41, pl: &::pLog, gMask: v4, label: v5);
  ai->GetEyeAxis(this: ai, a2: (idMat3 *)v47);
  Physics = idEntity::GetPhysics(this: ai);
  v7 = VELOCITY_SCALE;
  v8 = (float *)Physics->GetLinearVelocity(this: (idPhysics *)&v42, result: (idVec3 *)Physics, a3: 0);
  v9 = (float)(v8[1] * (float)v7);
  v10 = (float)((float)v7 * *v8);
  v11 = (float)(v8[2] * (float)v7);
  v42 = (float)v7 * *v8;
  v43 = v9;
  v44 = v11;
  v12 = (float)((float)((float)v11 * (float)v11)
              + (float)((float)((float)v10 * (float)v10) + (float)((float)v9 * (float)v9)));
  if ( v12 > 0.001 )
  {
    _FP7 = (float)((float)((float)((float)v11 * (float)v11)
                         + (float)((float)((float)v10 * (float)v10) + (float)((float)v9 * (float)v9)))
                 - idMath::FLT_SMALLEST_NON_DENORMAL);
    __asm { fsel      f3, f7, f0, f12 }
    v15 = __frsqrte(_FP3);
    v16 = (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15
                                                                                        * (float)((float)v12 * (float)0.5))
                                                                                * (float)v15)
                                                                        - (float)1.5)
                                                        * (float)v15)
                                                * (float)((float)v12 * (float)0.5))
                                        * (float)((float)-(float)((float)((float)((float)v15
                                                                                * (float)((float)v12 * (float)0.5))
                                                                        * (float)v15)
                                                                - (float)1.5)
                                                * (float)v15))
                                - (float)1.5)
                * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15)
                                        - (float)1.5)
                        * (float)v15));
    v17 = (float)(v44
                * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15)
                                                                                                * (float)((float)v12 * (float)0.5))
                                                                                        * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5)
                                                                                                * (float)v15))
                                                                                - (float)1.5)
                                                                * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5))
                                                                                                * (float)v15)
                                                                                        - (float)1.5)
                                                                        * (float)v15))
                                                        * (float)((float)v12 * (float)0.5))
                                                * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5)
                                                                                                * (float)v15)
                                                                                        * (float)((float)v12 * (float)0.5))
                                                                                * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5)
                                                                                        * (float)v15))
                                                                        - (float)1.5)
                                                        * (float)((float)-(float)((float)((float)((float)v15
                                                                                                * (float)((float)v12 * (float)0.5))
                                                                                        * (float)v15)
                                                                                - (float)1.5)
                                                                * (float)v15)))
                                        - (float)1.5)
                        * (float)v16));
    v18 = (float)(v47[1]
                * (float)(v43
                        * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15) * (float)((float)v12 * (float)0.5))
                                                                                                * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15))
                                                                                        - (float)1.5)
                                                                        * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15)
                                                                                                - (float)1.5)
                                                                                * (float)v15))
                                                                * (float)((float)v12 * (float)0.5))
                                                        * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15)
                                                                                                * (float)((float)v12 * (float)0.5))
                                                                                        * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5)
                                                                                                * (float)v15))
                                                                                - (float)1.5)
                                                                * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5))
                                                                                                * (float)v15)
                                                                                        - (float)1.5)
                                                                        * (float)v15)))
                                                - (float)1.5)
                                * (float)v16)));
    if ( (float)((float)(v47[0]
                       * (float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15) * (float)((float)v12 * (float)0.5)) * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15))
                                                                                               - (float)1.5)
                                                                               * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5)
                                                                                       * (float)v15))
                                                                       * (float)((float)v12 * (float)0.5))
                                                               * (float)((float)-(float)((float)((float)((float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15) * (float)((float)v12 * (float)0.5))
                                                                                               * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15) - (float)1.5) * (float)v15))
                                                                                       - (float)1.5)
                                                                       * (float)((float)-(float)((float)((float)((float)v15 * (float)((float)v12 * (float)0.5)) * (float)v15)
                                                                                               - (float)1.5)
                                                                               * (float)v15)))
                                                       - (float)1.5)
                                       * (float)v16)
                               * (float)v10))
               + (float)((float)(v47[2] * (float)v17) + (float)v18)) <= 0.85000002 )
    {
      this->lookForwardInterest = this->lookForwardInterest + (float)0.1;
    }
    else
    {
      v19 = (float)(this->lookForwardInterest - (float)0.1);
      this->lookForwardInterest = this->lookForwardInterest - (float)0.1;
      if ( v19 < 0.0 )
        this->lookForwardInterest = 0.0;
    }
  }
  v20 = 0;
  p_lookInterest = &this->lookInterest;
  do
  {
    v22 = (float *)((char *)gameLocal + v20 * 12);
    v23 = &gameLocal->directionVector[v20];
    v24 = (float)((float)(v22[437434] * v47[2]) + (float)((float)(v22[437432] * v47[0]) + (float)(v22[437433] * v47[1])));
    v25 = (float)((float)(v22[437434] * (float)v11)
                + (float)((float)(v22[437432] * (float)v10) + (float)(v22[437433] * (float)v9)));
    if ( v24 > 0.0 )
    {
      _FP11 = -(float)-(float)((float)((float)((float)v24 * (float)v24) * (float)0.029999999) - p_lookInterest->ptr[0]);
      __asm { fsel      f10, f11, f27, f12 }
      p_lookInterest->ptr[0] = _FP10;
    }
    if ( ai_debugLook.valueInteger >= 3 && ai_debugLevel.valueInteger > 0 )
    {
      v28 = idEntity::GetPhysics(this: ai);
      v29 = ai->GetEyeOffset(this: &v42, result: ai);
      v30 = (float *)v28->GetOrigin(this: v28, a2: 0);
      v31 = (float)(v29->x + *v30);
      v32 = (float)(v29->z + v30[2]);
      v33 = (float)(v29->y + v30[1]);
      v45[0] = v29->x + *v30;
      v45[2] = v32;
      v45[1] = v33;
      v34 = (float)((float)(v23->y * (float)(p_lookInterest->ptr[0] + (float)v25))
                  * (float)((float)(UNITS_PER_INCH_2 * (float)2.0) * (float)12.0));
      v35 = (float)((float)((float)(v23->z * (float)(p_lookInterest->ptr[0] + (float)v25))
                          * (float)((float)(UNITS_PER_INCH_2 * (float)2.0) * (float)12.0))
                  + (float)v32);
      v46[0] = (float)((float)((float)(p_lookInterest->ptr[0] + (float)v25) * v23->x)
                     * (float)((float)(UNITS_PER_INCH_2 * (float)2.0) * (float)12.0))
             + (float)v31;
      v46[2] = v35;
      v46[1] = (float)v34 + (float)v33;
      ((void (__fastcall *)(idRenderWorld *, idColor *, float *, float *, double))clientGame->renderWorld->DebugArrow)(
        a1: clientGame->renderWorld,
        a2: &idColor::colorGreen,
        a3: v45,
        a4: v46,
        a5: 5.0);
    }
    ++v20;
    p_lookInterest = (idArray<float,8> *)((char *)p_lookInterest + 4);
  }
  while ( v20 < 8 );
  if ( v41.logIndex >= 0 )
  {
    pLog = v41.pLog;
    v37 = &v41.pLog->logEntries.list[v41.logIndex];
    v38 = (unsigned __int64)Sys_GetClockTicks() >> 32;
    totalTicks = v37->totalTicks;
    HIDWORD(totalTicks) = v37->parent;
    LODWORD(v40) = v38 - totalTicks;
    v37->totalTicks = v40;
    pLog->lastEntry = HIDWORD(totalTicks);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$566611
// EA  : 0x82A1B7CC
// RVA : 0x00A1B7CC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566611()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 384 + 180));
}


// ========================================================================
// __unwind$566612
// EA  : 0x82A1B7F4
// RVA : 0x00A1B7F4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566612()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 384 + 88));
}


// ========================================================================
// ?Update@idCheckSurroundingsState@@QAAXPBVidAI2@@@Z
// EA  : 0x82A1B828
// RVA : 0x00A1B828
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idCheckSurroundingsState::Update(idCheckSurroundingsState *this, idAI2 *ai)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  int nextDirectionToTrace; // r29
  idPhysics *Physics; // r3
  float *v8; // r3
  signed int updated; // r3
  __int64 v10; // r11
  double v11; // fp13
  int v14; // r11
  idPLogScope v15; // [sp+50h] [-40h] BYREF
  __int64 v16; // [sp+58h] [-38h] BYREF

  RD_EventBegin(name: "idAI2::idCheckSurroundingState::Update");
  LODWORD(v4) = "idAI2::idCheckSurroundingState::Update";
  HIDWORD(v4) = 6;
  idPLogScope::idPLogScope(this: &v15, pl: &pLog, gMask: v4, label: v5);
  if ( (unsigned __int8)idCheckSurroundingsState::CanUse(this, ai) != 0 )
  {
    nextDirectionToTrace = this->nextDirectionToTrace;
    if ( (ai->entityNumber + idAccolade::Count(this: &clientGame->gameTimeManager)) % 4 == 0 )
    {
      Physics = idEntity::GetPhysics(this: ai);
      v8 = (float *)Physics->GetLinearVelocity(this: (idPhysics *)&v16, result: (idVec3 *)Physics, a3: 0);
      if ( (float)((float)(v8[2] * v8[2]) + (float)((float)(*v8 * *v8) + (float)(v8[1] * v8[1]))) > 0.1 )
      {
        updated = idCheckSurroundingsState::UpdateDirectionDistanceExponent(
                    this,
                    directionToTrace: nextDirectionToTrace,
                    ai);
        if ( updated > 0 )
          updated = __CFADD__(updated - 2, -2147483646) ? 0 : updated;
        LODWORD(v10) = updated;
        HIDWORD(v10) = nextDirectionToTrace + 9;
        v16 = v10;
        v11 = (double)v10;
        LODWORD(v10) = 4 * (nextDirectionToTrace + 9);
        _FP9 = -(float)((float)v11 + *(float *)((char *)&this->lookForwardInterest + v10));
        __asm { fsel      f8, f9, f0, f10 }
        *(float *)((char *)&this->lookForwardInterest + v10) = _FP8;
      }
      v14 = this->nextDirectionToTrace + 1;
      this->nextDirectionToTrace = v14;
      if ( v14 == 8 )
        this->nextDirectionToTrace = 0;
    }
    idCheckSurroundingsState::UpdateLookInterests(this, ai);
    idPLogScope::~idPLogScope(this: &v15);
  }
  else
  {
    idPLogScope::~idPLogScope(this: &v15);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$566799
// EA  : 0x82A1B9B4
// RVA : 0x00A1B9B4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566799()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 144 + 100));
}


// ========================================================================
// __unwind$566800
// EA  : 0x82A1B9DC
// RVA : 0x00A1B9DC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566800()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 144 + 80));
}


// ========================================================================
// ?FindAutoFocus@idAI2@@AAAXXZ
// EA  : 0x82A1BA10
// RVA : 0x00A1BA10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::FindAutoFocus(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idPhysics *Physics; // r3
  float *v5; // r3
  bool v6; // r26
  idAIEditable::idOnOffAuto_t autoFocusEntity; // r11
  char HasFocus; // r28
  idEntity *Neutral; // r29
  idPhysics *v10; // r3
  float *v11; // r25
  idPhysics *v12; // r3
  float *v13; // r3
  double v14; // fp31
  double v15; // fp30
  double v16; // fp29
  idAIOrientation *BodyOrientation; // r3
  double v18; // fp3
  double BestLookInterestPoint; // fp31
  idAIEditable::idOnOffAuto_t autoFocusSurroudings; // r11
  idAIEditable::idOnOffAuto_t v21; // r11
  idAI2 *v22; // r29
  double v23; // fp1
  double lookForwardInterest; // fp0
  int v25; // r29
  idPhysics *v26; // r3
  float *v27; // r3
  double v28; // fp31
  double v29; // fp30
  double v30; // fp29
  const idVec3 *v31; // r3
  double v32; // fp6
  double v33; // fp4
  int v34; // r28
  __int64 v35; // r10
  idMat3 *p_axis; // [sp+50h] [-90h] BYREF
  int v37; // [sp+54h] [-8Ch]
  idPLogScope v38; // [sp+60h] [-80h] BYREF
  idVec3 v39; // [sp+68h] [-78h] BYREF
  idVec3 v40; // [sp+78h] [-68h] BYREF

  RD_EventBegin(name: "idAI2::FindAutoFocus");
  LODWORD(v2) = "idAI2::FindAutoFocus";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: &v38, pl: &pLog, gMask: v2, label: v3);
  if ( ai_enableAutoFocus.valueInteger != 0 )
  {
    if ( idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this) )
    {
      if ( !idAI2::ActionScriptFlagIsSet(this, flags: 512) )
        goto LABEL_35;
    }
    else if ( !this->aiVolatile.focus.enableAutoFocus || idAI2::GetAlertCycle(this) != ALERTCYCLE_RELAXED )
    {
      goto LABEL_35;
    }
    Physics = idEntity::GetPhysics(this);
    v5 = (float *)Physics->GetLinearVelocity(this: (idPhysics *)&v39, result: (idVec3 *)Physics, a3: 0);
    v6 = (float)((float)(v5[2] * v5[2]) + (float)((float)(*v5 * *v5) + (float)(v5[1] * v5[1]))) > 0.1;
    autoFocusEntity = this->aiEditable.perception.autoFocusEntity;
    if ( autoFocusEntity != ONOFFAUTO_ON
      && ((float)((float)(v5[2] * v5[2]) + (float)((float)(*v5 * *v5) + (float)(v5[1] * v5[1]))) <= 0.1
       || autoFocusEntity != ONOFFAUTO_AUTO)
      || (unsigned __int8)idAI2::FindClosestFocus(this) == 0 )
    {
      HasFocus = idFocusInfo::HasFocus(this: &this->aiVolatile.focus.foci.ptr[1]);
      if ( HasFocus != 0 && this->aiVolatile.focus.foci.ptr[1].focusType == AIFOCUS_ENTITY )
      {
        Neutral = (idEntity *)idAIMemory::GetNeutral(this: &this->aiVolatile.focus.foci.ptr[1]);
        if ( Neutral != nullptr )
        {
          v10 = idEntity::GetPhysics(this);
          v11 = (float *)v10->GetOrigin(this: v10, a2: 0);
          v12 = idEntity::GetPhysics(this: Neutral);
          v13 = (float *)v12->GetOrigin(this: v12, a2: 0);
          v14 = (float)(v13[2] - v11[2]);
          v15 = (float)(v13[1] - v11[1]);
          v16 = (float)(*v13 - *v11);
          BodyOrientation = idAI2::GetBodyOrientation(this);
          v18 = (float)((float)((float)v16 * BodyOrientation->axis.mat[0].x)
                      + (float)((float)(BodyOrientation->axis.mat[0].y * (float)v15)
                              + (float)(BodyOrientation->axis.mat[0].z * (float)v14)));
          p_axis = &BodyOrientation->axis;
          if ( v18 < 0.0 )
            HasFocus = 0;
        }
      }
      if ( HasFocus == 0 )
      {
        BestLookInterestPoint = -1.0;
        if ( idAI2::GetAlertCycle(this) <= ALERTCYCLE_SEARCH )
        {
          autoFocusSurroudings = this->aiEditable.perception.autoFocusSurroudings;
          if ( autoFocusSurroudings == ONOFFAUTO_ON || v6 && autoFocusSurroudings == ONOFFAUTO_AUTO )
            BestLookInterestPoint = idCheckSurroundingsState::FindBestLookInterestPoint(
                                      this: &this->aiVolatile.focus.checkSurroundingsState,
                                      ai: this,
                                      lookTo: &v39);
        }
        v21 = this->aiEditable.perception.autoFocusEntity;
        v22 = nullptr;
        v23 = -1.0;
        p_axis = nullptr;
        if ( v21 == ONOFFAUTO_ON || v6 && v21 == ONOFFAUTO_AUTO )
        {
          v23 = idAI2::FindAutoFocusEntity(this, bestEntity: (idAI2 **)&p_axis);
          v22 = (idAI2 *)p_axis;
        }
        lookForwardInterest = this->aiVolatile.focus.checkSurroundingsState.lookForwardInterest;
        if ( BestLookInterestPoint <= v23 || BestLookInterestPoint <= lookForwardInterest )
        {
          if ( v23 > lookForwardInterest && v22 != nullptr )
          {
            v34 = idRandom2::RandomInt(
                    this: &clientGame->random,
                    max: this->aiEditable.perception.autoFocusMaxTime - this->aiEditable.perception.autoFocusMinTime)
                + this->aiEditable.perception.autoFocusMinTime;
            LODWORD(v35) = v34;
            v37 = (int)(float)((float)v35 * (float)1.5);
            idAI2::SetLookFocusEntity(this, ent: v22, keepFocusInView: false, aimPoint: AIMPOINT_HEAD, timeout: v37);
            idAI2::LookDebug(this, text: "focusing on entity", level: 1, duration: v34);
          }
          else
          {
            this->aiVolatile.focus.foci.ptr[1].focusType = AIFOCUS_NOTHING;
          }
        }
        else
        {
          v25 = idRandom2::RandomInt(
                  this: &clientGame->random,
                  max: this->aiEditable.perception.autoFocusMaxTime - this->aiEditable.perception.autoFocusMinTime)
              + this->aiEditable.perception.autoFocusMinTime;
          v26 = idEntity::GetPhysics(this);
          v27 = (float *)v26->GetOrigin(this: v26, a2: 0);
          v28 = (float)(v27[2] + v39.z);
          v29 = (float)(v27[1] + v39.y);
          v30 = (float)(*v27 + v39.x);
          v31 = this->GetEyeOffset(this: &p_axis, result: this);
          v32 = (float)(v31->z + (float)v28);
          v33 = (float)(v31->y + (float)v29);
          v40.x = v31->x + (float)v30;
          v40.z = v32;
          v40.y = v33;
          idFocusInfo::SetExplicitFocusPoint(
            this: &this->aiVolatile.focus.foci.ptr[1],
            owner: this,
            focusPoint: &v40,
            _keepFocusInView: false,
            duration: v25,
            _focusType: AIFOCUS_LOOK_AROUND);
          idAI2::LookDebug(this, text: "look into opening", level: 1, duration: v25);
        }
      }
    }
  }
LABEL_35:
  idPLogScope::~idPLogScope(this: &v38);
  RD_EventEnd();
}


// ========================================================================
// __unwind$566887
// EA  : 0x82A1BEC0
// RVA : 0x00A1BEC0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566887()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 224 + 132));
}


// ========================================================================
// __unwind$566888
// EA  : 0x82A1BEE8
// RVA : 0x00A1BEE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_566888()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 224 + 96));
}


// ========================================================================
// ?UpdateActions@idAI2@@QAAXH@Z
// EA  : 0x82A1BF18
// RVA : 0x00A1BF18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateActions(idAI2 *this, int curTime)
{
  unsigned __int64 v4; // r6
  const char *v5; // r7
  idPLogScope v6[8]; // [sp+50h] [-40h] BYREF

  RD_EventBegin(name: "idAI2::UpdateActions");
  LODWORD(v4) = "idAI2::UpdateActions";
  HIDWORD(v4) = 6;
  idPLogScope::idPLogScope(this: v6, pl: &pLog, gMask: v4, label: v5);
  idFiniteStateMachine::Update(
    this: &this->aiVolatile.fsms.actionManager.legsFSM,
    evaluate: true,
    curTime,
    info: nullptr);
  idComponentTimeLine::Update(this: &this->actionScript);
  idPLogScope::~idPLogScope(this: v6);
  RD_EventEnd();
}


// ========================================================================
// __unwind$567051
// EA  : 0x82A1BF8C
// RVA : 0x00A1BF8C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567051()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 144 + 88));
}


// ========================================================================
// __unwind$567052
// EA  : 0x82A1BFB4
// RVA : 0x00A1BFB4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567052()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 144 + 80));
}


// ========================================================================
// ?PrepTakeCoverFromEntity@idAI2@@QAA?AVidAICover@@PBVidEntity@@00@Z
// EA  : 0x82A1BFE8
// RVA : 0x00A1BFE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::PrepTakeCoverFromEntity(
        idAI2 *this,
        idAI2 *result,
        idEntity *enemy,
        idEntity *coverReference,
        idEntity *coverTarget)
{
  idAIWorldState *p_worldState; // r27
  idAIGameState *p_aiGameState; // r23
  const idSpawnId *v12; // r19
  const idAILogic *v13; // r3
  const idSpawnId *v14; // r8
  idAIEntityState *v15; // r3
  idAIEntityState *v16; // r27
  idEntityPtr<idEntity const > *p_currentEnemy; // r8
  idCoverQuery::coverTarget_t *v18; // r20
  idPhysics *Physics; // r3
  float *v20; // r3
  float v21; // r6
  float v22; // r5
  double z; // fp29
  double y; // fp31
  double x; // fp30
  idPhysics *v26; // r24
  idPhysics *v27; // r20
  int entityNumber; // r19
  int v29; // r24
  idClipModel *v30; // r3
  idAIGameState *v31; // r29
  const idSpawnId *v32; // r3
  idAIGameState *v33; // r29
  const idSpawnId *v34; // r3
  idPhysics *v35; // r3
  const idVec3 *v36; // r29
  idCoverQueryClosest *v37; // r3
  idPhysics *v38; // r29
  int GameMs; // r28
  const idVec3 *v40; // r3
  idPhysics *v41; // r3
  const idVec3 *v42; // r3
  int v44; // [sp+8h] [-418h]
  bool v45; // [sp+Fh] [-411h]
  const char *v46; // [sp+10h] [-410h]
  int v47; // [sp+14h] [-40Ch]
  int v48; // [sp+18h] [-408h]
  int v49; // [sp+1Ch] [-404h]
  int v50; // [sp+20h] [-400h]
  int v51; // [sp+24h] [-3FCh]
  int v52; // [sp+28h] [-3F8h]
  int v53; // [sp+2Ch] [-3F4h]
  int v54; // [sp+30h] [-3F0h]
  int v55; // [sp+34h] [-3ECh]
  int v56; // [sp+38h] [-3E8h]
  int v57; // [sp+3Ch] [-3E4h]
  int v58; // [sp+40h] [-3E0h]
  int v59; // [sp+44h] [-3DCh]
  int v60; // [sp+48h] [-3D8h]
  int v61; // [sp+4Ch] [-3D4h]
  int v62; // [sp+50h] [-3D0h]
  int v63; // [sp+58h] [-3C8h]
  int v64; // [sp+60h] [-3C0h]
  idSpawnId v65[2]; // [sp+70h] [-3B0h] BYREF
  float v66; // [sp+78h] [-3A8h]
  idList<idVehicleState *,5> v67; // [sp+80h] [-3A0h] BYREF
  int v68; // [sp+90h] [-390h]
  idVec3 v69; // [sp+98h] [-388h] BYREF
  idVec3 v70; // [sp+A8h] [-378h] BYREF
  idSpawnId v71; // [sp+B4h] [-36Ch] BYREF
  aiPhysicalState_t v72; // [sp+C0h] [-360h] BYREF
  idAILogic v73; // [sp+120h] [-300h] BYREF
  trace_t v74; // [sp+140h] [-2E0h] BYREF
  idCoverQuery v75; // [sp+1C0h] [-260h] BYREF
  idCoverQueryClosest v76; // [sp+2A0h] [-180h] BYREF

  v68 = 0;
  p_worldState = &result->aiVolatile.world.worldState;
  p_aiGameState = &gameLocal->aiGameState;
  idSpawnId::idSpawnId(this: &v71, ent: result);
  v12 = idSpawnId::idSpawnId(this: v65, ent: enemy);
  v13 = idAILogic::idAILogic(this: &v73, ai: result);
  idAIWorldState::AddEntityState(
    this: p_worldState,
    gameState: p_aiGameState,
    owner: v13,
    entId: v12,
    stimulusType: AISTIMULUS_TRIGGER,
    stimulusAmount: 1.0,
    sourceId: v14);
  v15 = idAIWorldState::StateForEntity(this: p_worldState, ent: enemy);
  v16 = v15;
  if ( v15 != nullptr )
    *((_BYTE *)v15 + 541) &= ~0x40u;
  p_currentEnemy = &result->aiVolatile.memory.currentEnemy;
  if ( enemy != nullptr )
  {
    v65[0] = (idSpawnId)enemy->entityNumber;
    p_currentEnemy->spawnId.value = (gameLocal->spawnIds.ptr[v65[0].value] << 13) | v65[0].value;
  }
  else
  {
    p_currentEnemy->spawnId.value = 0x1FFF;
  }
  idFocusInfo::SetFocusEntity(
    this: result->aiVolatile.focus.foci.ptr,
    owner: result,
    _ent: enemy,
    _keepFocusInView: true,
    _aimPoint: AIMPOINT_BEST,
    duration: -1);
  memset(&v67, 0, 14);
  *(_WORD *)&v67.memTag = 1280;
  idList<idThread *,58>::Clear(this: &v67);
  v18 = idList<idCoverQuery::coverTarget_t,5>::Alloc(this: (idList<idCoverQuery::coverTarget_t,5> *)&v67);
  v18->spawnId = (idSpawnId)idSpawnId::idSpawnId(this: v65, ent: enemy)->value;
  if ( coverTarget != nullptr )
  {
    Physics = idEntity::GetPhysics(this: coverTarget);
    v20 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v21 = v20[1];
    v22 = *v20;
    v66 = v20[2];
    z = v66;
    v65[1] = LODWORD(v21);
    y = v21;
    x = v22;
    v69.z = v66 + (float)0.25;
    v69.y = v21;
    v69.x = v22;
    v70.x = v22;
    v70.y = v21;
    v70.z = v66 - (float)64.0;
    *(float *)&v65[0].value = v21;
    v26 = idEntity::GetPhysics(this: enemy);
    v27 = idEntity::GetPhysics(this: enemy);
    entityNumber = enemy->entityNumber;
    v29 = v26->GetClipMask(this: v26, a2: -1);
    v30 = v27->GetClipModel(this: v27, a2: 0);
    idClip::Translation(
      this: (idClip *)v65,
      result: &clientGame->clip,
      a3: &v74,
      start: &v69,
      end: &v70,
      clipModel: v30,
      startAxis: &mat3_identity,
      clipMask: v29,
      passEntityNumber: v44,
      moveClipModel: v45,
      userName: v46,
      a12: v47,
      a13: v48,
      a14: v49,
      a15: v50,
      a16: v51,
      a17: v52,
      a18: v53,
      a19: v54,
      a20: v55,
      a21: v56,
      a22: v57,
      a23: v58,
      a24: v59,
      a25: v60,
      a26: v61,
      a27: v62,
      a28: entityNumber,
      a29: v63,
      a30: false,
      a31: v64,
      a32: 0);
    if ( v74.fraction != 1.0 )
    {
      x = v74.endpos.x;
      y = v74.endpos.y;
      z = v74.endpos.z;
    }
    idAILogic::idAILogic(this: &v73, ai: result);
    aiPhysicalState_t::aiPhysicalState_t(this: &v72);
    idAIGameState::GetPhysicalState(game: gameLocal, ent: enemy, ps: &v72);
    v72.eyePos.z = (float)z + (float)(v72.eyePos.z - v72.origin.z);
    v72.origin.z = z;
    v72.eyePos.y = (float)y + (float)(v72.eyePos.y - v72.origin.y);
    v72.origin.y = y;
    v72.eyePos.x = (float)(v72.eyePos.x - v72.origin.x) + (float)x;
    v72.origin.x = x;
    if ( v16 != nullptr )
    {
      v31 = &gameLocal->aiGameState;
      v32 = idSpawnId::idSpawnId(this: v65, ent: result);
      idAIEntityState::SetSenseState(
        this: v16,
        gameState: v31,
        aiOwner: &v73,
        sense: AISENSE_HEARING,
        physical: &v72,
        stimType: AISTIMULUS_HEARING,
        sourceId: v32);
      v33 = &gameLocal->aiGameState;
      v34 = idSpawnId::idSpawnId(this: v65, ent: result);
      idAIEntityState::SetSenseState(
        this: v16,
        gameState: v33,
        aiOwner: &v73,
        sense: AISENSE_SIGHT,
        physical: &v72,
        stimType: AISTIMULUS_SIGHT,
        sourceId: v34);
    }
  }
  idAICover::idAICover((idAICover *)this);
  v68 = 1;
  if ( coverReference != nullptr )
  {
    v35 = idEntity::GetPhysics(this: coverReference);
    v36 = v35->GetOrigin(this: v35, a2: 0);
    idCoverQueryClosest::idCoverQueryClosest(
      this: &v76,
      ai: result,
      exclude: &result->aiVolatile.memory.invalidCover,
      _desiredCoverPosition: v36);
    idCoverQuery::Execute(
      this: &v76,
      targets: (const idList<idCoverQuery::coverTarget_t,5> *)&v67,
      referencePoint: v36,
      bestCover: (idAICover *)this,
      inAvoid: false);
    v37 = &v76;
  }
  else
  {
    v38 = idEntity::GetPhysics(this: result);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    v40 = v38->GetOrigin(this: v38, a2: 0);
    idAICoverManager::UpdateCover(
      this: &result->aiVolatile.coverManager,
      ai: result,
      referencePoint: v40,
      curTime: GameMs,
      force: true,
      useStageFilter: false);
    idCoverQuery::idCoverQuery(this: &v75, ai: result, exclude: &result->aiVolatile.memory.invalidCover, flags: 31);
    v75.__vftable = (idCoverQuery_vtbl *)&idCoverQueryTakeCover::`vftable';
    v41 = idEntity::GetPhysics(this: result);
    v42 = v41->GetOrigin(this: v41, a2: 0);
    idCoverQuery::Execute(
      this: &v75,
      targets: (const idList<idCoverQuery::coverTarget_t,5> *)&v67,
      referencePoint: v42,
      bestCover: (idAICover *)this,
      inAvoid: false);
    v37 = (idCoverQueryClosest *)&v75;
  }
  idCoverQuery::~idCoverQuery(this: v37);
  idList<idThread *,58>::Clear(this: &v67);
  return this;
}


// ========================================================================
// __unwind$567110
// EA  : 0x82A1C4A0
// RVA : 0x00A1C4A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567110()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 1056 + 128));
}


// ========================================================================
// __unwind$567111
// EA  : 0x82A1C4C8
// RVA : 0x00A1C4C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567111()
{
  int v0; // r12
  int v1; // r31

  v1 = v0 - 1056;
  if ( (*(_DWORD *)(v0 - 1056 + 144) & 1) != 0 )
  {
    *(_DWORD *)(v1 + 144) &= ~1u;
    idPhysics_StaticMulti::UpdateTime(this: *(bfx::BinaryReplayLogOut **)(v1 + 1076));
  }
}


// ========================================================================
// __unwind$567114
// EA  : 0x82A1C50C
// RVA : 0x00A1C50C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567114()
{
  int v0; // r12

  idCoverQueryTakeCover::~idCoverQueryTakeCover(this: (idCoverQueryClosest *)(v0 - 1056 + 672));
}


// ========================================================================
// __unwind$567115
// EA  : 0x82A1C534
// RVA : 0x00A1C534
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567115()
{
  int v0; // r12

  idCoverQueryTakeCover::~idCoverQueryTakeCover(this: (idCoverQueryClosest *)(v0 - 1056 + 448));
}


// ========================================================================
// ?EnableInfluenceTrail@idAI2@@AAAXVidEntityInfluenceTrail@@@Z
// EA  : 0x82A1C568
// RVA : 0x00A1C568
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

// local variable allocation has failed, the output may be wrong!
void __fastcall idAI2::EnableInfluenceTrail(
        idAI2 *this,
        idEntityInfluenceTrail *trailInfo,
        __int64 a3,
        int a4,
        int a5,
        int a6,
        int a7,
        __int64 a8,
        __int64 a9,
        __int64 a10,
        __int64 a11,
        __int64 a12,
        __int64 a13)
{
  int v13; // r3
  int v14; // r30
  unsigned __int64 v15; // r6
  const char *v16; // r7
  idPresentable *v17; // r4
  idPLogScope v18[7]; // [sp+58h] [-38h] BYREF

  a11 = *(_QWORD *)&trailInfo;
  a12 = *(__int64 *)((char *)&a3 + 4);
  v14 = v13;
  a13 = a3;
  RD_EventBegin(name: "idAI2::EnableInfluenceTrail");
  LODWORD(v15) = "idAI2::EnableInfluenceTrail";
  HIDWORD(v15) = 2;
  idPLogScope::idPLogScope(this: v18, pl: &pLog, gMask: v15, label: v16);
  v17 = *(idPresentable **)(v14 + 488);
  if ( v17 != nullptr && ai_enableInfluenceTrails.valueInteger != 0 )
    idInfluenceTrailManager::Enable(
      this: &clientGame->influenceTrailManager,
      presentable: v17,
      trail: (const idEntityInfluenceTrail *)&a11,
      sndFoliage: nullptr);
  idPLogScope::~idPLogScope(this: v18);
  RD_EventEnd();
}


// ========================================================================
// __unwind$567361
// EA  : 0x82A1C604
// RVA : 0x00A1C604
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567361()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 144 + 96));
}


// ========================================================================
// __unwind$567362
// EA  : 0x82A1C62C
// RVA : 0x00A1C62C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_567362()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 144 + 88));
}


// ========================================================================
// ?Spawn@idAI2@@QAAXXZ
// EA  : 0x82A1DA90
// RVA : 0x00A1DA90
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Spawn(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  int GameMs; // r29
  int (__fastcall *GetGameMsPerFrame)(struct idGameLocal *, const gameTimeType_t); // r8
  idPLog *pLog; // r28
  int v7; // r28
  long double v8; // fp2
  long double v9; // fp2
  idAIHealth *p_aiHealth; // r29
  double v11; // fp1
  idPresentable *presentable; // r11
  idPresentable *v13; // r11
  idPresentable *v14; // r11
  idPresentable *v15; // r3
  idPresentableAnimatedEntity *v16; // r4
  idPresentable *v17; // r3
  const idDeclGore *goreDef; // r29
  idAIOrientation *BodyOrientation; // r3
  double value; // fp31
  idAIOrientation *v21; // r29
  long double v22; // fp2
  long double v23; // fp2
  idPhysics *Physics; // r3
  float *v25; // r3
  idAI2_vtbl *v26; // r11
  int v27; // r4
  int num; // r11
  int v29; // r28
  int v30; // r29
  int v31; // r9
  idEntity *v32; // r3
  idActionNode *v33; // r3
  idActionNode *v34; // r3
  char v35; // r11
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  idPresentable *v37; // r3
  idPhysics *v38; // r28
  idPresentable *v39; // r29
  int v40; // r3
  idPresentable *v41; // r11
  unsigned __int64 v42; // r6
  const char *v43; // r7
  idAIGameState *p_aiGameState; // r28
  const idSpawnId *SpawnId; // r3
  idPLog *v46; // r28
  idPLog::logEntry_t *v47; // r29
  int v48; // r3
  __int64 totalTicks; // r11
  __int64 v50; // r9
  int v51; // r10
  int v52; // r9
  int v53; // r8
  int v54; // r7
  idPhysics *v55; // r3
  const idBounds *v56; // r3
  BOOL v57; // r4
  const idDeclAIBehavior *decl; // r11
  const idDeclDamage *closeMeleeKickDamage; // r10
  const idDeclDamage *closeMeleePunchDamage; // r10
  __int64 v61; // [sp+8h] [-E8h]
  __int64 v62; // [sp+10h] [-E0h]
  __int64 v63; // [sp+18h] [-D8h]
  __int64 v64; // [sp+20h] [-D0h]
  __int64 v65; // [sp+28h] [-C8h]
  __int64 v66; // [sp+30h] [-C0h]
  idEntityPtr<idAI2> v67[2]; // [sp+50h] [-A0h] BYREF
  idPLogScope v68; // [sp+58h] [-98h] BYREF
  idPLogScope v69[2]; // [sp+60h] [-90h] BYREF
  idFSMManager::idFSMStack v70; // [sp+70h] [-80h] BYREF

  RD_EventBegin(name: "idAI2::Spawn");
  LODWORD(v2) = "idAI2::Spawn";
  HIDWORD(v2) = 2;
  idPLogScope::idPLogScope(this: v69, pl: &::pLog, gMask: v2, label: v3);
  if ( idEntity::GetPhysics(this) == nullptr )
  {
    idLib::Warning(
      fmt: "AI entity '%s' does not have a valid physics model, this is not a valid state so it has been removed from the world",
      this->name.data);
    idEventReceiver::PostEventMS(this, ev: &EV_Remove, time: 0);
    idPLogScope::~idPLogScope(this: v69);
LABEL_3:
    RD_EventEnd();
    return;
  }
  idEntity::BecomeActive(this, flags: 1);
  if ( this != nullptr )
    v67[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
  else
    v67[0].spawnId.value = 0x1FFF;
  idList<idEntityPtr<idEntity>,5>::AddUnique(
    this: (idList<idEntityPtr<idAI2>,5> *)&gameLocal->aiWorldStateUsers,
    obj: v67);
  if ( this != nullptr )
  {
    v67[0] = (idEntityPtr<idAI2>)this->entityNumber;
    v67[0].spawnId.value |= gameLocal->spawnIds.ptr[v67[0].spawnId.value] << 13;
  }
  else
  {
    v67[0].spawnId.value = 0x1FFF;
  }
  idList<idEntityPtr<idEntity>,5>::AddUnique(this: &gameLocal->activeAI, obj: v67);
  GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
  GetGameMsPerFrame = gameLocal->GetGameMsPerFrame;
  v68.pLog = (idPLog *)(int)(float)((float)1000.0 * this->dormancy.delay);
  pLog = v68.pLog;
  v7 = 10 * GetGameMsPerFrame(this: gameLocal, a2: GAMETIME_SCALED) - (_DWORD)pLog;
  this->dormancy.lastTimeInPlayerPVS = gameLocal->GetGameMsPerRealSec(this: gameLocal) + v7 + GameMs;
  idAI2::InitMemory(this);
  idAI2::InitScriptObjects(this);
  *(_BYTE *)&this->flags = (2 * (*((_BYTE *)&this->aiEditable.behaviors.decl->damageBehaviors + 84) >> 7)) & 2
                         | *(_BYTE *)&this->flags & 0xFD;
  idAI2::InitMovement(this);
  idAI2::InitPhysics(this);
  idAI2::SetMovePushStatus(this, newStatus: this->aiEditable.movement.movePushStatus, frameCount: 0);
  this->scriptProxy.owner = this;
  idAIEventManager::AddReceiver(this: &gameLocal->aiEventManager, receiver: this);
  idAI2::InitNav(this);
  idAI2::InitAAS(this);
  idAI2::UpdateTravelFlags(this);
  *(double *)&v8 = (float)((float)(this->aiEditable.perception.fieldOfView.value * (float)0.5) * idMath::M_DEG2RAD);
  v9 = cos(x: v8);
  p_aiHealth = &this->aiHealth;
  this->aiVolatile.perception.fovDot = *(double *)&v9;
  if ( this->aiHealth.IsDead_Impl(this: &this->aiHealth) )
  {
    idLib::Warning(fmt: "Entity '%s' spawned dead.", this->name.data);
    v11 = ((double (__fastcall *)(idAIHealth *))p_aiHealth->GetCurBaseHealth_Impl)(a1: &this->aiHealth);
    p_aiHealth->Heal_Impl(this: &this->aiHealth, a2: (float)((float)1.0 - (float)v11));
  }
  this->aiVolatile.world.worldState.radius = this->aiEditable.perception.actorPerceptionRadius;
  if ( (unsigned __int8)idAI2::InitAnimation(this) == 0 )
    idLib::Error(fmt: "AI '%s' failed to initialize animations", this->name.data);
  idAI2::InitHeadTracking(this);
  presentable = this->presentable;
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
  }
  presentable->model->g.dimShadowClipZ = -15.0;
  v13 = this->presentable;
  if ( v13 == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    v13 = this->presentable;
  }
  *((_BYTE *)&v13->model->g + 105) |= 0x10u;
  v14 = this->presentable;
  if ( v14 == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    v14 = this->presentable;
  }
  *((_BYTE *)&v14->model->g + 107) |= 0x20u;
  v15 = this->presentable;
  if ( v15 != nullptr )
    v16 = v15->GetAnimatedEntityInterface(this: v15);
  else
    v16 = nullptr;
  idGoreComponent::Init(
    this: &this->aiVolatile.death.goreComponent,
    inPresentable: v16,
    inGoreDecl: this->aiEditable.death.goreDef);
  v17 = this->presentable;
  if ( v17 == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    v17 = this->presentable;
  }
  goreDef = this->aiEditable.death.goreDef;
  v17->GetAIInterface(this: v17)->bloodSplatterEventInfo.goreInfo = goreDef;
  idAI2::UpdateMeleeCapabilities(this);
  idPhysics_StaticMulti::UpdateTime(this: (bfx::BinaryReplayLogOut *)&this->aiVolatile.voiceController);
  idAI2::InitActionSettings(this);
  if ( this->aiEditable.skill.skill == AISKILL_MAX )
  {
    idLib::Warning(fmt: "AISKILL_MAX is not a valid skill level for AI");
    this->aiEditable.skill.skill = AISKILL_NORMAL;
  }
  idAI2::InitFireControl(this);
  BodyOrientation = idAI2::GetBodyOrientation(this);
  idAIOrientation::Init(this: BodyOrientation, axis: &this->spawnOrientation);
  value = this->aiConstants.movement.alignmentTolerance.value;
  v21 = idAI2::GetBodyOrientation(this);
  *(double *)&v22 = (float)((float)value * idMath::M_DEG2RAD);
  v23 = cos(x: v22);
  v21->tolerance = *(double *)&v23;
  idAIPlayerInteraction::Init(
    this: &this->aiVolatile.aiPlayerInteraction,
    _owner: this,
    _decl: this->aiEditable.interactions.playerInteraction);
  idAI2::InitFSMs(this);
  if ( this->aiEditable.spawnSettings.alwaysInCombat )
  {
    idAI2::SetAlertCycle(this, ac: ALERTCYCLE_COMBAT);
    vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v70);
    idFSMManager::idFSMStack::Add(this: &v70, fsmType: &idAlertCycleFSM::Type, stateType: &idAlertCycle_Default::Type);
    idFSMManager::SetFSMStack(this: &this->aiVolatile.fsms.fsmManager, stack: &v70);
    idPLog::~idPLog(this: &v70);
  }
  Physics = idEntity::GetPhysics(this);
  v25 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
  this->aiVolatile.memory.spawnPosition.x = *v25;
  this->aiVolatile.memory.spawnPosition.y = v25[1];
  this->aiVolatile.memory.spawnPosition.z = v25[2];
  this->aiVolatile.memory.currentPlayerInteraction = -1;
  this->aiVolatile.memory.triggeredInteraction.spawnId.value = 0x1FFF;
  this->EnableAIEventResponse(this, a2: AIEVENT_ALL_AI);
  this->DisableAIEventResponse(this, a2: this->aiEditable.perception.eventsToIgnore);
  v26 = this->__vftable;
  if ( this->aiVolatile.aiPlayerInteraction.decl != nullptr )
    v26->EnableAIEventResponse(this, a2: AIEVENT_PLAYER_INTERACTION);
  else
    v26->DisableAIEventResponse(this, a2: AIEVENT_PLAYER_INTERACTION);
  num = this->targets.num;
  v29 = 0;
  this->aiVolatile.numActionNodes = 0;
  if ( num > 0 )
  {
    v30 = 0;
    do
    {
      if ( v29 < this->targets.num
        && (v31 = this->targets.list[v30].spawnId.value, gameLocal->spawnIds.ptr[v31 & 0x1FFF] == v31 >> 13)
        && (v32 = gameLocal->entities.ptr[v31 & 0x1FFF]) != nullptr )
      {
        v33 = (idActionNode *)idEntity::CastTo(c: v32);
      }
      else
      {
        v33 = nullptr;
      }
      v34 = idActionNode::CastTo(c: v33);
      if ( v34 != nullptr )
      {
        if ( v34->actionScript.num > 0 || (v35 = 0, v34->anims.num > 0) )
          v35 = 1;
        if ( v35 != 0 )
          ++this->aiVolatile.numActionNodes;
      }
      ++v29;
      ++v30;
    }
    while ( v29 < this->targets.num );
  }
  idAIWorldState::Init(
    this: &this->aiVolatile.world.worldState,
    visibleSightTime_: this->aiEditable.perception.exposedSightTime,
    friendlyVisibilityEffectsMask_: v27,
    enemyVisibilityEffectsMask_: -1);
  *((_BYTE *)&this->aiVolatile + 49704) |= 0x80u;
  if ( ai_moveModeLookAhead.valueInteger != 0 && idAnimatedEntity::GetTreeAnimatorFromPresentable(this) != nullptr )
  {
    TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
    idTreeAnimator::SetOriginDeltaLookAhead(this: TreeAnimatorFromPresentable, lookAhead: true);
  }
  v37 = this->presentable;
  if ( v37 == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    v37 = this->presentable;
  }
  idPresentable::SetClipModelInfo(
    this: v37,
    clipModelInfo_: &this->clipModelInfo,
    clipModelSpawnPos_: &this->spawnPosition,
    clipModelSpawnAxis_: &this->spawnOrientation);
  if ( idEntity::GetPhysics(this) != nullptr )
  {
    v38 = idEntity::GetPhysics(this);
    if ( this->presentable == nullptr )
      idEntity::InitPresentableInternal(this);
    v39 = this->presentable;
    v40 = v38->GetContents(this: v38, a2: -1);
    idPresentable::SetClipModelContents(this: v39, newContents: v40);
  }
  v41 = this->presentable;
  if ( v41 == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    v41 = this->presentable;
  }
  v41->clipModelDynamic = true;
  idDynamicCoverMgr::Init(this: &this->formationCover);
  RD_EventBegin(name: "idAI2::Spawn - force latch");
  LODWORD(v42) = "idAI2::Spawn - force latch";
  HIDWORD(v42) = 2;
  idPLogScope::idPLogScope(this: &v68, pl: &::pLog, gMask: v42, label: v43);
  p_aiGameState = &gameLocal->aiGameState;
  SpawnId = idGameLocal::GetSpawnId(this: (idGameLocal *)v67, result: (idSpawnId *)gameLocal, ent: this);
  idAIGameState::ForceLatch(this: p_aiGameState, spawnId: SpawnId);
  idAIGameState::UpdateForcedLatches(this: &gameLocal->aiGameState, game: gameLocal);
  if ( v68.logIndex >= 0 )
  {
    v46 = v68.pLog;
    v47 = &v68.pLog->logEntries.list[v68.logIndex];
    v48 = (unsigned __int64)Sys_GetClockTicks() >> 32;
    totalTicks = v47->totalTicks;
    HIDWORD(totalTicks) = v47->parent;
    LODWORD(v50) = v48 - totalTicks;
    v47->totalTicks = v50;
    v46->lastEntry = HIDWORD(totalTicks);
  }
  RD_EventEnd();
  idAI2::EnableInfluenceTrail(
    this: (idAI2 *)LODWORD(this->aiConstants.movement.influence.innerRadius),
    trailInfo: (idEntityInfluenceTrail *)LODWORD(this->aiConstants.movement.influence.angle),
    a3: *(_QWORD *)&this->aiConstants.movement.influence.trailFadeInTime,
    a4: v54,
    a5: v53,
    a6: v52,
    a7: v51,
    a8: v61,
    a9: v62,
    a10: v63,
    a11: v64,
    a12: v65,
    a13: v66);
  if ( this->aiEditable.startInDropState )
    this->aiVolatile.dropState = 0;
  if ( gameLocal->gamestate == GAMESTATE_ACTIVE )
    idAI2::InitEncounterGroup(this);
  *(_BYTE *)&this->flags |= 0x40u;
  v55 = idEntity::GetPhysics(this);
  v56 = v55->GetAbsBounds(this: v55, a2: -1);
  idEntity::UpdatePVSAreas(this, bounds: v56);
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
  {
    v57 = (unsigned __int8)Get_idCombatStage_useRelaxedChatterVO(ptr: this) != 0;
    this->aiVolatile.animation.animFSM.EnterHiddenMode(this: &this->aiVolatile.animation.animFSM, a2: v57);
  }
  idGameLocal::BotSystems_RegisterEntity(this: gameLocal, entity: this, entityType: 32, entityFlags: 608);
  decl = this->aiEditable.behaviors.decl;
  closeMeleeKickDamage = decl->closeMeleeKickDamage;
  v67[0].spawnId.value = (int)decl;
  if ( closeMeleeKickDamage != nullptr )
  {
    closeMeleePunchDamage = decl->closeMeleePunchDamage;
    v67[0].spawnId.value = (int)decl;
    if ( closeMeleePunchDamage != nullptr )
    {
      idPLogScope::~idPLogScope(this: v69);
      goto LABEL_3;
    }
  }
  if ( decl->closeMeleeKickDamage == nullptr )
    idLib::Warning(fmt: "%s has missing decls for closeMeleeKickDamage", this->name.data);
  if ( this->aiEditable.behaviors.decl->closeMeleePunchDamage == nullptr )
    idLib::Warning(fmt: "%s has missing decls for closeMeleePunchDamage", this->name.data);
  idLib::Error(fmt: "%s is missing required decls in idEditable.behaviors, did it default?", this->name.data);
  _LN369();
}


// ========================================================================
// $LN369
// EA  : 0x82A1E3E8
// RVA : 0x00A1E3E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _LN369()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 240 + 144));
}


// ========================================================================
// __unwind$569938
// EA  : 0x82A1E410
// RVA : 0x00A1E410
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_569938()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 240 + 96));
}


// ========================================================================
// __unwind$569939
// EA  : 0x82A1E438
// RVA : 0x00A1E438
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_569939()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 240 + 112));
}


// ========================================================================
// __unwind$569940
// EA  : 0x82A1E460
// RVA : 0x00A1E460
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_569940()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 240 + 145));
}


// ========================================================================
// __unwind$569941
// EA  : 0x82A1E488
// RVA : 0x00A1E488
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_569941()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 240 + 88));
}


// ========================================================================
// ?Show@idAI2@@UAAXXZ
// EA  : 0x82A1E4B0
// RVA : 0x00A1E4B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Show(idAI2 *this)
{
  char idCombatStage_useRelaxedChatterVO; // r30
  idPhysics *Physics; // r3
  idAI2 *v4; // r5
  idAIGameState *p_aiGameState; // r31
  const idSpawnId *SpawnId; // r3
  idEntityPtr<idAI2> v7[12]; // [sp+50h] [-30h] BYREF

  idCombatStage_useRelaxedChatterVO = Get_idCombatStage_useRelaxedChatterVO(ptr: this);
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    this->aiVolatile.animation.animFSM.EnterHiddenMode(this: &this->aiVolatile.animation.animFSM, a2: false);
  idEntity::BecomeActive(this, flags: 1);
  idEntity::BecomeActive(this, flags: 2);
  idAIMoveState::ResetStuck(this: &this->aiVolatile.physics.moveState);
  Physics = idEntity::GetPhysics(this);
  Physics->LinkClip(this: Physics);
  idEntity::LeaveDormancy(this);
  idActor::Show(this);
  if ( idCombatStage_useRelaxedChatterVO != 0 )
  {
    if ( this->IsDying(this) || this->IsDead(this) )
    {
      idEntity::BecomeActive(this, flags: 4);
    }
    else
    {
      v7[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
      idList<idEntityPtr<idEntity>,5>::AddUnique(this: &gameLocal->activeAI, obj: v7);
      v7[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
      idList<idEntityPtr<idEntity>,5>::AddUnique(
        this: (idList<idEntityPtr<idAI2>,5> *)&gameLocal->aiWorldStateUsers,
        obj: v7);
      idAI2::SetSolid(this, isSolid: true);
      v4 = this;
      p_aiGameState = &gameLocal->aiGameState;
      SpawnId = idGameLocal::GetSpawnId(this: (idGameLocal *)v7, result: (idSpawnId *)gameLocal, ent: v4);
      idAIGameState::ForceLatch(this: p_aiGameState, spawnId: SpawnId);
      idAIGameState::UpdateForcedLatches(this: &gameLocal->aiGameState, game: gameLocal);
    }
  }
}


// ========================================================================
// ?UpdateFSMs@idAI2@@IAAXXZ
// EA  : 0x82A1E658
// RVA : 0x00A1E658
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateFSMs(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idFiniteStateMachine *v4; // r24
  int GameMs; // r3
  signed int num; // r30
  int v7; // r3
  idGameLocal *v8; // r4
  int v9; // r8
  int v10; // r11
  bool v11; // r30
  bool v12; // zf
  int value; // r30
  idSpawnId *SpawnId; // r3
  int v15; // r3
  char v16; // r8
  int v17; // r11
  const idDeclVehicleUpgrade **v18; // r10
  int v19; // r30
  int v20; // r3
  int v21; // r27
  int v22; // r26
  const idDeclVehicleUpgrade **v23; // r29
  idClass *v24; // r3
  const char *Classname; // r25
  idClass *v26; // r3
  const char *v27; // r28
  const char *textSource; // r30
  const char *v29; // r3
  int v30; // r3
  const idDeclVehicleUpgrade *v31; // [sp+50h] [-80h] BYREF
  idPLogScope v32; // [sp+58h] [-78h] BYREF
  idList<idDeclVehicleUpgrade const *,5> v33[7]; // [sp+60h] [-70h] BYREF

  RD_EventBegin(name: "idAI2::UpdateFSMs");
  LODWORD(v2) = "idAI2::UpdateFSMs";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: &v32, pl: &pLog, gMask: v2, label: v3);
  if ( this->aiVolatile.fsms.suspend
    || (v4 = this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type)) == nullptr )
  {
    idPLogScope::~idPLogScope(this: &v32);
  }
  else
  {
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idAI2::UpdateActions(this, curTime: GameMs);
    idList<idVehicleKey *,5>::idList<idVehicleKey *,5>(this: v33);
    num = gameLocal->activeAI.num;
    if ( ai_limitFSMUpdates.valueInteger != 0 )
    {
      if ( num <= 7 )
        num = 7;
    }
    else if ( num < 1 )
    {
      num = 1;
    }
    v7 = idAccolade::Count(this: &clientGame->gameTimeManager);
    v8 = gameLocal;
    v9 = gameLocal->activeAI.num;
    v10 = v7 % num;
    __twllei(num, 0);
    __twlgei(num & ~(__ROL4__(v7, 1) - 1), 0xFFFFFFFF);
    v12 = v7 % num >= v9;
    v11 = false;
    if ( !v12 )
    {
      value = v8->activeAI.list[v10].spawnId.value;
      SpawnId = idGameLocal::GetSpawnId(this: (idGameLocal *)&v31, result: (idSpawnId *)v8, ent: this);
      v8 = gameLocal;
      v11 = (_cntlzw(SpawnId->value - value) & 0x20) != 0;
    }
    if ( (_cntlzw((char *)this - (char *)idGameLocal::GetDebugEntity(this: v8)) & 0x20) != 0
      && ai_debugState.valueInteger == 1
      || ai_debugState.valueInteger > 1 )
    {
      v15 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idFiniteStateMachine::Update(
        this: v4,
        evaluate: v11,
        curTime: v15,
        info: (idList<idState::transitionInfo_t,5> *)v33);
      if ( v33[0].num > 0 && ai_debugState.valueInteger > 0 && idAI2::GetDebugLevel() >= 0 )
      {
        v16 = 0;
        v17 = 0;
        if ( v33[0].num > 0 )
        {
          v18 = v33[0].list + 6;
          while ( *v18 == nullptr )
          {
            ++v17;
            v18 += 7;
            if ( v17 >= v33[0].num )
              goto LABEL_23;
          }
          v16 = 1;
        }
LABEL_23:
        if ( v16 != 0 )
        {
          v19 = v33[0].num;
          v20 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
          idLib::Printf(fmt: "State( %d ), %d state changes\n", v20, v19);
          idLib::Printf(fmt: "-- %s --\n", this->name.data);
          v21 = 0;
          if ( v33[0].num > 0 )
          {
            v22 = 0;
            do
            {
              v23 = &v33[0].list[v22];
              v24 = (idClass *)v33[0].list[v22 + 2];
              if ( v24 != nullptr )
              {
                v31 = v33[0].list[v22 + 2];
                Classname = idClass::GetClassname(this: v24);
              }
              else
              {
                Classname = "< NULL >";
              }
              v26 = (idClass *)v23[1];
              if ( v26 != nullptr )
              {
                v31 = v23[1];
                v27 = idClass::GetClassname(this: v26);
              }
              else
              {
                v27 = "< NULL >";
              }
              if ( *v23 != nullptr )
                textSource = (*v23)->textSource;
              else
                textSource = "< NULL >";
              v29 = idAIStateTransition::NameForTransitionCode(tc: (const idAIStateTransition::aiTransCode_t)v23[6]);
              idLib::Printf(fmt: "^7fsm: ^2%s ^7prev: ^2%s ^7new: ^2%s ^7code: ^2%s\n", textSource, v27, Classname, v29);
              ++v21;
              v22 += 7;
            }
            while ( v21 < v33[0].num );
          }
        }
      }
    }
    else
    {
      v30 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idFiniteStateMachine::Update(this: v4, evaluate: v11, curTime: v30, info: nullptr);
    }
    idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)v33);
    idPLogScope::~idPLogScope(this: &v32);
  }
  RD_EventEnd();
}


// ========================================================================
// __unwind$570898
// EA  : 0x82A1E9D0
// RVA : 0x00A1E9D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_570898()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 208 + 112));
}


// ========================================================================
// __unwind$570899
// EA  : 0x82A1E9F8
// RVA : 0x00A1E9F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_570899()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 208 + 88));
}


// ========================================================================
// __unwind$570900
// EA  : 0x82A1EA20
// RVA : 0x00A1EA20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_570900()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 208 + 96));
}


// ========================================================================
// ?StartDeathSystem@idAI2@@IAAXXZ
// EA  : 0x82A1EA50
// RVA : 0x00A1EA50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::StartDeathSystem(idAI2 *this)
{
  idAIDeathInfo *p_deathInfo; // r16
  int GameMs; // r3
  char v4; // r11
  bool v5; // r20
  const idDeclDamage *damageDecl; // r11
  idDeclDamage::damageType_t damageTypes; // r11
  char *v8; // r4
  damageDirection_t DamageDirection; // r3
  idIndex<short,enum invalidJointIndex_t> *TreeAnimatorFromPresentable; // r3
  idTreeAnimator *JointIndex; // r3
  idTreeAnimator *v12; // r3
  const idJointGroup *JointGroup; // r3
  const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *v14; // r22
  idDeclAnimWeb *StateIndexForName; // r3
  idEntity *curScenePoint; // r29
  const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *v17; // r21
  idScenePoint_Combat *v18; // r3
  idDeclAnimWeb *v19; // r3
  deathFlags_t deathFlags; // r7
  idPhysics *Physics; // r3
  idQuat *v22; // r27
  idScenePoint *ScenePointPos; // r29
  const idQuat *v24; // r3
  idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *decl; // r29
  idAnimator_AnimWeb *CurStateIndex; // r27
  idAnimator_AnimWeb *CurSubWebIndex; // r3
  idDeclAnimWebNode *v28; // r27
  int num; // r24
  int v30; // r26
  int v31; // r29
  const idDeclAnimWeb *v32; // r4
  idDeclAnimWeb::idEdgeCache *list; // r11
  int value; // r9
  __int16 v35; // r8
  idDeclAnimWebNode *v36; // r3
  idSmartLootComponent *v37; // r3
  idEventArg *v38; // r3
  int v39; // r4
  idGameLocal *v40; // r10
  idList<idEntityPtr<idEntity>,58> *p_aiWorldStateUsers; // r3
  int v42; // r8
  int v43; // r11
  idWeapon *v44; // r3
  idWeapon *v45; // r29
  idFXManager *v46; // r3
  const idDeclDamage *v47; // r11
  const char *str; // r4
  idStr *v49; // r29
  idEntity *v50; // r3
  int v51; // r9
  idEntity *v52; // r3
  int v53; // r9
  idEntity *v54; // r3
  idEntity *v55; // r29
  idEventArg *v56; // r3
  bool v57; // r28
  idPresentable *presentable; // r3
  int v59; // r3
  idScenePoint *v60; // r3
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r28
  int i; // r29
  idEncounterGroup *v63; // r28
  int v64; // r9
  idGameLocal *v65; // r11
  idEntity *v66; // r3
  idEntity *v67; // r3
  const idEntity *v68; // r29
  idEntity *v69; // r3
  idEntity *v70; // r5
  int v71; // r9
  idGameLocal *v72; // r11
  idEntity *v73; // r3
  idEntity *v74; // r3
  const idEntity *v75; // r27
  idEntity *v76; // r3
  idEntity *v77; // r28
  damageDirection_t v78; // r23
  const idHandle<int,enum invalidJointGroupHandle,0> *DeathGroupHandle; // r3
  __int64 v80; // r9
  idPhysics *v81; // r28
  idEntity *v82; // r3
  idEntity *v83; // r29
  int v84; // r27
  idPhysics *v85; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r26
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r28
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  const idVec3 *v89; // r3
  idPresentable *v90; // r11
  idRenderModel *model; // r9
  const idDeclDamage *v92; // [sp+8h] [-1D8h]
  idDeclAnimWeb v93; // [sp+60h] [-180h] BYREF

  p_deathInfo = &this->aiVolatile.death.deathInfo;
  if ( this->GetPosture(this) != POSTURE_CROUCHED
    || (this->aiVolatile.groupStatus.condition & 8) == 0
    || (GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED),
        v4 = 1,
        GameMs - this->actorVolatile.postureChangeTime <= 500) )
  {
    v4 = 0;
  }
  v5 = (this->aiVolatile.death.deathInfo.deathFlags & 0x10) == 0
    && (v4 != 0
     || this->aiVolatile.physics.moveState.IsPlayingTraversalAnim(this: &this->aiVolatile.physics.moveState)
     || (*((_BYTE *)&this->aiVolatile.death + 1760) & 0x80) != 0);
  if ( !v5 && (this->aiVolatile.death.deathInfo.deathFlags & 0x10) == 0 )
  {
    idStr::idStr(this: (idStr *)&v93.editorModels.size, text: "death");
    idStr::idStr(this: (idStr *)&v93.idResource + 1, text: &byte_8200D768);
    if ( this->aiEditable.death.deathAnim.len != 0 )
    {
      idAI2::GetSubWebAndStateFromAnimWebPath(
        this,
        animWebPath: this->aiEditable.death.deathAnim.data,
        subWebName: (idStr *)&v93.editorModels.size,
        stateName: (idStr *)&v93.idResource + 1);
      v5 = false;
    }
    else
    {
      damageDecl = p_deathInfo->impulse.damageDecl;
      if ( damageDecl != nullptr )
        damageTypes = damageDecl->damageTypes;
      else
        LOBYTE(damageTypes) = 0;
      if ( (damageTypes & 0x8C) != 0 )
      {
        idStr::Append(this: (idStr *)&v93.idResource + 1, text: "light_");
      }
      else if ( (damageTypes & 0x30) != 0 )
      {
        idStr::Append(this: (idStr *)&v93.idResource + 1, text: "heavy_");
      }
      else
      {
        v5 = true;
      }
      if ( !v5 )
      {
        if ( this->GetPosture(this) == POSTURE_CROUCHED )
          v8 = "crouch_";
        else
          v8 = "stand_";
        idStr::Append(this: (idStr *)&v93.idResource + 1, text: v8);
        DamageDirection = idActor::GetDamageDirection(
                            axis: &this->actorVolatile.modelInfo.modelAxis,
                            dir: &p_deathInfo->impulse.impactDir,
                            numDirs: 4);
        idStr::Append(this: (idStr *)&v93.idResource + 1, text: (char *)damageDirectionNames[DamageDirection]);
        idStr::Append(this: (idStr *)&v93.idResource + 1, text: "_");
        idActor::GetDeathGroupHandle(
          this: (idActor *)&v93.resourceError,
          result: (idHandle<int,enum invalidJointGroupHandle,0> *)this,
          joint: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)p_deathInfo->impulse.jointIndex.value);
        if ( v93.resourceError == (const char *)NULL_JOINT_GROUP.value )
        {
          TreeAnimatorFromPresentable = (idIndex<short,enum invalidJointIndex_t> *)idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
          JointIndex = idTreeAnimator::GetJointIndex(
                         this: (idTreeAnimator *)&v93,
                         result: TreeAnimatorFromPresentable,
                         jointName: "spine");
          v93.resourceError = (const char *)idActor::GetDeathGroupHandle(
                                              this: (idActor *)&v93.name,
                                              result: (idHandle<int,enum invalidJointGroupHandle,0> *)this,
                                              joint: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(JointIndex->__vftable))->value;
        }
        v12 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
        JointGroup = idJointGroupCollection::GetJointGroup(
                       this: &v12->decl->jointGroupCollection,
                       handle: (const idHandle<int,enum invalidJointGroupHandle,0> *)&v93.resourceError);
        idStr::Append(this: (idStr *)&v93.idResource + 1, text: (char *)JointGroup->groupName.str);
      }
    }
    LOWORD(v14) = HIWORD(idDeclAnimWeb::GetSubWebIndexForName(
                           this: &v93,
                           result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                           subWebName: *(const char **)&v93.editorModels.granularity)->__vftable);
    StateIndexForName = idDeclAnimWeb::GetStateIndexForName(
                          this: (idDeclAnimWeb *)&v93.name,
                          result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                          name: v93.textSource);
    curScenePoint = this->aiVolatile.memory.curScenePoint;
    LOWORD(v17) = HIWORD(StateIndexForName->__vftable);
    if ( curScenePoint != nullptr )
    {
      v5 = false;
      if ( curScenePoint[1].name.data == (char *)4 )
      {
        v18 = idScenePoint_Combat::CastTo(c: (idScenePoint_Combat *)this->aiVolatile.memory.curScenePoint);
        if ( v18->customSet.deathAnim.len != 0 )
        {
          v93.models.list = (const idDeclMD6 **)20;
          v93.states.size = 0;
          *(_DWORD *)&v93.states.granularity = &v93.models.num;
          HIBYTE(v93.models.num) = 0;
          v93.edgeCache.list = (idDeclAnimWeb::idEdgeCache *)20;
          *(_DWORD *)&v93.edges.granularity = &v93.edgeCache.num;
          v93.edges.size = 0;
          HIBYTE(v93.edgeCache.num) = 0;
          idAI2::GetSubWebAndStateFromAnimWebPath(
            this,
            animWebPath: v18->customSet.deathAnim.data,
            subWebName: (idStr *)&v93.states.size,
            stateName: (idStr *)&v93.edges.size);
          v14 = (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)HIWORD(idDeclAnimWeb::GetSubWebIndexForName(
                                                                                          this: (idDeclAnimWeb *)&v93.name,
                                                                                          result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                                                                                          subWebName: *(const char **)&v93.states.granularity)->__vftable);
          v19 = idDeclAnimWeb::GetStateIndexForName(
                  this: &v93,
                  result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                  name: *(const char **)&v93.edges.granularity);
          deathFlags = this->aiVolatile.death.deathInfo.deathFlags;
          v17 = (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)HIWORD(v19->__vftable);
          this->aiVolatile.death.deathInfo.deathFlags = deathFlags | 1;
          this->aiVolatile.death.deathInfo.deathFlags = deathFlags & 0xFFFFFFDE | 1;
          Physics = idEntity::GetPhysics(this: curScenePoint);
          v22 = (idQuat *)Physics->GetAxis(this: Physics, a2: 0);
          ScenePointPos = idScenePoint::GetScenePointPos(this: (idScenePoint *)&v93.name, result: curScenePoint);
          v24 = idMat3::ToQuat(this: (idMat3 *)&v93.nodeCache.size, result: v22);
          idAIMoveState::StartPerfectOrigin(
            this: &this->aiVolatile.physics.moveState,
            idealAxis: v24,
            idealPos: (const idVec3 *)ScenePointPos,
            lerpTimeMs: 400,
            swi: v14,
            si: v17);
          idStr::FreeData(this: (idStr *)&v93.edges.size);
          idStr::FreeData(this: (idStr *)&v93.states.size);
        }
      }
    }
    if ( (this->aiVolatile.death.deathInfo.deathFlags & 1) == 0 )
    {
      decl = (idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl;
      CurStateIndex = idAnimator_AnimWeb::GetCurStateIndex(
                        this: (idAnimator_AnimWeb *)&v93.name,
                        result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)&this->aiVolatile.animation);
      CurSubWebIndex = idAnimator_AnimWeb::GetCurSubWebIndex(
                         this: (idAnimator_AnimWeb *)&v93,
                         result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)&this->aiVolatile.animation);
      idDeclAnimWeb::FindNodeIndex(
        this: (idDeclAnimWeb *)&v93.networkID,
        result: decl,
        subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)HIWORD(CurSubWebIndex->__vftable),
        stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)HIWORD(CurStateIndex->__vftable));
      if ( v93.networkID >= 0 )
      {
        v28 = this->aiVolatile.animation.animWebAnimator.ptr[0].decl->nodes.list[SHIWORD(v93.networkID)];
        if ( v28 != nullptr )
        {
          num = v28->edges.num;
          if ( num > 0 )
          {
            v30 = 0;
            v31 = 0;
            while ( 1 )
            {
              v32 = this->aiVolatile.animation.animWebAnimator.ptr[0].decl;
              list = v32->edgeCache.list;
              value = v28->edges.list[v31].value;
              v93.name.str = (const char *)v32;
              v35 = list[value].destNodeIndex.value;
              v36 = v35 == -1 ? nullptr : v32->nodes.list[v35];
              v93.subWebs.list = (idDeclAnimWeb::idSubWebInfo *)20;
              v93.nodes.size = 0;
              *(_DWORD *)&v93.nodes.granularity = &v93.subWebs.num;
              HIBYTE(v93.subWebs.num) = 0;
              v93.name.str = (const char *)v32;
              idDeclAnimWebNode::GetStateName(this: v36, web: v32, name: (idStr *)&v93.nodes.size);
              if ( idStr::Find(
                     searchIn: *(const char **)&v93.nodes.granularity,
                     searchFor: "death_local",
                     casesensitive: true,
                     start: 0,
                     end: -1) != -1 )
                break;
              idStr::FreeData(this: (idStr *)&v93.nodes.size);
              ++v30;
              ++v31;
              if ( v30 >= num )
                goto LABEL_46;
            }
            LOWORD(v14) = HIWORD(idAnimator_AnimWeb::GetCurSubWebIndex(
                                   this: (idAnimator_AnimWeb *)&v93.name,
                                   result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)&this->aiVolatile.animation)->__vftable);
            LOWORD(v17) = HIWORD(idDeclAnimWeb::GetStateIndexForName(
                                   this: &v93,
                                   result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
                                   name: *(const char **)&v93.nodes.granularity)->__vftable);
            this->aiVolatile.death.deathInfo.deathFlags |= 2u;
            idStr::FreeData(this: (idStr *)&v93.nodes.size);
          }
        }
      }
    }
LABEL_46:
    p_deathInfo->deathAnimSubWeb.value = (__int16)v14;
    p_deathInfo->deathAnimState.value = (__int16)v17;
    idStr::FreeData(this: (idStr *)&v93.idResource + 1);
    idStr::FreeData(this: (idStr *)&v93.editorModels.size);
  }
  this->DropAttachment(this, a2: EQUIP_LEFT_HAND);
  this->DropAttachment(this, a2: EQUIP_RIGHT_HAND);
  if ( v5 )
    this->StartRagdoll(this, a2: &this->ragdollInfo);
  v37 = this->GetSmartLootComponent_2(this);
  if ( v37 != nullptr )
    idSmartLootComponent::Activate(this: v37, owner: this);
  v38 = (idEventArg *)this->aiVolatile.fsms.fsmManager.FindFSM_3(
                        this: &this->aiVolatile.fsms,
                        a2: &idAlertCycleFSM::Type);
  idEventReceiver::ProcessEvent(this: (idEventReceiver *)&v93.nodeCache.size, result: v38, ev: &FSM_Killed);
  v39 = 0;
  v40 = gameLocal;
  v93.name.str = (const char *)this->entityNumber;
  p_aiWorldStateUsers = (idList<idEntityPtr<idEntity>,58> *)&gameLocal->aiWorldStateUsers;
  v42 = gameLocal->aiWorldStateUsers.num;
  if ( v42 > 0 )
  {
    v43 = 0;
    while ( p_aiWorldStateUsers->list[v43].spawnId.value != ((*((_DWORD *)&gameLocal->__vftable
                                                              + (int)(v93.name.str + 29755)) << 13)
                                                           | (int)v93.name.str) )
    {
      ++v39;
      ++v43;
      if ( v39 >= v42 )
        goto LABEL_58;
    }
    if ( v39 >= 0 )
    {
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(this: p_aiWorldStateUsers, index: v39);
      v40 = gameLocal;
    }
  }
LABEL_58:
  idAIEventManager::RemoveReceiver(this: &v40->aiEventManager, receiver: this);
  idAIEventManager::RemoveEntityEvents(this: &gameLocal->aiEventManager, ent: this);
  idRibbon::~idRibbon(this: (idRibbon *)&this->aiVolatile.meleeTrace);
  idEntity::Unbind(this);
  this->walkIK.isDead = true;
  v44 = this->GetEquippedWeapon(this);
  v45 = v44;
  if ( v44 != nullptr )
  {
    v46 = this->GetFXMgrForAttachment(this, a2: v44);
    idWeapon::StopAllFX(this: v45, fxMgr: v46);
  }
  idEntity::StopSound(this, channel: SND_CHANNEL_VOICE, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_VOICE2, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_BODY, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_BODY2, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_BODY3, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_WEAPON, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_WEAPON2, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_WEAPON3, peerMask: 0xFFu);
  idEntity::StopSound(this, channel: SND_CHANNEL_WEAPON_LOOP, peerMask: 0xFFu);
  v47 = p_deathInfo->impulse.damageDecl;
  if ( v47 != nullptr )
  {
    str = v47->name.str;
    v93.name.str = (const char *)&v93.nodeCache.size;
    v49 = idStr::idStr(this: (idStr *)&v93.nodeCache.size, text: str);
    if ( gameLocal->spawnIds.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF] == p_deathInfo->attacker.spawnId.value >> 13 )
    {
      v50 = gameLocal->entities.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF];
      if ( v50 != nullptr )
        idEntity::CastTo(c: v50);
    }
    idStr::FreeData(this: v49);
  }
  v51 = this->aiEditable.death.trigger.spawnId.value;
  if ( gameLocal->spawnIds.ptr[v51 & 0x1FFF] == v51 >> 13 )
  {
    v52 = gameLocal->entities.ptr[v51 & 0x1FFF];
    if ( v52 != nullptr && idEntity::CastTo(c: v52) != nullptr )
    {
      v53 = this->aiEditable.death.trigger.spawnId.value;
      if ( gameLocal->spawnIds.ptr[v53 & 0x1FFF] == v53 >> 13
        && (v54 = gameLocal->entities.ptr[v53 & 0x1FFF]) != nullptr )
      {
        v55 = idEntity::CastTo(c: v54);
      }
      else
      {
        v55 = nullptr;
      }
      v56 = idEventArg::idEventArg(this: (idEventArg *)&v93.nodeCache.size, data: this);
      idEventReceiver::PostEventMS(
        this: v55,
        ev: &EV_Activate,
        time: *(_DWORD *)&v56->type,
        arg1: (const idEventArg *)LODWORD(v56->value.v[1]));
    }
  }
  v57 = idActor::IsLootable(this) && (idActor::HasLootableItems(this) || idActor::HasLootableProjectiles(this));
  presentable = this->presentable;
  if ( presentable == nullptr )
  {
    idEntity::InitPresentableInternal(this);
    presentable = this->presentable;
  }
  v59 = (int)presentable->GetAIInterface(this: presentable);
  *(_BYTE *)(v59 + 15792) = v57;
  *(_BYTE *)(v59 + 15794) = 1;
  v60 = this->aiVolatile.memory.curScenePoint;
  if ( v60 != nullptr )
  {
    idScenePoint::ReleaseScenePoint(this: v60, user: this);
    this->aiVolatile.memory.curScenePoint = nullptr;
  }
  p_focus = &this->aiVolatile.focus;
  this->aiVolatile.focus.enableHeadTracking = false;
  for ( i = 2; i != 0; --i )
  {
    idFocusInfo::SetEnableTracking(this: p_focus->foci.ptr, owner: this, enable: false);
    p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)p_focus + 272);
  }
  idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
  idFaceMgr::SetEnableEyeTracking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
  idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF )
  {
    v63 = idEncounterGroupManager::GroupForHandle(
            this: &gameLocal->encounterGroupManager,
            handle: &this->aiVolatile.encounterGroupHandle);
    if ( v63 != nullptr )
    {
      v64 = p_deathInfo->inflictor.spawnId.value;
      v65 = gameLocal;
      if ( gameLocal->spawnIds.ptr[v64 & 0x1FFF] == v64 >> 13
        && (v66 = gameLocal->entities.ptr[v64 & 0x1FFF]) != nullptr )
      {
        v67 = idEntity::CastTo(c: v66);
        v65 = gameLocal;
        v68 = v67;
      }
      else
      {
        v68 = nullptr;
      }
      if ( v65->spawnIds.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF] == p_deathInfo->attacker.spawnId.value >> 13
        && (v69 = v65->entities.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF]) != nullptr )
      {
        v70 = idEntity::CastTo(c: v69);
      }
      else
      {
        v70 = nullptr;
      }
      idEncounterGroup::MemberKilled(this: v63, ai: this, attacker: v70, inflictor: v68);
    }
  }
  idAI2::SetSolid(this, isSolid: false);
  v71 = p_deathInfo->inflictor.spawnId.value;
  v72 = gameLocal;
  if ( gameLocal->spawnIds.ptr[v71 & 0x1FFF] == v71 >> 13 && (v73 = gameLocal->entities.ptr[v71 & 0x1FFF]) != nullptr )
  {
    v74 = idEntity::CastTo(c: v73);
    v72 = gameLocal;
    v75 = v74;
  }
  else
  {
    v75 = nullptr;
  }
  if ( v72->spawnIds.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF] == p_deathInfo->attacker.spawnId.value >> 13
    && (v76 = v72->entities.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF]) != nullptr )
  {
    v77 = idEntity::CastTo(c: v76);
  }
  else
  {
    v77 = nullptr;
  }
  v78 = idActor::GetDamageDirection(
          axis: &this->actorVolatile.modelInfo.modelAxis,
          dir: &p_deathInfo->impulse.impactDir,
          numDirs: 4);
  DeathGroupHandle = idActor::GetDeathGroupHandle(
                       this: (idActor *)&v93.name,
                       result: (idHandle<int,enum invalidJointGroupHandle,0> *)this,
                       joint: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)p_deathInfo->impulse.jointIndex.value);
  idActor::SetPain(
    this,
    type: PAIN_DEATH,
    jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)(unsigned __int16)p_deathInfo->impulse.jointIndex.value,
    attacker: v77,
    inflictor: v75,
    jgh: DeathGroupHandle,
    damageDir: v78,
    damageIntensity: DAMAGEINTENSITY_NONE,
    damageDecl: v92);
  if ( this->aiEditable.death.removeTime != 0 )
  {
    idGameLocal::CheckDeadBodyRemoval(this: gameLocal);
    LODWORD(v80) = this->aiEditable.death.removeTime;
    *(_QWORD *)&v93.name.str = v80;
    idEventReceiver::PostEventSec(this, ev: &EV_RemoveBody, time: (float)v80);
  }
  if ( (*((_BYTE *)&this->aiEditable.death + 85) & 0x80) == 0 )
  {
    v93.name.str = (const char *)((gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber);
    idList<idEntityPtr<idEntity>,58>::Append(
      this: (idList<idEntityPtr<idEntity>,58> *)&gameLocal->deadAI,
      obj: (const idEntityPtr<idEntity> *)&v93.name);
  }
  idAIEventManager::RemoveReceiver(this: &gameLocal->aiEventManager, receiver: this);
  idAIEventManager::RemoveEntityEvents(this: &gameLocal->aiEventManager, ent: this);
  if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
  {
    v81 = idEntity::GetPhysics(this);
    if ( gameLocal->spawnIds.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF] == p_deathInfo->attacker.spawnId.value >> 13
      && (v82 = gameLocal->entities.ptr[p_deathInfo->attacker.spawnId.value & 0x1FFF]) != nullptr )
    {
      v83 = idEntity::CastTo(c: v82);
    }
    else
    {
      v83 = nullptr;
    }
    v84 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    v85 = v81;
    declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
    GetOrigin = v81->GetOrigin;
    p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
    v89 = GetOrigin(this: v85, a2: 0);
    idAIEventManager::AddEvent(
      this: (idAIEventManager *)&v93.name,
      result: p_aiEventManager,
      eventDecl: declBehaviorEvents->bodyEventDecl,
      curTime: v84,
      originator: this,
      instigator: v83,
      origin: v89,
      delay: 0);
  }
  if ( idActor::IsLootable(this) && ai_flashIfLootable.valueInteger != 0 )
  {
    v90 = this->presentable;
    if ( v90 == nullptr )
    {
      idEntity::InitPresentableInternal(this);
      v90 = this->presentable;
    }
    model = v90->model;
    v90->highlightColor = HIGHLIGHT_COLOR_LOOT;
    model->g.highlightColor = HIGHLIGHT_COLOR_LOOT;
  }
}


// ========================================================================
// __unwind$571102
// EA  : 0x82A1F78C
// RVA : 0x00A1F78C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_571102()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 480 + 288));
}


// ========================================================================
// __unwind$571103
// EA  : 0x82A1F7B4
// RVA : 0x00A1F7B4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_571103()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 480 + 128));
}


// ========================================================================
// __unwind$571104
// EA  : 0x82A1F7DC
// RVA : 0x00A1F7DC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_571104()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 480 + 192));
}


// ========================================================================
// __unwind$571105
// EA  : 0x82A1F804
// RVA : 0x00A1F804
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_571105()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 480 + 224));
}


// ========================================================================
// __unwind$571106
// EA  : 0x82A1F82C
// RVA : 0x00A1F82C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_571106()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 480 + 160));
}


// ========================================================================
// __unwind$571107
// EA  : 0x82A1F854
// RVA : 0x00A1F854
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_571107()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: *(idStr **)(v0 - 480 + 104));
}


// ========================================================================
// ?WaitForTraversal@idAI2@@QAA_NW4priority_t@idAnimWebEvent@@PBD1W4animWebEvent_t@@@Z
// EA  : 0x82A1F888
// RVA : 0x00A1F888
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

int __fastcall idAI2::WaitForTraversal(
        idAI2 *this,
        idAnimWebEvent::priority_t priority,
        const char *traversalAnimRef,
        const char *destAnimRef,
        animWebEvent_t ev)
{
  idAI2::idAIVolatile::idAIAnimationInfo *p_animation; // r28
  idStr *v11; // r3
  idDeclAnimWeb *SubWebIndexForName; // r3
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *decl; // r4
  idDeclAnimWeb *StateIndexForName; // r3
  idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *v15; // r4
  idDeclAnimWeb *v16; // r3
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *v17; // r4
  idDeclAnimWeb *v18; // r3
  idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *v19; // r4
  awPathResult_t v20; // r3
  unsigned __int16 v22; // [sp+50h] [-E0h] BYREF
  unsigned __int16 v23; // [sp+52h] [-DEh] BYREF
  int v24; // [sp+54h] [-DCh] BYREF
  _WORD v25[2]; // [sp+58h] [-D8h] BYREF
  __int16 v26; // [sp+5Ch] [-D4h] BYREF
  __int16 v27; // [sp+5Eh] [-D2h] BYREF
  idStr v28; // [sp+60h] [-D0h] BYREF
  idStr v29; // [sp+80h] [-B0h] BYREF
  idStr v30; // [sp+A0h] [-90h] BYREF
  idStr v31[3]; // [sp+C0h] [-70h] BYREF

  p_animation = &this->aiVolatile.animation;
  idAnimator_AnimWeb::GetCurSubWebIndex(
    this: (idAnimator_AnimWeb *)&v22,
    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)&this->aiVolatile.animation);
  idAnimator_AnimWeb::GetCurStateIndex(
    this: (idAnimator_AnimWeb *)&v23,
    result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation);
  if ( destAnimRef != nullptr && *destAnimRef != 0 )
  {
    v29.allocedAndFlag = 20;
    v29.len = 0;
    v29.data = v29.baseBuffer;
    v29.baseBuffer[0] = 0;
    v28.allocedAndFlag = 20;
    v28.data = v28.baseBuffer;
    v28.len = 0;
    v28.baseBuffer[0] = 0;
    if ( !idAI2::GetSubWebAndStateFromAnimWebPath(this, animWebPath: destAnimRef, subWebName: &v29, stateName: &v28) )
    {
      idLib::Warning(fmt: "idAI2::WaitForTraversal - invalid destination anim '%s'", destAnimRef);
      if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
      {
LABEL_5:
        idAnimBaseFSM::ClearDestination(this: &this->aiVolatile.animation.animFSM);
LABEL_7:
        this->aiEditable.movement.useTraversalClassA = false;
        this->aiEditable.movement.useTraversalClassB = false;
        this->aiEditable.movement.useTraversalClassC = false;
        this->aiEditable.movement.useTraversalClassD = false;
        this->aiEditable.movement.useTraversalClassE = false;
        idAI2::UpdateTravelFlags(this);
        idStr::FreeData(this: &v28);
        v11 = &v29;
_M572780:
        idStr::FreeData(this: v11);
        return 0;
      }
LABEL_6:
      idAIMoveState::Stop(this: &this->aiVolatile.physics.moveState, newStatus: AIMOVESTATUS_PATHING_FAILED);
      goto LABEL_7;
    }
    SubWebIndexForName = idDeclAnimWeb::GetSubWebIndexForName(
                           this: (idDeclAnimWeb *)&v24,
                           result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
                           subWebName: v29.data);
    decl = (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation->animWebAnimator.ptr[0].decl;
    v22 = HIWORD(SubWebIndexForName->__vftable);
    StateIndexForName = idDeclAnimWeb::GetStateIndexForName(this: (idDeclAnimWeb *)v25, result: decl, name: v28.data);
    v15 = (idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *)p_animation->animWebAnimator.ptr[0].decl;
    v23 = HIWORD(StateIndexForName->__vftable);
    if ( HIWORD(idDeclAnimWeb::FindNodeIndex(
                  this: (idDeclAnimWeb *)&v24,
                  result: v15,
                  subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v22,
                  stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v23)->__vftable) >= 0x8000u )
    {
      destAnimRef = "$weaponcombat:run";
      if ( !idAI2::GetSubWebAndStateFromAnimWebPath(
              this,
              animWebPath: "$weaponcombat:run",
              subWebName: &v29,
              stateName: &v28) )
      {
        idLib::Warning(fmt: "idAI2::WaitForTraversal - invalid destination anim '%s'", "$weaponcombat:run");
        if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
          goto LABEL_5;
        goto LABEL_6;
      }
      v16 = idDeclAnimWeb::GetSubWebIndexForName(
              this: (idDeclAnimWeb *)v25,
              result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
              subWebName: v29.data);
      v17 = (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation->animWebAnimator.ptr[0].decl;
      v22 = HIWORD(v16->__vftable);
      v18 = idDeclAnimWeb::GetStateIndexForName(this: (idDeclAnimWeb *)&v24, result: v17, name: v28.data);
      v19 = (idIndex<short,enum idDeclAnimWeb::invalidNodeIndex_t> *)p_animation->animWebAnimator.ptr[0].decl;
      v23 = HIWORD(v18->__vftable);
      if ( HIWORD(idDeclAnimWeb::FindNodeIndex(
                    this: (idDeclAnimWeb *)v25,
                    result: v19,
                    subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v22,
                    stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v23)->__vftable) >= 0x8000u )
      {
        idLib::Warning(fmt: "idAI2::WaitForTraversal - invalid destination anim '%s:%s'", v29.data, v28.data);
        idAIMoveState::Stop(this: &this->aiVolatile.physics.moveState, newStatus: AIMOVESTATUS_PATHING_FAILED);
        this->aiEditable.movement.useTraversalClassA = false;
        this->aiEditable.movement.useTraversalClassB = false;
        this->aiEditable.movement.useTraversalClassC = false;
        this->aiEditable.movement.useTraversalClassD = false;
        this->aiEditable.movement.useTraversalClassE = false;
        idAI2::UpdateTravelFlags(this);
        idStr::FreeData(this: &v28);
        v11 = &v29;
        goto _M572780;
      }
    }
    idStr::FreeData(this: &v28);
    idStr::FreeData(this: &v29);
  }
  v31[0].allocedAndFlag = 20;
  v31[0].len = 0;
  v31[0].data = v31[0].baseBuffer;
  v31[0].baseBuffer[0] = 0;
  v30.allocedAndFlag = 20;
  v30.data = v30.baseBuffer;
  v30.len = 0;
  v30.baseBuffer[0] = 0;
  if ( !idAI2::GetSubWebAndStateFromAnimWebPath(this, animWebPath: traversalAnimRef, subWebName: v31, stateName: &v30) )
  {
    idLib::Warning(fmt: "idAI2::WaitForTraversal - invalid traversal anim '%s'", destAnimRef);
    if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) == 0 )
      goto LABEL_25;
    goto LABEL_20;
  }
  idDeclAnimWeb::GetSubWebIndexForName(
    this: (idDeclAnimWeb *)&v26,
    result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
    subWebName: v31[0].data);
  idDeclAnimWeb::GetStateIndexForName(
    this: (idDeclAnimWeb *)&v27,
    result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)p_animation->animWebAnimator.ptr[0].decl,
    name: v30.data);
  if ( v26 < 0 )
  {
    idLib::Warning(
      fmt: "idAI2::WaitForTraversal - subweb '%s' not found in animWeb '%s'",
      v31[0].data,
      p_animation->animWebAnimator.ptr[0].decl->name.str);
    if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) == 0 )
      goto LABEL_25;
    goto LABEL_20;
  }
  if ( v27 < 0 )
  {
    idLib::Warning(
      fmt: "idAI2::WaitForTraversal - state '%s' not found in animWeb '%s'",
      v30.data,
      p_animation->animWebAnimator.ptr[0].decl->name.str);
    if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) == 0 )
    {
LABEL_25:
      idAIMoveState::Stop(this: &this->aiVolatile.physics.moveState, newStatus: AIMOVESTATUS_PATHING_FAILED);
      goto LABEL_26;
    }
LABEL_20:
    idAnimBaseFSM::ClearDestination(this: &this->aiVolatile.animation.animFSM);
LABEL_26:
    this->aiEditable.movement.useTraversalClassA = false;
    this->aiEditable.movement.useTraversalClassB = false;
    this->aiEditable.movement.useTraversalClassC = false;
    this->aiEditable.movement.useTraversalClassD = false;
    this->aiEditable.movement.useTraversalClassE = false;
    idAI2::UpdateTravelFlags(this);
    idStr::FreeData(this: &v30);
LABEL_32:
    v11 = v31;
    goto _M572780;
  }
  v20 = idAI2::ChangeAnimStateVia(
          this,
          web: AIANIMWEB_BODY,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v22,
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v23,
          viaSubWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v26,
          viaStateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)(unsigned __int16)v27,
          interruptPath: INTR_PATH_YES,
          interruptBlend: INTR_BLEND_MULTI);
  if ( v20 < AWPATH_OK )
  {
    idStr::FreeData(this: &v30);
    goto LABEL_32;
  }
  if ( v20 == AWPATH_OK )
  {
    v25[1] = (_WORD)p_animation;
    v25[0] = v22;
    idAnimator_AnimWeb::SetEvent(
      this: (idAnimator_AnimWeb *)p_animation,
      eventType: ev,
      subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)v22,
      stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)v23,
      eventDef: &EV_AnimWeb_Wait,
      priority);
  }
  idStr::FreeData(this: &v30);
  idStr::FreeData(this: v31);
  return 1;
}


// ========================================================================
// __unwind$572376
// EA  : 0x82A1FD8C
// RVA : 0x00A1FD8C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_572376()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 304 + 128));
}


// ========================================================================
// __unwind$572377
// EA  : 0x82A1FDB4
// RVA : 0x00A1FDB4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_572377()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 304 + 96));
}


// ========================================================================
// __unwind$572378
// EA  : 0x82A1FDDC
// RVA : 0x00A1FDDC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_572378()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 304 + 192));
}


// ========================================================================
// __unwind$572379
// EA  : 0x82A1FE04
// RVA : 0x00A1FE04
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_572379()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 304 + 160));
}


// ========================================================================
// ?DormantEnd@idAI2@@UAAXH@Z
// EA  : 0x82A1FE30
// RVA : 0x00A1FE30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DormantEnd(idAI2 *this, int timeDormant)
{
  idAIFireControl *fireControl; // r10
  idEntityPtr<idAI2> v5[12]; // [sp+50h] [-30h] BYREF

  idAIEventManager::AddReceiver(this: &gameLocal->aiEventManager, receiver: this);
  if ( this->aiVolatile.physics.moveState.GetMoveStatus(this: &this->aiVolatile.physics.moveState) != 11 )
    idAIMoveState::ResetStuck(this: &this->aiVolatile.physics.moveState);
  fireControl = this->aiVolatile.fireControl;
  if ( fireControl != nullptr )
    ((void (*)(void))fireControl->DormantEnd)();
  idFaceMgr::DormantEnd(this: &this->aiVolatile.faceMgr, owner: this, timeDormant);
  idPhysics_StaticMulti::UpdateTime(this: (bfx::BinaryReplayLogOut *)&this->aiVolatile.memory);
  if ( !this->IsDead(this) )
  {
    v5[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
    idList<idEntityPtr<idEntity>,5>::AddUnique(this: &gameLocal->activeAI, obj: v5);
    v5[0].spawnId.value = (gameLocal->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber;
    idList<idEntityPtr<idEntity>,5>::AddUnique(
      this: (idList<idEntityPtr<idAI2>,5> *)&gameLocal->aiWorldStateUsers,
      obj: v5);
  }
}


// ========================================================================
// ?UpdateLookFocus@idAI2@@AAAXXZ
// EA  : 0x82A1FF68
// RVA : 0x00A1FF68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::UpdateLookFocus(idAI2 *this)
{
  unsigned __int64 v2; // r6
  const char *v3; // r7
  idVec3 *p_offset; // r30
  char *num; // r20
  idEntity *Neutral; // r26
  unsigned __int64 v7; // r6
  const char *v8; // r7
  idAIEntityState *v9; // r3
  idAIEntityState *v10; // r27
  idPhysics *Physics; // r3
  int v12; // r3
  idPhysics *v13; // r27
  float *p_z; // r26
  aiSenseState_t *v15; // r25
  int lastConfirmedStimTime; // r11
  idPhysics *v17; // r3
  aimPoint_t aimPoint; // r5
  bool v19; // r3
  aimPoint_t v20; // r5
  double y; // fp13
  double z; // fp12
  double x; // fp13
  double v24; // fp12
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r3
  double v26; // fp31
  double v27; // fp30
  idPhysics *v28; // r27
  float *v29; // r26
  double v30; // fp0
  double v31; // fp13
  idAIOrientation *BodyOrientation; // r3
  double v33; // fp9
  double v34; // fp8
  double v35; // fp7
  double v36; // fp13
  double v37; // fp11
  double v38; // fp10
  unsigned __int64 v39; // r6
  const char *v40; // r7
  idEntity *v41; // r23
  int v42; // r30
  char v43; // r19
  bool v44; // r22
  char v45; // r18
  double v46; // fp31
  int v47; // r26
  char v48; // r25
  int v49; // r21
  idAI2::idAIVolatile::idAIWorldStateInfo *p_world; // r20
  idAI2::idAIVolatile::idAIWorldStateInfo *v51; // r11
  int value; // r11
  int v53; // r28
  idPlayer *Entity; // r27
  idFaction *v55; // r3
  int i; // r30
  int GameMs; // r3
  int v58; // r10
  int v59; // r11
  int v60; // r9
  double v61; // fp0
  int v62; // r11
  idPhysics *v63; // r30
  int v64; // r28
  idPhysics *v65; // r3
  const idDeclAIBehaviorEvents *declBehaviorEvents; // r27
  idHandle<int,enum invalidAIEvent_t,-1> *p_aiEventManager; // r30
  const idVec3 *(__fastcall *GetOrigin)(idPhysics *, int); // ctr
  const idVec3 *v69; // r3
  idAIGameState *p_aiGameState; // r30
  const idSpawnId *v71; // r27
  const idAILogic *v72; // r3
  const idSpawnId *v73; // r8
  idPhysics *v74; // r30
  int v75; // r28
  idPhysics *v76; // r3
  const idDeclAIBehaviorEvents *v77; // r27
  idHandle<int,enum invalidAIEvent_t,-1> *v78; // r30
  const idVec3 *(__fastcall *v79)(idPhysics *, int); // ctr
  const idVec3 *v80; // r3
  idAIGameState *v81; // r30
  const idSpawnId *v82; // r27
  const idAILogic *v83; // r3
  const idSpawnId *v84; // r8
  idPhysics *v85; // r30
  idPhysics *v86; // r3
  unsigned __int64 v87; // r6
  const char *v88; // r7
  aiSenseState_t *EnemySenseState; // r3
  aiSenseState_t *v90; // r30
  int ConfirmedStimTimeSafe; // r23
  int v92; // r3
  char v93; // r11
  unsigned __int64 v94; // r6
  const char *v95; // r7
  idEncounterGroup *v96; // r3
  int v97; // r25
  int j; // r24
  idAI2 *v99; // r30
  aiSenseState_t *v100; // r3
  idAIEntityState *v101; // r3
  aiSenseState_t *v102; // r28
  int v103; // r11
  idAIGameState *v104; // r28
  const aiSenseState_t *v105; // r19
  const idEntity *Enemy; // r3
  const idSpawnId *v107; // r30
  const idAILogic *v108; // r3
  const idSpawnId *v109; // r8
  unsigned __int64 v110; // r6
  const char *v111; // r7
  int v112; // r21
  int v113; // r19
  int v114; // r23
  int v115; // r30
  int v116; // r26
  idAIEntityState *v117; // r3
  idAI2 *v118; // r3
  idAI2 *v119; // r3
  idAI2 *v120; // r28
  idHandle<short,enum invalidEncounterGroup_t,-1> *p_encounterGroupHandle; // r25
  int v122; // r18
  int v123; // r30
  int v124; // r11
  int v125; // r26
  idAIMemory *p_memory; // r30
  idAIGameState *v127; // r28
  const idEntity *v128; // r3
  const idSpawnId *v129; // r30
  const idAILogic *v130; // r3
  const idSpawnId *v131; // r8
  idEncounterGroup *v132; // r3
  idEncounterGroup *v133; // r3
  idAIGameState *v134; // r27
  const idEntity *v135; // r3
  const idSpawnId *v136; // r18
  const idAILogic *v137; // r3
  const idSpawnId *v138; // r8
  idPhysics *v139; // r3
  idPhysics *v140; // r3
  idPhysics *v141; // r28
  int v142; // r27
  idPhysics *v143; // r3
  const idDeclAIBehaviorEvents *v144; // r26
  idHandle<int,enum invalidAIEvent_t,-1> *v145; // r28
  const idVec3 *(__fastcall *v146)(idPhysics *, int); // ctr
  const idVec3 *v147; // r18
  const idEntity *v148; // r3
  idEncounterGroup *v149; // r3
  int v150; // r26
  idAIGameState *v151; // r27
  const idEntity *LastAttacker; // r3
  const idSpawnId *v153; // r18
  const idAILogic *v154; // r3
  const idSpawnId *v155; // r8
  idPhysics *v156; // r3
  idPhysics *v157; // r3
  idPhysics *v158; // r28
  int v159; // r27
  idPhysics *v160; // r3
  const idDeclAIBehaviorEvents *v161; // r26
  idHandle<int,enum invalidAIEvent_t,-1> *v162; // r28
  const idVec3 *(__fastcall *v163)(idPhysics *, int); // ctr
  const idVec3 *v164; // r18
  const idEntity *v165; // r3
  idAIEventManager v166; // [sp+50h] [-2E0h] BYREF
  idVec3 v167; // [sp+A0h] [-290h] BYREF
  idVec3 v168; // [sp+B0h] [-280h] BYREF
  idVec3 v169; // [sp+C0h] [-270h] BYREF
  idPLogScope v170; // [sp+D0h] [-260h] BYREF
  idSpawnId v171; // [sp+DCh] [-254h] BYREF
  idSpawnId v172; // [sp+E0h] [-250h] BYREF
  idAIEventManager v173; // [sp+E4h] [-24Ch] BYREF
  int v174; // [sp+148h] [-1E8h] BYREF
  idStaticList<idAI2 *,64> v175; // [sp+160h] [-1D0h] BYREF

  RD_EventBegin(name: "idAI2::UpdateLookFocus");
  LODWORD(v2) = "idAI2::UpdateLookFocus";
  HIDWORD(v2) = 6;
  idPLogScope::idPLogScope(this: (idPLogScope *)&v166.receivers.size, pl: &pLog, gMask: v2, label: v3);
  p_offset = &this->aiVolatile.focus.foci.ptr[1].offset;
  num = &ai_useTurnTransitions.valueString.baseBuffer[12];
  this->aiVolatile.focus.foci.ptr[1].offset.x = vec3_origin.x;
  v166.eventList.num = (int)&ai_useTurnTransitions.valueString.baseBuffer[12];
  this->aiVolatile.focus.foci.ptr[1].offset.y = vec3_origin.y;
  v166.eventList.list = (idAIEvent **)&this->aiVolatile.focus.foci.ptr[1].offset;
  this->aiVolatile.focus.foci.ptr[1].offset.z = vec3_origin.z;
  if ( this->aiVolatile.focus.foci.ptr[1].focusTimeout != -1
    && idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED) >= this->aiVolatile.focus.foci.ptr[1].focusTimeout )
  {
    idFocusInfo::Clear(this: &this->aiVolatile.focus.foci.ptr[1], owner: this);
  }
  if ( idAI2::IsPlayerControlled(this)
    || this->aiVolatile.physics.moveState.movementMode == AIMOVEMODE_PLAYER
    || (this->aiVolatile.perception.flags & 1) != 0 )
  {
    goto _M574055;
  }
  idAI2::FindAutoFocus(this);
  Neutral = (idEntity *)idAIMemory::GetNeutral(this: &this->aiVolatile.focus.foci.ptr[1]);
  if ( Neutral != nullptr )
  {
    this->aiVolatile.focus.foci.ptr[1].focusType = AIFOCUS_ENTITY;
    RD_EventBegin(name: "idAI2::UpdateLookFocus - ent update");
    LODWORD(v7) = "idAI2::UpdateLookFocus - ent update";
    HIDWORD(v7) = 2;
    idPLogScope::idPLogScope(this: (idPLogScope *)&v166.eventHash, pl: &pLog, gMask: v7, label: v8);
    v9 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: Neutral);
    v10 = v9;
    if ( v9 == nullptr )
    {
      v166.eventList.list = (idAIEvent **)this->aiVolatile.focus.foci.ptr[1].aimPoint;
      if ( v166.eventList.list == (idAIEvent **)7 )
      {
        Physics = idEntity::GetPhysics(this: Neutral);
        v12 = (int)Physics->GetOrigin(this: Physics, a2: 0);
        v166.eventHash.lookupMask = *(int *)v12;
        v166.eventHash.memTag = *(memTag_t *)(v12 + 4);
        v166.receivers.list = *(idEntityPtr<idEntity> **)(v12 + 8);
        v13 = idEntity::GetPhysics(this);
        p_z = &this->GetEyeOffset(this: &v170, result: this)->z;
        *(float *)&v166.receivers.list = v13->GetOrigin(this: v13, a2: 0)->z + *p_z;
      }
      else
      {
        Neutral->GetAimPoint(
          this: Neutral,
          a2: (const aimPoint_t)v166.eventList.list,
          a3: (idVec3 *)&v166.eventHash.lookupMask);
      }
      idFocusInfo::SetTempFocusPoint(
        this: &this->aiVolatile.focus.foci.ptr[1],
        owner: this,
        focusPoint: (const idVec3 *)&v166.eventHash.lookupMask,
        _focusType: AIFOCUS_MISC);
      v166.eventList.list = (idAIEvent **)&this->aiVolatile.focus.foci.ptr[1].offset;
      goto LABEL_34;
    }
    v15 = v9->senses.ptr[v9->lastSense];
    if ( v15->lastUnconfirmedStimTime < 0 )
      goto LABEL_35;
    lastConfirmedStimTime = v15->lastConfirmedStimTime;
    v166.eventList.list = (idAIEvent **)v9->senses.ptr[v9->lastSense];
    if ( lastConfirmedStimTime <= 0 )
      goto LABEL_35;
    v17 = idEntity::GetPhysics(this);
    v17->GetOrigin(this: v17, a2: 0);
    if ( this->aiVolatile.focus.foci.ptr[1].focusType != AIFOCUS_ENTITY )
      goto LABEL_35;
    aimPoint = this->aiVolatile.focus.foci.ptr[1].aimPoint;
    if ( (unsigned int)aimPoint > AIMPOINT_LOOKAHEAD )
      goto LABEL_35;
    if ( aimPoint != AIMPOINT_ORIGIN )
    {
      if ( aimPoint == AIMPOINT_HEAD
        || aimPoint == AIMPOINT_TORSO
        || aimPoint == AIMPOINT_CENTER
        || aimPoint == AIMPOINT_LEGS
        || aimPoint == AIMPOINT_FEET )
      {
        goto LABEL_30;
      }
      if ( aimPoint == AIMPOINT_BEST )
      {
        if ( v10->lastVisible == 3 || (v19 = Neutral->IsDead(this: Neutral), v20 = AIMPOINT_TORSO, v19) )
          v20 = AIMPOINT_HEAD;
        idAIEntityState::GetAimPoint(this: v10, sense: (const aiSense_t)v10->lastSense, aimPoint: v20, point: &v167);
        y = v167.y;
        v166.eventList.list = (idAIEvent **)&this->aiVolatile.focus.foci.ptr[1].idealFocusPoint;
        z = v167.z;
        this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.x = v167.x;
        this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.y = y;
        goto LABEL_33;
      }
      if ( aimPoint != AIMPOINT_EYELEVEL )
      {
LABEL_30:
        idAIEntityState::GetAimPoint(this: v10, sense: (const aiSense_t)v10->lastSense, aimPoint, point: &v168);
        x = v168.x;
        v166.eventList.list = (idAIEvent **)&this->aiVolatile.focus.foci.ptr[1].idealFocusPoint;
        v24 = v168.y;
        this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.z = v168.z;
        this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.x = x;
        this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.y = v24;
LABEL_34:
        p_offset->x = vec3_origin.x;
        this->aiVolatile.focus.foci.ptr[1].offset.y = vec3_origin.y;
        this->aiVolatile.focus.foci.ptr[1].offset.z = vec3_origin.z;
LABEL_35:
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v166.eventHash);
        RD_EventEnd();
        goto LABEL_38;
      }
    }
    else
    {
      idLib::Warning(fmt: "AI %s looking at aimpoint origin.", this->name.data);
    }
    ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: v15);
    v26 = ConfirmedPhysicalSafe->origin.x;
    v27 = ConfirmedPhysicalSafe->origin.y;
    v28 = idEntity::GetPhysics(this);
    v29 = &this->GetEyeOffset(this: &v170, result: this)->z;
    v30 = v28->GetOrigin(this: v28, a2: 0)->z;
    v31 = *v29;
    this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.x = v26;
    z = (float)((float)v30 + (float)v31);
    this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.y = v27;
    v166.eventList.list = (idAIEvent **)&this->aiVolatile.focus.foci.ptr[1].idealFocusPoint;
LABEL_33:
    this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.z = z;
    goto LABEL_34;
  }
  if ( (unsigned __int8)idFocusInfo::HasFocus(this: &this->aiVolatile.focus.foci.ptr[1]) == 0 )
  {
    this->GetEyePos(this, a2: (idVec3 *)&v166.eventHash.hashSize);
    BodyOrientation = idAI2::GetBodyOrientation(this);
    v33 = BodyOrientation->axis.mat[0].x;
    v34 = BodyOrientation->axis.mat[0].z;
    v35 = BodyOrientation->axis.mat[0].y;
    v36 = *(float *)&v166.eventHash.hashSize;
    v37 = *(float *)&v166.eventHash.granularity;
    v38 = *(float *)&v166.eventHash.indexSize;
    v166.eventList.list = (idAIEvent **)&BodyOrientation->axis;
    this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.x = (float)((float)v33 * (float)64.0)
                                                         + *(float *)&v166.eventHash.hashSize;
    this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.y = (float)v38 + (float)((float)v35 * (float)64.0);
    this->aiVolatile.focus.foci.ptr[1].idealFocusPoint.z = (float)v37 + (float)((float)v34 * (float)64.0);
    *(float *)&v166.eventHash.granularity = (float)v37 + (float)((float)v34 * (float)64.0);
    p_offset->x = vec3_origin.x;
    this->aiVolatile.focus.foci.ptr[1].offset.y = vec3_origin.y;
    *(float *)&v166.eventHash.hashSize = (float)((float)v33 * (float)64.0) + (float)v36;
    *(float *)&v166.eventHash.indexSize = (float)v38 + (float)((float)v35 * (float)64.0);
    this->aiVolatile.focus.foci.ptr[1].offset.z = vec3_origin.z;
  }
LABEL_38:
  this->GetEyePos(this, a2: (idVec3 *)&v174);
  v166.eventList.list = (idAIEvent **)this->aiVolatile.focus.foci.ptr[1].focusType;
  if ( v166.eventList.list == nullptr || v166.eventList.list == (idAIEvent **)8 )
  {
    RD_EventBegin(name: "idAI2::UpdateLookFocus - partial sense");
    LODWORD(v39) = "idAI2::UpdateLookFocus - partial sense";
    HIDWORD(v39) = 2;
    idPLogScope::idPLogScope(this: (idPLogScope *)&v166.eventHash, pl: &pLog, gMask: v39, label: v40);
    v41 = nullptr;
    if ( idAIMemory::GetEnemy(this: &this->aiVolatile.memory) == nullptr
      || idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX) != nullptr
      && (v42 = idGameTimeManager::GetGameMs(
                  this: (idGameTimeManager *)(*(_DWORD *)(v166.eventList.num + 17592) + 504064),
                  type: GAMETIME_SCALED))
       - idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX)->lastConfirmedStimTime >= 1000 )
    {
      v43 = 0;
      v44 = false;
      v45 = 0;
      v46 = 0.0;
      v47 = 0;
      v48 = 10;
      v49 = 0;
      if ( this->aiVolatile.world.worldState.numEnts > 0 )
      {
        p_world = &this->aiVolatile.world;
        v51 = &this->aiVolatile.world;
        do
        {
          value = v51->worldState.ents[0].value;
          v53 = (int)&p_world->worldState.entityStates[value];
          if ( (idAI2::idAIVolatile::idAIWorldStateInfo *)((char *)p_world + value * 576) != (idAI2::idAIVolatile::idAIWorldStateInfo *)-24 )
          {
            Entity = (idPlayer *)idAIEntityState::GetEntity(this: &p_world->worldState.entityStates[value]);
            if ( Entity != nullptr )
            {
              v55 = this->GetFaction(this);
              if ( idFaction::GetAttitudeTowards(this: v55, otherEnt: Entity) < ATTITUDE_NEUTRAL
                && !Entity->IsDead(this: Entity)
                && (idPlayer::CastTo(c: Entity) == nullptr || (*((_BYTE *)idPlayer::CastTo(c: Entity) + 12824) & 8) == 0) )
              {
                for ( i = 0; i < 2; ++i )
                {
                  if ( *(int *)(*(_DWORD *)(4 * (i + 128) + v53) + 88) >= 0 )
                  {
                    GameMs = idGameTimeManager::GetGameMs(
                               this: (idGameTimeManager *)(*(_DWORD *)(v166.eventList.num + 17592) + 504064),
                               type: GAMETIME_SCALED);
                    v58 = 4 * ((unsigned __int8)i + 128);
                    v59 = *(_DWORD *)(v58 + v53);
                    v60 = *(_DWORD *)(v59 + 88);
                    v166.eventList.list = (idAIEvent **)v59;
                    if ( GameMs - v60 < 33 )
                    {
                      v61 = *(float *)(v59 + 180);
                      v166.eventList.list = (idAIEvent **)v59;
                      if ( v61 > v46 && v61 > 0.40000001 )
                      {
                        v46 = v61;
                        v41 = Entity;
                        v44 = false;
                        if ( i == 1 )
                          v44 = *(unsigned __int8 *)(v53 + 539) >= 3u;
                        v62 = *(_DWORD *)(v58 + v53);
                        v47 = i;
                        v166.eventList.list = (idAIEvent **)(v62 + 68);
                        v48 = *(_BYTE *)(v62 + 210);
                        v169.x = *(float *)(v62 + 68);
                        v166.eventList.list = (idAIEvent **)v62;
                        v169.y = *(float *)(v62 + 72);
                        v166.eventList.list = (idAIEvent **)v62;
                        v169.z = *(float *)(v62 + 76);
                        if ( v61 > 0.69999999 )
                          v43 = 1;
                        if ( v61 == 1.0 )
                          v45 = 1;
                      }
                    }
                  }
                }
              }
            }
          }
          ++v49;
          v51 = (idAI2::idAIVolatile::idAIWorldStateInfo *)((char *)p_world + v49);
        }
        while ( v49 < this->aiVolatile.world.worldState.numEnts );
        if ( v41 != nullptr )
        {
          idFocusInfo::SetExplicitFocusPoint(
            this: &this->aiVolatile.focus.foci.ptr[1],
            owner: this,
            focusPoint: &v169,
            _keepFocusInView: false,
            duration: 1000,
            _focusType: AIFOCUS_PARTIAL_SENSE);
          idAI2::LookDebug(this, text: "sense something2\n", level: 1, duration: 1);
          if ( idAI2::GetAlertCycle(this) < ALERTCYCLE_COMBAT && v43 != 0 && (v45 == 0 || v47 != 1) && v48 != 4 )
          {
            if ( v47 == 1 )
            {
              if ( !v44 && this->aiVolatile.focus.foci.ptr[1].focusType == AIFOCUS_PARTIAL_SENSE )
              {
                if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
                {
                  v63 = idEntity::GetPhysics(this);
                  v64 = idGameTimeManager::GetGameMs(
                          this: (idGameTimeManager *)(*(_DWORD *)(v166.eventList.num + 17592) + 504064),
                          type: GAMETIME_SCALED);
                  v65 = v63;
                  declBehaviorEvents = this->aiEditable.behaviors.declBehaviorEvents;
                  GetOrigin = v63->GetOrigin;
                  p_aiEventManager = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
                  v69 = GetOrigin(this: v65, a2: 0);
                  idAIEventManager::AddEvent(
                    this: &v166,
                    result: p_aiEventManager,
                    eventDecl: declBehaviorEvents->sawSomethingVoiceEventDecl,
                    curTime: v64,
                    originator: this,
                    instigator: v41,
                    origin: v69,
                    delay: 750);
                }
                p_aiGameState = &gameLocal->aiGameState;
                idSpawnId::idSpawnId(this: (idSpawnId *)&v166, ent: v41);
                v71 = idSpawnId::idSpawnId(this: (idSpawnId *)&v166.eventList.size, ent: v41);
                v72 = idAILogic::idAILogic(this: (idAILogic *)&v173.eventList.granularity, ai: this);
                idAIWorldState::AddEntityState(
                  this: &this->aiVolatile.world.worldState,
                  gameState: p_aiGameState,
                  owner: v72,
                  entId: v71,
                  stimulusType: AISTIMULUS_GROUP_SUSPECTED,
                  stimulusAmount: 1.0,
                  sourceId: v73);
              }
            }
            else if ( v47 == 0 )
            {
              if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
              {
                v74 = idEntity::GetPhysics(this);
                v75 = idGameTimeManager::GetGameMs(
                        this: (idGameTimeManager *)(*(_DWORD *)(v166.eventList.num + 17592) + 504064),
                        type: GAMETIME_SCALED);
                v76 = v74;
                v77 = this->aiEditable.behaviors.declBehaviorEvents;
                v79 = v74->GetOrigin;
                v78 = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
                v80 = v79(this: v76, a2: 0);
                idAIEventManager::AddEvent(
                  this: (idAIEventManager *)&v166.eventList.size,
                  result: v78,
                  eventDecl: v77->heardSomethingVoiceEventDecl,
                  curTime: v75,
                  originator: this,
                  instigator: v41,
                  origin: v80,
                  delay: 750);
              }
              v81 = &gameLocal->aiGameState;
              idSpawnId::idSpawnId(this: (idSpawnId *)&v166.eventList.size, ent: v41);
              v82 = idSpawnId::idSpawnId(this: (idSpawnId *)&v166, ent: v41);
              v83 = idAILogic::idAILogic(this: (idAILogic *)&v173.eventList.granularity, ai: this);
              idAIWorldState::AddEntityState(
                this: &this->aiVolatile.world.worldState,
                gameState: v81,
                owner: v83,
                entId: v82,
                stimulusType: AISTIMULUS_GROUP_SUSPECTED,
                stimulusAmount: 1.0,
                sourceId: v84);
              v85 = idEntity::GetPhysics(this);
              v86 = idEntity::GetPhysics(this: v41);
              v86->GetOrigin(this: v86, a2: 0);
              v85->GetOrigin(this: v85, a2: 0);
            }
          }
        }
      }
    }
    idPLogScope::~idPLogScope(this: (idPLogScope *)&v166.eventHash);
    RD_EventEnd();
    num = (char *)v166.eventList.num;
  }
  RD_EventBegin(name: "idAI2::UpdateLookFocus - friendly group");
  LODWORD(v87) = "idAI2::UpdateLookFocus - friendly group";
  HIDWORD(v87) = 6;
  idPLogScope::idPLogScope(this: (idPLogScope *)&v166.eventPools.size, pl: &pLog, gMask: v87, label: v88);
  EnemySenseState = (aiSenseState_t *)idAI2::GetEnemySenseState(this, senseType: AISENSE_MAX);
  v90 = EnemySenseState;
  ConfirmedStimTimeSafe = -1;
  if ( EnemySenseState == nullptr
    || (ConfirmedStimTimeSafe = aiSenseState_t::GetConfirmedStimTimeSafe(this: EnemySenseState),
        v92 = idGameTimeManager::GetGameMs(
                this: (idGameTimeManager *)(*((_DWORD *)num + 4398) + 504064),
                type: GAMETIME_SCALED),
        v93 = 1,
        v92 - v90->lastConfirmedStimTime >= 1000) )
  {
    v93 = 0;
  }
  if ( v93 == 0 && idAI2::GetAlertCycle(this) == ALERTCYCLE_COMBAT )
  {
    RD_EventBegin(name: "idAI2::UpdateLookFocus - friendly target");
    LODWORD(v94) = "idAI2::UpdateLookFocus - friendly target";
    HIDWORD(v94) = 2;
    idPLogScope::idPLogScope(this: (idPLogScope *)&v166.eventHash, pl: &pLog, gMask: v94, label: v95);
    if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF )
    {
      v96 = idEncounterGroupManager::GroupForHandle(
              this: &gameLocal->encounterGroupManager,
              handle: &this->aiVolatile.encounterGroupHandle);
      if ( v96 != nullptr )
      {
        v175.granularity = 1;
        v175.listStatic = 1;
        v97 = 0;
        v175.size = 64;
        v175.list = v175.staticList;
        v175.num = 0;
        v175.memTag = 5;
        idEncounterGroup::GetLivingMembers(this: v96, list: &v175);
        if ( v175.num >= 2 )
        {
          for ( j = v175.num; j != 0; --j )
          {
            v99 = v175.list[v97];
            if ( v99 != nullptr )
            {
              v100 = (aiSenseState_t *)idAI2::GetEnemySenseState(this: v175.list[v97], senseType: AISENSE_MAX);
              if ( v99 != this
                && v100 != nullptr
                && v100->lastConfirmedStimTime >= 0
                && aiSenseState_t::GetConfirmedStimTimeSafe(this: v100) > ConfirmedStimTimeSafe )
              {
                v101 = idAIWorldState::StateForEntity(this: &this->aiVolatile.world.worldState, ent: v99);
                if ( v101 != nullptr )
                {
                  v102 = v101->senses.ptr[1];
                  if ( v102->lastUnconfirmedStimTime >= 0 )
                  {
                    v103 = *((_DWORD *)num + 4398);
                    v166.eventList.size = (int)v101->senses.ptr[1];
                    if ( idGameTimeManager::GetGameMs(this: (idGameTimeManager *)(v103 + 504064), type: GAMETIME_SCALED)
                       - v102->lastConfirmedStimTime < 1000 )
                    {
                      v104 = &gameLocal->aiGameState;
                      v105 = (const aiSenseState_t *)idSpawnId::idSpawnId(this: (idSpawnId *)&v166, ent: v99);
                      Enemy = idAIMemory::GetEnemy(this: &v99->aiVolatile.memory);
                      v107 = idSpawnId::idSpawnId(this: (idSpawnId *)&v166.receivers.num, ent: Enemy);
                      v108 = idAILogic::idAILogic(this: (idAILogic *)&v173.eventList.granularity, ai: this);
                      idAIWorldState::AddEntityState(
                        this: &this->aiVolatile.world.worldState,
                        gameState: v104,
                        owner: v108,
                        entId: v107,
                        stimulusType: AISTIMULUS_HEARING,
                        stimulusAmount: 1.0,
                        sourceId: v109,
                        sourceSense: v105);
                    }
                  }
                }
              }
            }
            ++v97;
          }
        }
        idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)&v175);
      }
    }
    idPLogScope::~idPLogScope(this: (idPLogScope *)&v166.eventHash);
    RD_EventEnd();
  }
  idPLogScope::~idPLogScope(this: (idPLogScope *)&v166.eventPools.size);
  RD_EventEnd();
  if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 87) & 0x40) != 0
    || (*((_BYTE *)this->aiEditable.behaviors.decl + 87) & 0x20) != 0 && idAI2::GetAlertCycle(this) < ALERTCYCLE_COMBAT )
  {
    RD_EventBegin(name: "idAI2::UpdateLookFocus - bodies");
    LODWORD(v110) = "idAI2::UpdateLookFocus - bodies";
    HIDWORD(v110) = 2;
    idPLogScope::idPLogScope(this: &v170, pl: &pLog, gMask: v110, label: v111);
    idFriendlyDeadTargetFilter::idFriendlyDeadTargetFilter(
      this: (idFriendlyDeadTargetFilter *)&v166.eventPools,
      minAwareness_: AIAWARE_CONFIRMED);
    idTargetList::idTargetList(
      this: (idTargetList *)&v173.eventHash.memTag,
      targetCache_: &this->aiVolatile.world.worldState.targetCache);
    idTargetList::Filter(
      this: (idTargetList *)&v173.eventHash.memTag,
      owner: this,
      filter: (const idTargetFilter *)&v166.eventPools);
    v112 = 0;
    if ( v173.receivers.num > 0 )
    {
      v113 = v166.eventList.num;
      v114 = 0;
      while ( 1 )
      {
        v115 = *(_DWORD *)v173.eventHash.memTag;
        v116 = 52 * v173.receivers.list[v114].spawnId.value;
        v117 = *(idAIEntityState **)(v116 + *(_DWORD *)v173.eventHash.memTag);
        if ( v117 == nullptr )
          goto LABEL_145;
        v118 = (idAI2 *)idAIEntityState::GetEntity(this: v117);
        v119 = idAI2::CastTo(c: v118);
        v120 = v119;
        if ( v119 == this )
          goto LABEL_145;
        if ( v119 == nullptr )
          goto LABEL_145;
        p_encounterGroupHandle = &this->aiVolatile.encounterGroupHandle;
        if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF
          || idEncounterGroupManager::GroupForHandle(
               this: &gameLocal->encounterGroupManager,
               handle: &this->aiVolatile.encounterGroupHandle) == nullptr
          || idAI2::GetAlertCycle(this: v120) != ALERTCYCLE_DEAD && idAI2::GetAlertCycle(this: v120) != ALERTCYCLE_DYING )
        {
          goto LABEL_145;
        }
        v122 = idGameTimeManager::GetGameMs(
                 this: (idGameTimeManager *)(*(_DWORD *)(v113 + 17592) + 504064),
                 type: GAMETIME_SCALED);
        if ( v122
           - v120->aiVolatile.fsms.fsmManager.FindFSM(
               this: &v120->aiVolatile.fsms.fsmManager,
               a2: &idAlertCycleFSM::Type)->lastTransitionTime < 200 )
          goto LABEL_145;
        v123 = *(_DWORD *)(*(_DWORD *)(v116 + v115) + 516);
        if ( *(int *)(v123 + 88) < 0 )
          goto LABEL_145;
        v124 = *(_DWORD *)(v113 + 17592);
        v166.receivers.num = v123;
        v125 = idGameTimeManager::GetGameMs(this: (idGameTimeManager *)(v124 + 504064), type: GAMETIME_SCALED)
             - v120->aiVolatile.death.deathInfo.startDeathTime;
        if ( idGameTimeManager::GetGameMs(
               this: (idGameTimeManager *)(*(_DWORD *)(v113 + 17592) + 504064),
               type: GAMETIME_SCALED)
           - *(_DWORD *)(v123 + 176) >= 1000 )
          goto LABEL_145;
        p_memory = &v120->aiVolatile.memory;
        if ( idAIMemory::GetLastAttacker(this: &v120->aiVolatile.memory) == nullptr )
          goto LABEL_145;
        if ( v125 > 400 )
        {
          if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
            v149 = nullptr;
          else
            v149 = idEncounterGroupManager::GroupForHandle(
                     this: &gameLocal->encounterGroupManager,
                     handle: &this->aiVolatile.encounterGroupHandle);
          if ( idEncounterGroup::GetAnyMemberHasSeenDeadBody(this: v149) )
            goto LABEL_145;
          if ( this->aiVolatile.memory.highestAlertCycle >= ALERTCYCLE_COMBAT )
            goto LABEL_145;
          v150 = idGameTimeManager::GetGameMs(
                   this: (idGameTimeManager *)(*(_DWORD *)(v113 + 17592) + 504064),
                   type: GAMETIME_SCALED);
          if ( v150
             - v120->aiVolatile.fsms.fsmManager.FindFSM(
                 this: &v120->aiVolatile.fsms.fsmManager,
                 a2: &idAlertCycleFSM::Type)->lastTransitionTime <= 400 )
            goto LABEL_145;
          v151 = &gameLocal->aiGameState;
          idSpawnId::idSpawnId(this: &v171, ent: v120);
          LastAttacker = idAIMemory::GetLastAttacker(this: &v120->aiVolatile.memory);
          v153 = idSpawnId::idSpawnId(this: (idSpawnId *)&v166.eventPools.size, ent: LastAttacker);
          v154 = idAILogic::idAILogic(this: (idAILogic *)&v173.eventList.granularity, ai: this);
          idAIWorldState::AddEntityState(
            this: &this->aiVolatile.world.worldState,
            gameState: v151,
            owner: v154,
            entId: v153,
            stimulusType: AISTIMULUS_HEARING,
            stimulusAmount: 1.0,
            sourceId: v155);
          v156 = idEntity::GetPhysics(this);
          v156->GetOrigin(this: v156, a2: 0);
          v157 = idEntity::GetPhysics(this: v120);
          v157->GetOrigin(this: v157, a2: 0);
          if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
          {
            v158 = idEntity::GetPhysics(this);
            v159 = idGameTimeManager::GetGameMs(
                     this: (idGameTimeManager *)(*(_DWORD *)(v113 + 17592) + 504064),
                     type: GAMETIME_SCALED);
            v160 = v158;
            v161 = this->aiEditable.behaviors.declBehaviorEvents;
            v163 = v158->GetOrigin;
            v162 = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
            v164 = v163(this: v160, a2: 0);
            v165 = idAIMemory::GetLastAttacker(this: p_memory);
            idAIEventManager::AddEvent(
              this: (idAIEventManager *)&v166.eventHash,
              result: v162,
              eventDecl: v161->foundDeadBodyVoiceEventDecl,
              curTime: v159,
              originator: this,
              instigator: v165,
              origin: v164,
              delay: 0);
          }
          if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
          {
            v132 = nullptr;
            goto LABEL_144;
          }
          goto LABEL_143;
        }
        if ( idAI2::GetAlertCycle(this) != ALERTCYCLE_SEARCH )
          break;
        if ( v125 <= 300 )
        {
          v127 = &gameLocal->aiGameState;
          idSpawnId::idSpawnId(this: (idSpawnId *)&v166.eventList.size, ent: this);
          v128 = idAIMemory::GetLastAttacker(this: p_memory);
          v129 = idSpawnId::idSpawnId(this: (idSpawnId *)&v166, ent: v128);
          v130 = idAILogic::idAILogic(this: (idAILogic *)&v173.eventList.granularity, ai: this);
          idAIWorldState::AddEntityState(
            this: &this->aiVolatile.world.worldState,
            gameState: v127,
            owner: v130,
            entId: v129,
            stimulusType: AISTIMULUS_GUNFIRE,
            stimulusAmount: 1.0,
            sourceId: v131);
          if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
          {
            v132 = nullptr;
LABEL_144:
            idEncounterGroup::SetAnyMemberHasSeenDeadBody(this: v132, seen: true);
            goto LABEL_145;
          }
          goto LABEL_143;
        }
LABEL_145:
        ++v112;
        ++v114;
        if ( v112 >= v173.receivers.num )
          goto LABEL_146;
      }
      if ( idAI2::GetAlertCycle(this) != ALERTCYCLE_RELAXED )
        goto LABEL_145;
      v133 = (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF
           ? nullptr
           : idEncounterGroupManager::GroupForHandle(
               this: &gameLocal->encounterGroupManager,
               handle: &this->aiVolatile.encounterGroupHandle);
      if ( idEncounterGroup::GetAnyMemberHasSeenDeadBody(this: v133) || v125 <= 300 )
        goto LABEL_145;
      v134 = &gameLocal->aiGameState;
      idSpawnId::idSpawnId(this: (idSpawnId *)&v166.eventList.num, ent: v120);
      v135 = idAIMemory::GetLastAttacker(this: &v120->aiVolatile.memory);
      v136 = idSpawnId::idSpawnId(this: &v172, ent: v135);
      v137 = idAILogic::idAILogic(this: (idAILogic *)&v173.eventList.granularity, ai: this);
      idAIWorldState::AddEntityState(
        this: &this->aiVolatile.world.worldState,
        gameState: v134,
        owner: v137,
        entId: v136,
        stimulusType: AISTIMULUS_HEARING,
        stimulusAmount: 1.0,
        sourceId: v138);
      v139 = idEntity::GetPhysics(this);
      v139->GetOrigin(this: v139, a2: 0);
      v140 = idEntity::GetPhysics(this: v120);
      v140->GetOrigin(this: v140, a2: 0);
      if ( this->aiEditable.behaviors.declBehaviorEvents != nullptr )
      {
        v141 = idEntity::GetPhysics(this);
        v142 = idGameTimeManager::GetGameMs(
                 this: (idGameTimeManager *)(*(_DWORD *)(v113 + 17592) + 504064),
                 type: GAMETIME_SCALED);
        v143 = v141;
        v144 = this->aiEditable.behaviors.declBehaviorEvents;
        v146 = v141->GetOrigin;
        v145 = (idHandle<int,enum invalidAIEvent_t,-1> *)&gameLocal->aiEventManager;
        v147 = v146(this: v143, a2: 0);
        v148 = idAIMemory::GetLastAttacker(this: p_memory);
        idAIEventManager::AddEvent(
          this: &v173,
          result: v145,
          eventDecl: v144->memberKilledVoiceEventDecl,
          curTime: v142,
          originator: this,
          instigator: v148,
          origin: v147,
          delay: 0);
      }
      if ( (unsigned __int16)p_encounterGroupHandle->value == 0xFFFF )
      {
        v132 = nullptr;
        goto LABEL_144;
      }
LABEL_143:
      v132 = idEncounterGroupManager::GroupForHandle(
               this: &gameLocal->encounterGroupManager,
               handle: &this->aiVolatile.encounterGroupHandle);
      goto LABEL_144;
    }
LABEL_146:
    idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)&v173.eventHash.memTag);
    v166.eventPools.list = (idAIEventPool **)&idTargetFilter::`vftable';
    idPLogScope::~idPLogScope(this: &v170);
    RD_EventEnd();
  }
_M574055:
  idPLogScope::~idPLogScope(this: (idPLogScope *)&v166.receivers.size);
  RD_EventEnd();
}


// ========================================================================
// __unwind$573000
// EA  : 0x82A211C4
// RVA : 0x00A211C4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573000()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 816 + 624));
}


// ========================================================================
// __unwind$573001
// EA  : 0x82A211EC
// RVA : 0x00A211EC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573001()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 816 + 136));
}


// ========================================================================
// __unwind$573002
// EA  : 0x82A21214
// RVA : 0x00A21214
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573002()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 816 + 625));
}


// ========================================================================
// __unwind$573003
// EA  : 0x82A2123C
// RVA : 0x00A2123C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573003()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 816 + 96));
}


// ========================================================================
// __unwind$573004
// EA  : 0x82A21264
// RVA : 0x00A21264
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573004()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 816 + 626));
}


// ========================================================================
// __unwind$573005
// EA  : 0x82A2128C
// RVA : 0x00A2128C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573005()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 816 + 96));
}


// ========================================================================
// __unwind$573006
// EA  : 0x82A212B4
// RVA : 0x00A212B4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573006()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 816 + 627));
}


// ========================================================================
// __unwind$573007
// EA  : 0x82A212DC
// RVA : 0x00A212DC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573007()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 816 + 152));
}


// ========================================================================
// __unwind$573008
// EA  : 0x82A21304
// RVA : 0x00A21304
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573008()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 816 + 628));
}


// ========================================================================
// __unwind$573009
// EA  : 0x82A2132C
// RVA : 0x00A2132C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573009()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 816 + 96));
}


// ========================================================================
// __unwind$573010
// EA  : 0x82A21354
// RVA : 0x00A21354
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573010()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 816 + 352));
}


// ========================================================================
// __unwind$573011
// EA  : 0x82A2137C
// RVA : 0x00A2137C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573011()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 816 + 629));
}


// ========================================================================
// __unwind$573012
// EA  : 0x82A213A4
// RVA : 0x00A213A4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573012()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 816 + 208));
}


// ========================================================================
// __unwind$573013
// EA  : 0x82A213CC
// RVA : 0x00A213CC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573013()
{
  int v0; // r12

  idAvoidTargetFilter::~idAvoidTargetFilter(this: (idFriendlyDeadTargetFilter *)(v0 - 816 + 144));
}


// ========================================================================
// __unwind$573014
// EA  : 0x82A213F4
// RVA : 0x00A213F4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_573014()
{
  int v0; // r12

  idLobby::migrationInfo_t::~migrationInfo_t(this: (idSkin *)(v0 - 816 + 272));
}


// ========================================================================
// ?Think_PlayerControl@idAI2@@AAAXXZ
// EA  : 0x82A21428
// RVA : 0x00A21428
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Think_PlayerControl(idAI2 *this)
{
  unsigned __int64 v1; // r15
  bool *p_popping; // r19
  bool v4; // r24
  int GameMs; // r3
  idPlayer *v6; // r3
  int FocusTracker; // r3
  float v8; // r9
  float v9; // r8
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  const tagData_t *Tag; // r3
  char *v12; // r10
  idHandle<unsigned short,enum invalidJointHandle_t,65535> *p_parentJoint; // r9
  int i; // ctr
  idTreeAnimator *v15; // r3
  double y; // fp26
  double x; // fp25
  double v18; // fp30
  idClipQuery *p_attackQuery; // r29
  idClip *p_clip; // r28
  unsigned __int64 index; // r11
  idAI2 *v22; // r3
  idAI2 *v23; // r28
  idPhysics *Physics; // r3
  idPhysics *v25; // r3
  idPhysics *v26; // r28
  idPhysics *v27; // r27
  idPhysics *v28; // r26
  int entityNumber; // r25
  double v30; // fp29
  double v31; // fp28
  double v32; // fp24
  float *v33; // r3
  double v34; // fp0
  double v35; // fp13
  float *v36; // r3
  double v37; // fp3
  double v38; // fp1
  idMat3 *v39; // r3
  idPlayer *ControllingPlayer; // r3
  idGameLocal_vtbl *v41; // r6
  idPlayer *v42; // r29
  __int64 v43; // r4
  double CurrentValue; // fp1
  idPresentable *presentable; // r3
  double v46; // fp28
  int v47; // r3
  idPresentable *v48; // r3
  int v49; // r3
  idPresentable *v50; // r3
  int v51; // r3
  int *p_endControlTime; // r22
  int v53; // r26
  int v54; // r25
  idPresentable *v55; // r3
  bool *p_heartBeatLub; // r27
  const idDeclPlayerProps::playerSounds_t *v57; // r3
  __int64 v58; // r10
  const idSoundShader *sndHeartBeatDub; // r5
  const idDeclPlayerProps::playerSounds_t *v60; // r4
  soundChannel_t v61; // r4
  double v62; // fp24
  __int64 v63; // r10
  usercmd_t *p_prevcmd; // r20
  usercmd_t *p_usercmd; // r21
  int v66; // r8
  idVec3 *v67; // r28
  int v68; // r10
  int buttons; // r11
  int v70; // r11
  int v71; // r11
  int v72; // r11
  idWeapon *v73; // r3
  _DWORD *v74; // r25
  int v75; // r11
  int v76; // r11
  int v77; // r11
  const idEventArg *v78; // r29
  int v79; // r11
  int v80; // r11
  int v81; // r11
  int v82; // r11
  int v83; // r11
  int v84; // r29
  idEventArg *v85; // r23
  int v86; // r11
  int v87; // r11
  const idEventArg *v88; // r29
  idPhysics *v89; // r3
  const idMat3 *v90; // r3
  float v91; // r7
  float z; // r6
  double v93; // fp12
  idEventArg *v94; // r29
  idAIFireControl *fireControl; // r29
  int v96; // r3
  int v97; // r11
  char v98; // r29
  idAIOrientation *v99; // r3
  double v100; // fp29
  double v101; // fp31
  idAIOrientation *v102; // r3
  const char *v103; // r6
  idAnimator_AnimWeb *v104; // r28
  int v105; // r3
  int numFrames; // r7
  int frameRate; // r9
  int v108; // r10
  int v109; // r11
  long double v110; // fp2
  const char *v111; // r6
  idAIOrientation *BodyOrientation; // r3
  double v113; // fp31
  idPhysics *v114; // r27
  int GameHz; // r3
  idPhysics_vtbl *v116; // r10
  __int64 v117; // r9
  const idVec3 *v118; // r27
  idAIOrientation *v119; // r3
  double v120; // fp31
  __int64 v121; // r4
  __int64 v122; // r6
  __int64 v123; // r11
  double v124; // fp3
  double v125; // fp31
  double v126; // fp12
  double v127; // fp8
  double v128; // fp7
  double v129; // fp6
  double v130; // fp5
  double v131; // fp3
  double v132; // fp0
  double v133; // fp0
  double v134; // fp1
  idPhysics_AI_vtbl *v135; // r11
  __int64 v136; // r7
  int forwardmove; // r4
  __int64 v138; // r4
  double v139; // fp7
  idAI2::idAIVolatile::idAIAnimationInfo *v140; // r11
  double v141; // fp3
  int v142; // r3
  char v143; // r11
  interruptPath_t v144; // r6
  const char *v145; // r5
  idPhysics *v146; // r3
  idPhysics *v147; // r3
  int v148; // [sp+8h] [-5A8h]
  bool v149; // [sp+Fh] [-5A1h]
  const char *v150; // [sp+10h] [-5A0h]
  int v151; // [sp+14h] [-59Ch]
  int v152; // [sp+18h] [-598h]
  int v153; // [sp+1Ch] [-594h]
  int v154; // [sp+20h] [-590h]
  int v155; // [sp+24h] [-58Ch]
  int v156; // [sp+28h] [-588h]
  int v157; // [sp+2Ch] [-584h]
  int v158; // [sp+30h] [-580h]
  int v159; // [sp+34h] [-57Ch]
  int v160; // [sp+38h] [-578h]
  int v161; // [sp+3Ch] [-574h]
  int v162; // [sp+40h] [-570h]
  int v163; // [sp+44h] [-56Ch]
  int v164; // [sp+48h] [-568h]
  int v165; // [sp+4Ch] [-564h]
  int v166; // [sp+50h] [-560h]
  int v167; // [sp+58h] [-558h]
  int v168; // [sp+60h] [-550h]
  _BYTE v169[20]; // [sp+70h] [-540h] BYREF
  _BYTE v170[20]; // [sp+90h] [-520h] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> v171; // [sp+B0h] [-500h] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> v172; // [sp+B2h] [-4FEh] BYREF
  char v173; // [sp+B4h] [-4FCh]
  char v174; // [sp+B5h] [-4FBh]
  char v175; // [sp+B6h] [-4FAh]
  _BYTE v176[20]; // [sp+C0h] [-4F0h] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> v177; // [sp+D4h] [-4DCh] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> v178; // [sp+D6h] [-4DAh] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> v179; // [sp+D8h] [-4D8h] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> v180; // [sp+DAh] [-4D6h] BYREF
  idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> v181; // [sp+DCh] [-4D4h] BYREF
  idAI2::idAIVolatile::idAIAnimationInfo *p_animation; // [sp+E0h] [-4D0h]
  const idVec3 *v183; // [sp+E4h] [-4CCh]
  idQuat v184; // [sp+F0h] [-4C0h] BYREF
  idVec3 v185; // [sp+100h] [-4B0h] BYREF
  idVec3 v186; // [sp+110h] [-4A0h] BYREF
  idVec3 v187; // [sp+120h] [-490h] BYREF
  const idEventArg *v188[5]; // [sp+130h] [-480h] BYREF
  _DWORD v189[5]; // [sp+150h] [-460h] BYREF
  int *v190; // [sp+164h] [-44Ch]
  bool *v191; // [sp+168h] [-448h]
  idAnimator_AnimWeb::animInfo_t v192; // [sp+170h] [-440h] BYREF
  idTypesafeNumber<int,enum gameTimeUnique_t> v193; // [sp+17Ch] [-434h] BYREF
  idVec3 v194; // [sp+180h] [-430h] BYREF
  idVec3 v195; // [sp+190h] [-420h] BYREF
  idVec3 v196; // [sp+1A0h] [-410h] BYREF
  idVec3 v197; // [sp+1B0h] [-400h] BYREF
  float v198[16]; // [sp+1C0h] [-3F0h] BYREF
  idEventArg v199; // [sp+200h] [-3B0h] BYREF
  idMat3 v200; // [sp+220h] [-390h] BYREF
  idStr v201; // [sp+250h] [-360h] BYREF
  tagData_t v202; // [sp+270h] [-340h] BYREF
  idMat3 v203; // [sp+290h] [-320h] BYREF
  trace_t v204; // [sp+2C0h] [-2F0h] BYREF
  _BYTE v205[208]; // [sp+340h] [-270h] BYREF
  int v206; // [sp+410h] [-1A0h] BYREF

  p_popping = &this->aiVolatile.playerControl.popping;
  v191 = &this->aiVolatile.playerControl.popping;
  idAnimatedEntity::UpdateFrameCommands(this);
  if ( !this->aiVolatile.playerControl.popping )
  {
    LODWORD(v1) = 0;
    v174 = 0;
    v173 = 0;
    v175 = 0;
    v4 = false;
    if ( !this->aiVolatile.fsms.suspend )
    {
      if ( this->aiVolatile.fsms.fsmManager.FindFSM_3(this: &this->aiVolatile.fsms, a2: &idAlertCycleFSM::Type) == nullptr )
        return;
      GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idAI2::UpdateActions(this, curTime: GameMs);
      v4 = idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this);
    }
    if ( !this->aiHealth.IsDead_Impl(this: &this->aiHealth) )
    {
      v6 = idEntityPtr<idPlayer>::operator->(this: &this->aiVolatile.playerControl.player);
      FocusTracker = idPlayer::GetFocusTracker(this: v6);
      v8 = *(float *)(FocusTracker + 140);
      v9 = *(float *)(FocusTracker + 144);
      v187.x = *(float *)(FocusTracker + 136);
      v187.y = v8;
      v187.z = v9;
      TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      Tag = idPropsCollection::GetTag(
              this: &TreeAnimatorFromPresentable->decl->props,
              propName: idPropInfo::INFO_PROP_NAME,
              tagName: "mc_camera");
      v12 = &v201.baseBuffer[16];
      p_parentJoint = &Tag[-1].parentJoint;
      for ( i = 8; i != 0; --i )
      {
        p_parentJoint += 2;
        v12 += 4;
        *(_DWORD *)v12 = *(_DWORD *)&p_parentJoint->value;
      }
      v15 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      if ( (unsigned __int8)idTreeAnimator::GetWorldSpaceTagTransform(
                              this: v15,
                              tagData: &v202,
                              origin: &v195,
                              axis: &v203) == 0 )
        this->GetEyePos(this, a2: &v195);
      y = v187.y;
      x = v187.x;
      v185.x = v187.x - v195.x;
      v18 = 0.0;
      v185.y = v187.y - v195.y;
      v185.z = 0.0;
      idVec3::NormalizeFast(this: &v185);
      p_attackQuery = &this->aiVolatile.playerControl.attackQuery;
      p_clip = &clientGame->clip;
      if ( (unsigned __int8)idClip::QueryIsValid(
                              this: &clientGame->clip,
                              clipQuery: &this->aiVolatile.playerControl.attackQuery) != 0 )
      {
        index = p_attackQuery->index;
        p_attackQuery->index = v1;
        LODWORD(v184.x) = p_clip;
        idCollisionModelManager::GetContentsResult(
          this: collisionModelManager,
          result: &v204,
          query: &p_clip->collisionQueries[index & 0xFFF].query,
          peek: false);
        if ( v204.fraction < 1.0 && !v4 )
        {
          v22 = idAI2::CastTo(c: (idAI2 *)gameLocal->entities.ptr[v204.c.entityNum]);
          v23 = v22;
          if ( v22 != nullptr && !v22->IsDead(this: v22) )
          {
            Physics = idEntity::GetPhysics(this);
            Physics->GetOrigin(this: Physics, a2: 0);
            v25 = idEntity::GetPhysics(this: v23);
            v25->GetOrigin(this: v25, a2: 0);
            idAI2::GetBodyOrientation(this: v23);
          }
        }
      }
      v26 = idEntity::GetPhysics(this);
      v27 = idEntity::GetPhysics(this);
      v28 = idEntity::GetPhysics(this);
      entityNumber = this->entityNumber;
      v30 = (float)(ai_controlTakeDownDistance.valueFloat * v185.z);
      v31 = (float)(ai_controlTakeDownDistance.valueFloat * v185.y);
      v32 = (float)(v185.x * ai_controlTakeDownDistance.valueFloat);
      v33 = (float *)v27->GetAbsBounds(this: v27, a2: -1);
      v34 = (float)((float)(v33[1] + v33[4]) * (float)0.5);
      v35 = (float)((float)(*v33 + v33[3]) * (float)0.5);
      v196.z = (float)v30 + (float)((float)(v33[2] + v33[5]) * (float)0.5);
      v196.y = (float)v31 + (float)v34;
      v196.x = (float)v35 + (float)v32;
      v36 = (float *)v28->GetAbsBounds(this: v28, a2: -1);
      v37 = (float)(v36[1] + v36[4]);
      v38 = (float)(*v36 + v36[3]);
      v194.z = (float)(v36[2] + v36[5]) * (float)0.5;
      v194.y = (float)v37 * (float)0.5;
      v194.x = (float)v38 * (float)0.5;
      v39 = (idMat3 *)v26->GetAxis(this: v26, a2: 0);
      p_attackQuery->index = *(unsigned __int64 *)&idClip::Translation(
                                                     this: (idClip *)&v184,
                                                     result: &clientGame->clip,
                                                     a3: nullptr,
                                                     start: &v194,
                                                     end: &v196,
                                                     clipModel: nullptr,
                                                     startAxis: v39,
                                                     clipMask: 1025,
                                                     passEntityNumber: v148,
                                                     moveClipModel: v149,
                                                     userName: v150,
                                                     a12: v151,
                                                     a13: v152,
                                                     a14: v153,
                                                     a15: v154,
                                                     a16: v155,
                                                     a17: v156,
                                                     a18: v157,
                                                     a19: v158,
                                                     a20: v159,
                                                     a21: v160,
                                                     a22: v161,
                                                     a23: v162,
                                                     a24: v163,
                                                     a25: v164,
                                                     a26: v165,
                                                     a27: v166,
                                                     a28: entityNumber,
                                                     a29: v167,
                                                     a30: false,
                                                     a31: v168,
                                                     a32: (int)"w:\\tech5\\tungsten\\game\\ai\\AI2.cpp(14706) : Contents")->world;
      LODWORD(v184.x) = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
      ControllingPlayer = idAI2::GetControllingPlayer(this);
      v198[0] = 0.0;
      v198[2] = 0.0;
      v198[9] = 1.0;
      v198[10] = 1.0;
      v198[1] = -60.0;
      LODWORD(v198[4]) = 200;
      v198[5] = -60.0;
      LODWORD(v198[3]) = 100;
      v198[6] = -60.0;
      LODWORD(v198[7]) = 20;
      v198[11] = 5000.0;
      LODWORD(v198[8]) = 40;
      v198[13] = 0.0;
      v198[12] = 0.0;
      v198[14] = 0.0;
      v41 = gameLocal->__vftable;
      v42 = ControllingPlayer;
      p_animation = &this->aiVolatile.animation;
      LODWORD(v43) = v41->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
      HIDWORD(v43) = (char *)this + 0x10000;
      *(_QWORD *)v176 = v43;
      CurrentValue = idInterpolate<float>::GetCurrentValue(
                       this: &this->aiVolatile.playerControl.introInterp,
                       time: (float)v43);
      presentable = v42->presentable;
      v46 = CurrentValue;
      if ( presentable != nullptr )
        v47 = (int)presentable->GetPlayerInterface_2(this: presentable);
      else
        v47 = 0;
      v198[0] = *(float *)(*(_DWORD *)(v47 + 16208) + 344) * (float)v46;
      v48 = v42->presentable;
      if ( v48 != nullptr )
        v49 = (int)v48->GetPlayerInterface_2(this: v48);
      else
        v49 = 0;
      v198[1] = (float)((float)(*(float *)(*(_DWORD *)(v49 + 16208) + 348) - (float)-60.0) * (float)v46) - (float)60.0;
      v50 = v42->presentable;
      if ( v50 != nullptr )
        v51 = (int)v50->GetPlayerInterface_2(this: v50);
      else
        v51 = 0;
      v198[2] = *(float *)(*(_DWORD *)(v51 + 16208) + 352) * (float)v46;
      clientGame->soundWorld->OverrideEnvironmentParams(
        this: clientGame->soundWorld,
        a2: (const soundEnvironment_t *)v198,
        a3: v42->entityNumber);
      p_endControlTime = &this->aiVolatile.playerControl.endControlTime;
      v190 = &this->aiVolatile.playerControl.endControlTime;
      v53 = this->aiVolatile.playerControl.endControlTime - this->aiVolatile.playerControl.startControlTime;
      v54 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) - this->aiVolatile.playerControl.startControlTime;
      if ( this->aiVolatile.playerControl.nextBeatTime <= gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED) )
      {
        v55 = v42->presentable;
        p_heartBeatLub = &this->aiVolatile.playerControl.heartBeatLub;
        if ( this->aiVolatile.playerControl.heartBeatLub )
        {
          if ( v55 != nullptr )
          {
            v57 = (const idDeclPlayerProps::playerSounds_t *)v55->GetPlayerInterface_2(this: v55);
            sndHeartBeatDub = idPresentablePlayer::GetPlayerSounds(this: (idPresentablePlayer *)v205, result: v57)->sndHeartBeatDub;
          }
          else
          {
            sndHeartBeatDub = idPresentablePlayer::GetPlayerSounds(this: (idPresentablePlayer *)v205, result: nullptr)->sndHeartBeatDub;
          }
        }
        else
        {
          if ( v55 != nullptr )
            v60 = (const idDeclPlayerProps::playerSounds_t *)v55->GetPlayerInterface_2(this: v55);
          else
            v60 = nullptr;
          sndHeartBeatDub = idPresentablePlayer::GetPlayerSounds(this: (idPresentablePlayer *)&v206, result: v60)->sndHeartBeatLub;
        }
        if ( sndHeartBeatDub != nullptr )
        {
          v61 = SND_CHANNEL_HEARTBEAT1;
          if ( !*p_heartBeatLub )
            v61 = SND_CHANNEL_HEARTBEAT2;
          idEntity::StartSoundShader(this, channel: v61, shader: sndHeartBeatDub, soundShaderFlags: 0, peerMask: 0);
        }
        LODWORD(v58) = v53;
        *(_QWORD *)v176 = v58;
        v62 = (float)((float)((float)(ai_controlHeartBeatIntervalsMax.valueFloat
                                    - ai_controlHeartBeatIntervalsMin.valueFloat)
                            * (float)((float)__SPAIR64__(v53, v54) / (float)v58))
                    + ai_controlHeartBeatIntervalsMin.valueFloat);
        LODWORD(v63) = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
        HIDWORD(v63) = *p_heartBeatLub;
        *(_QWORD *)v176 = v63;
        *p_heartBeatLub = (_cntlzw(HIDWORD(v63)) & 0x20) != 0;
        this->aiVolatile.playerControl.nextBeatTime = (int)(float)((float)v63 + (float)v62);
      }
      ((void (__fastcall *)(idSoundWorld *, int, double))clientGame->soundWorld->Fade)(
        a1: clientGame->soundWorld,
        a2: 6,
        a3: (float)((float)v46 * (float)-60.0));
      p_prevcmd = &idPlayer::GetUCmdTracker2(this: v42)->prevcmd;
      p_usercmd = &idPlayer::GetUCmdTracker2(this: v42)->usercmd;
      idAICamera_Control::Update(
        this: &this->aiVolatile.playerControl.camera,
        prevcmd: p_prevcmd,
        curcmd: p_usercmd,
        actionScriptRunning: v4);
      v66 = *((_BYTE *)&idPlayer::GetUCmdTracker2(this: v42)->usercmd + 9) & 0x80;
      v67 = &vec3_origin;
      v183 = &vec3_origin;
      if ( v66 != 0 || v4 )
      {
LABEL_132:
        v142 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        v143 = 1;
        if ( v142 <= *p_endControlTime )
          v143 = v174;
        if ( v143 != 0 )
        {
          v144 = INTR_PATH_NO;
          v145 = "pop";
        }
        else
        {
          if ( v173 == 0 )
          {
LABEL_139:
            this->SetPosture(this, a2: POSTURE_STANDING);
            this->SetWalkState(this, a2: WALKSTATE_WALKING);
            return;
          }
          v144 = INTR_PATH_YES;
          v145 = "pop_fast";
        }
        idAnimator_AnimWeb::ChangeState(
          this: (idAnimator_AnimWeb *)p_animation,
          subWebName: "mind_control",
          stateName: v145,
          interruptPath_: v144,
          interruptBlend_: INTR_BLEND_MULTI,
          blendEventMask_: 0);
        *p_popping = true;
        v146 = idEntity::GetPhysics(this);
        v146->SetLinearVelocity(this: v146, a2: v67, a3: 0);
        v147 = idEntity::GetPhysics(this);
        v147->SetAngularVelocity(this: v147, a2: v67, a3: 0);
        goto LABEL_139;
      }
      idAIFireControl::SetFireMode(this: this->aiVolatile.fireControl, owner: this, mode: FIREMODE_WEAPON);
      if ( ((double (__fastcall *)(idTungstenHealth *))v42->playerHealth.GetTotalCurHealth_Impl)(a1: &v42->playerHealth) < this->aiVolatile.playerControl.minHealth )
        v173 = 1;
      v68 = *((unsigned __int8 *)p_usercmd + 9) >> 7;
      LOWORD(buttons) = 0;
      if ( v68 == 0 )
        buttons = p_usercmd->buttons;
      if ( (buttons & 0x100) != 0 )
      {
        LOWORD(v70) = 0;
        if ( (*((_BYTE *)p_prevcmd + 9) & 0x80) == 0 )
          v70 = p_prevcmd->buttons;
        if ( (v70 & 0x100) == 0 )
          v174 = 1;
      }
      v71 = 0;
      if ( v68 == 0 )
        v71 = p_usercmd->buttons;
      if ( (v71 & 0x200000) != 0 )
      {
        v72 = 0;
        if ( (*((_BYTE *)p_prevcmd + 9) & 0x80) == 0 )
          v72 = p_prevcmd->buttons;
        if ( (v72 & 0x200000) == 0 )
        {
          idActor::SetFaction(this, faction: this->aiEditable.behaviors.decl->berzerkerFaction);
          *p_endControlTime = -1;
          idAI2::RelinquishControl(this);
          return;
        }
      }
      v73 = this->GetEquippedWeapon(this);
      v74 = &v73->__vftable;
      LOBYTE(v75) = 0;
      if ( (*((_BYTE *)p_usercmd + 9) & 0x80) == 0 )
        v75 = p_usercmd->buttons;
      if ( (v75 & 1) != 0 )
      {
        LOBYTE(v76) = 0;
        if ( (*((_BYTE *)p_prevcmd + 9) & 0x80) == 0 )
          v76 = p_prevcmd->buttons;
        if ( (v76 & 1) == 0 && v73 != nullptr )
        {
          if ( v73->NeedsReload(this: v73, a2: false) )
          {
            v77 = v74[11];
            v78 = nullptr;
            if ( v77 != 0 )
              v78 = *(const idEventArg **)(v77 + 12);
            idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
            this->aiVolatile.fsms.actionManager.actionEventTransCode = 7;
            v188[1] = v78;
            HIBYTE(v188[0]) = 100;
            HIBYTE(v189[0]) = 105;
            v189[1] = 2;
            *(_DWORD *)v176 = idEventArg::idEventArg(this: &v199, data: this);
            memcpy(Dst: v169, Src: v188, Size: sizeof(v169));
            idEventReceiver::ProcessEvent(
              this: (idEventReceiver *)&v200,
              result: (idEventArg *)&this->aiVolatile.fsms.actionManager,
              ev: **(const idEventDef ***)v176,
              arg1: *(const idEventArg **)(*(_DWORD *)v176 + 8),
              arg2: *(const idEventArg **)(*(_DWORD *)v176 + 12),
              arg3: (const idEventArg *)__ROL4__(*(_DWORD *)(*(_DWORD *)v176 + 16), 32));
          }
          else if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 197) & 0x20) != 0 )
          {
            idStr::idStr(this: &v201, text: "$weaponcombat:shoot");
            idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
            this->aiVolatile.fsms.actionManager.actionEventTransCode = 7;
            HIBYTE(v189[0]) = 105;
            v189[1] = 0;
            HIBYTE(v188[0]) = 115;
            v188[1] = (const idEventArg *)v201.data;
            *(_DWORD *)v176 = idEventArg::idEventArg(this: (idEventArg *)&v200, data: this);
            memcpy(Dst: v169, Src: v189, Size: sizeof(v169));
            idEventReceiver::ProcessEvent(
              this: (idEventReceiver *)&v199,
              result: (idEventArg *)&this->aiVolatile.fsms.actionManager,
              ev: **(const idEventDef ***)v176,
              arg1: *(const idEventArg **)(*(_DWORD *)v176 + 8),
              arg2: *(const idEventArg **)(*(_DWORD *)v176 + 12),
              arg3: (const idEventArg *)__ROL4__(*(_DWORD *)(*(_DWORD *)v176 + 16), 32));
            idStr::FreeData(this: &v201);
          }
          else
          {
            (*(void (__fastcall **)(_DWORD *, idAI2 *, _DWORD))(*v74 + 96))(a1: v74, a2: this, a3: 0);
          }
        }
      }
      LOBYTE(v79) = 0;
      if ( (*((_BYTE *)p_usercmd + 9) & 0x80) == 0 )
        v79 = p_usercmd->buttons;
      if ( (v79 & 1) == 0 )
      {
        LOBYTE(v80) = 0;
        if ( (*((_BYTE *)p_prevcmd + 9) & 0x80) == 0 )
          v80 = p_prevcmd->buttons;
        if ( (v80 & 1) != 0 && v74 != nullptr )
        {
          if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 197) & 0x20) != 0 )
          {
            idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
            this->aiVolatile.fsms.actionManager.actionEventTransCode = 7;
            v189[1] = 1;
            HIBYTE(v189[0]) = 105;
            HIBYTE(v188[0]) = 105;
            v188[1] = (const idEventArg *)-1;
            *(_DWORD *)v176 = idEventArg::idEventArg(this: (idEventArg *)&v200, data: this);
            memcpy(Dst: v169, Src: v189, Size: sizeof(v169));
            idEventReceiver::ProcessEvent(
              this: (idEventReceiver *)&v199,
              result: (idEventArg *)&this->aiVolatile.fsms.actionManager,
              ev: **(const idEventDef ***)v176,
              arg1: *(const idEventArg **)(*(_DWORD *)v176 + 8),
              arg2: *(const idEventArg **)(*(_DWORD *)v176 + 12),
              arg3: (const idEventArg *)__ROL4__(*(_DWORD *)(*(_DWORD *)v176 + 16), 32));
          }
          else
          {
            (*(void (__fastcall **)(_DWORD *, idAI2 *))(*v74 + 100))(a1: v74, a2: this);
          }
        }
      }
      LOBYTE(v81) = 0;
      if ( (*((_BYTE *)p_usercmd + 9) & 0x80) == 0 )
        v81 = p_usercmd->buttons;
      if ( (v81 & 1) != 0 )
      {
        LOBYTE(v82) = 0;
        if ( (*((_BYTE *)p_prevcmd + 9) & 0x80) == 0 )
          v82 = p_prevcmd->buttons;
        if ( (v82 & 1) != 0 && v74 != nullptr )
        {
          if ( (*(unsigned __int8 (__fastcall **)(_DWORD *, _DWORD))(*v74 + 136))(a1: v74, a2: 0) != 0 )
          {
            v83 = v74[11];
            v84 = 0;
            if ( v83 != 0 )
              v84 = *(_DWORD *)(v83 + 12);
            idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
            this->aiVolatile.fsms.actionManager.actionEventTransCode = 7;
            v189[1] = v84;
            HIBYTE(v189[0]) = 100;
            HIBYTE(v188[0]) = 105;
            v188[1] = (const idEventArg *)2;
            v85 = idEventArg::idEventArg(this: (idEventArg *)&v200, data: this);
            memcpy(Dst: v169, Src: v189, Size: sizeof(v169));
            idEventReceiver::ProcessEvent(
              this: (idEventReceiver *)&v199,
              result: (idEventArg *)&this->aiVolatile.fsms.actionManager,
              ev: *(const idEventDef **)&v85->type,
              arg1: (const idEventArg *)LODWORD(v85->value.v[1]),
              arg2: (const idEventArg *)LODWORD(v85->value.v[2]),
              arg3: (const idEventArg *)__ROL4__(LODWORD(v85->value.q[3]), 32));
          }
          else
          {
            (*(void (__fastcall **)(_DWORD *, idAI2 *, _DWORD))(*v74 + 96))(a1: v74, a2: this, a3: 0);
          }
        }
      }
      LOBYTE(v86) = 0;
      if ( (*((_BYTE *)p_usercmd + 9) & 0x80) == 0 )
        v86 = p_usercmd->buttons;
      if ( (v86 & 2) != 0 )
      {
        LOBYTE(v87) = 0;
        if ( (*((_BYTE *)p_prevcmd + 9) & 0x80) == 0 )
          v87 = p_prevcmd->buttons;
        if ( (v87 & 2) == 0 )
        {
          v88 = (const idEventArg *)AIMeleeTypeToOverrideAnim(meleeType: AIMELEE_FORWARD);
          v89 = idEntity::GetPhysics(this);
          v90 = v89->GetAxis(this: v89, a2: 0);
          v91 = v90->mat[0].y;
          z = v90->mat[0].z;
          *(float *)v176 = v90->mat[0].x;
          *(float *)&v176[4] = v91;
          *(float *)&v176[8] = z;
          idVec3::NormalizeFast(this: (idVec3 *)v176);
          if ( v88 != nullptr )
          {
            idComponentActionScript::ClearActionScript(this: &this->actionScript, entity: this);
            this->aiVolatile.fsms.actionManager.actionEventTransCode = 7;
            v93 = *(float *)&v176[8];
            *(float *)&v176[8] = *(float *)&v176[4];
            *(float *)&v176[4] = *(float *)v176;
            v176[0] = 118;
            *(float *)&v176[12] = v93;
            HIBYTE(v189[0]) = 105;
            v189[1] = 1;
            HIBYTE(v188[0]) = 105;
            v188[1] = v88;
            v94 = idEventArg::idEventArg(this: (idEventArg *)&v200, data: this);
            memcpy(Dst: v170, Src: v176, Size: sizeof(v170));
            memcpy(Dst: v169, Src: v189, Size: sizeof(v169));
            idEventReceiver::ProcessEvent(
              this: (idEventReceiver *)&v199,
              result: (idEventArg *)&this->aiVolatile.fsms.actionManager,
              ev: *(const idEventDef **)&v94->type,
              arg1: (const idEventArg *)LODWORD(v94->value.v[1]),
              arg2: (const idEventArg *)LODWORD(v94->value.v[2]),
              arg3: (const idEventArg *)__ROL4__(LODWORD(v94->value.q[3]), 32),
              arg4: v188[2]);
          }
        }
      }
      fireControl = this->aiVolatile.fireControl;
      v96 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
      idAIFireControl::Update(this: fireControl, owner: this, curTime: v96);
      LOBYTE(v97) = 0;
      if ( (*((_BYTE *)p_usercmd + 9) & 0x80) == 0 )
        v97 = p_usercmd->buttons;
      v98 = 1;
      if ( (v97 & 0x10) == 0 )
        v98 = v175;
      idAI2::SetSubWeb(this, sw: AISUBWEB_COMBAT);
      if ( p_usercmd->forwardmove != 0 || p_usercmd->rightmove != 0 )
      {
        v179.value = -1;
        v178.value = -1;
        if ( v98 != 0 )
          v111 = "run";
        else
          v111 = "walk";
        idAI2::FindAnimWebAndStateIndices(
          this,
          web: AIANIMWEB_BODY,
          subWeb: AISUBWEB_COMBAT,
          stateName: v111,
          changeWeapon: false,
          newWeapon: nullptr,
          subWebIndex: &v179,
          stateIndex: &v178);
        idAI2::ChangeAnimState(
          this,
          web: AIANIMWEB_BODY,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v179.value,
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)(unsigned __int16)v178.value,
          interruptPath: INTR_PATH_NO,
          interruptBlend: INTR_BLEND_NO);
        BodyOrientation = idAI2::GetBodyOrientation(this);
        idAIOrientation::SetIdealDir(
          this: BodyOrientation,
          ai: this,
          dir: this->aiVolatile.playerControl.camera.camAxis.mat);
        v113 = (float)((float)(this->aiConstants.movement.bodyTurnRate.maxRange
                             - this->aiConstants.movement.bodyTurnRate.minRange)
                     + this->aiConstants.movement.bodyTurnRate.minRange);
        *(_DWORD *)v176 = &this->aiConstants.movement.bodyTurnRate;
        v114 = idEntity::GetPhysics(this);
        GameHz = idGameTimeManager::GetGameHz(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        v116 = v114->__vftable;
        LODWORD(v117) = GameHz;
        *(_QWORD *)v176 = v117;
        v118 = v116->GetGravityNormal(this: v114);
        v119 = idAI2::GetBodyOrientation(this);
        idAIOrientation::UpdateAxis(
          this: v119,
          normal: v118,
          turnRate: v113,
          timeSeconds: (float)((float)1.0 / (float)*(__int64 *)v176));
        idTreeAnimator::GetLastOriginDeltas(this: (idTreeAnimator *)LODWORD(v184.x), rot: &v200, trans: &v197);
        v120 = (float)((float)(v197.z * v197.z) + (float)((float)(v197.x * v197.x) + (float)(v197.y * v197.y)));
        HIDWORD(v121) = gameLocal->GetGameHz(this: gameLocal, a2: GAMETIME_SCALED);
        LODWORD(v121) = HIDWORD(v121);
        HIDWORD(v122) = (unsigned __int8)p_usercmd->forwardmove;
        HIDWORD(v123) = (unsigned __int8)p_usercmd->rightmove;
        v124 = __fsqrts(v120);
        LODWORD(v123) = SBYTE3(v122);
        *(_QWORD *)&v184.x = v123;
        LODWORD(v122) = SBYTE3(v123);
        *(_QWORD *)v176 = v122;
        v125 = (float)((float)v121 * (float)v124);
        v126 = this->aiVolatile.playerControl.camera.camAxis.mat[1].x;
        v127 = -(float)((float)((float)v122 * (float)0.0078740157) * (float)((float)v121 * (float)v124));
        v129 = (float)(this->aiVolatile.playerControl.camera.camAxis.mat[0].z
                     * (float)((float)((float)v123 * (float)0.0078740157) * (float)((float)v121 * (float)v124)));
        v130 = (float)((float)((float)((float)v123 * (float)0.0078740157) * (float)((float)v121 * (float)v124))
                     * this->aiVolatile.playerControl.camera.camAxis.mat[0].x);
        v128 = (float)(this->aiVolatile.playerControl.camera.camAxis.mat[0].y
                     * (float)((float)((float)v123 * (float)0.0078740157) * (float)((float)v121 * (float)v124)));
        v132 = (float)((float)(this->aiVolatile.playerControl.camera.camAxis.mat[0].y
                             * (float)((float)((float)v123 * (float)0.0078740157) * (float)((float)v121 * (float)v124)))
                     + (float)(this->aiVolatile.playerControl.camera.camAxis.mat[1].y * (float)v127));
        v131 = (float)(this->aiVolatile.playerControl.camera.camAxis.mat[1].z * (float)v127);
        v186.y = (float)v128 + (float)(this->aiVolatile.playerControl.camera.camAxis.mat[1].y * (float)v127);
        LODWORD(v184.x) = &this->aiVolatile.playerControl.camera.camAxis.mat[1];
        v186.z = (float)v129 + (float)v131;
        v186.x = (float)v130 + (float)((float)v127 * (float)v126);
        v133 = __fsqrts((float)((float)(v186.x * v186.x)
                              + (float)((float)(v186.z * v186.z) + (float)((float)v132 * (float)v132))));
        if ( v133 >= 0.0 )
        {
          if ( v133 <= v125 )
            v18 = v133;
          else
            v18 = v125;
        }
        if ( v98 != 0 )
          v18 = (float)((float)v18 * (float)2.0);
        v134 = idVec3::NormalizeFast(this: &v186);
        v186.x = (float)v18 * v186.x;
        v186.y = (float)v18 * v186.y;
        v135 = this->aiVolatile.physics.object.__vftable;
        v186.z = (float)v18 * v186.z;
        ((void (__fastcall *)(idAI2::idAIVolatile *, idVec3 *, _DWORD, double))v135->SetLinearVelocity)(
          a1: &this->aiVolatile,
          a2: &v186,
          a3: 0,
          a4: v134);
        idAIMoveState::SetMoveStatus(this: &this->aiVolatile.physics.moveState, status: AIMOVESTATUS_MOVING);
        this->aiConstants.movement.moveSpeed.minRange = v125;
        HIDWORD(v136) = (unsigned __int8)p_usercmd->rightmove;
        forwardmove = p_usercmd->forwardmove;
        v67 = (idVec3 *)v183;
        HIDWORD(v138) = SBYTE3(v136);
        p_popping = v191;
        LODWORD(v136) = pm_walkthreshold.valueInteger;
        *(_QWORD *)&v184.x = v136;
        LODWORD(v136) = abs32(forwardmove);
        HIDWORD(v136) = abs8(SBYTE3(v136));
        v139 = (double)*(__int64 *)&v184.x;
        v140 = p_animation;
        LODWORD(v138) = HIDWORD(v136) * HIDWORD(v136) + v136 * v136;
        v141 = __fsqrts((double)v138);
        *(_QWORD *)&v184.x = v138;
        p_animation->animWebAnimator.ptr[0].runRate = (float)v141 * (float)0.0078740157;
        v140->animWebAnimator.ptr[0].walkRate = (float)v141 / (float)v139;
        goto LABEL_131;
      }
      if ( p_prevcmd->forwardmove != 0 || p_prevcmd->rightmove != 0 )
      {
        v177.value = -1;
        v180.value = -1;
        idAI2::FindAnimWebAndStateIndices(
          this,
          web: AIANIMWEB_BODY,
          subWeb: AISUBWEB_COMBAT,
          stateName: "idle",
          changeWeapon: false,
          newWeapon: nullptr,
          subWebIndex: &v177,
          stateIndex: &v180);
        idAI2::ChangeAnimState(
          this,
          web: AIANIMWEB_BODY,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v177.value,
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)(unsigned __int16)v180.value,
          interruptPath: INTR_PATH_NO,
          interruptBlend: INTR_BLEND_NO);
      }
      v99 = idAI2::GetBodyOrientation(this);
      v100 = (float)((float)(v185.x * v99->axis.mat[0].x)
                   + (float)((float)(v99->axis.mat[0].y * v185.y) + (float)(v99->axis.mat[0].z * v185.z)));
      if ( v100 >= 0.89999998 )
      {
LABEL_120:
        this->aiVolatile.physics.object.SetLinearVelocity(
          this: (struct idPhysics_AI *)&this->aiVolatile,
          a2: v183,
          a3: 0);
        idAIMoveState::SetMoveStatus(this: &this->aiVolatile.physics.moveState, status: AIMOVESTATUS_DONE);
        v67 = (idVec3 *)v183;
        p_popping = v191;
        this->aiConstants.movement.moveSpeed.minRange = 0.0;
LABEL_131:
        p_endControlTime = v190;
        goto LABEL_132;
      }
      v171.value = -1;
      v181.value = -1;
      idAI2::FindAnimWebAndStateIndices(
        this,
        web: AIANIMWEB_BODY,
        subWeb: AISUBWEB_COMBAT,
        stateName: "idle",
        changeWeapon: false,
        newWeapon: nullptr,
        subWebIndex: &v171,
        stateIndex: &v181);
      v172.value = -1;
      v101 = (float)((float)3.1415927 * (float)0.5);
      v102 = idAI2::GetBodyOrientation(this);
      if ( (float)((float)((float)x * v102->axis.mat[1].x)
                 + (float)((float)(v102->axis.mat[1].y * (float)y) + (float)(v102->axis.mat[1].z * v187.z))) <= 0.0 )
      {
        if ( v100 < -0.70710677 )
        {
          idAI2::FindAnimWebAndStateIndices(
            this,
            web: AIANIMWEB_BODY,
            subWeb: AISUBWEB_COMBAT,
            stateName: "turn_right_157",
            changeWeapon: false,
            newWeapon: nullptr,
            subWebIndex: &v171,
            stateIndex: &v172);
          v101 = (float)(3.1415927 * (float)0.875);
          goto LABEL_119;
        }
        v103 = "turn_right";
      }
      else
      {
        if ( v100 < -0.70710677 )
        {
          idAI2::FindAnimWebAndStateIndices(
            this,
            web: AIANIMWEB_BODY,
            subWeb: AISUBWEB_COMBAT,
            stateName: "turn_left_157",
            changeWeapon: false,
            newWeapon: nullptr,
            subWebIndex: &v171,
            stateIndex: &v172);
          v101 = (float)(3.1415927 * (float)0.875);
LABEL_119:
          v104 = (idAnimator_AnimWeb *)p_animation;
          idAnimator_AnimWeb::ChangeStateVia(
            this: (idAnimator_AnimWeb *)p_animation,
            subWebIndex_: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v171.value,
            stateIndex_: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)(unsigned __int16)v181.value,
            _viaSubWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v171.value,
            _viaStateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)(unsigned __int16)v172.value,
            interruptPath_: INTR_PATH_NO,
            interruptBlend_: INTR_BLEND_MULTI,
            blendEventMask_: 0);
          memset(&v192, 0, sizeof(v192));
          v105 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
          idAnimator_AnimWeb::GetNodeAnimLength(
            this: v104,
            curTime: v105,
            modelIndex: nullptr,
            swi: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)(unsigned __int16)v171.value,
            si: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)(unsigned __int16)v172.value,
            wrapMode: WRAP_CLAMP,
            ignoreAdditive: true,
            animInfo: &v192);
          numFrames = v192.numFrames;
          *(float *)v176 = v101;
          frameRate = v192.frameRate;
          v187.x = 0.0;
          v187.y = 0.0;
          v108 = timeManager.gameHz;
          v187.z = 1.0;
          __twllei(v192.frameRate, 0);
          v109 = numFrames * timeManager.gameTimePerFrame.value * v108;
          v193.value = v109 / frameRate;
          __twlgei(frameRate & ~(__ROL4__(v109, 1) - 1), 0xFFFFFFFF);
          idQuat::idQuat(
            this: &v184,
            axis: &v187,
            angle: (const idTypesafeNumber<float,enum RadiansUnique_t> *)v176,
            a4: v110);
          idAIMoveState::BeginTurn(
            this: &this->aiVolatile.physics.moveState,
            idealDir: &v185,
            rotDelta: &v184,
            totalTurnTime: &v193);
          goto LABEL_120;
        }
        v103 = "turn_left";
      }
      idAI2::FindAnimWebAndStateIndices(
        this,
        web: AIANIMWEB_BODY,
        subWeb: AISUBWEB_COMBAT,
        stateName: v103,
        changeWeapon: false,
        newWeapon: nullptr,
        subWebIndex: &v171,
        stateIndex: &v172);
      goto LABEL_119;
    }
  }
}


// ========================================================================
// __unwind$574185
// EA  : 0x82A229F4
// RVA : 0x00A229F4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_574185()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 1456 + 592));
}


// ========================================================================
// ?ForceTakeCoverFromEntity@idAI2@@QAAXPBVidEntity@@00@Z
// EA  : 0x82A22A28
// RVA : 0x00A22A28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceTakeCoverFromEntity(
        idAI2 *this,
        idEntity *enemy,
        idEntity *coverReference,
        idEntity *coverTarget)
{
  bfx::BinaryReplayLogOut v5; // [sp+50h] [-30h] BYREF

  idAI2::PrepTakeCoverFromEntity(this: (idAI2 *)&v5, result: this, enemy, coverReference, coverTarget);
  if ( idAICover::IsValid(this: (idAICover *)&v5) || ai_debugLevel.valueInteger <= 0 )
  {
    idAICover::operator=(this: &this->aiVolatile.memory.cachedCover, other: (const idAICover *)&v5);
    this->aiVolatile.memory.flags |= 1u;
  }
  else
  {
    idLib::Warning(
      fmt: "AI '%s' AIOVERRIDE_COVER_FROM_PLAYER / AIOVERRIDE_COVER_FROM_ENTITY with no valid coverpoint",
      this->name.data);
  }
  idPhysics_StaticMulti::UpdateTime(this: &v5);
}


// ========================================================================
// __unwind$575648
// EA  : 0x82A22ADC
// RVA : 0x00A22ADC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_575648()
{
  int v0; // r12

  idPhysics_StaticMulti::UpdateTime(this: (bfx::BinaryReplayLogOut *)(v0 - 128 + 80));
}


// ========================================================================
// ?Think_AIControl@idAI2@@AAAXXZ
// EA  : 0x82A23058
// RVA : 0x00A23058
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::Think_AIControl(idAI2 *this)
{
  signed int num; // r29
  int v3; // r3
  idClientGame *v4; // r11
  int lastSubmitFrame; // r27
  int v6; // r29
  char v7; // r7
  bool v8; // r11
  idGameLocal *v9; // r4
  unsigned __int64 v10; // r6
  const char *v11; // r7
  int value; // r7
  idEntity *v13; // r3
  idEntity *v14; // r29
  idAIGameState *p_aiGameState; // r26
  const idSpawnId *v16; // r29
  const idAILogic *v17; // r3
  const idSpawnId *v18; // r8
  unsigned __int64 v19; // r6
  const char *v20; // r7
  idFiniteStateMachine *v21; // r29
  int GameMs; // r3
  int v23; // r3
  __int64 v24; // r6
  int v25; // r3
  idSpawnId v26; // [sp+50h] [-90h] BYREF
  idSpawnId v27; // [sp+54h] [-8Ch] BYREF
  idPLogScope v28; // [sp+58h] [-88h] BYREF
  idAILogic v29[4]; // [sp+60h] [-80h] BYREF

  if ( (this->thinkFlags & 1) != 0 )
  {
    if ( ai_enableWorldState.valueInteger != 0 && !this->IsDead(this) && !this->IsDying(this) )
      idAI2::UpdateWorldState(this);
    if ( (*((_BYTE *)this->aiEditable.behaviors.decl + 196) & 0x80) != 0 )
    {
      num = gameLocal->activeAI.num;
      if ( num < 1 )
        num = 1;
      v3 = idAccolade::Count(this: &clientGame->gameTimeManager);
      v4 = clientGame;
      lastSubmitFrame = this->aiVolatile.visibilityObscurity.lastSubmitFrame;
      __twllei(num, 0);
      __twlgei(num & ~(__ROL4__(v3, 1) - 1), 0xFFFFFFFF);
      v6 = v3 % num;
      v7 = _cntlzw(idAccolade::Count(this: &v4->gameTimeManager) - 1 - lastSubmitFrame);
      v8 = (v7 & 0x20) != 0;
      if ( (v7 & 0x20) == 0 )
      {
        v9 = gameLocal;
        if ( v6 < gameLocal->activeAI.num )
          v8 = (_cntlzw(
                  idGameLocal::GetSpawnId(this: (idGameLocal *)&v26, result: (idSpawnId *)gameLocal, ent: this)->value
                - v9->activeAI.list[v6].spawnId.value)
              & 0x20) != 0;
      }
      if ( v8 )
        idAI2::idVisibilityObscurity::Update(this: &this->aiVolatile.visibilityObscurity, ai: this);
    }
    idAnimatedEntity::UpdateFrameCommands(this);
    if ( this->aiVolatile.memory.justTouched )
    {
      RD_EventBegin(name: "idAI2::Think_AIControl - just touched");
      LODWORD(v10) = "idAI2::Think_AIControl - just touched";
      HIDWORD(v10) = 6;
      idPLogScope::idPLogScope(this: &v28, pl: &pLog, gMask: v10, label: v11);
      value = this->aiVolatile.memory.lastToucher.spawnId.value;
      if ( gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
      {
        v13 = gameLocal->entities.ptr[value & 0x1FFF];
        if ( v13 != nullptr )
        {
          v14 = idEntity::CastTo(c: v13);
          if ( v14 != nullptr )
          {
            p_aiGameState = &gameLocal->aiGameState;
            idSpawnId::idSpawnId(this: &v26, ent: this);
            v16 = idSpawnId::idSpawnId(this: &v27, ent: v14);
            v17 = idAILogic::idAILogic(this: v29, ai: this);
            idAIWorldState::AddEntityState(
              this: &this->aiVolatile.world.worldState,
              gameState: p_aiGameState,
              owner: v17,
              entId: v16,
              stimulusType: AISTIMULUS_TOUCH,
              stimulusAmount: 1.0,
              sourceId: v18);
          }
        }
      }
      this->aiVolatile.memory.justTouched = false;
      idPLogScope::~idPLogScope(this: &v28);
      RD_EventEnd();
    }
    if ( !this->IsDead(this) && !this->IsDying(this) )
    {
      idAI2::UpdateConfidenceLevel(this);
      idAI2::UpdatePathToEnemy(this, force: false);
    }
    if ( this->actorConstants.actorClass != ACTORCLASS_MUTANT
      && !idComponentActionScript::RunningActionScript(this: &this->actionScript, entity: this)
      && !idAI2::IsExecutingScript(this) )
    {
      RD_EventBegin(name: "DisableAnimators");
      LODWORD(v19) = "DisableAnimators";
      HIDWORD(v19) = 2;
      idPLogScope::idPLogScope(this: &v28, pl: &pLog, gMask: v19, label: v20);
      if ( this->aiVolatile.faceMgr.voiceOver == nullptr )
      {
        v26.value = 960;
        if ( !idFaceMgr::RecentlyPlayedVoiceOver(
                this: &this->aiVolatile.faceMgr,
                threshold: (const idTypesafeNumber<int,enum gameTimeUnique_t> *)&v26) )
        {
          if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x40) != 0 )
            idFaceMgr::SetEnableMoodAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
          if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x20) != 0 )
            idFaceMgr::SetEnableLipSyncAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
          if ( (*((_BYTE *)&this->aiConstants.animation + 93) & 0x10) != 0 )
            idFaceMgr::SetEnableGestureAnimation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
        }
      }
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 0x10) != 0 )
        idFaceMgr::SetEnableEyeTracking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 4) != 0 )
        idFaceMgr::SetEnableBlinking(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      if ( (*((_BYTE *)&this->aiConstants.animation + 92) & 2) != 0 )
        idFaceMgr::SetEnableLidDeformation(this: &this->aiVolatile.faceMgr, owner: this, enable: false);
      idPLogScope::~idPLogScope(this: &v28);
      RD_EventEnd();
    }
    idAI2::HandlePendingAIEvents(this);
    if ( !this->IsDead(this) && !this->IsDying(this) && (unsigned __int8)idAI2::IsOnElevator(this) != 0 )
    {
      v21 = this->aiVolatile.fsms.fsmManager.FindFSM_4(this: &this->aiVolatile.fsms, a2: "FSM_alertCycle");
      if ( v21 != nullptr )
      {
        GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
        idFiniteStateMachine::Restart(this: v21, curTime: GameMs);
      }
      idFocusInfo::Clear(this: this->aiVolatile.focus.foci.ptr, owner: this);
    }
    if ( this->aiEditable.actionSettings.customRobot.usesRobot )
    {
      v23 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idAI2::ThinkRobot(this, _curTime: v23, a3: v24);
    }
    if ( ai_enableFSM.valueInteger != 0 )
      idAI2::UpdateFSMs(this);
    if ( this->aiVolatile.fireControl != nullptr )
    {
      v25 = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
      idAIFireControl::Update(this: this->aiVolatile.fireControl, owner: this, curTime: v25);
    }
    this->aiVolatile.memory.transitionEntity.spawnId.value = 0x1FFF;
    if ( !this->IsDead(this) && !this->IsDying(this) )
    {
      idCheckSurroundingsState::Update(this: &this->aiVolatile.focus.checkSurroundingsState, ai: this);
      idAI2::UpdateAimFocus(this);
      idAI2::UpdateLookFocus(this);
    }
  }
}


// ========================================================================
// __unwind$576114
// EA  : 0x82A23630
// RVA : 0x00A23630
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576114()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 224 + 128));
}


// ========================================================================
// __unwind$576115
// EA  : 0x82A23658
// RVA : 0x00A23658
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576115()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 224 + 88));
}


// ========================================================================
// __unwind$576116
// EA  : 0x82A23680
// RVA : 0x00A23680
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576116()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 224 + 129));
}


// ========================================================================
// __unwind$576117
// EA  : 0x82A236A8
// RVA : 0x00A236A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576117()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 224 + 88));
}


// ========================================================================
// ?UpdateDeaths@idAI2@@SAXXZ
// EA  : 0x82A236D0
// RVA : 0x00A236D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

static void __fastcall idAI2::UpdateDeaths()
{
  int v0; // r21
  idGameLocal *v1; // r11
  int i; // r23
  int value; // r9
  idAI2 *v4; // r3
  idAI2 *v5; // r3
  idAI2 *v6; // r28
  unsigned __int8 v7; // r11
  idAI2::idAIVolatile::idAIPain *p_pain; // r29
  int v9; // r30
  char started; // r31
  int num; // r6
  int v12; // r11
  int v13; // r7
  idDamageImpulse *list; // r8
  int v15; // r9
  float *v16; // r10
  idDamageImpulse *v17; // r9
  int v18; // r10
  int v19; // ctr
  double recentUnscaledDamage; // fp30
  __int16 v21; // r31
  const idVec3 *v22; // r30
  const idDeclDamage *v23; // r16
  const idVec3 *v24; // r15
  idPlayer *Attacker; // r14
  idEntity *Inflictor; // r3
  const idVec3 *v27; // r7
  idPhysics *Physics; // r31
  idRenderWorld *v29; // r30
  __int128 v30; // r6
  __int64 v31; // r10
  __int64 v32; // r8
  va *v33; // r29
  idRenderWorld_vtbl *v34; // r28
  int v35; // r3
  int v36; // [sp+8h] [-1108h]
  int v37; // [sp+Ch] [-1104h]
  int v38; // [sp+10h] [-1100h]
  int v39; // [sp+14h] [-10FCh]
  int v40; // [sp+18h] [-10F8h]
  int v41; // [sp+1Ch] [-10F4h]
  double v42; // [sp+20h] [-10F0h]
  double recentBodyDamage; // [sp+28h] [-10E8h]
  int v44; // [sp+30h] [-10E0h]
  int v45; // [sp+34h] [-10DCh]
  int v46; // [sp+38h] [-10D8h]
  int v47; // [sp+3Ch] [-10D4h]
  int v48; // [sp+40h] [-10D0h]
  int v49; // [sp+44h] [-10CCh]
  int v50; // [sp+48h] [-10C8h]
  idIndex<short,enum invalidJointIndex_t> *v51; // [sp+4Ch] [-10C4h]
  va v52; // [sp+60h] [-10B0h] BYREF

  v0 = 0;
  v1 = gameLocal;
  if ( gameLocal->activeAI.num > 0 )
  {
    for ( i = 0; ; ++i )
    {
      value = v1->activeAI.list[i].spawnId.value;
      if ( v1->spawnIds.ptr[value & 0x1FFF] == value >> 13 )
      {
        v4 = (idAI2 *)v1->entities.ptr[value & 0x1FFF];
        if ( v4 == nullptr )
          goto LABEL_54;
        v5 = idAI2::CastTo(c: v4);
        v6 = v5;
        if ( v5 != nullptr && (*((_BYTE *)&v5->aiVolatile + 49704) & 0x80) != 0x80 )
          break;
LABEL_53:
        v1 = gameLocal;
      }
LABEL_54:
      if ( ++v0 >= v1->activeAI.num )
        return;
    }
    if ( v5->aiVolatile.pain.damageInfo.deathImpulseIdx >= 0
      || (v7 = 0, (*((_BYTE *)&v5->aiVolatile.death + 1760) & 8) != 0) )
    {
      v7 = 1;
    }
    p_pain = &v5->aiVolatile.pain;
    v9 = v7;
    if ( v7 != 0 && v5->aiVolatile.death.deathInfo.startDeathTime < 0 )
      idAIDeathInfo::Set(this: &v5->aiVolatile.death.deathInfo, info: &v5->aiVolatile.pain.damageInfo);
    if ( (unsigned __int8)idAI2::CheckForGore(this: v6) != 0 )
    {
      if ( v9 == 0 )
        goto LABEL_50;
    }
    else
    {
      if ( v9 == 0 || idAI2::GetAlertCycle(this: v6) == ALERTCYCLE_DEAD )
      {
        if ( v6->aiVolatile.pain.damageInfo.impulses.num > 0 )
        {
          started = 0;
          if ( idAIDamageInfo::Stunned(this: &v6->aiVolatile.pain.damageInfo) )
            started = idAI2::StartStunningPain(this: v6, info: &v6->aiVolatile.pain.damageInfo);
          if ( started == 0
            && (unsigned __int8)idAI2::StartStaggeringPain(this: v6, info: (idVec3 *)&v6->aiVolatile.pain) == 0 )
          {
            num = v6->aiVolatile.pain.damageInfo.impulses.num;
            v12 = 0;
            v13 = 0;
            if ( num >= 4 )
            {
              list = p_pain->damageInfo.impulses.list;
              v15 = 0;
              do
              {
                if ( v12 == 0 || (v16 = (float *)&list[v15], *(float *)(v12 + 32) < (double)list[v15].damage) )
                {
                  v16 = (float *)&list[v15];
                  v12 = (int)&list[v15];
                }
                if ( v12 == 0 || *(float *)(v12 + 32) < (double)v16[18] )
                  v12 = (int)(v16 + 10);
                if ( v12 == 0 || *(float *)(v12 + 32) < (double)v16[28] )
                  v12 = (int)&list[v15 + 2];
                if ( v12 == 0 || *(float *)(v12 + 32) < (double)v16[38] )
                  v12 = (int)&list[v15 + 3];
                v13 += 4;
                v15 += 4;
              }
              while ( v13 < num - 3 );
            }
            if ( v13 < num )
            {
              v17 = p_pain->damageInfo.impulses.list;
              v18 = v13;
              v19 = num - v13;
              do
              {
                if ( v12 == 0 || *(float *)(v12 + 32) < (double)v17[v18].damage )
                  v12 = (int)&v17[v18];
                ++v18;
                --v19;
              }
              while ( v19 != 0 );
            }
            if ( v12 != 0 && (*((_BYTE *)&v6->aiEditable.behaviors.decl->damageBehaviors + 84) & 0x40) != 0 )
            {
              recentUnscaledDamage = v6->aiVolatile.pain.damageInfo.recentUnscaledDamage;
              v21 = *(_WORD *)(v12 + 28);
              v22 = (const idVec3 *)(v12 + 4);
              v23 = *(const idDeclDamage **)v12;
              v24 = (const idVec3 *)(v12 + 16);
              Attacker = (idPlayer *)idAIDamageInfo::GetAttacker(this: &v6->aiVolatile.pain.damageInfo);
              Inflictor = idAIDamageInfo::GetInflictor(this: &v6->aiVolatile.pain.damageInfo);
              idAI2::PlayAdditivePain(
                this: v6,
                inflictor: Inflictor,
                attacker: Attacker,
                damageDecl: v23,
                damage: recentUnscaledDamage,
                impactPoint: v27,
                impactDir: v24,
                joint: v22,
                a9: v21,
                a10: v36,
                a11: v37,
                a12: v38,
                a13: v39,
                a14: v40,
                a15: v41,
                a16: SHIDWORD(v42),
                a17: SLODWORD(v42),
                a18: SHIDWORD(recentBodyDamage),
                a19: SLODWORD(recentBodyDamage),
                a20: v44,
                a21: v45,
                a22: v46,
                a23: v47,
                a24: v48,
                a25: v49,
                a26: v50,
                a27: v51);
            }
          }
        }
        goto LABEL_50;
      }
      if ( v6->aiVolatile.death.deathInfo.startDeathTime < 0 )
        idLib::Warning(fmt: "Failed to call StartDeath() - no death impulse");
    }
    idAI2::StartDeathSystem(this: v6);
LABEL_50:
    idAIDamageInfo::EndFrame(this: &v6->aiVolatile.pain.damageInfo);
    if ( ai_debugLevel.valueInteger > 0 && ai_debugHealth.valueInteger >= 2 )
    {
      Physics = idEntity::GetPhysics(this: v6);
      v29 = common->RW(this: common);
      recentBodyDamage = v6->aiVolatile.pain.damageInfo.recentBodyDamage;
      LODWORD(v30) = LODWORD(recentBodyDamage);
      v42 = v6->aiVolatile.pain.damageInfo.recentUnscaledDamage;
      *(double *)((char *)&v30 + 4) = v42;
      v33 = va::va(
              this: &v52,
              fmt: (const char *)HIDWORD(v42),
              a3: v30,
              a4: v32,
              a5: v31,
              a6: v36,
              a7: v37,
              a8: v38,
              a9: v39,
              a10: v40,
              a11: v41);
      v34 = v29->__vftable;
      v35 = (int)Physics->GetOrigin(this: Physics, a2: 0);
      ((void (__fastcall *)(idRenderWorld *, va *, int, void (__fastcall *)(idRenderWorld *, const char *, const idVec3 *, float, const idVec4 *, const int, const int, const bool, const bool), idColor *, int, _DWORD, _DWORD, double))v34->DebugText)(
        a1: v29,
        a2: v33,
        a3: v35,
        a4: v34->DebugText,
        a5: &idColor::colorOrange,
        a6: 1,
        a7: 0,
        a8: 0,
        a9: 0.2);
    }
    goto LABEL_53;
  }
}


// ========================================================================
// ?ForceTakeCoverFromNearestPlayer@idAI2@@QAAXPBVidEntity@@0@Z
// EA  : 0x82A23B10
// RVA : 0x00A23B10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::ForceTakeCoverFromNearestPlayer(idAI2 *this, idEntity *coverReference, idEntity *coverTarget)
{
  idPlayer *PlayerTarget; // r3

  PlayerTarget = idAI2::GetPlayerTarget(this, player: AIPLAYER_CLOSEST);
  if ( PlayerTarget != nullptr || (PlayerTarget = idAI2::GetPlayerTarget(this, player: AIPLAYER_CLOSEST)) != nullptr )
    idAI2::ForceTakeCoverFromEntity(this, enemy: PlayerTarget, coverReference, coverTarget);
  else
    idLib::Warning(fmt: "idAI2::TakeCoverFromNearestPlayer - no players found.");
}


// ========================================================================
// ?DoSpawnSettings@idAI2@@AAAXXZ
// EA  : 0x82A23B88
// RVA : 0x00A23B88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DoSpawnSettings(idAI2 *this)
{
  aiStateOverride_t initialState; // r27
  idEncounterGroup *v3; // r28
  idEncounterGroup *v4; // r3
  char v5; // r22
  int GameMs; // r3
  const idEntity *Target; // r3
  alertCycle_t v8; // r5
  idEntity *v9; // r3
  idEntity *v10; // r3
  idEntity *v11; // r29
  idEntity *v12; // r3
  int v13; // r24
  int v14; // r25
  idDamageGroup *DamageGroup; // r3
  idDamageGroup *v16; // r28
  int num; // r11
  int v18; // r26
  int v19; // r27
  const char *data; // r29
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  int MeshIndex; // r29
  char v23; // r11
  const idDeclAIBehavior *decl; // r11
  int v25; // r10
  idScenePoint *overrideScenePoint; // r11
  scenePointType_t type; // r11
  const idTypeInfo *v28; // r5
  const idTypeInfo *v29; // r4
  idPlayer *PlayerTarget; // r3
  idStr *FileName; // r3
  idPlayer *Player; // r3
  idDeclAnimWeb v33; // [sp+50h] [-140h] BYREF

  initialState = this->aiEditable.spawnSettings.initialState;
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value == 0xFFFF )
  {
    v3 = nullptr;
  }
  else
  {
    v4 = idEncounterGroupManager::GroupForHandle(
           this: &gameLocal->encounterGroupManager,
           handle: &this->aiVolatile.encounterGroupHandle);
    v3 = v4;
    if ( v4 != nullptr )
    {
      if ( this->aiEditable.spawnSettings.onlyIfGroupAlerted
        && idEncounterGroup::AnyMemberHighestAlertCycle(this: v4) != ALERTCYCLE_COMBAT )
      {
        initialState = initialState != AIOVERRIDE_DEFAULT ? AIOVERRIDE_DEFAULT : initialState;
      }
      if ( idEncounterGroup::GetShouldAmbush(this: v3) )
        idEncounterGroup::SetShouldAmbush(this: v3, val: false);
    }
  }
  if ( this->aiEditable.spawnSettings.actionScript.num > 0 )
  {
    if ( idComponentActionScript::NumScriptActions(this: &this->actionScript, entity: this) <= 0 )
      idAI2::SetActionScript(
        this,
        script: &this->aiEditable.spawnSettings.actionScript,
        scriptExecutor: this,
        activator: this);
    else
      idLib::Warning(
        fmt: "ai %s has spawnsettings.actionScript and the actionScript component scripts. spawnsettings.actionScript will not be executed.",
        this->name.data);
  }
  v5 = 1;
  if ( idComponentActionScript::NumScriptActions(this: &this->actionScript, entity: this) > 0 )
  {
    if ( initialState != AIOVERRIDE_DEFAULT )
      idLib::Warning(
        fmt: "ai %s has actionscript but spawn setting is not AIOVERRIDE_DEFAULT.  Spawn setting will have no effect.",
        this->name.data);
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idAI2::StartActionScript(this, curTime: GameMs);
    goto LABEL_41;
  }
  if ( (unsigned int)initialState > AIOVERRIDE_PLAY_ENTRANCE_ANIMATION )
    goto LABEL_41;
  switch ( initialState )
  {
    case AIOVERRIDE_DEFAULT:
      if ( v3 == nullptr )
        break;
      if ( idEncounterGroup::AnyMemberHighestAlertCycle(this: v3) == ALERTCYCLE_COMBAT )
      {
        if ( idEncounterGroup::GetNumTargets(this: v3) <= 0 )
          break;
        Target = idEncounterGroup::GetTarget(this: v3, index: 0);
        v8 = ALERTCYCLE_COMBAT;
      }
      else
      {
        if ( idEncounterGroup::AnyMemberHighestAlertCycle(this: v3) != ALERTCYCLE_SEARCH
          || idEncounterGroup::GetNumTargets(this: v3) <= 0 )
        {
          break;
        }
        Target = idEncounterGroup::GetTarget(this: v3, index: 0);
        v8 = ALERTCYCLE_SEARCH;
      }
LABEL_40:
      idAI2::GiveAwarenessOfEntity(this, ent: Target, alertCycle: v8);
      break;
    case AIOVERRIDE_FORCE_AWARENESS_OF_PLAYER:
      idAI2::ForceAwarenessOfNearestPlayer(this);
      break;
    case AIOVERRIDE_FORCE_AWARENESS_OF_ENTITY:
      Target = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.spawnSettings.initialTarget);
      v8 = ALERTCYCLE_COMBAT;
      goto LABEL_40;
    case AIOVERRIDE_FORCE_SEARCH_TO_PLAYER:
      idAI2::ForceSearchToNearestPlayer(this);
      break;
    case AIOVERRIDE_FORCE_SEARCH_TO_ENTITY:
      v9 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.spawnSettings.initialTarget);
      idAI2::ForceSearchToEntity(this, ent: v9);
      break;
    case AIOVERRIDE_COVER_FROM_PLAYER:
      v10 = idEntity::GetTarget(this, i: 0);
      idAI2::ForceTakeCoverFromNearestPlayer(this, coverReference: v10, coverTarget: nullptr);
      break;
    case AIOVERRIDE_COVER_FROM_PLAYER_TARGET:
      v11 = idEntity::GetTarget(this, i: 0);
      v12 = idEntityPtr<idEntity const>::operator->(this: &this->aiEditable.spawnSettings.initialTarget);
      idAI2::ForceTakeCoverFromNearestPlayer(this, coverReference: v11, coverTarget: v12);
      break;
    case AIOVERRIDE_CHARGE_MELEE_PLAYER:
LABEL_92:
      break;
    default:
      idAI2::ForceEntranceAnimationToCombat(this);
      v5 = 0;
      goto LABEL_92;
  }
LABEL_41:
  idAIMemory::FirstThink(this: &this->aiVolatile.memory, bdef: this->aiEditable.behaviors.decl);
  idAI2::PlayAmbientSound(this, snd: this->aiEditable.sounds.sndAmbient);
  v13 = 0;
  if ( this->aiEditable.spawnSettings.missingArmor.num > 0 )
  {
    v14 = 0;
    do
    {
      DamageGroup = idActor::GetDamageGroup(this, name: this->aiEditable.spawnSettings.missingArmor.list[v14].data);
      v16 = DamageGroup;
      if ( DamageGroup != nullptr )
      {
        num = DamageGroup->hideMeshes.num;
        DamageGroup->locationArmor = 0.0;
        v18 = 0;
        if ( num > 0 )
        {
          v19 = 0;
          do
          {
            data = v16->hideMeshes.list[v19].data;
            TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
            MeshIndex = idTreeAnimator::GetMeshIndex(this: TreeAnimatorFromPresentable, meshName: data);
            if ( MeshIndex >= 0 )
              idAnimatedEntity::GetTreeAnimatorFromPresentable(this)->meshVisibility.list[MeshIndex] = false;
            ++v18;
            ++v19;
          }
          while ( v18 < v16->hideMeshes.num );
        }
      }
      else
      {
        idLib::Warning(
          fmt: "%s has no damage group named %s to hide armor",
          this->name.data,
          this->aiEditable.spawnSettings.missingArmor.list[v14].data);
      }
      ++v13;
      ++v14;
    }
    while ( v13 < this->aiEditable.spawnSettings.missingArmor.num );
  }
  if ( this->aiEditable.spawnSettings.entranceAnimPath.len != 0 )
  {
    if ( this->aiEditable.usesScenePoints )
    {
      v23 = 1;
    }
    else
    {
      decl = this->aiEditable.behaviors.decl;
      if ( decl == nullptr || (v25 = *((_BYTE *)decl + 196) & 0x40, v23 = 1, v25 == 0) )
        v23 = 0;
    }
    if ( v23 == 0 )
    {
      idLib::Warning(fmt: "aiEditable->usesScenepoints needs to be true");
      v5 = 0;
    }
    if ( v5 != 0 )
    {
      vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v33.resourceListPtr);
      overrideScenePoint = this->aiVolatile.memory.overrideScenePoint;
      if ( overrideScenePoint != nullptr )
      {
        type = overrideScenePoint->type;
        if ( type == ROAM )
        {
          idFSMManager::idFSMStack::Add(
            this: (idFSMManager::idFSMStack *)&v33.resourceListPtr,
            fsmType: &idAlertCycleFSM::Type,
            stateType: &idAlertCycle_RoamScenePoint::Type);
          v28 = &idRoamScenePoint_SharedWaitForAnimation::Type;
          v29 = &idRoamScenePointFSM::Type;
        }
        else
        {
          if ( type != 4 )
            goto LABEL_66;
          idFSMManager::idFSMStack::Add(
            this: (idFSMManager::idFSMStack *)&v33.resourceListPtr,
            fsmType: &idAlertCycleFSM::Type,
            stateType: &idAlertCycle_CombatScenePoint::Type);
          v28 = &idCombatScenePoint_SharedWaitForAnimation::Type;
          v29 = &idCombatScenePointFSM::Type;
        }
        idFSMManager::idFSMStack::Add(
          this: (idFSMManager::idFSMStack *)&v33.resourceListPtr,
          fsmType: v29,
          stateType: v28);
        idFSMManager::SetFSMStack(
          this: &this->aiVolatile.fsms.fsmManager,
          stack: (const idFSMManager::idFSMStack *)&v33.resourceListPtr);
      }
LABEL_66:
      PlayerTarget = idAI2::GetPlayerTarget(this, player: AIPLAYER_CLOSEST);
      if ( PlayerTarget != nullptr || (PlayerTarget = idAI2::GetPlayerTarget(this, player: AIPLAYER_CLOSEST)) != nullptr )
        idAI2::GiveAwarenessOfEntity(this, ent: PlayerTarget, alertCycle: ALERTCYCLE_COMBAT);
      else
        idLib::Warning(fmt: "idAI2::ForceAwarenessOfNearestPlayer - no players found.");
      if ( v33.resourceError == nullptr )
      {
        idFSMManager::idFSMStack::Add(
          this: (idFSMManager::idFSMStack *)&v33.resourceListPtr,
          fsmType: &idAlertCycleFSM::Type,
          stateType: &idAlertCycle_CombatScenePoint::Type);
        idFSMManager::idFSMStack::Add(
          this: (idFSMManager::idFSMStack *)&v33.resourceListPtr,
          fsmType: &idCombatScenePointFSM::Type,
          stateType: &idCombatScenePoint_SharedWaitForAnimation::Type);
        idFSMManager::SetFSMStack(
          this: &this->aiVolatile.fsms.fsmManager,
          stack: (const idFSMManager::idFSMStack *)&v33.resourceListPtr);
      }
      idStr::idStr(this: (idStr *)&v33.edgeCache.size, text: &this->aiEditable.spawnSettings.entranceAnimPath);
      *(_DWORD *)&v33.programaticallyDefined = 0;
      v33.nodes.list = (idDeclAnimWebNode **)20;
      v33.declSource = (idDeclSource *)&v33.nodes.num;
      HIBYTE(v33.nodes.num) = 0;
      v33.states.list = (idDeclAnimWeb::idStateInfo *)20;
      *(_DWORD *)&v33.subWebs.granularity = &v33.states.num;
      v33.subWebs.size = 0;
      HIBYTE(v33.states.num) = 0;
      idAI2::GetSubWebAndStateFromAnimWebPath(
        this,
        animWebPath: *(const char **)&v33.edgeCache.granularity,
        subWebName: (idStr *)&v33.programaticallyDefined,
        stateName: (idStr *)&v33.subWebs.size);
      blendParms_t::blendParms_t(this: (blendParms_t *)&v33.models.size);
      blendParms_t::SetDurationMS(this: (blendParms_t *)&v33.models.size, ms: 0);
      if ( idAnimator_AnimWeb::ForceState(
             this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
             subWebName: (const char *)v33.declSource,
             stateName: *(const char **)&v33.subWebs.granularity,
             blendParms: (const blendParms_t *)&v33.models.size,
             blendEventMask_: 0) != 0 )
      {
        idDeclAnimWeb::GetSubWebIndexForName(
          this: &v33,
          result: (idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
          subWebName: (const char *)v33.declSource);
        idDeclAnimWeb::GetStateIndexForName(
          this: (idDeclAnimWeb *)((char *)&v33.__vftable + 2),
          result: (idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)this->aiVolatile.animation.animWebAnimator.ptr[0].decl,
          name: *(const char **)&v33.subWebs.granularity);
        LOWORD(v33.trackedMemory) = (_WORD)this - 32576;
        HIWORD(v33.trackedMemory) = HIWORD(v33.__vftable);
        idAnimator_AnimWeb::SetEvent(
          this: (idAnimator_AnimWeb *)&this->aiVolatile.animation,
          eventType: ANIMWEB_EVENT_START_BLEND_OUT,
          subWebIndex: (const idIndex<short,enum idDeclAnimWeb::invalidSubWebIndex_t> *)HIWORD(v33.__vftable),
          stateIndex: (const idIndex<short,enum idDeclAnimWeb::invalidStateIndex_t> *)LOWORD(v33.__vftable),
          eventDef: &EV_AnimWeb_Wait,
          priority: PRIORITY_LOW);
      }
      else
      {
        FileName = idStr::GetFileName(this: (idStr *)&v33.scalars.size, result: (idStr *)&v33.edgeCache.size);
        idLib::Warning(fmt: "Animation %s not found inside web %s", FileName->data, "<unknown>");
        idStr::FreeData(this: (idStr *)&v33.scalars.size);
      }
      idStr::FreeData(this: (idStr *)&v33.subWebs.size);
      idStr::FreeData(this: (idStr *)&v33.programaticallyDefined);
      idStr::FreeData(this: (idStr *)&v33.edgeCache.size);
      if ( LOBYTE(v33.md5Checksum) == 0 || LOBYTE(v33.md5Checksum) == 2 )
      {
        if ( *((_DWORD *)&v33.idResource + 8) != 0 )
          idMem::Free(this: &mem, ptr: *((void **)&v33.idResource + 8), align: ALIGN_16);
        *((_DWORD *)&v33.idResource + 8) = 0;
        v33.textLength = 0;
      }
      v33.textSource = nullptr;
      if ( LOBYTE(v33.staleCount) == 0 || LOBYTE(v33.staleCount) == 2 )
      {
        if ( v33.resourceListPtr != nullptr )
          idMem::Free(this: &mem, ptr: v33.resourceListPtr, align: ALIGN_16);
        v33.resourceListPtr = nullptr;
        v33.networkID = 0;
      }
      v33.resourceError = nullptr;
    }
  }
  if ( this->aiEditable.actionSettings.squad.playerIsLeader )
  {
    Player = idGameLocal::GetPlayer(this: gameLocal, i: 0);
    if ( Player != nullptr )
      this->aiEditable.actionSettings.squad.squadLeader.spawnId.value = (gameLocal->spawnIds.ptr[Player->entityNumber] << 13)
                                                                      | Player->entityNumber;
    else
      this->aiEditable.actionSettings.squad.squadLeader.spawnId.value = 0x1FFF;
  }
}


// ========================================================================
// __unwind$576604
// EA  : 0x82A24288
// RVA : 0x00A24288
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576604()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 400 + 96));
}


// ========================================================================
// __unwind$576605
// EA  : 0x82A242B0
// RVA : 0x00A242B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576605()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 400 + 224));
}


// ========================================================================
// __unwind$576606
// EA  : 0x82A242D8
// RVA : 0x00A242D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576606()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 400 + 128));
}


// ========================================================================
// __unwind$576607
// EA  : 0x82A24300
// RVA : 0x00A24300
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576607()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 400 + 160));
}


// ========================================================================
// __unwind$576608
// EA  : 0x82A24328
// RVA : 0x00A24328
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576608()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 400 + 256));
}


// ========================================================================
// __unwind$576925
// EA  : 0x82A24350
// RVA : 0x00A24350
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_576925()
{
  int v0; // r12

  idList<idDeclSecretType const *,5>::~idList<idDeclSecretType const *,5>(this: (idStaticList<idVehicleState *,4> *)(v0 - 400 + 96));
}


// ========================================================================
// ?DropComplete@idAI2@@QAAXXZ
// EA  : 0x82A24378
// RVA : 0x00A24378
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::DropComplete(idAI2 *this)
{
  idPhysics *Physics; // r3

  idAI2::DoSpawnSettings(this);
  Physics = idEntity::GetPhysics(this);
  this->spawnPosition = *Physics->GetOrigin(this: Physics, a2: 0);
  this->aiVolatile.dropState = 3;
}


// ========================================================================
// ??0idAIVolatile@idAI2@@QAA@XZ
// EA  : 0x82A247D8
// RVA : 0x00A247D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2::idAIVolatile *__fastcall idAI2::idAIVolatile::idAIVolatile(idAI2::idAIVolatile *this)
{
  _DWORD *v2; // r9
  int v3; // ctr

  idAI2::idAIVolatile::idAIPhysics::idAIPhysics(this: &this->physics);
  this->eyeTracking.eyeInfoHandle.value = -1;
  idAI2::idAIVolatile::idAIFocusInfo::idAIFocusInfo(this: &this->focus);
  this->facialInfo.currentFacialAnimSet = nullptr;
  idAIWorldState::idAIWorldState(this: &this->world.worldState);
  this->world.fakeEnemy.spawnId.value = 0x1FFF;
  idGoreComponent::idGoreComponent(this: &this->death.goreComponent);
  idAIDeathInfo::idAIDeathInfo(this: &this->death.deathInfo);
  idAIDamageInfo::idAIDamageInfo(this: &this->pain.damageInfo);
  idAI2::idAIVolatile::idAIFSMInfo::idAIFSMInfo(this: &this->fsms);
  this->aiEvents.pendingAIEvents.num = 0;
  this->aiEvents.pendingAIEvents.granularity = 1;
  this->aiEvents.pendingAIEvents.listStatic = 1;
  this->aiEvents.pendingAIEvents.size = 4;
  this->aiEvents.pendingAIEvents.list = this->aiEvents.pendingAIEvents.staticList;
  this->aiEvents.pendingAIEvents.memTag = 5;
  this->aiEvents.pendingAIEvents.staticList[0].value = -1;
  this->aiEvents.pendingAIEvents.staticList[1].value = -1;
  this->aiEvents.pendingAIEvents.staticList[2].value = -1;
  this->aiEvents.pendingAIEvents.staticList[3].value = -1;
  idAI2::idAIVolatile::idAIAnimationInfo::idAIAnimationInfo(this: &this->animation);
  idAI2::idAIVolatile::idPlayerAIControl::idPlayerAIControl(this: &this->playerControl);
  this->script.threads.size = 4;
  this->script.threads.num = 0;
  this->script.threads.granularity = 1;
  this->script.threads.list = this->script.threads.staticList;
  this->script.threads.memTag = 5;
  this->script.threads.listStatic = 1;
  this->script.threads.staticList[0].value = 0;
  this->script.threads.staticList[1].value = 0;
  this->script.threads.staticList[2].value = 0;
  this->script.threads.staticList[3].value = 0;
  this->script.fibers.list = this->script.fibers.staticList;
  this->script.fibers.size = 4;
  this->script.fibers.num = 0;
  this->script.fibers.granularity = 1;
  this->script.fibers.memTag = 5;
  this->script.fibers.listStatic = 1;
  this->script.fibers.staticList[0].value = 0;
  this->script.fibers.staticList[1].value = 0;
  this->script.fibers.staticList[2].value = 0;
  this->script.fibers.staticList[3].value = 0;
  this->script.lastAIEventOriginator.spawnId.value = 0x1FFF;
  this->script.lastAIEventInstigator.spawnId.value = 0x1FFF;
  this->debugging.debugText.allocedAndFlag = 20;
  this->debugging.debugText.data = this->debugging.debugText.baseBuffer;
  this->debugging.debugText.len = 0;
  this->debugging.debugText.baseBuffer[0] = 0;
  this->groupStatus.currentRole = ROLE_NONE;
  this->groupStatus.pendingRole = ROLE_NONE;
  this->groupStatus.condition = CONDITION_NONE;
  this->groupStatus.roleChangeResponseRequired = false;
  this->groupStatus.voChainAudible = false;
  this->groupStatus.voChainCategory = VOCHAIN_NONE;
  this->groupStatus.voChainState = VOCHAIN_NONE;
  this->groupStatus.preventativeCondition = CONDITION_NONE;
  `eh vector constructor iterator'(
    ptr: &this->trajectories,
    size: 0x17Cu,
    count: 4,
    pCtor: (void (__fastcall *)(void *))idTrajectory_Parabolic::idTrajectory_Parabolic,
    pDtor: (void (__fastcall *)(void *))idTrajectory_Parabolic::~idTrajectory_Parabolic);
  idAIMemory::idAIMemory(this: &this->memory);
  idAIVoiceController::idAIVoiceController(this: &this->voiceController, controllerType_: VC_SELF);
  this->encounterGroupHandle.value = -1;
  idAICoverManager::idAICoverManager(this: &this->coverManager);
  idFaceMgr::idFaceMgr(this: &this->faceMgr);
  idAIPlayerInteraction::idAIPlayerInteraction(this: &this->aiPlayerInteraction);
  v2 = (_DWORD *)&this->visibilityObscurity.clipQuery[6].index + 1;
  this->tempPlayerInteractionInfoState = PISTATE_INACTIVE;
  this->visibilityObscurity.clipQuery[0].index = 0xFFFFFFFF00000000uLL;
  this->visibilityObscurity.clipQuery[1].index = 0xFFFFFFFF00000000uLL;
  v3 = 7;
  this->visibilityObscurity.clipQuery[2].index = 0xFFFFFFFF00000000uLL;
  this->visibilityObscurity.clipQuery[3].index = 0xFFFFFFFF00000000uLL;
  this->visibilityObscurity.clipQuery[4].index = 0xFFFFFFFF00000000uLL;
  this->visibilityObscurity.clipQuery[5].index = 0xFFFFFFFF00000000uLL;
  this->visibilityObscurity.clipQuery[6].index = 0xFFFFFFFF00000000uLL;
  this->visibilityObscurity.lastSubmitFrame = -1;
  this->visibilityObscurity.anyCover = false;
  this->visibilityObscurity.anyClearLanes = false;
  this->visibilityObscurity.valid = false;
  do
  {
    *++v2 = 0;
    --v3;
  }
  while ( v3 != 0 );
  idMeleeTrace::idMeleeTrace(this: &this->meleeTrace);
  this->dropToGroundQuery.index = 0xFFFFFFFF00000000uLL;
  return this;
}


// ========================================================================
// __unwind$577425
// EA  : 0x82A24A78
// RVA : 0x00A24A78
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577425()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIPhysics::~idAIPhysics(this: *(idAI2::idAIVolatile::idAIPhysics **)(v0 - 160 + 180));
}


// ========================================================================
// __unwind$577426
// EA  : 0x82A24AA0
// RVA : 0x00A24AA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577426()
{
  int v0; // r12

  idArray<idFocusInfo,2>::~idArray<idFocusInfo,2>(this: (idAI2::idAIVolatile::idAIFocusInfo *)(*(_DWORD *)(v0 - 160 + 180)
                                                                                             + 1820));
}


// ========================================================================
// __unwind$577427
// EA  : 0x82A24ACC
// RVA : 0x00A24ACC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577427()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIWorldStateInfo::~idAIWorldStateInfo(this: (idAI2::idAIVolatile::idAIWorldStateInfo *)(*(_DWORD *)(v0 - 160 + 180) + 2544));
}


// ========================================================================
// __unwind$577428
// EA  : 0x82A24AF8
// RVA : 0x00A24AF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577428()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIDeath::~idAIDeath(this: (idAI2::idAIVolatile::idAIDeath *)(*(_DWORD *)(v0 - 160 + 180) + 7704));
}


// ========================================================================
// __unwind$577429
// EA  : 0x82A24B24
// RVA : 0x00A24B24
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577429()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIPain::~idAIPain(this: (idAI2::idAIVolatile::idAIPain *)(*(_DWORD *)(v0 - 160 + 180) + 9472));
}


// ========================================================================
// __unwind$577430
// EA  : 0x82A24B50
// RVA : 0x00A24B50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577430()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIFSMInfo::~idAIFSMInfo(this: (idAI2::idAIVolatile::idAIFSMInfo *)(*(_DWORD *)(v0 - 160 + 180)
                                                                                          + 9908));
}


// ========================================================================
// __unwind$577431
// EA  : 0x82A24B7C
// RVA : 0x00A24B7C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577431()
{
  int v0; // r12

  idFireParms::~idFireParms(this: (idAI2::idAIVolatile::idAIEventInfo *)(*(_DWORD *)(v0 - 160 + 180) + 21388));
}


// ========================================================================
// __unwind$577432
// EA  : 0x82A24BA8
// RVA : 0x00A24BA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577432()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIAnimationInfo::~idAIAnimationInfo(this: (idAI2::idAIVolatile::idAIAnimationInfo *)(*(_DWORD *)(v0 - 160 + 180) + 21440));
}


// ========================================================================
// __unwind$577433
// EA  : 0x82A24BD4
// RVA : 0x00A24BD4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577433()
{
  int v0; // r12

  idAI2::idAIVolatile::idPlayerAIControl::~idPlayerAIControl(this: (idAI2::idAIVolatile::idPlayerAIControl *)(*(_DWORD *)(v0 - 160 + 180) + 44544));
}


// ========================================================================
// __unwind$577434
// EA  : 0x82A24C08
// RVA : 0x00A24C08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577434()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIScriptInfo::~idAIScriptInfo(this: (idAI2::idAIVolatile::idAIScriptInfo *)(*(_DWORD *)(v0 - 160 + 180) + 44728));
}


// ========================================================================
// __unwind$577435
// EA  : 0x82A24C3C
// RVA : 0x00A24C3C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577435()
{
  int v0; // r12

  idAI2::idAIVolatile::idAIDebugging::~idAIDebugging(this: (idAI2::idAIVolatile::idAIDebugging *)(*(_DWORD *)(v0 - 160 + 180)
                                                                                                + 44828));
}


// ========================================================================
// __unwind$577436
// EA  : 0x82A24C70
// RVA : 0x00A24C70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577436()
{
  int v0; // r12

  idArray<idTrajectory_Parabolic,4>::~idArray<idTrajectory_Parabolic,4>(this: (idArray<idTrajectory_Parabolic,4> *)(*(_DWORD *)(v0 - 160 + 180) + 44956));
}


// ========================================================================
// __unwind$577437
// EA  : 0x82A24CA4
// RVA : 0x00A24CA4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577437()
{
  int v0; // r12

  idAIMemory::~idAIMemory(this: (idAIMemory *)(*(_DWORD *)(v0 - 160 + 180) + 46476));
}


// ========================================================================
// __unwind$577438
// EA  : 0x82A24CD8
// RVA : 0x00A24CD8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577438()
{
  int v0; // r12

  idPhysics_StaticMulti::UpdateTime(this: (bfx::BinaryReplayLogOut *)(*(_DWORD *)(v0 - 160 + 180) + 47648));
}


// ========================================================================
// __unwind$577439
// EA  : 0x82A24D0C
// RVA : 0x00A24D0C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577439()
{
  int v0; // r12

  idList<idAICover,5>::Clear(this: (idAICoverManager *)(*(_DWORD *)(v0 - 160 + 180) + 47708));
}


// ========================================================================
// __unwind$577440
// EA  : 0x82A24D40
// RVA : 0x00A24D40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577440()
{
  int v0; // r12

  idFaceMgr::~idFaceMgr(this: (idFaceMgr *)(*(_DWORD *)(v0 - 160 + 180) + 47748));
}


// ========================================================================
// __unwind$577441
// EA  : 0x82A24D74
// RVA : 0x00A24D74
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_577441()
{
  int v0; // r12

  idAIEvent::~idAIEvent(this: (idAimAssist *)(*(_DWORD *)(v0 - 160 + 180) + 49688));
}


// ========================================================================
// ?FirstThink@idAI2@@AAAXXZ
// EA  : 0x82A24DA8
// RVA : 0x00A24DA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::FirstThink(idAI2 *this)
{
  idPhysics *Physics; // r3
  float *v3; // r3
  double v4; // fp12
  double v5; // fp11
  idPhysics *v6; // r3
  float *v7; // r3
  double v8; // fp8
  double v9; // fp7
  idPhysics *v10; // r3
  int entityNumber; // r30
  idClipModel *v12; // r3
  idPhysics *v13; // r3
  posture_t v14; // r30
  int v15; // r26
  int v16; // r27
  int value; // r9
  idEntity *v18; // r3
  idInfoPath *v19; // r30
  idInfoPath *v20; // r4
  idScenePoint *v21; // r4
  idVolume_Restriction *v22; // r3
  idFiniteStateMachine *v23; // r30
  int GameMs; // r3
  idScriptObject *v25; // r3
  idScriptObject *v26; // r29
  idThread **p_thread; // r30
  const function_t *Function; // r5
  int v29; // [sp+8h] [-168h]
  bool v30; // [sp+Fh] [-161h]
  const char *v31; // [sp+10h] [-160h]
  int v32; // [sp+14h] [-15Ch]
  int v33; // [sp+18h] [-158h]
  int v34; // [sp+1Ch] [-154h]
  int v35; // [sp+20h] [-150h]
  int v36; // [sp+24h] [-14Ch]
  int v37; // [sp+28h] [-148h]
  int v38; // [sp+2Ch] [-144h]
  int v39; // [sp+30h] [-140h]
  int v40; // [sp+34h] [-13Ch]
  int v41; // [sp+38h] [-138h]
  int v42; // [sp+3Ch] [-134h]
  int v43; // [sp+40h] [-130h]
  int v44; // [sp+44h] [-12Ch]
  int v45; // [sp+48h] [-128h]
  int v46; // [sp+4Ch] [-124h]
  int v47; // [sp+50h] [-120h]
  int v48; // [sp+58h] [-118h]
  int v49; // [sp+60h] [-110h]
  idVec3 v50; // [sp+70h] [-100h] BYREF
  idVec3 v51; // [sp+80h] [-F0h] BYREF
  char v52; // [sp+90h] [-E0h] BYREF
  trace_t v53; // [sp+A0h] [-D0h] BYREF

  *((_BYTE *)&this->aiVolatile + 49704) &= ~0x80u;
  if ( (unsigned __int8)idLobbyBackend360::StartArbitration(pexcept: (_exception *)this) != 0 )
    this->aiVolatile.animation.animFSM.EnterHiddenMode(this: &this->aiVolatile.animation.animFSM, a2: false);
  if ( this->aiEditable.spawnSettings.initialState == AIOVERRIDE_PLAY_ENTRANCE_ANIMATION )
  {
    idAI2::SetWorldCollision(this, collideWithWorld: false);
    idPhysics_StaticMulti::UpdateTime(this: (bfx::BinaryReplayLogOut *)&this->aiVolatile.physics.moveState);
  }
  else if ( this->aiConstants.movement.defaultMovementMode != AIMOVEMODE_STATIC )
  {
    Physics = idEntity::GetPhysics(this);
    v3 = (float *)Physics->GetOrigin(this: Physics, a2: 0);
    v4 = v3[1];
    v5 = (float)(v3[2] + (float)0.25);
    v51.x = *v3;
    v51.y = v4;
    v51.z = v5;
    v6 = idEntity::GetPhysics(this);
    v7 = (float *)v6->GetOrigin(this: v6, a2: 0);
    v8 = v7[1];
    v9 = (float)(v7[2] - (float)64.0);
    v50.x = *v7;
    v50.y = v8;
    v50.z = v9;
    v10 = idEntity::GetPhysics(this);
    entityNumber = this->entityNumber;
    v12 = v10->GetClipModel(this: v10, a2: 0);
    idClip::Translation(
      this: (idClip *)&v52,
      result: &clientGame->clip,
      a3: &v53,
      start: &v51,
      end: &v50,
      clipModel: v12,
      startAxis: &mat3_identity,
      clipMask: 106513,
      passEntityNumber: v29,
      moveClipModel: v30,
      userName: v31,
      a12: v32,
      a13: v33,
      a14: v34,
      a15: v35,
      a16: v36,
      a17: v37,
      a18: v38,
      a19: v39,
      a20: v40,
      a21: v41,
      a22: v42,
      a23: v43,
      a24: v44,
      a25: v45,
      a26: v46,
      a27: v47,
      a28: entityNumber,
      a29: v48,
      a30: false,
      a31: v49,
      a32: 0);
    if ( v53.fraction != 1.0 )
    {
      v13 = idEntity::GetPhysics(this);
      v13->SetOrigin(this: v13, a2: &v53.endpos, a3: -1);
    }
  }
  this->aiVolatile.memory.enemyTrailUpdatePeriod = (int)(float)(this->aiEditable.actionSettings.enemyTrailUpdatePeriod
                                                              * (float)1000.0);
  idAI2::InitEncounterGroup(this);
  v14 = this->GetPosture(this);
  this->SetPosture(this, a2: POSTURE_NONE);
  this->SetPosture(this, a2: v14);
  v15 = 0;
  if ( this->targets.num > 0 )
  {
    v16 = 0;
    do
    {
      if ( v15 < this->targets.num
        && (value = this->targets.list[v16].spawnId.value, gameLocal->spawnIds.ptr[value & 0x1FFF] == value >> 13)
        && (v18 = gameLocal->entities.ptr[value & 0x1FFF]) != nullptr )
      {
        v19 = (idInfoPath *)idEntity::CastTo(c: v18);
      }
      else
      {
        v19 = nullptr;
      }
      if ( v19 != nullptr )
      {
        v20 = idInfoPath::CastTo(c: v19);
        if ( v20 != nullptr )
        {
          idAIMemory::SetCurrentPath(this: &this->aiVolatile.memory, path: v20);
        }
        else if ( idScenePoint::CastTo(c: (idScenePoint *)v19) != nullptr )
        {
          if ( (unsigned __int8)idAI2::UsesScenePoints(this) != 0 )
            idAIMemory::SetOverrideScenePoint(this: &this->aiVolatile.memory, scenePoint: v21);
        }
        else
        {
          v22 = idVolume_Restriction::CastTo(c: (idVolume_Restriction *)v19);
          if ( v22 != nullptr )
            idAIMemory::SetRestrictionVolume(
              this: &this->aiVolatile.memory,
              volume: (idEntityPtr<idVolume_Restriction> *)((gameLocal->spawnIds.ptr[v22->entityNumber] << 13)
                                                  | v22->entityNumber));
          else
            idEntity::Activate(this: v19, activator: this);
        }
      }
      ++v15;
      ++v16;
    }
    while ( v15 < this->targets.num );
  }
  if ( this->aiVolatile.dropState == 1 )
  {
    idAIMoveState::SetMovementModeForReal(this: &this->aiVolatile.physics.moveState, mode: AIMOVEMODE_DROP);
  }
  else if ( !idAI2::IsExecutingScript(this) )
  {
    idAI2::DoSpawnSettings(this);
  }
  v23 = this->aiVolatile.fsms.fsmManager.FindFSM_4(this: &this->aiVolatile.fsms, a2: "FSM_alertCycle");
  if ( idFiniteStateMachine::GetStatus(this: v23) == FSMSTATUS_DONE )
  {
    GameMs = idGameTimeManager::GetGameMs(this: &clientGame->gameTimeManager, type: GAMETIME_SCALED);
    idFiniteStateMachine::Restart(this: v23, curTime: GameMs);
  }
  v25 = this->GetScriptObject_2(this);
  v26 = v25;
  p_thread = &this->aiVolatile.script.thread;
  if ( this->aiVolatile.script.thread != nullptr && idScriptObject::HasObject(this: v25) )
  {
    Function = idScriptObject::GetFunction(this: v26, name: "onSpawn");
    if ( Function != nullptr )
    {
      idThread::CallObjectFunction(this: *p_thread, self: this, func: Function, clearStack: true);
      this->ExecuteThread(this, a2: *p_thread);
    }
  }
}


// ========================================================================
// ??1idAI2@@UAA@XZ
// EA  : 0x82A25570
// RVA : 0x00A25570
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __fastcall idAI2::~idAI2(idAI2 *this)
{
  int v2; // r4
  idGameLocal *v3; // r10
  idList<idEntityPtr<idEntity>,58> *p_aiWorldStateUsers; // r3
  int num; // r8
  int v6; // r11
  int v7; // r4
  idList<idEntityPtr<idEntity>,58> *p_activeAI; // r3
  int v9; // r8
  int v10; // r11
  idGameLocal *v11; // r10
  int v12; // r4
  idList<idEntityPtr<idEntity>,58> *p_deadAI; // r3
  int v14; // r8
  int v15; // r11
  idEncounterGroup *v16; // r3
  idAI2::idAIVolatile::idAIFocusInfo *p_focus; // r28
  int i; // r29
  idTreeAnimator *TreeAnimatorFromPresentable; // r3
  idAIFireControl *fireControl; // r3
  idClipModel *extendedClipModel; // r4
  int v22; // r27
  idAI2::idAIVolatile::idAIDebugging *p_debugging; // r29
  idRenderModel *v24; // r3

  this->__vftable = (idAI2_vtbl *)&idAI2::`vftable';
  idPhysics_StaticMulti::UpdateTime((bfx::BinaryReplayLogOut *)this);
  idPhysics_StaticMulti::UpdateTime((bfx::BinaryReplayLogOut *)this);
  idAI2::SetDebugText(this, text: nullptr, debugLevel: AIDEBUGLEVEL_NONE);
  v2 = 0;
  v3 = gameLocal;
  p_aiWorldStateUsers = (idList<idEntityPtr<idEntity>,58> *)&gameLocal->aiWorldStateUsers;
  num = gameLocal->aiWorldStateUsers.num;
  if ( num > 0 )
  {
    v6 = 0;
    while ( p_aiWorldStateUsers->list[v6].spawnId.value != ((gameLocal->spawnIds.ptr[this->entityNumber] << 13)
                                                          | this->entityNumber) )
    {
      ++v2;
      ++v6;
      if ( v2 >= num )
        goto LABEL_8;
    }
    if ( v2 >= 0 )
    {
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(this: p_aiWorldStateUsers, index: v2);
      v3 = gameLocal;
    }
  }
LABEL_8:
  v7 = 0;
  p_activeAI = (idList<idEntityPtr<idEntity>,58> *)&v3->activeAI;
  v9 = v3->activeAI.num;
  if ( v9 > 0 )
  {
    v10 = 0;
    while ( p_activeAI->list[v10].spawnId.value != ((v3->spawnIds.ptr[this->entityNumber] << 13) | this->entityNumber) )
    {
      ++v7;
      ++v10;
      if ( v7 >= v9 )
        goto LABEL_15;
    }
    if ( v7 >= 0 )
    {
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(this: p_activeAI, index: v7);
      v3 = gameLocal;
    }
  }
LABEL_15:
  idGameLocal::RemoveDyingAI(this: v3, ai: this);
  v11 = gameLocal;
  v12 = 0;
  p_deadAI = (idList<idEntityPtr<idEntity>,58> *)&gameLocal->deadAI;
  v14 = gameLocal->deadAI.num;
  if ( v14 > 0 )
  {
    v15 = 0;
    while ( p_deadAI->list[v15].spawnId.value != ((gameLocal->spawnIds.ptr[this->entityNumber] << 13)
                                                | this->entityNumber) )
    {
      ++v12;
      ++v15;
      if ( v12 >= v14 )
        goto LABEL_22;
    }
    if ( v12 >= 0 )
    {
      idList<idHandle<int,enum invalidAIEvent_t,-1>,5>::RemoveIndex(this: p_deadAI, index: v12);
      v11 = gameLocal;
    }
  }
LABEL_22:
  if ( (unsigned __int16)this->aiVolatile.encounterGroupHandle.value != 0xFFFF )
  {
    v16 = idEncounterGroupManager::GroupForHandle(
            this: &v11->encounterGroupManager,
            handle: &this->aiVolatile.encounterGroupHandle);
    if ( v16 != nullptr )
      idEncounterGroup::Remove(this: v16, ai: this);
    v11 = gameLocal;
  }
  idAIEventManager::RemoveEntityEvents(this: &v11->aiEventManager, ent: this);
  p_focus = &this->aiVolatile.focus;
  for ( i = 2; i != 0; --i )
  {
    idFocusInfo::Shutdown(this: p_focus->foci.ptr, owner: this);
    p_focus = (idAI2::idAIVolatile::idAIFocusInfo *)((char *)p_focus + 272);
  }
  TreeAnimatorFromPresentable = idAnimatedEntity::GetTreeAnimatorFromPresentable(this);
  idFaceMgr::Shutdown(this: &this->aiVolatile.faceMgr, owner: this, ta: TreeAnimatorFromPresentable);
  fireControl = this->aiVolatile.fireControl;
  if ( fireControl != nullptr )
  {
    ((void (__fastcall *)(idAIFireControl *, int))fireControl->dtr_idClass)(a1: fireControl, a2: 1);
    this->aiVolatile.fireControl = nullptr;
  }
  extendedClipModel = this->aiVolatile.physics.extendedClipModel;
  if ( extendedClipModel != nullptr )
  {
    idClip::DeleteClipModel(this: &clientGame->clip, clipModel: extendedClipModel);
    this->aiVolatile.physics.extendedClipModel = nullptr;
  }
  v22 = 6;
  p_debugging = &this->aiVolatile.debugging;
  do
  {
    v24 = p_debugging->debugModels.ptr[0];
    if ( p_debugging->debugModels.ptr[0] != nullptr )
    {
      v24->unlinked = true;
      v24->deleteOnSync = true;
      idRenderModel::CommitThisFrame(this: v24);
      p_debugging->debugModels.ptr[0] = nullptr;
    }
    --v22;
    p_debugging = (idAI2::idAIVolatile::idAIDebugging *)((char *)p_debugging + 4);
  }
  while ( v22 != 0 );
  idDynamicCoverMgr::Shutdown(this: &this->formationCover);
  idGameLocal::BotSystems_UnRegisterEntity(this: gameLocal, entity: this);
  idState::~idState(this: &this->patch1.stateStuck);
  this->scriptProxy.__vftable = (idAIScriptProxy_vtbl *)&idAIScriptProxy::`vftable';
  idEventReceiver::~idEventReceiver(this: &this->scriptProxy);
  idDynamicCoverMgr::~idDynamicCoverMgr(this: &this->formationCover);
  this->fsmCallback.__vftable = (idAIFSMCallback_vtbl *)&idAIFSMCallback::`vftable';
  idFSMLog::~idFSMLog(this: &this->fsmCallback.log);
  this->fsmCallback.__vftable = (idAIFSMCallback_vtbl *)&idFSMCallback::`vftable';
  idComponentActionScript::~idComponentActionScript(this: &this->actionScript);
  this->aiHealth.__vftable = (idAIHealth_vtbl *)&idBaseHealth::`vftable';
  idAI2::idAIVolatile::~idAIVolatile(this: &this->aiVolatile);
  idAIEditable::~idAIEditable(this: &this->aiEditable);
  idStr::FreeData(this: &this->aiConstants.animation.eyeInfoName);
  `eh vector destructor iterator'(
    ptr: this->aiConstants.animation.animWebDefaults,
    size: 0x34u,
    count: 1,
    pDtor: (void (__fastcall *)(void *))idAI2::idAnimWebDefaults::~idAnimWebDefaults);
  idStr::FreeData(this: &this->aiConstants.movement.aasName);
  idActor::~idActor(this);
}


// ========================================================================
// __unwind$578494
// EA  : 0x82A2592C
// RVA : 0x00A2592C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578494()
{
  int v0; // r12

  idActor::~idActor(this: *(idActor **)(v0 - 160 + 180));
}


// ========================================================================
// __unwind$578495
// EA  : 0x82A25954
// RVA : 0x00A25954
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578495()
{
  int v0; // r12

  idAI2::idAIConstant::~idAIConstant(this: (idAI2::idAIConstant *)(*(_DWORD *)(v0 - 160 + 180) + 10328));
}


// ========================================================================
// __unwind$578496
// EA  : 0x82A25980
// RVA : 0x00A25980
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578496()
{
  int v0; // r12

  idAIEditable::~idAIEditable(this: (idAIEditable *)(*(_DWORD *)(v0 - 160 + 180) + 10560));
}


// ========================================================================
// __unwind$578497
// EA  : 0x82A259AC
// RVA : 0x00A259AC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578497()
{
  int v0; // r12

  idAI2::idAIVolatile::~idAIVolatile(this: (idAI2::idAIVolatile *)(*(_DWORD *)(v0 - 160 + 180) + 11520));
}


// ========================================================================
// __unwind$578498
// EA  : 0x82A259D8
// RVA : 0x00A259D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578498()
{
  int v0; // r12

  idSimpleHealth::~idSimpleHealth(this: (idAIHealth *)(*(_DWORD *)(v0 - 160 + 180) + 61488));
}


// ========================================================================
// __unwind$578499
// EA  : 0x82A25A0C
// RVA : 0x00A25A0C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578499()
{
  int v0; // r12

  idComponentActionScript::~idComponentActionScript(this: (idComponentActionScript *)(*(_DWORD *)(v0 - 160 + 180) + 61552));
}


// ========================================================================
// __unwind$578500
// EA  : 0x82A25A40
// RVA : 0x00A25A40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578500()
{
  int v0; // r12

  idAIFSMCallback::~idAIFSMCallback(this: (idAIFSMCallback *)(*(_DWORD *)(v0 - 160 + 180) + 61592));
}


// ========================================================================
// __unwind$578501
// EA  : 0x82A25A74
// RVA : 0x00A25A74
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578501()
{
  int v0; // r12

  idFormationCoverMgr::~idFormationCoverMgr(this: (idVehicleCoverMgr *)(*(_DWORD *)(v0 - 160 + 180) + 61624));
}


// ========================================================================
// __unwind$578502
// EA  : 0x82A25AA8
// RVA : 0x00A25AA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578502()
{
  int v0; // r12

  idAIScriptProxy::~idAIScriptProxy(this: (idAIScriptProxy *)(*(_DWORD *)(v0 - 160 + 180) + 61652));
}


// ========================================================================
// __unwind$578503
// EA  : 0x82A25ADC
// RVA : 0x00A25ADC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578503()
{
  int v0; // r12

  idAI2Patch1::~idAI2Patch1(this: (idAI2Patch1 *)(*(_DWORD *)(v0 - 160 + 180) + 61672));
}


// ========================================================================
// __unwind$578908
// EA  : 0x82A25B10
// RVA : 0x00A25B10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578908()
{
  int v0; // r12

  idFSMCallback::~idFSMCallback(this: *(idFSMCallback **)(v0 - 160 + 80));
}


// ========================================================================
// __unwind$578943
// EA  : 0x82A25B38
// RVA : 0x00A25B38
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578943()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(*(_DWORD *)(v0 - 160 + 80) + 32));
}


// ========================================================================
// __unwind$578946
// EA  : 0x82A25B64
// RVA : 0x00A25B64
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_578946()
{
  int v0; // r12

  `eh vector destructor iterator'(
    ptr: (void *)(*(_DWORD *)(v0 - 160 + 84) + 4),
    size: 0x34u,
    count: 1,
    pDtor: (void (__fastcall *)(void *))idAI2::idAnimWebDefaults::~idAnimWebDefaults);
}


// ========================================================================
// ?Think@idAI2@@UAAXXZ
// EA  : 0x82A25EF8
// RVA : 0x00A25EF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

// local variable allocation has failed, the output may be wrong!
void __fastcall idAI2::Think(idAI2 *this)
{
  idAI2 *v1; // r29
  unsigned __int64 v2; // r6
  idPLog *x_low; // r16
  const char *v4; // r7
  char v5; // r11
  float v6; // r14
  int v7; // r3
  idWeapon *v8; // r30
  idFXManager *v9; // r3
  int v10; // r3
  idPlayer *Player; // r27
  idEncounterGroup *v12; // r3
  const idEntity *v13; // r4
  idEventArg *v14; // r3
  __int16 *p_parmIndexA; // r10
  _DWORD *v16; // r11
  int i; // ctr
  idEntity *v18; // r3
  const trackingParms_t *v19; // r30
  idAIGameState *p_aiGameState; // r28
  const idAILogic *v21; // r3
  float v22; // r15
  float z; // r27
  unsigned __int64 v24; // r6
  const char *v25; // r7
  unsigned __int64 v26; // r6
  const char *v27; // r7
  idAnimator_AF *v28; // r30
  idPhysics *v29; // r28
  int v30; // r3
  char v31; // r11
  char v32; // r11
  unsigned __int64 v33; // r6
  const char *v34; // r7
  idPhysics *v35; // r3
  unsigned __int64 v36; // r6
  const char *v37; // r7
  unsigned __int64 v38; // r6
  const char *v39; // r7
  idPresentable *presentable; // r3
  idPresentableAnimatedEntity *v41; // r3
  unsigned __int64 v42; // r6
  const char *v43; // r7
  unsigned __int64 v44; // r6
  const char *v45; // r7
  unsigned __int64 v46; // r6
  const char *v47; // r7
  unsigned __int64 v48; // r6
  const char *v49; // r7
  idPresentable *v50; // r3
  idPresentableAI *v51; // r3
  unsigned __int64 v52; // r6
  const char *v53; // r7
  idAI2::aiCondition_t condition; // r5
  unsigned __int64 v55; // r6
  const char *v56; // r7
  idClip *p_clip; // r28
  idClipQuery *p_bleedOutHipQuery; // r23
  __int128 v59; // r11
  idAI2Patch1 *p_patch1; // r28
  idClip *v61; // r26
  __int128 v62; // r11
  idEntity *v63; // r25
  idEntity *v64; // r26
  idPhysics *Physics; // r3
  idAI2_vtbl *v66; // r28
  const idDeclAIBehavior *decl; // r24
  idRenderWorld *v68; // r3
  idRenderWorld *v69; // r3
  idIndex<short,enum invalidJointIndex_t> *TreeAnimatorFromPresentable; // r3
  idTreeAnimator *v71; // r3
  idPhysics *v72; // r28
  idPhysics *v73; // r26
  int entityNumber; // r25
  idMat3 *v75; // r24
  idClipModel *v76; // r3
  idRenderWorld *v77; // r3
  idIndex<short,enum invalidJointIndex_t> *v78; // r3
  idTreeAnimator *v79; // r3
  idPhysics *v80; // r26
  idPhysics *v81; // r25
  int v82; // r24
  idMat3 *v83; // r26
  idClipModel *v84; // r3
  idRenderWorld *v85; // r3
  signed int v86; // r30
  int v87; // r3
  double standingBleedRate; // fp31
  idEntity *LastInflictor; // r26
  idEntity *LastAttacker; // r30
  idPhysics *v91; // r3
  idAI2_vtbl *v92; // r28
  const idDeclAIBehavior *v93; // r25
  unsigned __int64 v94; // r6
  const char *v95; // r7
  int v96; // r30
  idPhysics *v97; // r3
  float y; // r24
  int v99; // r28
  idAnimator_AF *v100; // r3
  int thinkFlags; // r6
  float v102; // r14
  unsigned __int64 v103; // r6
  const char *v104; // r7
  idPhysics *v105; // r3
  int v106; // r3
  float v107; // r5
  float v108; // r4
  posture_t (__fastcall *GetPosture)(struct idAI2 *); // r11
  int v110; // r28
  idPhysics *v111; // r3
  float *v112; // r3
  float v113; // r6
  float v114; // r8
  double v115; // fp24
  double v116; // fp30
  double v117; // fp31
  idPhysics *v118; // r3
  float *v119; // r3
  double v120; // fp10
  double v121; // fp8
  int *v122; // r11
  int v123; // r7
  int v124; // r6
  int v125; // r5
  double v126; // fp9
  double v127; // fp6
  double v128; // fp5
  float x; // r11
  double v130; // fp12
  double v131; // fp10
  double v132; // fp9
  int v133; // r6
  int v134; // r5
  int v135; // r4
  __int64 v136; // r10
  __int64 v137; // r8
  __int64 v138; // r6
  double lastTurnRate; // fp0
  va *v140; // r3
  unsigned __int64 v141; // r6
  const char *v142; // r7
  idVolume_Restriction *v143; // r30
  int v144; // r7
  int v145; // r6
  int v146; // r5
  idPhysics *v147; // r3
  int v148; // r3
  float v149; // r8
  float v150; // r7
  float *v151; // r11
  double v152; // fp31
  float v153; // r9
  float v154; // r8
  idCommon_vtbl *v155; // r7
  idRenderWorld *v156; // r3
  idPlayer *v157; // r30
  const idEntity *Enemy; // r3
  idGameLocal *v159; // r3
  idPlayer *v160; // r3
  idAIEntityState *v161; // r3
  idAIEntityState *v162; // r15
  idTreeAnimator_vtbl *v163; // r15
  float v164; // r27
  float v165; // r29
  float v166; // r26
  float v167; // r20
  float v168; // r19
  float v169; // r18
  float v170; // r17
  float v171; // r16
  float v172; // r10
  float v173; // r9
  float v174; // r4
  float v175; // r3
  float v176; // r25
  float v177; // r24
  float v178; // r23
  float v179; // r22
  float v180; // r21
  float v181; // r8
  float v182; // r6
  idTreeAnimator_vtbl *p_senses; // r23
  idColor *v184; // r25
  int v185; // r20
  aiSenseState_t *v186; // r30
  int v187; // r24
  idBounds *v188; // r3
  int v189; // r11
  double v190; // fp10
  double v191; // fp9
  double v192; // fp7
  double v193; // fp6
  int v194; // r23
  const aiPhysicalState_t *ConfirmedPhysicalSafe; // r14
  const aiPhysicalState_t *v196; // r3
  idBounds *v197; // r3
  int v198; // r23
  const aiPhysicalState_t *v199; // r3
  const aiPhysicalState_t *v200; // r3
  double v201; // fp30
  double v202; // fp29
  double v203; // fp28
  const aiPhysicalState_t *v204; // r3
  int v205; // r11
  double v206; // fp10
  double v207; // fp9
  int v208; // r24
  const aiPhysicalState_t *v209; // r3
  const aiPhysicalState_t *v210; // r3
  __int64 v211; // r9
  double v212; // fp30
  double v213; // fp29
  double v214; // fp28
  idPhysics *v215; // r3
  float *v216; // r3
  int v217; // r11
  int v218; // r24
  double v219; // fp4
  double v220; // fp3
  int GameMs; // r23
  __int64 v222; // r11 OVERLAPPED
  __int128 v223; // r6
  __int64 v224; // r8 OVERLAPPED
  va *v225; // r3
  idPhysics *v226; // r3
  int *v227; // r3
  int v228; // r6
  float v229; // r5
  const idVec3 *(__fastcall *GetEyeOffset)(struct idAI2 *, const idVec3 *); // r11
  float *v231; // r3
  double fovScale; // fp30
  double v233; // fp29
  double v234; // fp28
  double v235; // fp22
  double v236; // fp21
  double v237; // fp20
  idPhysics *v238; // r3
  float *v239; // r3
  double v240; // fp19
  double v241; // fp18
  double v242; // fp17
  idPhysics *v243; // r3
  float *v244; // r3
  double v245; // fp16
  double v246; // fp15
  double v247; // fp14
  int v248; // r3
  __int64 v249; // r8
  int v250; // r6
  int v251; // r5
  int v252; // r11
  double v253; // fp1
  double v254; // fp12
  double v255; // fp0
  double v256; // fp13
  double v257; // fp2
  idPhysics *v258; // r3
  int v259; // r30
  __int64 v260; // r6
  __int64 v261; // r10
  __int64 v262; // r8
  va *v263; // r3
  const idEntity *Instigator; // r3
  idAIEntityState *v265; // r3
  idAIEntityState *v266; // r22
  float v267; // r11
  float v268; // r9
  float v269; // r5
  float v270; // r10
  float v271; // r28
  float v272; // r26
  float v273; // r25
  float v274; // r24
  float v275; // r23
  float v276; // r21
  float v277; // r20
  float v278; // r19
  float v279; // r7
  float v280; // r6
  float v281; // r4
  unsigned __int8 v282; // r23
  idArray<aiSenseState_t *,2> *v283; // r21
  idColor *v284; // r26
  aiSenseState_t *v285; // r28
  int v286; // r24
  idBounds *v287; // r3
  int v288; // r25
  idBounds *v289; // r3
  unsigned __int64 v290; // r6
  const char *v291; // r7
  XAUDIO2::CX2Voice::EVoiceState valueInteger; // r11
  int v293; // r28
  int v294; // r30
  unsigned __int64 v295; // r6
  const char *v296; // r7
  unsigned __int64 v297; // r6
  const char *v298; // r7
  unsigned __int64 v299; // r6
  const char *v300; // r7
  unsigned __int64 v301; // r6
  const char *v302; // r7
  int v303; // r3
  const idMaterial **p_customMaterial; // r4
  idPhysics *v305; // r3
  int v306; // r3
  float *p_z; // r10
  _DWORD *v308; // r11
  int j; // ctr
  idPhysics *v310; // r3
  float *v311; // r3
  int v312; // r3
  char v313; // r11
  int v314; // r3
  unsigned __int64 v315; // r6
  const char *v316; // r7
  int v317; // r3
  const idIndex<short,enum invalidJointIndex_t> *v318; // r30
  idTreeAnimator *v319; // r3
  int v320; // r5
  int v321; // r4
  int v322; // r3
  int v323; // r8
  int v324; // r7
  int v325; // r6
  int v326; // r11
  int v327; // [sp+8h] [-15B8h]
  int v328; // [sp+8h] [-15B8h]
  int v329; // [sp+Ch] [-15B4h]
  bool v330; // [sp+Fh] [-15B1h]
  const char *v331; // [sp+10h] [-15B0h]
  const char *v332; // [sp+10h] [-15B0h]
  int v333; // [sp+14h] [-15ACh]
  int v334; // [sp+14h] [-15ACh]
  int v335; // [sp+18h] [-15A8h]
  int v336; // [sp+18h] [-15A8h]
  int v337; // [sp+1Ch] [-15A4h]
  int v338; // [sp+1Ch] [-15A4h]
  int v339; // [sp+20h] [-15A0h]
  int v340; // [sp+20h] [-15A0h]
  int v341; // [sp+24h] [-159Ch]
  int v342; // [sp+24h] [-159Ch]
  int v343; // [sp+28h] [-1598h]
  int v344; // [sp+28h] [-1598h]
  int v345; // [sp+2Ch] [-1594h]
  int v346; // [sp+2Ch] [-1594h]
  int v347; // [sp+30h] [-1590h]
  int v348; // [sp+30h] [-1590h]
  int v349; // [sp+34h] [-158Ch]
  int v350; // [sp+34h] [-158Ch]
  int v351; // [sp+38h] [-1588h]
  int v352; // [sp+38h] [-1588h]
  int v353; // [sp+3Ch] [-1584h]
  int v354; // [sp+3Ch] [-1584h]
  int v355; // [sp+40h] [-1580h]
  int v356; // [sp+40h] [-1580h]
  int v357; // [sp+44h] [-157Ch]
  int v358; // [sp+44h] [-157Ch]
  int v359; // [sp+48h] [-1578h]
  int v360; // [sp+48h] [-1578h]
  int v361; // [sp+4Ch] [-1574h]
  int v362; // [sp+4Ch] [-1574h]
  int v363; // [sp+50h] [-1570h]
  int v364; // [sp+50h] [-1570h]
  int v365; // [sp+58h] [-1568h]
  int v366; // [sp+58h] [-1568h]
  int v367; // [sp+60h] [-1560h]
  int v368; // [sp+60h] [-1560h]
  idTreeAnimator v369[2]; // [sp+70h] [-1550h] BYREF

  v1 = this;
  RD_EventBegin(name: "idAI2::Think");
  LODWORD(v2) = "idAI2::Think";
  x_low = &pLog;
  HIDWORD(v2) = 6;
  LODWORD(v369[0].referenceBounds.b[1].x) = &pLog;
  idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].g.castDimShadows, pl: &pLog, gMask: v2, label: v4);
  if ( ai_enable.valueInteger != 0 && (unsigned __int8)Get_idCombatStage_useRelaxedChatterVO(ptr: v1) == 0 )
  {
    if ( v1->aiVolatile.pain.damageInfo.deathImpulseIdx >= 0
      || (v5 = 0, (*((_BYTE *)&v1->aiVolatile.death + 1760) & 8) != 0) )
    {
      v5 = 1;
    }
    v6 = COERCE_FLOAT(&idEventDef::eventDefList[3154]);
    LODWORD(v369[0].deferredAxis.mat[2].y) = &idEventDef::eventDefList[3154];
    if ( v5 == 0
      && v1->aiHealth.IsDead_Impl(this: &v1->aiHealth)
      && idAI2::GetAlertCycle(this: v1) != ALERTCYCLE_DYING
      && idAI2::GetAlertCycle(this: v1) != ALERTCYCLE_DEAD )
    {
      v7 = (int)v1->GetEquippedWeapon(this: v1);
      v8 = (idWeapon *)v7;
      if ( v7 != 0 )
      {
        v9 = v1->GetFXMgrForAttachment(this: v1, a2: (idInventoryItem *)v7);
        idWeapon::StopAllFX(this: v8, fxMgr: v9);
      }
      idAnimatedEntity::KillFX(this: v1);
      idLib::Warning(fmt: "AI '%s' is dead but not ALERTCYCLE_DYING or ALERTCYCLE_DEAD.", v1->name.data);
      v1->StartRagdoll(this: v1, a2: &v1->ragdollInfo);
      v10 = (int)v1->GetAF_2(this: v1);
      (*(void (__fastcall **)(int, idVec3 *))(*(_DWORD *)(v10 + 288) + 96))(
        a1: v10 + 288,
        a2: &gameLocal->clientGame.gravity);
      vehicleAiSetup_t::encounter_t::encounter_t(this: (idASEModel *)&v369[0].gameParmBlock.staticOps[21]);
      idFSMManager::idFSMStack::Add(
        this: (idFSMManager::idFSMStack *)&v369[0].gameParmBlock.staticOps[21],
        fsmType: &idAlertCycleFSM::Type,
        stateType: &idAlertCycle_Dead::Type);
      idFSMManager::SetFSMStack(
        this: &v1->aiVolatile.fsms.fsmManager,
        stack: (const idFSMManager::idFSMStack *)&v369[0].gameParmBlock.staticOps[21]);
      Player = idGameLocal::GetPlayer(this: gameLocal, i: 0);
      if ( (unsigned __int16)v1->aiVolatile.encounterGroupHandle.value != 0xFFFF
        && idEncounterGroupManager::GroupForHandle(
             this: &gameLocal->encounterGroupManager,
             handle: &v1->aiVolatile.encounterGroupHandle) != nullptr )
      {
        if ( (unsigned __int16)v1->aiVolatile.encounterGroupHandle.value == 0xFFFF )
          v12 = nullptr;
        else
          v12 = idEncounterGroupManager::GroupForHandle(
                  this: &gameLocal->encounterGroupManager,
                  handle: &v1->aiVolatile.encounterGroupHandle);
        idEncounterGroup::MemberKilled(this: v12, ai: v1, attacker: Player, inflictor: nullptr);
      }
      if ( idEntityPtr<idEntity const>::operator->(this: &v1->aiEditable.death.trigger) != nullptr )
      {
        v13 = v1;
        if ( Player != nullptr )
          v13 = Player;
        v14 = idEventArg::idEventArg(this: (idEventArg *)&v369[0].gameParmBlock.staticConstants[9], data: v13);
        p_parmIndexA = &v369[0].gameParmBlock.staticOps[30].parmIndexA;
        v16 = (_DWORD *)&v14[-1].value.q[3];
        for ( i = 5; i != 0; --i )
        {
          ++v16;
          p_parmIndexA += 2;
          *(_DWORD *)p_parmIndexA = *v16;
        }
        v18 = idEntityPtr<idEntity const>::operator->(this: &v1->aiEditable.death.trigger);
        idEventReceiver::PostEventMS(
          this: v18,
          ev: &EV_Activate,
          time: 0,
          arg1: *(const idEventArg **)&v369[0].gameParmBlock.staticOps[32].type);
      }
      LODWORD(v369[0].g.origin.y) = v1->entityNumber;
      LODWORD(v369[0].deferredAxis.mat[1].z) = (gameLocal->spawnIds.ptr[LODWORD(v369[0].g.origin.y)] << 13)
                                             | LODWORD(v369[0].g.origin.y);
      idList<idEntityPtr<idPlayer>,5>::Remove(
        this: &gameLocal->activeAI,
        obj: (const idEntityPtr<idAI2> *)&v369[0].deferredAxis.mat[1].z);
      idGameLocal::RemoveDyingAI(this: gameLocal, ai: v1);
      idPLog::~idPLog(this: (idFSMManager::idFSMStack *)&v369[0].gameParmBlock.staticOps[21]);
    }
    if ( v1->aiVolatile.world.worldState.initialUpdateCount >= 2 )
    {
      v19 = &v1->aiEditable.behaviors.lookTrackingParms->parms.list[v1->aiEditable.skill.lookRate];
      idTargetCache::Clear(this: &v1->aiVolatile.world.worldState.targetCache);
      p_aiGameState = &gameLocal->aiGameState;
      v21 = idAILogic::idAILogic(this: (idAILogic *)&v369[0].gameParmBlock.staticOps[21], ai: v1);
      idAIWorldState::Update(
        this: &v1->aiVolatile.world.worldState,
        gameState: p_aiGameState,
        aiOwner: v21,
        trackingParms: v19);
      idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].g.castDimShadows);
      goto LABEL_194;
    }
    if ( (*((_BYTE *)&v1->aiVolatile + 49704) & 0x80) == 0x80 )
      idAI2::FirstThink(this: v1);
    if ( !idEntity::UpdateDormant(this: v1) )
    {
      idTargetCache::Clear(this: &v1->aiVolatile.world.worldState.targetCache);
      LODWORD(v22) = (unsigned __int8)idAI2::ShouldDeadThink(this: v1);
      z = COERCE_FLOAT((idCVar *)&ai_useTurnTransitions.valueString.baseBuffer[12]);
      v369[0].g.origin.y = v22;
      LODWORD(v369[0].deferredAxis.mat[2].z) = &ai_useTurnTransitions.valueString.baseBuffer[12];
      LODWORD(v369[0].deferredAxis.mat[2].x) = &idColor::colorGreen;
      LODWORD(v369[0].deferredAxis.mat[1].y) = &idColor::colorRed;
      if ( v22 == 0.0 )
      {
        RD_EventBegin(name: "idAI2::Think - alive");
        LODWORD(v36) = "idAI2::Think - alive";
        HIDWORD(v36) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: &pLog, gMask: v36, label: v37);
        RD_EventBegin(name: "idAI2::Think - aim assist");
        LODWORD(v38) = "idAI2::Think - aim assist";
        HIDWORD(v38) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v38, label: v39);
        presentable = v1->presentable;
        if ( presentable == nullptr )
        {
          idEntity::InitPresentableInternal(this: v1);
          presentable = v1->presentable;
        }
        v41 = presentable->GetAIInterface(this: presentable);
        idPresentableAnimatedEntity::UpdateAimAssist(this: v41);
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
        RD_EventEnd();
        RD_EventBegin(name: "idAI2::Think - melee trace");
        LODWORD(v42) = "idAI2::Think - melee trace";
        HIDWORD(v42) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v42, label: v43);
        if ( v1->aiVolatile.meleeTrace.numSamples != 0 )
          idMeleeTrace::Update(this: &v1->aiVolatile.meleeTrace, owner: v1);
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
        RD_EventEnd();
        RD_EventBegin(name: "idAI2::Think - UpdateDrop");
        LODWORD(v44) = "idAI2::Think - UpdateDrop";
        HIDWORD(v44) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v44, label: v45);
        idAI2::UpdateDrop(this: v1);
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
        RD_EventEnd();
        RD_EventBegin(name: "idAI2::Think - UpdateTempFaction");
        LODWORD(v46) = "idAI2::Think - UpdateTempFaction";
        HIDWORD(v46) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v46, label: v47);
        idActor::UpdateTempFaction(this: v1);
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
        RD_EventEnd();
        RD_EventBegin(name: "idAI2::Think - influence trail");
        LODWORD(v48) = "idAI2::Think - influence trail";
        HIDWORD(v48) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v48, label: v49);
        v50 = v1->presentable;
        if ( v50 == nullptr )
        {
          idEntity::InitPresentableInternal(this: v1);
          v50 = v1->presentable;
        }
        v51 = v50->GetAIInterface(this: v50);
        idPresentableAI::UpdateInfluenceTrail(this: v51);
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
        RD_EventEnd();
        idAI2::UpdateTravelFlags(this: v1);
        if ( idAI2::GetControllingPlayer(this: v1) != nullptr )
        {
          idAI2::Think_PlayerControl(this: v1);
        }
        else
        {
          RD_EventBegin(name: "Think_AIControl");
          LODWORD(v52) = "Think_AIControl";
          HIDWORD(v52) = 6;
          idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v52, label: v53);
          idAI2::Think_AIControl(this: v1);
          idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
          RD_EventEnd();
        }
        if ( v1->IsDying(this: v1) )
          idAI2::UpdateDeathCollision(this: v1);
        condition = v1->aiVolatile.groupStatus.condition;
        LODWORD(v369[0].deferredAxis.mat[1].z) = &idColor::colorBlue;
        LODWORD(v369[0].referenceBounds.b[1].z) = &idColor::colorYellow;
        if ( (condition & 8) != 0 && !v1->IsDead(this: v1) )
        {
          RD_EventBegin(name: "idAI2::Think - bleedout");
          LODWORD(v55) = "idAI2::Think - bleedout";
          HIDWORD(v55) = 6;
          idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].committed, pl: &pLog, gMask: v55, label: v56);
          p_clip = &clientGame->clip;
          p_bleedOutHipQuery = &v1->patch1.bleedOutHipQuery;
          if ( (unsigned __int8)idClip::QueryIsValid(this: &clientGame->clip, clipQuery: &v1->patch1.bleedOutHipQuery) != 0 )
          {
            LODWORD(v59) = 0;
            *(idClipQuery *)((char *)&v59 + 4) = (idClipQuery)p_bleedOutHipQuery->index;
            p_bleedOutHipQuery->index = v59;
            *((_DWORD *)&v369[0].__vftable + 2) = p_clip;
            idCollisionModelManager::GetContentsResult(
              this: collisionModelManager,
              result: (trace_t *)&v369[0].gameParmBlock.staticConstants[20],
              query: &p_clip->collisionQueries[WORD5(v59) & 0xFFF].query,
              peek: false);
            if ( v369[0].gameParmBlock.staticConstants[20].value[0] < 1.0 )
            {
              p_patch1 = &v1->patch1;
              v61 = &clientGame->clip;
              if ( (unsigned __int8)idClip::QueryIsValid(
                                      this: &clientGame->clip,
                                      clipQuery: &v1->patch1.bleedOutGroundQuery) != 0 )
              {
                LODWORD(v62) = 0;
                *(_QWORD *)((char *)&v62 + 4) = p_patch1->bleedOutGroundQuery.index;
                p_patch1->bleedOutGroundQuery.index = v62;
                *((_DWORD *)&v369[0].__vftable + 2) = v61;
                idCollisionModelManager::GetContentsResult(
                  this: collisionModelManager,
                  result: (trace_t *)&v369[0].gameParmBlock.staticConstants[12],
                  query: &v61->collisionQueries[WORD5(v62) & 0xFFF].query,
                  peek: false);
                if ( v369[0].gameParmBlock.staticConstants[12].value[0] >= 1.0
                  && v1->GetPosture(this: v1) == POSTURE_CROUCHED
                  && v1->aiVolatile.animation.animWebAnimator.ptr[0].runIndexType == ANIMWEBAI_RUNINDEXTYPE_INJURED )
                {
                  v63 = idAIMemory::GetLastInflictor(this: &v1->aiVolatile.memory) != nullptr
                      ? idAIMemory::GetLastInflictor(this: &v1->aiVolatile.memory)
                      : v1;
                  v64 = idAIMemory::GetLastAttacker(this: &v1->aiVolatile.memory) != nullptr
                      ? idAIMemory::GetLastAttacker(this: &v1->aiVolatile.memory)
                      : v1;
                  Physics = idEntity::GetPhysics(this: v1);
                  v66 = v1->__vftable;
                  decl = v1->aiEditable.behaviors.decl;
                  Physics->GetGravityNormal(this: Physics);
                  ((void (__fastcall *)(idAI2 *, idEntity *, idEntity *, const idDeclDamage *, double))v66->Damage)(
                    a1: v1,
                    a2: v63,
                    a3: v64,
                    a4: decl->damageBehaviors.bleedOutDamageDecl,
                    a5: 100.0);
                  if ( ai_debugBleedoutCheck.valueInteger >= 1 )
                  {
                    v68 = common->RW(this: common);
                    v68->DebugPoint(
                      this: v68,
                      a2: (const idVec4 *)&idColor::colorYellow,
                      a3: (const idVec3 *)&v369[0].gameParmBlock.staticConstants[23].swizzle[2],
                      a4: 10000,
                      a5: false);
                    v69 = common->RW(this: common);
                    *(float *)&v369[0].gameParmBlock.staticOps[19].type = v369[0].gameParmBlock.staticConstants[12].value[3]
                                                                        + (float)(vec3_up.z * (float)20.0);
                    *(float *)&v369[0].gameParmBlock.staticOps[18].parmIndexA = v369[0].gameParmBlock.staticConstants[12].value[2]
                                                                              + (float)(vec3_up.y * (float)20.0);
                    *(float *)&v369[0].gameParmBlock.staticOps[18].type = v369[0].gameParmBlock.staticConstants[12].value[1]
                                                                        + (float)(vec3_up.x * (float)20.0);
                    v69->DebugLine(
                      this: v69,
                      a2: (const idVec4 *)&idColor::colorBlue,
                      a3: (const idVec3 *)(&v369[0].gameParmBlock.staticConstants[12].string + 1),
                      a4: (const idVec3 *)&v369[0].gameParmBlock.staticOps[18],
                      a5: 10000,
                      a6: false);
                  }
                }
              }
            }
          }
          TreeAnimatorFromPresentable = (idIndex<short,enum invalidJointIndex_t> *)idAnimatedEntity::GetTreeAnimatorFromPresentable(this: v1);
          idTreeAnimator::GetJointIndex(this: v369, result: TreeAnimatorFromPresentable, jointName: "hips");
          v71 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this: v1);
          idTreeAnimator::GetWorldSpaceJointTransform(
            this: v71,
            pose: (animationPose_t)0,
            jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(v369[0].__vftable),
            origin: (idVec3 *)&v369[0].name,
            axis: (idMat3 *)&v369[0].gameParmBlock.staticOps[21]);
          v72 = idEntity::GetPhysics(this: v1);
          v73 = idEntity::GetPhysics(this: v1);
          entityNumber = v1->entityNumber;
          *(float *)&v369[0].gameParmBlock.staticOps[8].type = (float)((float)(vec3_up.x * (float)-1.0) * (float)8.0)
                                                             + *(float *)&v369[0].name.str;
          *(float *)&v369[0].gameParmBlock.staticOps[9].type = v369[0].deferredOrigin.x
                                                             + (float)((float)(vec3_up.z * (float)-1.0) * (float)8.0);
          *(float *)&v369[0].gameParmBlock.staticOps[8].parmIndexA = *(float *)&v369[0].debugName
                                                                   + (float)((float)(vec3_up.y * (float)-1.0)
                                                                           * (float)8.0);
          v75 = (idMat3 *)v72->GetAxis(this: v72, a2: 0);
          v76 = v73->GetClipModel(this: v73, a2: 0);
          p_bleedOutHipQuery->index = *(unsigned __int64 *)&idClip::Translation(
                                                              this: (idClip *)((char *)&v369[0].g + 108),
                                                              result: &clientGame->clip,
                                                              a3: nullptr,
                                                              start: (const idVec3 *)&v369[0].name,
                                                              end: (const idVec3 *)&v369[0].gameParmBlock.staticOps[8],
                                                              clipModel: v76,
                                                              startAxis: v75,
                                                              clipMask: 1,
                                                              passEntityNumber: v327,
                                                              moveClipModel: v329,
                                                              userName: v331,
                                                              a12: v333,
                                                              a13: v335,
                                                              a14: v337,
                                                              a15: v339,
                                                              a16: v341,
                                                              a17: v343,
                                                              a18: v345,
                                                              a19: v347,
                                                              a20: v349,
                                                              a21: v351,
                                                              a22: v353,
                                                              a23: v355,
                                                              a24: v357,
                                                              a25: v359,
                                                              a26: v361,
                                                              a27: v363,
                                                              a28: entityNumber,
                                                              a29: v365,
                                                              a30: false,
                                                              a31: v367,
                                                              a32: (int)"w:\\tech5\\tungsten\\game\\ai\\AI2.cpp(2946) : TranslationHip")->world;
          if ( ai_debugBleedoutCheck.valueInteger >= 2 )
          {
            v77 = common->RW(this: common);
            *((float *)&v369[0].g + 29) = (float)((float)(vec3_up.x * (float)-1.0) * (float)8.0)
                                        + *(float *)&v369[0].name.str;
            *(float *)&v369[0].g.highlightColor = v369[0].deferredOrigin.x
                                                + (float)((float)(vec3_up.z * (float)-1.0) * (float)8.0);
            v369[0].g.staticReflectionStrength = *(float *)&v369[0].debugName
                                               + (float)((float)(vec3_up.y * (float)-1.0) * (float)8.0);
            v77->DebugLine(
              this: v77,
              a2: (const idVec4 *)LODWORD(v369[0].deferredAxis.mat[1].y),
              a3: (const idVec3 *)&v369[0].name,
              a4: (const idVec3 *)((char *)&v369[0].g + 116),
              a5: 0,
              a6: false);
          }
          v78 = (idIndex<short,enum invalidJointIndex_t> *)idAnimatedEntity::GetTreeAnimatorFromPresentable(this: v1);
          HIWORD(v369[0].__vftable) = HIWORD(idTreeAnimator::GetJointIndex(
                                               this: (idTreeAnimator *)&v369[0].referenceBounds.b[0].y,
                                               result: v78,
                                               jointName: "rightfoot")->__vftable);
          v79 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this: v1);
          idTreeAnimator::GetWorldSpaceJointTransform(
            this: v79,
            pose: (animationPose_t)0,
            jointIndex: (const idIndex<short,enum invalidJointIndex_t> *)HIWORD(v369[0].__vftable),
            origin: (idVec3 *)&v369[0].name,
            axis: (idMat3 *)&v369[0].gameParmBlock.staticOps[21]);
          *(float *)&v369[0].name.str = (float)(vec3_up.x * (float)4.0) + *(float *)&v369[0].name.str;
          v369[0].deferredOrigin.x = v369[0].deferredOrigin.x + (float)(vec3_up.z * (float)4.0);
          *(float *)&v369[0].debugName = *(float *)&v369[0].debugName + (float)(vec3_up.y * (float)4.0);
          v80 = idEntity::GetPhysics(this: v1);
          v81 = idEntity::GetPhysics(this: v1);
          v82 = v1->entityNumber;
          *(float *)&v369[0].gameParmBlock.staticOps[4].type = (float)((float)(vec3_up.x * (float)-1.0) * (float)20.0)
                                                             + *(float *)&v369[0].name.str;
          *(float *)&v369[0].gameParmBlock.staticOps[5].type = v369[0].deferredOrigin.x
                                                             + (float)((float)(vec3_up.z * (float)-1.0) * (float)20.0);
          *(float *)&v369[0].gameParmBlock.staticOps[4].parmIndexA = *(float *)&v369[0].debugName
                                                                   + (float)((float)(vec3_up.y * (float)-1.0)
                                                                           * (float)20.0);
          v83 = (idMat3 *)v80->GetAxis(this: v80, a2: 0);
          v84 = v81->GetClipModel(this: v81, a2: 0);
          v1->patch1.bleedOutGroundQuery.index = *(_QWORD *)&idClip::Translation(
                                                               this: (idClip *)((char *)&v369[0].g + 108),
                                                               result: &clientGame->clip,
                                                               a3: nullptr,
                                                               start: (const idVec3 *)&v369[0].name,
                                                               end: (const idVec3 *)&v369[0].gameParmBlock.staticOps[4],
                                                               clipModel: v84,
                                                               startAxis: v83,
                                                               clipMask: 1,
                                                               passEntityNumber: v328,
                                                               moveClipModel: v330,
                                                               userName: v332,
                                                               a12: v334,
                                                               a13: v336,
                                                               a14: v338,
                                                               a15: v340,
                                                               a16: v342,
                                                               a17: v344,
                                                               a18: v346,
                                                               a19: v348,
                                                               a20: v350,
                                                               a21: v352,
                                                               a22: v354,
                                                               a23: v356,
                                                               a24: v358,
                                                               a25: v360,
                                                               a26: v362,
                                                               a27: v364,
                                                               a28: v82,
                                                               a29: v366,
                                                               a30: false,
                                                               a31: v368,
                                                               a32: (int)"w:\\tech5\\tungsten\\game\\ai\\AI2.cpp(2954) : TranslationFoot")->world;
          if ( ai_debugBleedoutCheck.valueInteger >= 2 )
          {
            v85 = common->RW(this: common);
            *(float *)&v369[0].gameParmBlock.constants.granularity = *(float *)&v369[0].debugName
                                                                   + (float)((float)(vec3_up.y * (float)-1.0)
                                                                           * (float)20.0);
            *(float *)&v369[0].gameParmBlock.thread = v369[0].deferredOrigin.x
                                                    + (float)((float)(vec3_up.z * (float)-1.0) * (float)20.0);
            *(float *)&v369[0].gameParmBlock.constants.size = (float)((float)(vec3_up.x * (float)-1.0) * (float)20.0)
                                                            + *(float *)&v369[0].name.str;
            v85->DebugLine(
              this: v85,
              a2: (const idVec4 *)&idColor::colorBlue,
              a3: (const idVec3 *)&v369[0].name,
              a4: (const idVec3 *)&v369[0].gameParmBlock.constants.size,
              a5: 0,
              a6: false);
          }
          v86 = gameLocal->GetGameHz(this: gameLocal, a2: GAMETIME_SCALED);
          v87 = gameLocal->GetGameFrame(this: gameLocal);
          __twllei(v86, 0);
          __twlgei(v86 & ~(__ROL4__(v87, 1) - 1), 0xFFFFFFFF);
          if ( v87 % v86 == 0 )
          {
            standingBleedRate = v1->aiEditable.behaviors.decl->damageBehaviors.standingBleedRate;
            if ( v1->GetPosture(this: v1) == POSTURE_CROUCHED )
              standingBleedRate = v1->aiEditable.behaviors.decl->damageBehaviors.groundBleedRate;
            if ( standingBleedRate > 0.0 )
            {
              if ( idAIMemory::GetLastInflictor(this: &v1->aiVolatile.memory) != nullptr )
                LastInflictor = idAIMemory::GetLastInflictor(this: &v1->aiVolatile.memory);
              else
                LastInflictor = v1;
              if ( idAIMemory::GetLastAttacker(this: &v1->aiVolatile.memory) != nullptr )
                LastAttacker = idAIMemory::GetLastAttacker(this: &v1->aiVolatile.memory);
              else
                LastAttacker = v1;
              v91 = idEntity::GetPhysics(this: v1);
              v92 = v1->__vftable;
              v93 = v1->aiEditable.behaviors.decl;
              v91->GetGravityNormal(this: v91);
              ((void (__fastcall *)(idAI2 *, idEntity *, idEntity *, const idDeclDamage *, double))v92->Damage)(
                a1: v1,
                a2: LastInflictor,
                a3: LastAttacker,
                a4: v93->damageBehaviors.bleedOutDamageDecl,
                a5: standingBleedRate);
            }
          }
          idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].committed);
          RD_EventEnd();
        }
        if ( (v1->thinkFlags & 1) != 0 && ai_enableMovement.valueInteger != 0 )
          idAI2::UpdateMovement(this: v1);
        RD_EventBegin(name: "idAI2::Think - sync AF");
        LODWORD(v94) = "idAI2::Think - sync AF";
        HIDWORD(v94) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1, pl: &pLog, gMask: v94, label: v95);
        v96 = (int)v1->GetAF_2(this: v1);
        v97 = idEntity::GetPhysics(this: v1);
        y = v369[0].deferredAxis.mat[2].y;
        LOBYTE(v96) = v97 != (idPhysics *)(v96 + 288);
        v99 = (*(int (__fastcall **)(_DWORD, int))(**(_DWORD **)(LODWORD(v369[0].deferredAxis.mat[2].y) + 20512) + 156))(
                a1: *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[2].y) + 20512),
                a2: 1);
        v100 = v1->GetAF_2(this: v1);
        idAnimator_AF::Sync(this: v100, time: v99, runPhysics: v96);
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].__vftable + 1);
        RD_EventEnd();
        thinkFlags = v1->thinkFlags;
        v102 = COERCE_FLOAT(&idColor::colorWhite);
        LODWORD(v369[0].referenceBounds.b[0].y) = &idColor::colorWhite;
        LODWORD(v369[0].g.origin.x) = &idColor::colorCyan;
        if ( (thinkFlags & 2) != 0 && ai_enablePhysics.valueInteger != 0 )
        {
          RD_EventBegin(name: "idAI2::Think - physics");
          LODWORD(v103) = "idAI2::Think - physics";
          HIDWORD(v103) = 6;
          idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].committed, pl: &pLog, gMask: v103, label: v104);
          v105 = idEntity::GetPhysics(this: v1);
          v106 = (int)v105->GetOrigin(this: v105, a2: 0);
          v107 = *(float *)(v106 + 4);
          v108 = *(float *)(v106 + 8);
          GetPosture = v1->GetPosture;
          v369[0].g.axis.mat[2].z = *(float *)v106;
          v369[0].g.scale.x = v107;
          v369[0].g.scale.y = v108;
          v1->aiVolatile.physics.object.crouched = (_cntlzw(GetPosture(this: v1) - 2) & 0x20) != 0;
          idEntity::RunPhysics(this: v1);
          if ( ai_debugMove.valueInteger > 0 && ai_debugLevel.valueInteger > 0 )
          {
            v110 = (((unsigned int)ai_debugLevel.valueInteger >> 31) - (ai_debugLevel.valueInteger > 1u)) & 0xBB8;
            v111 = idEntity::GetPhysics(this: v1);
            v112 = (float *)v111->GetOrigin(this: v111, a2: 0);
            v113 = v112[2];
            v114 = *v112;
            v369[0].deferredAxis.mat[0].z = v112[1];
            v369[0].deferredAxis.mat[1].x = v113;
            v369[0].deferredAxis.mat[0].y = v114;
            v115 = (float)(v114 - v369[0].g.axis.mat[2].z);
            v116 = (float)(v369[0].deferredAxis.mat[0].z - v369[0].g.scale.x);
            v117 = (float)(v113 - v369[0].g.scale.y);
            v118 = idEntity::GetPhysics(this: v1);
            v119 = (float *)v118->GetGravityNormal(this: v118);
            v120 = (float)((float)((float)v116 * v119[2]) - (float)((float)v117 * v119[1]));
            v121 = (float)((float)((float)v117 * *v119) - (float)((float)v115 * v119[2]));
            v122 = (int *)(v1->aiVolatile.physics.moveState.movementMode == AIMOVEMODE_GROUND
                         ? &idColor::colorYellow
                         : &idColor::colorOrange);
            v123 = v122[1];
            v124 = v122[2];
            v125 = v122[3];
            v126 = (float)((float)((float)((float)v115 * v119[1]) - (float)((float)v116 * *v119)) * (float)0.5);
            v369[0].gameParmBlock.staticConstants[8].swizzle[0] = *v122;
            v369[0].gameParmBlock.staticConstants[8].swizzle[1] = v123;
            v369[0].gameParmBlock.staticConstants[8].swizzle[2] = v124;
            v369[0].gameParmBlock.staticConstants[8].swizzle[3] = v125;
            *((float *)&v369[0].__vftable + 2) = (float)v121 * (float)0.5;
            *(float *)&v369[0].gameParmBlock.staticOps[15].type = v369[0].deferredAxis.mat[1].x + (float)v126;
            *(float *)&v369[0].gameParmBlock.staticOps[14].type = (float)((float)v120 * (float)0.5)
                                                                + v369[0].deferredAxis.mat[0].y;
            *(float *)&v369[0].gameParmBlock.staticOps[14].parmIndexA = v369[0].deferredAxis.mat[0].z
                                                                      + *((float *)&v369[0].__vftable + 2);
            *(float *)&v369[0].gameParmBlock.staticOps[2].parmIndexA = v369[0].deferredAxis.mat[0].z
                                                                     - *((float *)&v369[0].__vftable + 2);
            *(float *)&v369[0].gameParmBlock.staticOps[3].type = v369[0].deferredAxis.mat[1].x - (float)v126;
            *(float *)&v369[0].gameParmBlock.staticOps[2].type = v369[0].deferredAxis.mat[0].y
                                                               - (float)((float)v120 * (float)0.5);
            clientGame->renderWorld->DebugLine(
              this: clientGame->renderWorld,
              a2: (const idVec4 *)&idColor::colorDkGrey,
              a3: (const idVec3 *)&v369[0].gameParmBlock.staticOps[2],
              a4: (const idVec3 *)&v369[0].gameParmBlock.staticOps[14],
              a5: v110,
              a6: true);
            clientGame->renderWorld->DebugLine(
              this: clientGame->renderWorld,
              a2: (const idVec4 *)&v369[0].gameParmBlock.staticConstants[8],
              a3: (const idVec3 *)&v369[0].g.axis.mat[2].z,
              a4: (const idVec3 *)&v369[0].deferredAxis.mat[0].y,
              a5: v110,
              a6: true);
            if ( ai_debugLevel.valueInteger > 2 )
            {
              v127 = (float)(v1->aiVolatile.physics.moveState.moveOrientation.axis.mat[0].z * (float)72.0);
              v128 = (float)(v1->aiVolatile.physics.moveState.moveOrientation.axis.mat[0].y * (float)72.0);
              *(float *)&v369[0].gameParmBlock.staticOps[16].type = (float)(v1->aiVolatile.physics.moveState.moveOrientation.axis.mat[0].x
                                                                          * (float)72.0)
                                                                  + v369[0].deferredAxis.mat[0].y;
              *((_DWORD *)&v369[0].__vftable + 2) = &v1->aiVolatile.physics.moveState.moveOrientation.axis;
              *(float *)&v369[0].gameParmBlock.staticOps[17].type = v369[0].deferredAxis.mat[1].x + (float)v127;
              *(float *)&v369[0].gameParmBlock.staticOps[16].parmIndexA = v369[0].deferredAxis.mat[0].z + (float)v128;
              ((void (__fastcall *)(idRenderWorld *, _DWORD, float *, expOp_t *, double))clientGame->renderWorld->DebugArrow)(
                a1: clientGame->renderWorld,
                a2: LODWORD(v369[0].deferredAxis.mat[1].y),
                a3: &v369[0].deferredAxis.mat[0].y,
                a4: &v369[0].gameParmBlock.staticOps[16],
                a5: 12.0);
              x = COERCE_FLOAT(&idColor::colorCyan);
              if ( v1->aiVolatile.physics.moveState.movementMode != AIMOVEMODE_ANIM )
                x = v369[0].deferredAxis.mat[2].x;
              v130 = (float)(v1->aiVolatile.physics.moveState.moveOrientation.idealDir.x * (float)64.0);
              v131 = (float)(v1->aiVolatile.physics.moveState.moveOrientation.idealDir.z * (float)64.0);
              v132 = (float)(v1->aiVolatile.physics.moveState.moveOrientation.idealDir.y * (float)64.0);
              v133 = *(_DWORD *)(LODWORD(x) + 4);
              v134 = *(_DWORD *)(LODWORD(x) + 8);
              v135 = *(_DWORD *)(LODWORD(x) + 12);
              v369[0].gameParmBlock.staticConstants[7].swizzle[0] = *(_DWORD *)LODWORD(x);
              v369[0].gameParmBlock.staticConstants[7].swizzle[1] = v133;
              v369[0].gameParmBlock.staticConstants[7].swizzle[2] = v134;
              v369[0].gameParmBlock.staticConstants[7].swizzle[3] = v135;
              *(float *)&v369[0].gameParmBlock.staticOps[6].type = (float)v130 + v369[0].deferredAxis.mat[0].y;
              *(float *)&v369[0].gameParmBlock.staticOps[7].type = v369[0].deferredAxis.mat[1].x + (float)v131;
              *(float *)&v369[0].gameParmBlock.staticOps[6].parmIndexA = v369[0].deferredAxis.mat[0].z + (float)v132;
              ((void (__fastcall *)(idRenderWorld *, parmValue_t *, float *, expOp_t *, double))clientGame->renderWorld->DebugArrow)(
                a1: clientGame->renderWorld,
                a2: &v369[0].gameParmBlock.staticConstants[7],
                a3: &v369[0].deferredAxis.mat[0].y,
                a4: &v369[0].gameParmBlock.staticOps[6],
                a5: 8.0);
              lastTurnRate = v1->aiVolatile.physics.moveState.moveOrientation.lastTurnRate;
              *((float *)&v369[0].__vftable + 2) = v1->aiVolatile.physics.moveState.moveOrientation.lastTurnRate;
              if ( lastTurnRate > 0.0 )
              {
                HIDWORD(v138) = LODWORD(lastTurnRate);
                *((float *)&v369[0].__vftable + 2) = lastTurnRate;
                v140 = va::va(
                         this: (va *)&v369[0].gameParmBlock.staticConstants[28],
                         fmt: "turnRate = %.2f",
                         a3: v138,
                         a4: v137,
                         a5: v136,
                         a6: v327,
                         a7: v329,
                         a8: (int)v331,
                         a9: v333,
                         a10: v335,
                         a11: v337,
                         lastTurnRate);
                ((void (__fastcall *)(idRenderWorld *, va *, float *, idRenderWorld_vtbl *, idColor *, int, _DWORD, double))clientGame->renderWorld->DebugText)(
                  a1: clientGame->renderWorld,
                  a2: v140,
                  a3: &v369[0].deferredAxis.mat[0].y,
                  a4: clientGame->renderWorld->__vftable,
                  a5: &idColor::colorWhite,
                  a6: 1,
                  a7: 0,
                  a8: 0.2);
              }
            }
          }
          if ( v1->aiEditable.movement.touchTriggers )
            idEntity::TouchTriggers(this: v1);
          idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].committed);
          RD_EventEnd();
        }
        else
        {
          v1->UpdateAnimationControllers(this: v1);
        }
        if ( (v1->thinkFlags & 1) != 0 )
        {
          RD_EventBegin(name: "idAI2::Think - debug stuff");
          LODWORD(v141) = "idAI2::Think - debug stuff";
          HIDWORD(v141) = 6;
          idPLogScope::idPLogScope(this: (idPLogScope *)((char *)&v369[0].g + 108), pl: &pLog, gMask: v141, label: v142);
          if ( ai_debugLevel.valueInteger > 0
            && (idAIMemory::HasRestrictionVolume(this: &v1->aiVolatile.memory) || ai_debugLevel.valueInteger >= 3) )
          {
            v369[0].__vftable = (idTreeAnimator_vtbl *)v1->aiVolatile.memory.restrictionVolume.spawnId.value;
            v143 = idEntityPtr<idVolume_Restriction>::operator idVolume_Restriction *(this: (idEntityPtr<idVolume_Restriction> *)v369);
            if ( v143 != nullptr )
            {
              v144 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 4);
              v145 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 8);
              v146 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 12);
              v369[0].gameParmBlock.staticConstants[5].swizzle[0] = *(_DWORD *)LODWORD(v369[0].deferredAxis.mat[1].y);
              v369[0].gameParmBlock.staticConstants[5].swizzle[1] = v144;
              v369[0].gameParmBlock.staticConstants[5].swizzle[2] = v145;
              v369[0].gameParmBlock.staticConstants[5].swizzle[3] = v146;
              idStr::idStr(this: (idStr *)&v369[0].gameParmBlock.staticConstants[3], text: "Restricted ( ");
              idStr::Append(this: (idStr *)&v369[0].gameParmBlock.staticConstants[3], text: v143->name.data);
              idStr::Append(this: (idStr *)&v369[0].gameParmBlock.staticConstants[3], text: " )");
              if ( !idAIMemory::HasRestrictionVolume(this: &v1->aiVolatile.memory) )
              {
                v369[0].gameParmBlock.staticConstants[5] = (parmValue_t)idColor::colorWhite;
                idStr::Append(this: (idStr *)&v369[0].gameParmBlock.staticConstants[3], text: " Not active");
              }
              v147 = idEntity::GetPhysics(this: v1);
              v148 = (int)v147->GetOrigin(this: v147, a2: 0);
              v149 = *(float *)v148;
              v150 = *(float *)(v148 + 4);
              v151 = (float *)v1->presentable;
              v369[0].g.axis.mat[0].z = *(float *)(v148 + 8);
              v369[0].g.axis.mat[0].x = v149;
              v152 = (float)(v369[0].g.axis.mat[0].z + (float)100.0);
              v369[0].g.axis.mat[0].y = v150;
              if ( v151 == nullptr )
              {
                idEntity::InitPresentableInternal(this: v1);
                v151 = (float *)v1->presentable;
              }
              v153 = v151[40];
              v154 = v151[41];
              v155 = common->__vftable;
              v369[0].g.axis.mat[1].y = v151[39];
              v369[0].g.axis.mat[1].z = v153;
              v369[0].g.axis.mat[2].x = v154;
              v156 = v155->RW(this: common);
              *(float *)&v369[0].gameParmBlock.staticOps[12].parmIndexA = v369[0].g.axis.mat[0].y
                                                                        + (float)(v369[0].g.axis.mat[1].z * (float)40.0);
              *(float *)&v369[0].gameParmBlock.staticOps[12].type = (float)(v369[0].g.axis.mat[1].y * (float)40.0)
                                                                  + v369[0].g.axis.mat[0].x;
              *(float *)&v369[0].gameParmBlock.staticOps[13].type = (float)v152
                                                                  + (float)(v369[0].g.axis.mat[2].x * (float)40.0);
              ((void (__fastcall *)(idRenderWorld *, int, expOp_t *, idRenderWorld_vtbl *, parmValue_t *, int, int, _DWORD, double))v156->DebugText)(
                a1: v156,
                a2: v369[0].gameParmBlock.staticConstants[3].swizzle[1],
                a3: &v369[0].gameParmBlock.staticOps[12],
                a4: v156->__vftable,
                a5: &v369[0].gameParmBlock.staticConstants[5],
                a6: 1,
                a7: 1,
                a8: 0,
                a9: 0.25);
              idStr::FreeData(this: (idStr *)&v369[0].gameParmBlock.staticConstants[3]);
            }
          }
          v157 = idGameLocal::GetPlayer(this: *(idGameLocal **)(LODWORD(y) + 20512), i: 0);
          if ( v157 != nullptr )
          {
            Enemy = idAIMemory::GetEnemy(this: &v1->aiVolatile.memory);
            if ( Enemy != nullptr && Enemy->entityNumber == v157->entityNumber )
              idPlayer::SetMaxTension(this: v157, tension: PLAYER_TENSION_HOSTILE);
          }
          v159 = *(idGameLocal **)(LODWORD(y) + 20512);
          *((_DWORD *)&v369[0].__vftable + 2) = &v1->aiVolatile.world;
          v160 = idGameLocal::GetPlayer(this: v159, i: 0);
          v161 = idAIWorldState::StateForEntity(this: &v1->aiVolatile.world.worldState, ent: v160);
          v162 = v161;
          *(_DWORD *)&v369[0].needWriteToSnapshot = v161;
          if ( ai_debugEnemy.valueInteger > 0 && v161 != nullptr && idAI2::GetDebugLevel() > 0 && !v1->IsDead(this: v1) )
          {
            v369[0].__vftable = (idTreeAnimator_vtbl *)senseColors_0;
            if ( (_S18_1 & 1) == 0 )
            {
              v163 = *(idTreeAnimator_vtbl **)(LODWORD(v369[0].deferredAxis.mat[1].z) + 8);
              v164 = *(float *)LODWORD(v369[0].referenceBounds.b[1].z);
              v165 = *(float *)(LODWORD(v369[0].referenceBounds.b[1].z) + 4);
              v369[0].__vftable = (idTreeAnimator_vtbl *)LODWORD(idColor::colorMagenta.r);
              v166 = *(float *)(LODWORD(v369[0].referenceBounds.b[1].z) + 8);
              *(float *)&v369[0].useDeferredPosition = idColor::colorMagenta.g;
              v167 = *(float *)LODWORD(v369[0].deferredAxis.mat[1].y);
              v168 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 4);
              v169 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 8);
              v369[0].nextOnCommitList = (idRenderModel *)LODWORD(idColor::colorMagenta.b);
              v369[0].committed = (idRenderModelCommitted *)LODWORD(idColor::colorMagenta.a);
              v170 = *(float *)LODWORD(v369[0].deferredAxis.mat[1].z);
              v171 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].z) + 4);
              v172 = *(float *)LODWORD(v369[0].g.origin.x);
              v173 = *(float *)(LODWORD(v369[0].referenceBounds.b[1].z) + 12);
              v174 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 12);
              v175 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].z) + 12);
              v176 = *(float *)(LODWORD(v369[0].g.origin.x) + 4);
              v177 = *(float *)(LODWORD(v369[0].g.origin.x) + 8);
              v178 = *(float *)LODWORD(v369[0].deferredAxis.mat[2].x);
              v179 = *(float *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 4);
              v369[0].__vftable = v163;
              v180 = *(float *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 8);
              senseColors_0[0].a = v173;
              senseColors_0[1].r = v172;
              senseColors_0[3].a = v174;
              senseColors_0[4].a = v175;
              v181 = *(float *)(LODWORD(v369[0].g.origin.x) + 12);
              v182 = *(float *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 12);
              senseColors_0[0].r = v164;
              senseColors_0[0].g = v165;
              v102 = v369[0].referenceBounds.b[0].y;
              v1 = this;
              z = v369[0].deferredAxis.mat[2].z;
              _S18_1 |= 1u;
              senseColors_0[0].b = v166;
              senseColors_0[1].g = v176;
              senseColors_0[1].b = v177;
              senseColors_0[1].a = v181;
              senseColors_0[2].r = v178;
              senseColors_0[2].g = v179;
              senseColors_0[2].b = v180;
              senseColors_0[2].a = v182;
              senseColors_0[3].r = v167;
              senseColors_0[3].g = v168;
              senseColors_0[3].b = v169;
              senseColors_0[4].r = v170;
              senseColors_0[4].g = v171;
              LODWORD(senseColors_0[4].b) = v163;
              v162 = *(idAIEntityState **)&v369[0].needWriteToSnapshot;
              senseColors_0[5] = idColor::colorMagenta;
            }
            p_senses = (idTreeAnimator_vtbl *)&v162->senses;
            v369[0].__vftable = (idTreeAnimator_vtbl *)&v162->senses;
            *(_DWORD *)&v369[0].useDeferredPosition = "buddy ";
            v369[0].nextOnCommitList = (idRenderModel *)"lastSeen ";
            v184 = senseColors_0;
            v369[0].committed = (idRenderModelCommitted *)"group ";
            v185 = 0;
            LODWORD(v369[0].deferredAxis.mat[2].z) = "self ";
            do
            {
              if ( *((int *)p_senses->Save + 22) >= 0 )
              {
                v186 = v162->senses.ptr[(unsigned __int8)v185];
                v187 = **(_DWORD **)(*(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[2].y) + 20512) + 695676);
                v188 = idBoundsShort::ToBounds(
                         this: (idBoundsShort *)&v369[0].gameParmBlock.staticOps[21],
                         result: (idBounds *)&v186->unConfirmedPhysical.bounds);
                (*(void (__fastcall **)(_DWORD, idColor *, idBounds *, aiPhysicalState_t *, _DWORD, _DWORD))(v187 + 220))(
                  a1: *(_DWORD *)(*(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[2].y) + 20512) + 695676),
                  a2: v184,
                  a3: v188,
                  a4: &v186->unConfirmedPhysical,
                  a5: 0,
                  a6: 0);
                (*(void (__fastcall **)(_DWORD, idColor *, idVec3 *, aiPhysicalState_t *, double))(**(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4)
                                                                                                 + 180))(
                  a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                  a2: v184,
                  a3: &v186->aiOrigin,
                  a4: &v186->unConfirmedPhysical,
                  a5: 1.0);
                v189 = *(_DWORD *)(LODWORD(z) + 17592);
                v190 = (float)(v186->unConfirmedPhysical.viewfwd.x * (float)64.0);
                v191 = (float)(v186->unConfirmedPhysical.viewfwd.z * (float)64.0);
                v192 = v186->unConfirmedPhysical.origin.x;
                v193 = v186->unConfirmedPhysical.origin.z;
                *(float *)&v369[0].gameParmBlock.staticOps[10].parmIndexA = v186->unConfirmedPhysical.origin.y
                                                                          + (float)(v186->unConfirmedPhysical.viewfwd.y
                                                                                  * (float)64.0);
                *(_DWORD *)&v369[0].needWriteToSnapshot = &v186->unConfirmedPhysical.viewfwd;
                *(float *)&v369[0].gameParmBlock.staticOps[10].type = (float)v192 + (float)v190;
                *(float *)&v369[0].gameParmBlock.staticOps[11].type = (float)v193 + (float)v191;
                (*(void (__fastcall **)(_DWORD, idColor *, aiPhysicalState_t *, expOp_t *, double))(**(_DWORD **)(v189 + 4)
                                                                                                  + 180))(
                  a1: *(_DWORD *)(v189 + 4),
                  a2: v184,
                  a3: &v186->unConfirmedPhysical,
                  a4: &v369[0].gameParmBlock.staticOps[10],
                  a5: 3.0);
                if ( v186->lastConfirmedStimTime > 0 )
                {
                  v194 = **(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4);
                  ConfirmedPhysicalSafe = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  v196 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  v197 = idBoundsShort::ToBounds(
                           this: (idBoundsShort *)&v369[0].gameParmBlock.staticOps[21],
                           result: (idBounds *)&v196->bounds);
                  (*(void (__fastcall **)(_DWORD, idColor *, idBounds *, const aiPhysicalState_t *, _DWORD, _DWORD))(v194 + 220))(
                    a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a2: v184 + 2,
                    a3: v197,
                    a4: ConfirmedPhysicalSafe,
                    a5: 0,
                    a6: 0);
                  v198 = **(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4);
                  v199 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  (*(void (__fastcall **)(_DWORD, idColor *, idVec3 *, const aiPhysicalState_t *, double))(v198 + 180))(
                    a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a2: v184 + 2,
                    a3: &v186->aiOrigin,
                    a4: v199,
                    a5: 1.0);
                  v200 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  v201 = (float)(v200->viewfwd.z * (float)64.0);
                  v202 = (float)(v200->viewfwd.y * (float)64.0);
                  v203 = (float)(v200->viewfwd.x * (float)64.0);
                  v204 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  v205 = *(_DWORD *)(LODWORD(z) + 17592);
                  v206 = v204->origin.y;
                  v207 = (float)(v204->origin.z + (float)v201);
                  *(float *)&v369[0].g.viewport.y2 = (float)v203 + v204->origin.x;
                  *(float *)&v369[0].gameParmBlock.ops.list = v207;
                  *((float *)&v369[0].g + 42) = (float)v206 + (float)v202;
                  v208 = **(_DWORD **)(v205 + 4);
                  v209 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  (*(void (__fastcall **)(_DWORD, idColor *, const aiPhysicalState_t *, int *, double))(v208 + 180))(
                    a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a2: v184 + 2,
                    a3: v209,
                    a4: &v369[0].g.viewport.y2,
                    a5: 3.0);
                  idStr::idStr(this: (idStr *)&v369[0].gameParmBlock.staticConstants[1], text: &byte_8200D768);
                  if ( (v186->senseFlags & 1) != 0 )
                    idStr::Append(
                      this: (idStr *)&v369[0].gameParmBlock.staticConstants[1],
                      text: (char *)LODWORD(v369[0].deferredAxis.mat[2].z));
                  if ( (v186->senseFlags & 2) != 0 )
                    idStr::Append(
                      this: (idStr *)&v369[0].gameParmBlock.staticConstants[1],
                      text: (char *)v369[0].committed);
                  if ( (v186->senseFlags & 4) != 0 )
                    idStr::Append(
                      this: (idStr *)&v369[0].gameParmBlock.staticConstants[1],
                      text: (char *)v369[0].nextOnCommitList);
                  if ( (v186->senseFlags & 8) != 0 )
                    idStr::Append(
                      this: (idStr *)&v369[0].gameParmBlock.staticConstants[1],
                      text: *(char **)&v369[0].useDeferredPosition);
                  v210 = aiSenseState_t::GetConfirmedPhysicalSafe(this: v186);
                  LODWORD(v211) = v185 + 2;
                  v369[0].gameParmBlock.staticOps[29] = (expOp_t)v211;
                  v212 = (float)(v210->origin.z * (float)v211);
                  v213 = (float)(v210->origin.y * (float)v211);
                  v214 = (float)((float)v211 * v210->origin.x);
                  v215 = idEntity::GetPhysics(this: v1);
                  v216 = (float *)v215->GetOrigin(this: v215, a2: 0);
                  v217 = *(_DWORD *)(LODWORD(z) + 17592);
                  v218 = v369[0].gameParmBlock.staticConstants[1].swizzle[1];
                  *(_QWORD *)&v369[0].g.axis.mat[0].x = __PAIR64__((unsigned int)v216, v185 + 3);
                  v219 = (float)(v216[1] + (float)v213);
                  v220 = (float)(*v216 + (float)v214);
                  *(float *)&v369[0].gameParmBlock.constants.list = (float)(v216[2] + (float)v212)
                                                                  * (float)((float)1.0
                                                                          / (float)__SPAIR64__(
                                                                                     (unsigned int)v216,
                                                                                     v185 + 3));
                  *(float *)&v369[0].gameParmBlock.ops.granularity = (float)v219
                                                                   * (float)((float)1.0
                                                                           / (float)__SPAIR64__(
                                                                                      (unsigned int)v216,
                                                                                      v185 + 3));
                  *(float *)&v369[0].gameParmBlock.ops.size = (float)v220
                                                            * (float)((float)1.0
                                                                    / (float)__SPAIR64__((unsigned int)v216, v185 + 3));
                  GameMs = idGameTimeManager::GetGameMs(
                             this: (idGameTimeManager *)(v217 + 504064),
                             type: GAMETIME_SCALED);
                  LODWORD(v222) = GameMs - aiSenseState_t::GetConfirmedStimTimeSafe(this: v186);
                  *(_QWORD *)&v369[0].g.axis.mat[1].y = v222;
                  LODWORD(v223) = v218;
                  *(double *)((char *)&v223 + 4) = (float)((float)v222 * (float)0.001);
                  v225 = va::va(
                           this: (va *)&v369[0].gameParmBlock.staticConstants[28],
                           fmt: (const char *)DWORD1(v223),
                           a3: v223,
                           a4: v224,
                           a5: *(__int64 *)((char *)&v222 + 4),
                           a6: v327,
                           a7: v329,
                           a8: (int)v331,
                           a9: v333,
                           a10: v335,
                           a11: v337);
                  (*(void (__fastcall **)(_DWORD, va *, int *, _DWORD, idColor *, int, double))(**(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4)
                                                                                              + 268))(
                    a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a2: v225,
                    a3: &v369[0].gameParmBlock.ops.size,
                    a4: **(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a5: v184 + 2,
                    a6: 1,
                    a7: 0.2);
                  idStr::FreeData(this: (idStr *)&v369[0].gameParmBlock.staticConstants[1]);
                  p_senses = v369[0].__vftable;
                  v102 = v369[0].referenceBounds.b[0].y;
                }
                v226 = idEntity::GetPhysics(this: v1);
                v227 = (int *)v226->GetOrigin(this: v226, a2: 0);
                v228 = v227[1];
                v229 = *((float *)v227 + 2);
                GetEyeOffset = v1->GetEyeOffset;
                v369[0].g.suppressShadowInLightIndex = *v227;
                v369[0].g.firstVisibleFrameCount = v228;
                v369[0].g.fovScale = v229;
                v231 = (float *)GetEyeOffset(
                                  this: (struct idAI2 *)&v369[0].gameParmBlock.staticConstants[10].swizzle[2],
                                  result: (const idVec3 *)v1);
                fovScale = v369[0].g.fovScale;
                v233 = *(float *)&v369[0].g.firstVisibleFrameCount;
                v234 = *(float *)&v369[0].g.suppressShadowInLightIndex;
                v235 = (float)(v231[2] + v369[0].g.fovScale);
                v236 = (float)(v231[1] + *(float *)&v369[0].g.firstVisibleFrameCount);
                v237 = (float)(*v231 + *(float *)&v369[0].g.suppressShadowInLightIndex);
                v238 = idEntity::GetPhysics(this: v1);
                v239 = (float *)v238->GetLinearVelocity(
                                  this: (idPhysics *)&v369[0].gameParmBlock.staticConstants[9],
                                  result: (idVec3 *)v238,
                                  a3: 0);
                v240 = (float)((float)((float)v234 - (float)(*v239 * (float)0.033333335)) + (float)1.0);
                v241 = (float)((float)((float)fovScale - (float)(v239[2] * (float)0.033333335)) + (float)1.0);
                v242 = (float)((float)((float)v233 - (float)(v239[1] * (float)0.033333335)) + (float)1.0);
                v243 = idEntity::GetPhysics(this: v1);
                v244 = (float *)((int (__fastcall *)(expOp_t *))v243->GetLinearVelocity)(a1: &v369[0].gameParmBlock.staticOps[31]);
                v245 = (float)((float)v237 - (float)(*v244 * (float)0.033333335));
                v246 = (float)((float)v235 - (float)(v244[2] * (float)0.033333335));
                v247 = (float)((float)v236 - (float)(v244[1] * (float)0.033333335));
                v248 = idGameTimeManager::GetGameMs(
                         this: (idGameTimeManager *)(*(_DWORD *)(LODWORD(z) + 17592) + 504064),
                         type: GAMETIME_SCALED);
                idLeakyIntegrator<0,1>::Update(this: &v186->integrator, curTimeMS: v248, a3: v251, a4: v250, a5: v249);
                v252 = *(_DWORD *)(LODWORD(z) + 17592);
                v253 = (float)((float)((float)v237 - (float)v234) * v186->integrator.value);
                v254 = (float)((float)((float)v245 - (float)v240) * v186->integrator.value);
                v255 = (float)((float)((float)v246 - (float)v241) * v186->integrator.value);
                v256 = (float)((float)((float)v247 - (float)v242) * v186->integrator.value);
                v257 = (float)((float)((float)v236 - (float)v233) * v186->integrator.value);
                *(float *)&v369[0].gameParmBlock.staticOps[1].type = (float)fovScale
                                                                   + (float)((float)((float)v235 - (float)fovScale)
                                                                           * v186->integrator.value);
                *(float *)&v369[0].gameParmBlock.staticOps[0].type = (float)v253 + (float)v234;
                *(float *)&v369[0].g.referenceModel = (float)v254 + (float)v240;
                *(float *)&v369[0].g.viewport.y1 = (float)v255 + (float)v241;
                *(float *)&v369[0].g.viewport.x1 = (float)v256 + (float)v242;
                *(float *)&v369[0].gameParmBlock.staticOps[0].parmIndexA = (float)v233 + (float)v257;
                (*(void (__fastcall **)(_DWORD, idColor *, idRenderModel **, expOp_t *, int, _DWORD))(**(_DWORD **)(v252 + 4) + 176))(
                  a1: *(_DWORD *)(v252 + 4),
                  a2: v184,
                  a3: &v369[0].g.referenceModel,
                  a4: v369[0].gameParmBlock.staticOps,
                  a5: 3000,
                  a6: 0);
                v258 = idEntity::GetPhysics(this: v1);
                v259 = (int)v258->GetOrigin(this: v258, a2: 0);
                HIDWORD(v260) = v1->aiVolatile.memory.lastActuallySeenEnemyTime;
                v263 = va::va(
                         this: (va *)&v369[0].gameParmBlock.staticConstants[28],
                         fmt: "%d",
                         a3: v260,
                         a4: v262,
                         a5: v261,
                         a6: v327,
                         a7: v329,
                         a8: (int)v331,
                         a9: v333,
                         a10: v335,
                         a11: v337);
                (*(void (__fastcall **)(_DWORD, va *, int, _DWORD, double, int, _DWORD, _DWORD, double))(**(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4) + 268))(
                  a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                  a2: v263,
                  a3: v259,
                  a4: *(_DWORD *)(**(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4) + 268),
                  a5: COERCE_DOUBLE(LODWORD(v102)),
                  a6: 1,
                  a7: 0,
                  a8: 0,
                  a9: 0.2);
              }
              v184 += 3;
              p_senses = (idTreeAnimator_vtbl *)((char *)p_senses + 4);
              ++v185;
              v369[0].__vftable = p_senses;
            }
            while ( (int)v184 <= (int)&senseColors_0[3] );
          }
          if ( ai_debugFriendly.valueInteger != 0
            && idAIEvent::GetInstigator(this: (idAIEvent *)&v1->aiVolatile.memory) != nullptr
            && idAI2::GetDebugLevel() >= 0 )
          {
            Instigator = idAIEvent::GetInstigator(this: (idAIEvent *)&v1->aiVolatile.memory);
            v265 = idAIWorldState::StateForEntity(this: *((idAIWorldState **)&v369[0].__vftable + 2), ent: Instigator);
            v266 = v265;
            if ( v265 != nullptr )
            {
              if ( (_S18_1 & 2) == 0 )
              {
                _S18_1 |= 2u;
                v267 = *(float *)(LODWORD(v369[0].referenceBounds.b[1].z) + 4);
                v268 = *(float *)(LODWORD(v369[0].referenceBounds.b[1].z) + 8);
                v269 = *(float *)(LODWORD(v369[0].referenceBounds.b[1].z) + 12);
                v270 = *(float *)LODWORD(v369[0].g.origin.x);
                v271 = *(float *)(LODWORD(v369[0].g.origin.x) + 4);
                v272 = *(float *)(LODWORD(v369[0].g.origin.x) + 8);
                v273 = *(float *)LODWORD(v369[0].deferredAxis.mat[2].x);
                v274 = *(float *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 4);
                v275 = *(float *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 8);
                v276 = *(float *)LODWORD(v369[0].deferredAxis.mat[1].z);
                v277 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].z) + 4);
                v278 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].z) + 8);
                v279 = *(float *)(LODWORD(v369[0].g.origin.x) + 12);
                v280 = *(float *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 12);
                v281 = *(float *)(LODWORD(v369[0].deferredAxis.mat[1].z) + 12);
                senseColors[0].r = *(float *)LODWORD(v369[0].referenceBounds.b[1].z);
                senseColors[0].g = v267;
                senseColors[0].b = v268;
                senseColors[0].a = v269;
                senseColors[1].r = v270;
                senseColors[1].g = v271;
                senseColors[1].b = v272;
                senseColors[1].a = v279;
                senseColors[2].r = v273;
                senseColors[2].g = v274;
                senseColors[2].b = v275;
                senseColors[2].a = v280;
                senseColors[3].r = v276;
                senseColors[3].g = v277;
                senseColors[3].b = v278;
                senseColors[3].a = v281;
              }
              v282 = 0;
              v283 = &v265->senses;
              v284 = &senseColors[1];
              do
              {
                if ( v283->ptr[0]->lastUnconfirmedStimTime >= 0 )
                {
                  v285 = v266->senses.ptr[v282];
                  v286 = **(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4);
                  v287 = idBoundsShort::ToBounds(
                           this: (idBoundsShort *)&v369[0].gameParmBlock.staticOps[21],
                           result: (idBounds *)&v285->unConfirmedPhysical.bounds);
                  (*(void (__fastcall **)(_DWORD, idColor *, idBounds *, aiPhysicalState_t *, _DWORD, _DWORD))(v286 + 220))(
                    a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a2: v284 - 1,
                    a3: v287,
                    a4: &v285->unConfirmedPhysical,
                    a5: 0,
                    a6: 0);
                  v288 = **(_DWORD **)(*(_DWORD *)(LODWORD(z) + 17592) + 4);
                  v289 = idBoundsShort::ToBounds(
                           this: (idBoundsShort *)&v369[0].gameParmBlock.staticOps[21],
                           result: (idBounds *)&v285->unConfirmedPhysical.bounds);
                  (*(void (__fastcall **)(_DWORD, idColor *, idBounds *, idVec3 *, _DWORD, _DWORD))(v288 + 220))(
                    a1: *(_DWORD *)(*(_DWORD *)(LODWORD(z) + 17592) + 4),
                    a2: v284,
                    a3: v289,
                    a4: &v285->aiOrigin,
                    a5: 0,
                    a6: 0);
                }
                v284 += 2;
                ++v282;
                v283 = (idArray<aiSenseState_t *,2> *)((char *)v283 + 4);
              }
              while ( (int)v284 <= (int)&senseColors[3] );
            }
          }
          idPLogScope::~idPLogScope(this: (idPLogScope *)((char *)&v369[0].g + 108));
          RD_EventEnd();
          v22 = v369[0].g.origin.y;
          x_low = (idPLog *)LODWORD(v369[0].referenceBounds.b[1].x);
        }
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
        RD_EventEnd();
        v6 = v369[0].deferredAxis.mat[2].y;
      }
      else
      {
        RD_EventBegin(name: "idAI2::Think - dead");
        LODWORD(v24) = "idAI2::Think - dead";
        HIDWORD(v24) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].g.origin.y, pl: &pLog, gMask: v24, label: v25);
        RD_EventBegin(name: "idAI2::Think - sync AF");
        LODWORD(v26) = "idAI2::Think - sync AF";
        HIDWORD(v26) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].referenceBounds.b[1], pl: &pLog, gMask: v26, label: v27);
        v28 = v1->GetAF_2(this: v1);
        v29 = (idPhysics *)v1->GetAF_2(this: v1);
        LOBYTE(v29) = idEntity::GetPhysics(this: v1) != &v29[6];
        v30 = gameLocal->GetGameMs(this: gameLocal, a2: GAMETIME_SCALED);
        idAnimator_AF::Sync(this: v28, time: v30, runPhysics: (bool)v29);
        if ( !v28->walkIKDisabled )
        {
          if ( v28->isActive || (v31 = 0, v28->isClientAuthoritativeActive) )
            v31 = 1;
          if ( v31 != 0 && idAnimator_Base::GetAlpha(this: v28) >= 1.0 )
          {
            idAI2::DisableAnimatorsOnDeath(this: v1);
            v28->walkIKDisabled = true;
          }
        }
        if ( v28->isActive || (v32 = 0, v28->isClientAuthoritativeActive) )
          v32 = 1;
        if ( v32 == 0 )
          idAI2::SetIsRagdolling(this: v1, isRagdolling: false);
        if ( !v28->isSyncing )
        {
          idAI2::SetIsRagdolling(this: v1, isRagdolling: false);
          idEntity::StopSound(this: v1, channel: SND_CHANNEL_WEAPON, peerMask: 0xFFu);
        }
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].referenceBounds.b[1]);
        RD_EventEnd();
        if ( (v1->thinkFlags & 2) != 0 && ai_enablePhysics.valueInteger != 0 )
        {
          RD_EventBegin(name: "idAI2::Think - physics");
          LODWORD(v33) = "idAI2::Think - physics";
          HIDWORD(v33) = 6;
          idPLogScope::idPLogScope(
            this: (idPLogScope *)&v369[0].referenceBounds.b[1],
            pl: &pLog,
            gMask: v33,
            label: v34);
          v35 = idEntity::GetPhysics(this: v1);
          v35->GetOrigin(this: v35, a2: 0);
          idEntity::RunPhysics(this: v1);
          if ( v1->aiEditable.movement.touchTriggers && (*((_BYTE *)&v1->flags + 1) & 8) != 0 )
            idEntity::TouchTriggers(this: v1);
          idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].referenceBounds.b[1]);
          RD_EventEnd();
        }
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].g.origin.y);
        RD_EventEnd();
      }
      if ( ai_enableAnimation.valueInteger != 0 )
      {
        RD_EventBegin(name: "idAI2::Think - UpdateAnimation");
        LODWORD(v290) = "idAI2::Think - UpdateAnimation";
        HIDWORD(v290) = 6;
        idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: x_low, gMask: v290, label: v291);
        valueInteger = ai_mood.valueInteger;
        if ( ai_mood.valueInteger >= 0 )
        {
          if ( ai_mood.valueInteger > 8 )
            valueInteger = 8;
          XAUDIO2::CX2SourceVoice::SetVoiceState(
            this: (XAUDIO2::CX2Voice *)&v1->aiVolatile.faceMgr,
            eNewState: valueInteger);
        }
        idAnimatedEntity::UpdateAnimation(this: v1, forceNonDeferredBlend: false);
        v293 = 0;
        if ( v1->aiEditable.ponytails.num > 0 )
        {
          v294 = 0;
          do
          {
            idPonytail::Update(this: &v1->aiEditable.ponytails.list[v294]);
            ++v293;
            ++v294;
          }
          while ( v293 < v1->aiEditable.ponytails.num );
        }
        if ( v1->aiVolatile.animation.animWebAnimator.ptr[0].error != ANIMWEB_ERROR_NONE )
        {
          idAI2::SetDebugText(this: v1, text: "NO ANIMWEB PATH", debugLevel: AIDEBUGLEVEL_ERROR);
          v1->aiVolatile.debugging.errorFlags |= 0x20u;
        }
        idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
        RD_EventEnd();
      }
      RD_EventBegin(name: "idAI2::Think - UpdateEffects");
      LODWORD(v295) = "idAI2::Think - UpdateEffects";
      HIDWORD(v295) = 6;
      idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: x_low, gMask: v295, label: v296);
      idAI2::UpdateEffects(this: v1);
      idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
      RD_EventEnd();
      RD_EventBegin(name: "idAI2::Think - UpdateImpacts");
      LODWORD(v297) = "idAI2::Think - UpdateImpacts";
      HIDWORD(v297) = 6;
      idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: x_low, gMask: v297, label: v298);
      idAnimatedEntity::UpdateImpacts(this: v1);
      idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
      RD_EventEnd();
      RD_EventBegin(name: "idAI2::Think - UpdateInfluenceTrail");
      LODWORD(v299) = "idAI2::Think - UpdateInfluenceTrail";
      HIDWORD(v299) = 6;
      idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: x_low, gMask: v299, label: v300);
      idAI2::UpdateInfluenceTrail(this: v1);
      idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
      RD_EventEnd();
      RD_EventBegin(name: "idAI2::Think - UpdatePVSAreas");
      LODWORD(v301) = "idAI2::Think - UpdatePVSAreas";
      HIDWORD(v301) = 6;
      idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: x_low, gMask: v301, label: v302);
      if ( v22 == 0.0 || v1->GetAF_2(this: v1) == nullptr )
      {
        v305 = idEntity::GetPhysics(this: v1);
        v306 = (int)v305->GetBounds(this: v305, a2: -1);
        p_z = &v369[0].g.scale.z;
        v308 = (_DWORD *)(v306 - 4);
        for ( j = 6; j != 0; --j )
          *++p_z = *(float *)++v308;
        v310 = idEntity::GetPhysics(this: v1);
        v311 = (float *)v310->GetOrigin(this: v310, a2: 0);
        p_customMaterial = &v369[0].g.customMaterial;
        *(float *)&v369[0].g.customMaterial = *(float *)&v369[0].g.customMaterial + *v311;
        *(float *)&v369[0].g.customSkin = *(float *)&v369[0].g.customSkin + v311[1];
        *(float *)&v369[0].g.groupMasterIndex = *(float *)&v369[0].g.groupMasterIndex + v311[2];
        *(float *)&v369[0].g.allowSurfaceOnlyInViewID = *(float *)&v369[0].g.allowSurfaceOnlyInViewID + *v311;
        *(float *)&v369[0].g.suppressSurfaceInViewID = *(float *)&v369[0].g.suppressSurfaceInViewID + v311[1];
        *(float *)&v369[0].g.suppressShadowInViewID = *(float *)&v369[0].g.suppressShadowInViewID + v311[2];
      }
      else
      {
        v303 = (int)v1->GetAF_2(this: v1);
        p_customMaterial = (const idMaterial **)(*(int (__fastcall **)(int, int))(*(_DWORD *)(v303 + 288) + 44))(
                                                  a1: v303 + 288,
                                                  a2: -1);
      }
      idEntity::UpdatePVSAreas(this: v1, bounds: (const idBounds *)p_customMaterial);
      idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
      RD_EventEnd();
      v312 = (int)v1->GetAF_2(this: v1);
      if ( *(_BYTE *)(v312 + 267) != 0 || (v313 = 0, *(_BYTE *)(v312 + 268) != 0) )
        v313 = 1;
      if ( v313 != 0 )
      {
        v314 = (int)v1->GetAF_2(this: v1);
        if ( (*(unsigned __int8 (__fastcall **)(int))(*(_DWORD *)(v314 + 288) + 300))(a1: v314 + 288) != 0 )
        {
          idLib::Warning(fmt: "Removed AI '%s' because its ragdoll was outside of the world.", v1->name.data);
          idEventReceiver::PostEventMS(this: v1, ev: &EV_Remove, time: 0);
          idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].g.castDimShadows);
          goto LABEL_194;
        }
      }
      RD_EventBegin(name: "idAI2::Think - formationCover");
      LODWORD(v315) = "idAI2::Think - formationCover";
      HIDWORD(v315) = 6;
      idPLogScope::idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z, pl: x_low, gMask: v315, label: v316);
      if ( com_production.valueInteger == 0 && (*(_BYTE *)&v1->aiEditable.behaviors.decl->dynamicCoverCaps & 0x20) != 0 )
      {
        v317 = (*(int (__fastcall **)(_DWORD, int))(**(_DWORD **)(LODWORD(v6) + 20512) + 156))(
                 a1: *(_DWORD *)(LODWORD(v6) + 20512),
                 a2: 1);
        idDynamicCoverMgr::UpdateUsable(this: &v1->formationCover, owner: v1, curTime: v317);
      }
      idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].deferredOrigin.z);
      RD_EventEnd();
      if ( takedownWindowDebug.valueInteger != 0 )
      {
        v318 = (const idIndex<short,enum invalidJointIndex_t> *)(__int16)tester;
        v319 = idAnimatedEntity::GetTreeAnimatorFromPresentable(this: v1);
        idTreeAnimator::GetWorldSpaceJointTransform(
          this: v319,
          pose: (animationPose_t)0,
          jointIndex: v318,
          origin: (idVec3 *)&v369[0].g.maxTexelDensity,
          axis: (idMat3 *)&v369[0].gameParmBlock.staticOps[21]);
        v320 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 4);
        v321 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 8);
        v322 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[1].y) + 12);
        v369[0].gameParmBlock.staticConstants[6].swizzle[0] = *(_DWORD *)LODWORD(v369[0].deferredAxis.mat[1].y);
        v369[0].gameParmBlock.staticConstants[6].swizzle[1] = v320;
        v369[0].gameParmBlock.staticConstants[6].swizzle[2] = v321;
        v369[0].gameParmBlock.staticConstants[6].swizzle[3] = v322;
        if ( takedownWindoMaxTime.valueInteger == -1 || idAI2::TakedownWindoIsOpen(this: v1) )
        {
          v323 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 4);
          v324 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 8);
          v325 = *(_DWORD *)(LODWORD(v369[0].deferredAxis.mat[2].x) + 12);
          v369[0].gameParmBlock.staticConstants[6].swizzle[0] = *(_DWORD *)LODWORD(v369[0].deferredAxis.mat[2].x);
          v369[0].gameParmBlock.staticConstants[6].swizzle[1] = v323;
          v369[0].gameParmBlock.staticConstants[6].swizzle[2] = v324;
          v369[0].gameParmBlock.staticConstants[6].swizzle[3] = v325;
        }
        v326 = *(_DWORD *)(LODWORD(z) + 17592);
        *(float *)&v369[0].gameParmBlock.staticOps[28].type = v369[0].g.maxVisibleRange;
        *(float *)&v369[0].gameParmBlock.staticOps[27].type = v369[0].g.maxTexelDensity;
        *(float *)&v369[0].gameParmBlock.staticOps[27].parmIndexA = v369[0].g.modelFade;
        *(float *)&v369[0].gameParmBlock.staticOps[28].parmIndexA = 16.0;
        (*(void (__fastcall **)(_DWORD, parmValue_t *, expOp_t *, int, _DWORD, _DWORD))(**(_DWORD **)(v326 + 4) + 216))(
          a1: *(_DWORD *)(v326 + 4),
          a2: &v369[0].gameParmBlock.staticConstants[6],
          a3: &v369[0].gameParmBlock.staticOps[27],
          a4: 12,
          a5: 0,
          a6: 0);
      }
    }
  }
  if ( ai_thinkTrace.valueInteger != 0 )
    idCVar::SetBool(this: &ai_thinkTrace, newValue: false, force: true);
  idPLogScope::~idPLogScope(this: (idPLogScope *)&v369[0].g.castDimShadows);
LABEL_194:
  RD_EventEnd();
}


// ========================================================================
// __unwind$579490
// EA  : 0x82A286E8
// RVA : 0x00A286E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579490()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5248));
}


// ========================================================================
// __unwind$579491
// EA  : 0x82A28710
// RVA : 0x00A28710
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579491()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 328));
}


// ========================================================================
// __unwind$579492
// EA  : 0x82A28738
// RVA : 0x00A28738
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579492()
{
  int v0; // r12

  idPLog::~idPLog(this: (idFSMManager::idFSMStack *)(v0 - 5568 + 608));
}


// ========================================================================
// __unwind$579493
// EA  : 0x82A28760
// RVA : 0x00A28760
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579493()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5249));
}


// ========================================================================
// __unwind$579494
// EA  : 0x82A28788
// RVA : 0x00A28788
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579494()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 232));
}


// ========================================================================
// __unwind$579495
// EA  : 0x82A287B0
// RVA : 0x00A287B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579495()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5250));
}


// ========================================================================
// __unwind$579496
// EA  : 0x82A287D8
// RVA : 0x00A287D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579496()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 216));
}


// ========================================================================
// __unwind$579497
// EA  : 0x82A28800
// RVA : 0x00A28800
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579497()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5251));
}


// ========================================================================
// __unwind$579498
// EA  : 0x82A28828
// RVA : 0x00A28828
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579498()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 216));
}


// ========================================================================
// __unwind$579499
// EA  : 0x82A28850
// RVA : 0x00A28850
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579499()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5252));
}


// ========================================================================
// __unwind$579500
// EA  : 0x82A28878
// RVA : 0x00A28878
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579500()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// __unwind$579501
// EA  : 0x82A288A0
// RVA : 0x00A288A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579501()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5253));
}


// ========================================================================
// __unwind$579502
// EA  : 0x82A288C8
// RVA : 0x00A288C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579502()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579503
// EA  : 0x82A288F0
// RVA : 0x00A288F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579503()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5254));
}


// ========================================================================
// __unwind$579504
// EA  : 0x82A28918
// RVA : 0x00A28918
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579504()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579505
// EA  : 0x82A28940
// RVA : 0x00A28940
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579505()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5255));
}


// ========================================================================
// __unwind$579506
// EA  : 0x82A28968
// RVA : 0x00A28968
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579506()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579507
// EA  : 0x82A28990
// RVA : 0x00A28990
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579507()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5256));
}


// ========================================================================
// __unwind$579508
// EA  : 0x82A289B8
// RVA : 0x00A289B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579508()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579509
// EA  : 0x82A289E0
// RVA : 0x00A289E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579509()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5257));
}


// ========================================================================
// __unwind$579510
// EA  : 0x82A28A08
// RVA : 0x00A28A08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579510()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579511
// EA  : 0x82A28A30
// RVA : 0x00A28A30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579511()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5258));
}


// ========================================================================
// __unwind$579512
// EA  : 0x82A28A58
// RVA : 0x00A28A58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579512()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579513
// EA  : 0x82A28A80
// RVA : 0x00A28A80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579513()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5259));
}


// ========================================================================
// __unwind$579514
// EA  : 0x82A28AA8
// RVA : 0x00A28AA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579514()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 200));
}


// ========================================================================
// __unwind$579515
// EA  : 0x82A28AD0
// RVA : 0x00A28AD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579515()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5260));
}


// ========================================================================
// __unwind$579516
// EA  : 0x82A28AF8
// RVA : 0x00A28AF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579516()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 120));
}


// ========================================================================
// __unwind$579517
// EA  : 0x82A28B20
// RVA : 0x00A28B20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579517()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5261));
}


// ========================================================================
// __unwind$579518
// EA  : 0x82A28B48
// RVA : 0x00A28B48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579518()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 200));
}


// ========================================================================
// __unwind$579519
// EA  : 0x82A28B70
// RVA : 0x00A28B70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579519()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5262));
}


// ========================================================================
// __unwind$579520
// EA  : 0x82A28B98
// RVA : 0x00A28B98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579520()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 336));
}


// ========================================================================
// __unwind$579521
// EA  : 0x82A28BC0
// RVA : 0x00A28BC0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579521()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 5568 + 752));
}


// ========================================================================
// __unwind$579523
// EA  : 0x82A28BE8
// RVA : 0x00A28BE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579523()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 5568 + 720));
}


// ========================================================================
// __unwind$579525
// EA  : 0x82A28C10
// RVA : 0x00A28C10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579525()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5263));
}


// ========================================================================
// __unwind$579526
// EA  : 0x82A28C38
// RVA : 0x00A28C38
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579526()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// __unwind$579527
// EA  : 0x82A28C60
// RVA : 0x00A28C60
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579527()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5264));
}


// ========================================================================
// __unwind$579528
// EA  : 0x82A28C88
// RVA : 0x00A28C88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579528()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// __unwind$579529
// EA  : 0x82A28CB0
// RVA : 0x00A28CB0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579529()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5265));
}


// ========================================================================
// __unwind$579530
// EA  : 0x82A28CD8
// RVA : 0x00A28CD8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579530()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// __unwind$579531
// EA  : 0x82A28D00
// RVA : 0x00A28D00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579531()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5266));
}


// ========================================================================
// __unwind$579532
// EA  : 0x82A28D28
// RVA : 0x00A28D28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579532()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// __unwind$579533
// EA  : 0x82A28D50
// RVA : 0x00A28D50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579533()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5267));
}


// ========================================================================
// __unwind$579534
// EA  : 0x82A28D78
// RVA : 0x00A28D78
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579534()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// __unwind$579535
// EA  : 0x82A28DA0
// RVA : 0x00A28DA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579535()
{
  int v0; // r12

  idRDScopedEvent::~idRDScopedEvent(this: (idRDScopedEvent *)(v0 - 5568 + 5268));
}


// ========================================================================
// __unwind$579536
// EA  : 0x82A28DC8
// RVA : 0x00A28DC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_579536()
{
  int v0; // r12

  idPLogScope::~idPLogScope(this: (idPLogScope *)(v0 - 5568 + 144));
}


// ========================================================================
// ??0idAIEditable@@QAA@XZ
// EA  : 0x82A28DF8
// RVA : 0x00A28DF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAIEditable *__fastcall idAIEditable::idAIEditable(idAIEditable *this)
{
  idAIEditable::idAIActionSettings *p_actionSettings; // r26
  long double v3; // fp2
  char v4; // r6
  char v5; // r4

  this->actionSettings.squad.squadLeader.spawnId.value = 0x1FFF;
  this->actionSettings.customRobot.triggerOnPowerOut.spawnId.value = 0x1FFF;
  p_actionSettings = &this->actionSettings;
  this->actionSettings.customRobot.triggerOnChargingDone.spawnId.value = 0x1FFF;
  this->actionSettings.customRobot.stageTriggers.list = nullptr;
  this->actionSettings.customRobot.stageTriggers.granularity = 0;
  this->actionSettings.customRobot.stageTriggers.memTag = 5;
  this->actionSettings.customRobot.stageTriggers.listStatic = 0;
  this->actionSettings.customRobot.stageTriggers.size = 0;
  this->actionSettings.customRobot.stageTriggers.num = 0;
  idList<idThread *,58>::Clear(this: (idList<idVehicleState *,5> *)&this->actionSettings.customRobot.stageTriggers);
  idAIEditable::idAIDeath::idAIDeath(this: &this->death);
  idAIEditable::idInteractions::idInteractions(this: &this->interactions);
  idAIEditable::idAISpawn::idAISpawn(this: &this->spawnSettings);
  idAIBehaviors::idAIBehaviors(this: &this->behaviors);
  this->groupName.len = 0;
  this->groupName.allocedAndFlag = 20;
  this->groupName.data = this->groupName.baseBuffer;
  this->groupName.baseBuffer[0] = 0;
  this->ponytails.memTag = 5;
  this->ponytails.granularity = 0;
  this->ponytails.listStatic = 0;
  this->ponytails.list = nullptr;
  this->ponytails.size = 0;
  this->ponytails.num = 0;
  this->onSpotEnemyTrigger.spawnId.value = 0x1FFF;
  this->onDetectEnemyTrigger.spawnId.value = 0x1FFF;
  this->onDamageTrigger.spawnId.value = 0x1FFF;
  this->onIgnoredDamageTrigger.spawnId.value = 0x1FFF;
  this->perception.slowIdleSpot = false;
  this->perception.autoFocusMinTime = 800;
  this->perception.autoFocusMaxTime = 1200;
  this->perception.actorPerceptionRadius = 2048.0;
  this->perception.autoFocusEntity = ONOFFAUTO_AUTO;
  this->perception.obstaclePerceptionRadius = 1024.0;
  this->perception.autoFocusSurroudings = ONOFFAUTO_AUTO;
  this->perception.fieldOfView.value = 180.0;
  this->perception.eventsToIgnore = AIEVENT_NONE;
  this->perception.exposedSightTime = 0.30000001;
  this->perception.senseUpdatesOnNonEnemies = true;
  this->perception.hearingStimulus = 1.0;
  this->perception.combatTimeoutInterval = -1.0;
  this->perception.searchTimeoutInterval = -1.0;
  this->targeting.rangeMax = 2048.0;
  this->targeting.rangeWeight = 3.0;
  this->targeting.angleWeight = 1.0;
  this->targeting.relationWeight = 1.0;
  this->targeting.groupWeight = 1.0;
  this->targeting.currentWeight = 0.25;
  this->targeting.damagerWeight = 0.5;
  this->targeting.spottedWeight = 3.0;
  this->targeting.spottedMax = 5.0;
  this->targeting.playerWeight = 1.0;
  this->targeting.aiWeight = 1.0;
  this->targeting.fakeWeight = 1.0;
  this->targeting.vehicleWeight = 1.0;
  this->targeting.aggroWeight = 1.0;
  idAIEditable::idAIActionSettings::Clear(this: p_actionSettings, a2: v3);
  this->sounds.sndAmbient = nullptr;
  this->sounds.sndDeath = nullptr;
  this->skill.aimAccuracy = ACCURACY_FROMSKILL;
  this->skill.lookRate = LOOKRATE_NORMAL;
  this->skill.skill = AISKILL_NORMAL;
  this->death.ignoreDamageType = DAMAGETYPE_NONE;
  this->death.trigger.spawnId.value = 0x1FFF;
  this->death.bodyFadeTime = 1.0;
  this->death.fadeOutTime = 0.0;
  this->death.removeTime = 0;
  this->cover.coverRadius = 512.0;
  this->cover.maxEnemyCoverDistance = 1600.0;
  this->death.goreDef = nullptr;
  this->interactions.idleTrackFriendlyDist = 128.0;
  this->death.declTwitchPain = nullptr;
  this->spawnSettings.activatedAttractorRange = 0.0;
  this->maxDropSpeed = -500.0;
  this->damageMultiplier = 1.0;
  v4 = *((_BYTE *)&this->death + 85);
  v5 = *((_BYTE *)&this->cover + 8);
  *((_BYTE *)&this->death + 84) = -19;
  this->death.onlineCashMin = 0;
  this->death.onlineCashMax = 0;
  this->movement.dodgeChance = 0;
  this->movement.dodgeInterval = 5000;
  this->movement.walkMod = AIWALKMOD_DEFAULT;
  *((_BYTE *)&this->death + 85) = v4 & 0x7F;
  this->movement.runMod = AIWALKMOD_DEFAULT;
  this->movement.minWalkState = WALKSTATE_NOCLIP;
  this->movement.maxWalkState = WALKSTATE_SPRINTING;
  this->movement.suppressBodyRotation = false;
  this->movement.useTraversalClassA = false;
  this->movement.useTraversalClassB = false;
  this->movement.useTraversalClassC = false;
  this->movement.useTraversalClassD = false;
  *(_WORD *)&this->movement.useTraversalClassE = 1;
  this->movement.ignoreFriendlyVehicles = true;
  this->movement.turretMode = false;
  this->movement.canSetCrouchPhysics = false;
  this->movement.noAdvanceIfStatic = false;
  this->movement.touchTriggers = true;
  this->movement.movePushStatus = AIMOVEPUSHSTATUS_PUSH_NONE;
  this->movement.combatHintClass = CLASS_ALL;
  *((_BYTE *)&this->cover + 8) = v5 & 0x7F;
  this->interactions.playerInteraction = nullptr;
  this->interactions.vehicleMerchant = false;
  this->interactions.playerShouldLowerWeapon = false;
  this->interactions.playerMustLeaveBeforeIdleTracking = false;
  this->interactions.takeDownType = TAKEDOWNTYPE_DEFAULT;
  this->spawnSettings.initialState = AIOVERRIDE_DEFAULT;
  this->spawnSettings.onlyIfGroupAlerted = false;
  this->spawnSettings.entranceAnim = ANIMOVERRIDE_NONE;
  this->spawnSettings.returnToSpawnPos = true;
  this->spawnSettings.alwaysInCombat = false;
  this->facialInfo.defaultFacialAnimSet = nullptr;
  this->aiPortrait = nullptr;
  this->rollBonesDecl = nullptr;
  this->dragJointsDecl = nullptr;
  this->startInDropState = false;
  *(_WORD *)&this->ignoreDamageWhileDropping = 1;
  return this;
}


// ========================================================================
// __unwind$581392
// EA  : 0x82A29124
// RVA : 0x00A29124
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581392()
{
  int v0; // r12

  idAIEditable::idAIActionSettings::~idAIActionSettings(this: (idAIEditable::idAIActionSettings *)(*(_DWORD *)(v0 - 160 + 180)
                                                                                                 + 108));
}


// ========================================================================
// __unwind$581393
// EA  : 0x82A29150
// RVA : 0x00A29150
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581393()
{
  int v0; // r12

  idAIEditable::idAIDeath::~idAIDeath(this: (idAIEditable::idAIDeath *)(*(_DWORD *)(v0 - 160 + 180) + 412));
}


// ========================================================================
// __unwind$581394
// EA  : 0x82A2917C
// RVA : 0x00A2917C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581394()
{
  int v0; // r12

  idAIEditable::idInteractions::~idInteractions(this: (idAIEditable::idInteractions *)(*(_DWORD *)(v0 - 160 + 180) + 548));
}


// ========================================================================
// __unwind$581395
// EA  : 0x82A291A8
// RVA : 0x00A291A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581395()
{
  int v0; // r12

  idAIEditable::idAISpawn::~idAISpawn(this: (idAIEditable::idAISpawn *)(*(_DWORD *)(v0 - 160 + 180) + 744));
}


// ========================================================================
// __unwind$581396
// EA  : 0x82A291D4
// RVA : 0x00A291D4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581396()
{
  int v0; // r12

  idAIEvent::~idAIEvent(this: (idAimAssist *)(*(_DWORD *)(v0 - 160 + 180) + 836));
}


// ========================================================================
// __unwind$581397
// EA  : 0x82A29200
// RVA : 0x00A29200
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581397()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(*(_DWORD *)(v0 - 160 + 180) + 868));
}


// ========================================================================
// ??0idAI2@@QAA@XZ
// EA  : 0x82A29238
// RVA : 0x00A29238
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idAI2 *__fastcall idAI2::idAI2(idAI2 *this)
{
  long double v2; // fp2
  idAI2::idAnimWebDefaults *v3; // r25
  int allocedAndFlag; // r11
  size_t len; // r24
  int v6; // r4
  char v7; // r9
  char v8; // r3
  double value; // fp13
  long double v10; // fp2
  long double v11; // fp2
  int valueInteger; // r11
  char v13; // r9
  int v14; // ctr
  idRenderModel **v15; // r11
  _DWORD *v16; // r10
  int i; // ctr
  float *v18; // r11
  int j; // ctr
  idRotationTrackerRange v21; // [sp+60h] [-E0h] BYREF
  idAI2::idAnimWebDefaults v22; // [sp+70h] [-D0h] BYREF

  idActor::idActor(this);
  this->__vftable = (idAI2_vtbl *)&idAI2::`vftable';
  idAI2::idAIConstant::idAIConstant(this: &this->aiConstants);
  idAIEditable::idAIEditable(this: &this->aiEditable);
  idAI2::idAIVolatile::idAIVolatile(this: &this->aiVolatile);
  this->aiHealth.components[0].type = AI_HEALTH_MAX;
  this->aiHealth.components[1].type = AI_HEALTH_MAX;
  this->aiHealth.components[0].max = 100.0;
  this->aiHealth.components[0].cur = 100.0;
  this->aiHealth.components[1].max = 100.0;
  this->aiHealth.components[1].cur = 100.0;
  this->aiHealth.killThreshold = 0.0;
  this->aiHealth.accumulatedDamageFrame = -1;
  this->aiHealth.killingBlowDamage = 0.0;
  this->aiHealth.isDead = false;
  this->aiHealth.accumulatedFrameDamage = 0.0;
  this->aiHealth.components[0].type = AI_HEALTH_HITPOINTS;
  this->aiHealth.components[1].type = AI_HEALTH_SHIELD;
  this->aiHealth.lastShieldIntervalFrame = -1;
  this->aiHealth.shieldRegenDelay = 5.0;
  this->aiHealth.__vftable = (idAIHealth_vtbl *)&idAIHealth::`vftable';
  this->aiHealth.shieldRegenRate = 20.0;
  this->aiHealth.shieldRegenInterval = 1.0;
  idComponentActionScript::idComponentActionScript(this: &this->actionScript);
  idAIFSMCallback::idAIFSMCallback(this: &this->fsmCallback);
  idDynamicCoverMgr::idDynamicCoverMgr(this: &this->formationCover);
  this->formationCover.__vftable = (idFormationCoverMgr_vtbl *)&idFormationCoverMgr::`vftable';
  idEventReceiver::idEventReceiver(this: &this->scriptProxy);
  this->scriptProxy.owner = nullptr;
  this->scriptProxy.blocking = false;
  this->scriptProxy.__vftable = (idAIScriptProxy_vtbl *)&idAIScriptProxy::`vftable';
  idAI2Patch1::idAI2Patch1(this: &this->patch1);
  this->actorConstants.actorClass = ACTORCLASS_HUMAN;
  this->aiConstants.physics.playerCollisionSize.x = 0.0;
  this->aiConstants.physics.playerCollisionSize.y = 0.0;
  this->aiConstants.physics.playerCollisionSize.z = 0.0;
  this->aiConstants.physics.heightCrouched = 48.0;
  this->aiConstants.physics.aiPathfindRadius = 9.0;
  idContents::FromFlags(this: &this->aiConstants.physics.contents, flags: 0x20400u);
  idContents::FromFlags(this: &this->aiConstants.physics.clipMask, flags: 0x1A011u);
  idContents::FromFlags(this: &this->aiConstants.physics.playerClipMask, flags: 0);
  idStr::operator=(this: &this->aiConstants.movement.aasName, text: &byte_8200D768);
  this->aiConstants.movement.moveSpeed.maxRange = 260.0;
  this->aiConstants.movement.moveSpeed.minRange = 60.0;
  this->aiConstants.movement.bodyTurnRate.minRange = 0.0;
  this->aiConstants.movement.bodyTurnRate.maxRange = 0.0;
  this->aiConstants.movement.moveTurnRate.minRange = 0.0;
  this->aiConstants.movement.moveTurnRate.maxRange = 0.0;
  this->aiConstants.movement.defaultMovementMode = AIMOVEMODE_GROUND;
  this->aiConstants.movement.accelRate = 640.0;
  this->aiConstants.movement.decelRate = 1280.0;
  *(double *)&v2 = 0.99984771;
  this->aiConstants.movement.alignmentTolerance.value = idMath::ACos(a: v2) * idMath::M_RAD2DEG;
  *(_WORD *)&this->aiConstants.movement.useMoveFSM = 1;
  this->aiConstants.animation.animWebs[0] = nullptr;
  v3 = idAI2::idAnimWebDefaults::idAnimWebDefaults(
         this: &v22,
         subWebName_: "$weaponrelaxed",
         stateName_: "idle",
         enabled_: true);
  allocedAndFlag = this->aiConstants.animation.animWebDefaults[0].webPath.allocedAndFlag;
  len = v3->webPath.len;
  v6 = v3->webPath.len + 1;
  if ( allocedAndFlag >= 0 )
  {
    if ( v6 > (allocedAndFlag & 0x7FFFFFFF) )
      idStr::ReAllocate(this: &this->aiConstants.animation.animWebDefaults[0].webPath, amount: v6, keepold: false);
  }
  else if ( v6 > (allocedAndFlag & 0x7FFFFFFF)
         && AssertFailed(
              file: "w:\\tech5\\shared\\idlib\\text/Str.h",
              line: 463,
              expression: "amount <= GetAlloced()",
              inlineBreak: true) )
  {
    __trap();
  }
  memcpy(Dst: this->aiConstants.animation.animWebDefaults[0].webPath.data, Src: v3->webPath.data, Size: len);
  this->aiConstants.animation.animWebDefaults[0].webPath.data[len] = 0;
  this->aiConstants.animation.animWebDefaults[0].webPath.len = len;
  idList<idAtomicString,109>::operator=(
    this: (idList<idAtomicString,109> *)&this->aiConstants.animation.animWebDefaults[0].activeLayers,
    other: (const idList<idAtomicString,109> *)&v3->activeLayers);
  this->aiConstants.animation.animWebDefaults[0].enabled = v3->enabled;
  if ( v22.activeLayers.listStatic == 0 || v22.activeLayers.listStatic == 2 )
  {
    if ( v22.activeLayers.list != nullptr )
      idMem::Free(this: &mem, ptr: v22.activeLayers.list, align: ALIGN_16);
    v22.activeLayers.list = nullptr;
    v22.activeLayers.size = 0;
  }
  v22.activeLayers.num = 0;
  idStr::FreeData(this: &v22.webPath);
  v7 = *((_BYTE *)&this->aiConstants.animation + 93);
  *((_BYTE *)&this->aiConstants.animation + 92) &= 8u;
  *((_BYTE *)&this->aiConstants.animation + 93) = v7 & 0x7F;
  idStr::operator=(this: &this->aiConstants.animation.eyeInfoName, text: idEyeInfoCollection::DEFAULT_NAME);
  v8 = *((_BYTE *)&this->aiConstants.animation + 93);
  this->aiConstants.onlineScoring.heavy = false;
  value = this->aiEditable.perception.fieldOfView.value;
  *((_BYTE *)&this->aiConstants.animation + 93) = v8 & 0x83;
  *(double *)&v10 = (float)((float)((float)value * (float)0.5) * idMath::M_DEG2RAD);
  v11 = cos(x: v10);
  this->aiVolatile.perception.fovDot = *(double *)&v11;
  this->aiVolatile.physics.extendedClipModelStatus = AIEXTENDEDCLIPMODELSTATUS_NONE;
  this->aiVolatile.physics.extendedClipModelEndTime = 0;
  this->aiVolatile.physics.extendedClipModel = nullptr;
  this->aiVolatile.physics.movePushEndTime = 0;
  this->aiVolatile.physics.restoreSolidCollisionTime = 0;
  v21.minYaw = -90.0;
  this->aiVolatile.animation.subWeb = AISUBWEB_RELAXED;
  v21.maxYaw = 90.0;
  this->aiVolatile.animation.meleeFlags = 0;
  v21.minPitch = -80.0;
  this->aiVolatile.animation.crouchMeleeFlags = 0;
  v21.maxPitch = 80.0;
  idFocusInfo::SetConstraints(this: this->aiVolatile.focus.foci.ptr, constraints: &v21);
  idFocusInfo::SetConstraints(this: &this->aiVolatile.focus.foci.ptr[1], constraints: &v21);
  this->aiVolatile.facialInfo.currentFacialAnimSet = nullptr;
  this->aiVolatile.death.nextPainTime = 0;
  this->aiVolatile.death.ragdollAtRestTime = -1;
  this->aiVolatile.death.deathTime = -1;
  this->aiVolatile.fireControl = nullptr;
  valueInteger = ai_maxDeferDeathTime.valueInteger;
  v13 = *((_BYTE *)&this->aiVolatile.death + 1761) & 0x3F;
  this->aiVolatile.fsms.alertCycle = ALERTCYCLE_MAX;
  this->aiVolatile.fsms.previousAlertCycle = ALERTCYCLE_MAX;
  *((_BYTE *)&this->aiVolatile.death + 1761) = v13;
  this->aiVolatile.fsms.suspend = false;
  this->aiVolatile.death.maxDeferDeathTime = valueInteger;
  *((_BYTE *)&this->aiVolatile.death + 1760) = 0;
  this->aiVolatile.aas.aas = nullptr;
  this->aiVolatile.aas.travelFlags = 0;
  this->aiVolatile.headTracking.targetKickOffset.pitch = 0.0;
  this->aiVolatile.headTracking.targetKickOffset.yaw = 0.0;
  this->aiVolatile.headTracking.targetKickOffset.roll = 0.0;
  this->aiVolatile.headTracking.curKickOffset.pitch = 0.0;
  this->aiVolatile.headTracking.curKickOffset.yaw = 0.0;
  this->aiVolatile.headTracking.curKickOffset.roll = 0.0;
  this->aiVolatile.headTracking.kickAccelRate.pitch = 180.0;
  this->aiVolatile.headTracking.kickAccelRate.yaw = 360.0;
  this->aiVolatile.headTracking.kickAccelRate.roll = 0.0;
  this->aiVolatile.headTracking.kickDecelRate.pitch = 60.0;
  this->aiVolatile.headTracking.kickDecelRate.yaw = 90.0;
  this->aiVolatile.headTracking.kickDecelRate.roll = 0.0;
  this->aiVolatile.dodging.nextDodgeTime = 0;
  this->aiVolatile.aiEvents.overloadDisableFlags = 0;
  this->aiVolatile.dodging.preDodgeMoveMode = AIMOVEMODE_GROUND;
  this->aiVolatile.cover.coverAction = COVERACTION_NONE;
  this->aiVolatile.cover.coverActionToAvoid = COVERACTION_NONE;
  this->aiVolatile.aiEvents.overloadEnableFlags = 0;
  this->aiVolatile.aiEvents.flags = -1048577;
  this->aiVolatile.cover.coverOrientation = COVERORIENT_BACKWARD;
  this->aiVolatile.aiEvents.nextAIEventTime = 0;
  this->aiVolatile.eyeTracking.eyeInfoHandle = NULL_EYE_INFO_12;
  this->aiVolatile.playerControl.player.spawnId.value = 0x1FFF;
  this->aiVolatile.playerControl.minHealth = 0.0;
  this->aiVolatile.playerControl.startControlTime = 0;
  this->aiVolatile.playerControl.endControlTime = 0;
  this->aiVolatile.playerControl.nextBeatTime = 0;
  this->aiVolatile.playerControl.heartBeatLub = true;
  v14 = 6;
  v15 = &this->aiVolatile.debugging.debugModels.ptr[5];
  this->aiVolatile.playerControl.bodyHitNormal = vec3_origin;
  this->aiVolatile.playerControl.viewAngle = ang_zero;
  this->aiVolatile.script.thread = nullptr;
  this->aiVolatile.playerControl.popping = false;
  this->aiVolatile.script.flags = 0;
  this->aiVolatile.script.currentAIEvent = nullptr;
  this->aiVolatile.script.lastAIEventClass = 0;
  this->aiVolatile.script.lastAIEventOrigin = vec3_origin;
  this->aiVolatile.perception.flags = 0;
  do
  {
    *(v15 - 5) = nullptr;
    *++v15 = nullptr;
    --v14;
  }
  while ( v14 != 0 );
  this->aiVolatile.debugging.modelLevel = AIDEBUGLEVEL_NONE;
  this->aiVolatile.debugging.soundLevel = AIDEBUGLEVEL_NONE;
  idStr::operator=(this: &this->aiVolatile.debugging.debugText, text: &byte_8200D768);
  this->aiVolatile.debugging.textLevel = AIDEBUGLEVEL_NONE;
  this->aiVolatile.debugging.errorFlags = 0;
  this->aiVolatile.debugging.modelIndex = -1;
  this->aiVolatile.debugging.soundIndex = -1;
  this->aiVolatile.dropState = -1;
  *((_BYTE *)&this->aiVolatile + 49704) = -118;
  this->aiVolatile.numActionNodes = 0;
  v16 = (_DWORD *)&this->aiVolatile.dropToGroundQuery.index + 1;
  for ( i = 6; i != 0; --i )
    *++v16 = 0;
  v18 = &this->aiVolatile.playerDamageTaken.ptr[5];
  for ( j = 6; j != 0; --j )
    *++v18 = 0.0;
  this->aiVolatile.facialInfo.currentFacialAnimSet = nullptr;
  this->inventoryDecl = nullptr;
  this->takedownWindowClosed = -1;
  return this;
}


// ========================================================================
// __unwind$581789
// EA  : 0x82A299B8
// RVA : 0x00A299B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581789()
{
  int v0; // r12

  idActor::~idActor(this: *(idActor **)(v0 - 320 + 340));
}


// ========================================================================
// __unwind$581790
// EA  : 0x82A299E0
// RVA : 0x00A299E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581790()
{
  int v0; // r12

  idAI2::idAIConstant::~idAIConstant(this: (idAI2::idAIConstant *)(*(_DWORD *)(v0 - 320 + 340) + 10328));
}


// ========================================================================
// __unwind$581791
// EA  : 0x82A29A0C
// RVA : 0x00A29A0C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581791()
{
  int v0; // r12

  idAIEditable::~idAIEditable(this: (idAIEditable *)(*(_DWORD *)(v0 - 320 + 340) + 10560));
}


// ========================================================================
// __unwind$581792
// EA  : 0x82A29A38
// RVA : 0x00A29A38
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581792()
{
  int v0; // r12

  idAI2::idAIVolatile::~idAIVolatile(this: (idAI2::idAIVolatile *)(*(_DWORD *)(v0 - 320 + 340) + 11520));
}


// ========================================================================
// __unwind$581793
// EA  : 0x82A29A64
// RVA : 0x00A29A64
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581793()
{
  int v0; // r12

  idSimpleHealth::~idSimpleHealth(this: (idAIHealth *)(*(_DWORD *)(v0 - 320 + 340) + 61488));
}


// ========================================================================
// __unwind$581794
// EA  : 0x82A29A98
// RVA : 0x00A29A98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581794()
{
  int v0; // r12

  idComponentActionScript::~idComponentActionScript(this: (idComponentActionScript *)(*(_DWORD *)(v0 - 320 + 340) + 61552));
}


// ========================================================================
// __unwind$581795
// EA  : 0x82A29ACC
// RVA : 0x00A29ACC
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581795()
{
  int v0; // r12

  idAIFSMCallback::~idAIFSMCallback(this: (idAIFSMCallback *)(*(_DWORD *)(v0 - 320 + 340) + 61592));
}


// ========================================================================
// __unwind$581796
// EA  : 0x82A29B00
// RVA : 0x00A29B00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581796()
{
  int v0; // r12

  idFormationCoverMgr::~idFormationCoverMgr(this: (idVehicleCoverMgr *)(*(_DWORD *)(v0 - 320 + 340) + 61624));
}


// ========================================================================
// __unwind$581797
// EA  : 0x82A29B34
// RVA : 0x00A29B34
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581797()
{
  int v0; // r12

  idAIScriptProxy::~idAIScriptProxy(this: (idAIScriptProxy *)(*(_DWORD *)(v0 - 320 + 340) + 61652));
}


// ========================================================================
// __unwind$581798
// EA  : 0x82A29B68
// RVA : 0x00A29B68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581798()
{
  int v0; // r12

  idAI2Patch1::~idAI2Patch1(this: (idAI2Patch1 *)(*(_DWORD *)(v0 - 320 + 340) + 61672));
}


// ========================================================================
// __unwind$581799
// EA  : 0x82A29B9C
// RVA : 0x00A29B9C
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581799()
{
  int v0; // r12

  idAI2::idAnimWebDefaults::~idAnimWebDefaults(this: (idAI2::idAnimWebDefaults *)(v0 - 320 + 112));
}


// ========================================================================
// __unwind$581992
// EA  : 0x82A29BC4
// RVA : 0x00A29BC4
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void _unwind_581992()
{
  int v0; // r12

  idStrStatic<260>::~idStrStatic<260>(this: (idStr *)(v0 - 320 + 112));
}


// ========================================================================
// `dynamic initializer for 'ai_limitFSMUpdates''
// EA  : 0x833641F8
// RVA : 0x013641F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_limitFSMUpdates__()
{
  idCVar::idCVar(
    this: &ai_limitFSMUpdates,
    name: "ai_limitFSMUpdates",
    value: "1",
    flags: 1,
    description: "1 = don't allow AI FSM logic to update faster than 10Hz",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_limitFSMUpdates__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugLevel''
// EA  : 0x83364250
// RVA : 0x01364250
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugLevel__()
{
  idCVar::idCVar(
    this: &ai_debugLevel,
    name: "ai_debugLevel",
    value: "0",
    flags: 2,
    description: "1 = show debug models for errors only, 2 = show talking & interaction state, 3 = show leg state, 4 = show torso state",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugLevel__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugTracking''
// EA  : 0x833642A8
// RVA : 0x013642A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugTracking__()
{
  idCVar::idCVar(
    this: &ai_debugTracking,
    name: "ai_debugTracking",
    value: "0",
    flags: 2,
    description: "1 = show aim and look tracking information",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugTracking__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugHealth''
// EA  : 0x83364300
// RVA : 0x01364300
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugHealth__()
{
  idCVar::idCVar(
    this: &ai_debugHealth,
    name: "ai_debugHealth",
    value: "0",
    flags: 2,
    description: "1 = show health bar above ai, 2 = show text at damage location on ai, 3 = show health text above ai",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugHealth__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugEvents''
// EA  : 0x83364358
// RVA : 0x01364358
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugEvents__()
{
  idCVar::idCVar(
    this: &ai_debugEvents,
    name: "ai_debugEvents",
    value: "0",
    flags: 2,
    description: "1 = show debug info for received AI events",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugEvents__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugState''
// EA  : 0x833643B0
// RVA : 0x013643B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugState__()
{
  idCVar::idCVar(
    this: &ai_debugState,
    name: "ai_debugState",
    value: "0",
    flags: 2,
    description: "1 = show ai state information for debug entity, 2 = show for all ai, 3 = break on state Enter, 4 = break on state Ex"
    "it, 5 = break on state Work",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugState__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugAim''
// EA  : 0x83364408
// RVA : 0x01364408
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugAim__()
{
  idCVar::idCVar(
    this: &ai_debugAim,
    name: "ai_debugAim",
    value: "0",
    flags: 2,
    description: "set to 1 to show aim point debug info",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugAim__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugLook''
// EA  : 0x83364460
// RVA : 0x01364460
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugLook__()
{
  idCVar::idCVar(
    this: &ai_debugLook,
    name: "ai_debugLook",
    value: "0",
    flags: 2,
    description: "set to 1 to show look point debug info ",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugLook__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugOrientation''
// EA  : 0x833644B8
// RVA : 0x013644B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugOrientation__()
{
  idCVar::idCVar(
    this: &ai_debugOrientation,
    name: "ai_debugOrientation",
    value: "0",
    flags: 2,
    description: "1 - show body, 2 - show move, 3 - show both",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugOrientation__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugCover''
// EA  : 0x83364510
// RVA : 0x01364510
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugCover__()
{
  idCVar::idCVar(
    this: &ai_debugCover,
    name: "ai_debugCover",
    value: "0",
    flags: 2,
    description: "show debug info for cover determination",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugCover__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugCoverActions''
// EA  : 0x83364568
// RVA : 0x01364568
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugCoverActions__()
{
  idCVar::idCVar(
    this: &ai_debugCoverActions,
    name: "ai_debugCoverActions",
    value: "0",
    flags: 1,
    description: "show cover action choice",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugCoverActions__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugCoverEntityId''
// EA  : 0x833645C0
// RVA : 0x013645C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugCoverEntityId__()
{
  idCVar::idCVar(
    this: &ai_debugCoverEntityId,
    name: "ai_debugCoverEntityId",
    value: "0",
    flags: 2,
    description: "0: debug cover for all entities, > 0: debug cover for specified entity only",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugCoverEntityId__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugEnemy''
// EA  : 0x83364618
// RVA : 0x01364618
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugEnemy__()
{
  idCVar::idCVar(
    this: &ai_debugEnemy,
    name: "ai_debugEnemy",
    value: "0",
    flags: 2,
    description: "1 = show debug lines for enemy debugging, 2 = show console prints also",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugEnemy__);
}


// ========================================================================
// `dynamic initializer for 'ai_visibilitySenseScale''
// EA  : 0x83364670
// RVA : 0x01364670
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_visibilitySenseScale__()
{
  idCVar::idCVar(
    this: &ai_visibilitySenseScale,
    name: "ai_visibilitySenseScale",
    value: "1",
    flags: 4,
    description: "scale of AI visual sensory input",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_visibilitySenseScale__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableSenseVolumes''
// EA  : 0x833646C8
// RVA : 0x013646C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableSenseVolumes__()
{
  idCVar::idCVar(
    this: &ai_enableSenseVolumes,
    name: "ai_enableSenseVolumes",
    value: "1",
    flags: 1,
    description: "true to enable designer placed sense scale volumes, false to disable for debugging",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableSenseVolumes__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugSearch''
// EA  : 0x83364720
// RVA : 0x01364720
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugSearch__()
{
  idCVar::idCVar(
    this: &ai_debugSearch,
    name: "ai_debugSearch",
    value: "0",
    flags: 1,
    description: "true to enable search debugging",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugSearch__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugFriendly''
// EA  : 0x83364778
// RVA : 0x01364778
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugFriendly__()
{
  idCVar::idCVar(
    this: &ai_debugFriendly,
    name: "ai_debugFriendly",
    value: "0",
    flags: 1,
    description: "true to enable friendly debugging",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugFriendly__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugPain''
// EA  : 0x833647D0
// RVA : 0x013647D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugPain__()
{
  idCVar::idCVar(
    this: &ai_debugPain,
    name: "ai_debugPain",
    value: "0",
    flags: 2,
    description: "1 = show debug output for pain and death, 2 = show traces that indicate if AI is at moving pain speed",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugPain__);
}


// ========================================================================
// `dynamic initializer for 'ai_newMovingPainTest''
// EA  : 0x83364828
// RVA : 0x01364828
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_newMovingPainTest__()
{
  idCVar::idCVar(
    this: &ai_newMovingPainTest,
    name: "ai_newMovingPainTest",
    value: "1",
    flags: 2,
    description: "0 = use old alert cycle moving pain test, 1 = use ai2 moving pain test",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_newMovingPainTest__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugInjured''
// EA  : 0x83364880
// RVA : 0x01364880
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugInjured__()
{
  idCVar::idCVar(
    this: &ai_debugInjured,
    name: "ai_debugInjured",
    value: "0",
    flags: 1,
    description: "1 = show debug output for injured state",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugInjured__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugDeath''
// EA  : 0x833648D8
// RVA : 0x013648D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugDeath__()
{
  idCVar::idCVar(
    this: &ai_debugDeath,
    name: "ai_debugDeath",
    value: "0",
    flags: 1,
    description: "1 = show debug output for death",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugDeath__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugVoice''
// EA  : 0x83364930
// RVA : 0x01364930
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugVoice__()
{
  idCVar::idCVar(
    this: &ai_debugVoice,
    name: "ai_debugVoice",
    value: "0",
    flags: 2,
    description: "set to >= 1 to show voice calls, 2 for sound traces",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugVoice__);
}


// ========================================================================
// `dynamic initializer for 'ai_useCombatSubtitles''
// EA  : 0x83364988
// RVA : 0x01364988
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useCombatSubtitles__()
{
  idCVar::idCVar(
    this: &ai_useCombatSubtitles,
    name: "ai_useCombatSubtitles",
    value: "0",
    flags: 2,
    description: "set to = 1 to show combat subtitles",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useCombatSubtitles__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugTargetList''
// EA  : 0x833649E0
// RVA : 0x013649E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugTargetList__()
{
  idCVar::idCVar(
    this: &ai_debugTargetList,
    name: "ai_debugTargetList",
    value: "0",
    flags: 2,
    description: "set to 1 to show ai targeting weights",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugTargetList__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugEnemyTargetSelector''
// EA  : 0x83364A38
// RVA : 0x01364A38
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugEnemyTargetSelector__()
{
  idCVar::idCVar(
    this: &ai_debugEnemyTargetSelector,
    name: "ai_debugEnemyTargetSelector",
    value: "0",
    flags: 2,
    description: "set to -1 to show all enemy targeting weight factors, or entity # to show just that AI",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugEnemyTargetSelector__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugInteraction''
// EA  : 0x83364A90
// RVA : 0x01364A90
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugInteraction__()
{
  idCVar::idCVar(
    this: &ai_debugInteraction,
    name: "ai_debugInteraction",
    value: "0",
    flags: 1,
    description: "show interaction debug info",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugInteraction__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugInteractionDistance''
// EA  : 0x83364AE8
// RVA : 0x01364AE8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugInteractionDistance__()
{
  idCVar::idCVar(
    this: &ai_debugInteractionDistance,
    name: "ai_debugInteractionDistance",
    value: "0",
    flags: 1,
    description: "show spheres for interaction distances",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugInteractionDistance__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugInteraction_Approach''
// EA  : 0x83364B40
// RVA : 0x01364B40
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugInteraction_Approach__()
{
  idCVar::idCVar(
    this: &ai_debugInteraction_Approach,
    name: "ai_debugInteraction_Approach",
    value: "0",
    flags: 4,
    description: "if not zero, use this value as the approach radius",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugInteraction_Approach__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugInteraction_Departure''
// EA  : 0x83364B98
// RVA : 0x01364B98
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugInteraction_Departure__()
{
  idCVar::idCVar(
    this: &ai_debugInteraction_Departure,
    name: "ai_debugInteraction_Departure",
    value: "0",
    flags: 4,
    description: "if not zero, use this value as the departure radius",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugInteraction_Departure__);
}


// ========================================================================
// `dynamic initializer for 'ai_fastJobInteraction''
// EA  : 0x83364BF0
// RVA : 0x01364BF0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_fastJobInteraction__()
{
  idCVar::idCVar(
    this: &ai_fastJobInteraction,
    name: "ai_fastJobInteraction",
    value: "0",
    flags: 1,
    description: "if true, the player can interupt the ai talking to go to next state",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_fastJobInteraction__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugmelee''
// EA  : 0x83364C48
// RVA : 0x01364C48
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugmelee__()
{
  idCVar::idCVar(
    this: &ai_debugmelee,
    name: "ai_debugmelee",
    value: "0",
    flags: 1,
    description: "if true, show meele attack direction and target extrapolation",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugmelee__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugOpenCombatMove''
// EA  : 0x83364CA0
// RVA : 0x01364CA0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugOpenCombatMove__()
{
  idCVar::idCVar(
    this: &ai_debugOpenCombatMove,
    name: "ai_debugOpenCombatMove",
    value: "0",
    flags: 1,
    description: "if true, show open combat move scoring",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugOpenCombatMove__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugLeapAttack''
// EA  : 0x83364CF8
// RVA : 0x01364CF8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugLeapAttack__()
{
  idCVar::idCVar(
    this: &ai_debugLeapAttack,
    name: "ai_debugLeapAttack",
    value: "0",
    flags: 1,
    description: "if true, show leap attack target and trace",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugLeapAttack__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugThrow''
// EA  : 0x83364D50
// RVA : 0x01364D50
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugThrow__()
{
  idCVar::idCVar(
    this: &ai_debugThrow,
    name: "ai_debugThrow",
    value: "0",
    flags: 1,
    description: "if true, show throw projectile trace",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugThrow__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugRage''
// EA  : 0x83364DA8
// RVA : 0x01364DA8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugRage__()
{
  idCVar::idCVar(
    this: &ai_debugRage,
    name: "ai_debugRage",
    value: "0",
    flags: 1,
    description: "if true, show rage states above ai",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugRage__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugTraversals''
// EA  : 0x83364E00
// RVA : 0x01364E00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugTraversals__()
{
  idCVar::idCVar(
    this: &ai_debugTraversals,
    name: "ai_debugTraversals",
    value: "0",
    flags: 2,
    description: "if > 0, show dynamic traversal visualization for value * 1000 milliseconds",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugTraversals__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugEyePos''
// EA  : 0x83364E58
// RVA : 0x01364E58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugEyePos__()
{
  idCVar::idCVar(
    this: &ai_debugEyePos,
    name: "ai_debugEyePos",
    value: "0",
    flags: 2,
    description: "number of milliseconds to show AI eye position markers.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugEyePos__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugEncounterGroupRoles''
// EA  : 0x83364EB0
// RVA : 0x01364EB0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugEncounterGroupRoles__()
{
  idCVar::idCVar(
    this: &ai_debugEncounterGroupRoles,
    name: "ai_debugEncounterGroupRoles",
    value: "0",
    flags: 2,
    description: "1: show encounter group role changes, 2: also draw combat hints for current stage",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugEncounterGroupRoles__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugCoverTransitions''
// EA  : 0x83364F08
// RVA : 0x01364F08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugCoverTransitions__()
{
  idCVar::idCVar(
    this: &ai_debugCoverTransitions,
    name: "ai_debugCoverTransitions",
    value: "0",
    flags: 2,
    description: "1 = ai show cover transition debug information, 2 = also show wall corner checking logic",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugCoverTransitions__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugStartTransitions''
// EA  : 0x83364F60
// RVA : 0x01364F60
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugStartTransitions__()
{
  idCVar::idCVar(
    this: &ai_debugStartTransitions,
    name: "ai_debugStartTransitions",
    value: "0",
    flags: 1,
    description: "1 = ai show start transition debug information",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugStartTransitions__);
}


// ========================================================================
// `dynamic initializer for 'ai_showAASName''
// EA  : 0x83364FB8
// RVA : 0x01364FB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_showAASName__()
{
  idCVar::idCVar(
    this: &ai_showAASName,
    name: "ai_showAASName",
    value: "0",
    flags: 1,
    description: "shows the name of the AAS that AI are using",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_showAASName__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugPathToEnemy''
// EA  : 0x83365010
// RVA : 0x01365010
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugPathToEnemy__()
{
  idCVar::idCVar(
    this: &ai_debugPathToEnemy,
    name: "ai_debugPathToEnemy",
    value: "0",
    flags: 1,
    description: "shows approach point from the enemy and path time",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugPathToEnemy__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugAnimDeltaScale''
// EA  : 0x83365068
// RVA : 0x01365068
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugAnimDeltaScale__()
{
  idCVar::idCVar(
    this: &ai_debugAnimDeltaScale,
    name: "ai_debugAnimDeltaScale",
    value: "0",
    flags: 1,
    description: "shows animation scaling from the DeltaScaleToTarget frame command",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugAnimDeltaScale__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugDeathVolumes''
// EA  : 0x833650C0
// RVA : 0x013650C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugDeathVolumes__()
{
  idCVar::idCVar(
    this: &ai_debugDeathVolumes,
    name: "ai_debugDeathVolumes",
    value: "0",
    flags: 1,
    description: "1 = show debug orientation for death volumes for ai's.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugDeathVolumes__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugBlendTree''
// EA  : 0x83365118
// RVA : 0x01365118
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugBlendTree__()
{
  idCVar::idCVar(
    this: &ai_debugBlendTree,
    name: "ai_debugBlendTree",
    value: "-1",
    flags: 2,
    description: ">= 0, entity number of AI to debug the blend tree for",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugBlendTree__);
}


// ========================================================================
// `dynamic initializer for 'ai_blendTreeName''
// EA  : 0x83365170
// RVA : 0x01365170
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_blendTreeName__()
{
  idCVar::idCVar(
    this: &ai_blendTreeName,
    name: "ai_blendTreeName",
    value: &byte_8200D768,
    flags: 0,
    description: "name of blend tree to debug",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_blendTreeName__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugDodge''
// EA  : 0x833651C8
// RVA : 0x013651C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugDodge__()
{
  idCVar::idCVar(
    this: &ai_debugDodge,
    name: "ai_debugDodge",
    value: "0",
    flags: 2,
    description: "1 to show dive resapons, 2 to show decision lines",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugDodge__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugAvoid''
// EA  : 0x83365220
// RVA : 0x01365220
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugAvoid__()
{
  idCVar::idCVar(
    this: &ai_debugAvoid,
    name: "ai_debugAvoid",
    value: "0",
    flags: 1,
    description: "true to show avoid decision lines",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugAvoid__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugPanic''
// EA  : 0x83365278
// RVA : 0x01365278
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugPanic__()
{
  idCVar::idCVar(
    this: &ai_debugPanic,
    name: "ai_debugPanic",
    value: "0",
    flags: 1,
    description: "true to show panic decision lines",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugPanic__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugConfidence''
// EA  : 0x833652D0
// RVA : 0x013652D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugConfidence__()
{
  idCVar::idCVar(
    this: &ai_debugConfidence,
    name: "ai_debugConfidence",
    value: "0",
    flags: 1,
    description: "true to show confidence factors",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugConfidence__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableConfidence''
// EA  : 0x83365328
// RVA : 0x01365328
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableConfidence__()
{
  idCVar::idCVar(
    this: &ai_enableConfidence,
    name: "ai_enableConfidence",
    value: "1",
    flags: 1,
    description: "false to disable confidence updating",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableConfidence__);
}


// ========================================================================
// `dynamic initializer for 'ai_useAimTracker''
// EA  : 0x83365380
// RVA : 0x01365380
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useAimTracker__()
{
  idCVar::idCVar(
    this: &ai_useAimTracker,
    name: "ai_useAimTracker",
    value: "1",
    flags: 1,
    description: "0 = disable aim tracking",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useAimTracker__);
}


// ========================================================================
// `dynamic initializer for 'ai_useLookTracker''
// EA  : 0x833653D8
// RVA : 0x013653D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useLookTracker__()
{
  idCVar::idCVar(
    this: &ai_useLookTracker,
    name: "ai_useLookTracker",
    value: "1",
    flags: 1,
    description: "0 = disable look tracking",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useLookTracker__);
}


// ========================================================================
// `dynamic initializer for 'ai_useWanderingAim''
// EA  : 0x83365430
// RVA : 0x01365430
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useWanderingAim__()
{
  idCVar::idCVar(
    this: &ai_useWanderingAim,
    name: "ai_useWanderingAim",
    value: "1",
    flags: 1,
    description: "set to 1 to use realistic wandering aim model",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useWanderingAim__);
}


// ========================================================================
// `dynamic initializer for 'ai_useWeaponSpread''
// EA  : 0x83365488
// RVA : 0x01365488
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useWeaponSpread__()
{
  idCVar::idCVar(
    this: &ai_useWeaponSpread,
    name: "ai_useWeaponSpread",
    value: "1",
    flags: 1,
    description: "set to 1 to add spread to aim model",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useWeaponSpread__);
}


// ========================================================================
// `dynamic initializer for 'ai_useGrenades''
// EA  : 0x833654E0
// RVA : 0x013654E0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useGrenades__()
{
  idCVar::idCVar(
    this: &ai_useGrenades,
    name: "ai_useGrenades",
    value: "1",
    flags: 1,
    description: "0 = ai will never throw grenades",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useGrenades__);
}


// ========================================================================
// `dynamic initializer for 'ai_useTransitions''
// EA  : 0x83365538
// RVA : 0x01365538
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useTransitions__()
{
  idCVar::idCVar(
    this: &ai_useTransitions,
    name: "ai_useTransitions",
    value: "1",
    flags: 1,
    description: "0 = disable all transition types",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useTransitions__);
}


// ========================================================================
// `dynamic initializer for 'ai_useCoverTransitions''
// EA  : 0x83365590
// RVA : 0x01365590
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useCoverTransitions__()
{
  idCVar::idCVar(
    this: &ai_useCoverTransitions,
    name: "ai_useCoverTransitions",
    value: "1",
    flags: 1,
    description: "1 = ai will use cover transitions (requires ai_useTransitions)",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useCoverTransitions__);
}


// ========================================================================
// `dynamic initializer for 'ai_enable''
// EA  : 0x833655E8
// RVA : 0x013655E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enable__()
{
  idCVar::idCVar(
    this: &ai_enable,
    name: "ai_enable",
    value: "1",
    flags: 1,
    description: "enable AI think",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enable__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableWorldState''
// EA  : 0x83365640
// RVA : 0x01365640
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableWorldState__()
{
  idCVar::idCVar(
    this: &ai_enableWorldState,
    name: "ai_enableWorldState",
    value: "1",
    flags: 1,
    description: "enable AI world state updates",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableWorldState__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableFSM''
// EA  : 0x83365698
// RVA : 0x01365698
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableFSM__()
{
  idCVar::idCVar(
    this: &ai_enableFSM,
    name: "ai_enableFSM",
    value: "1",
    flags: 1,
    description: "enable finite state machine updates",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableFSM__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableAnimation''
// EA  : 0x833656F0
// RVA : 0x013656F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableAnimation__()
{
  idCVar::idCVar(
    this: &ai_enableAnimation,
    name: "ai_enableAnimation",
    value: "1",
    flags: 1,
    description: "enable AI animation updates",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableAnimation__);
}


// ========================================================================
// `dynamic initializer for 'ai_enablePhysics''
// EA  : 0x83365748
// RVA : 0x01365748
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enablePhysics__()
{
  idCVar::idCVar(
    this: &ai_enablePhysics,
    name: "ai_enablePhysics",
    value: "1",
    flags: 1,
    description: "enable AI physics",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enablePhysics__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableMovement''
// EA  : 0x833657A0
// RVA : 0x013657A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableMovement__()
{
  idCVar::idCVar(
    this: &ai_enableMovement,
    name: "ai_enableMovement",
    value: "1",
    flags: 1,
    description: "enable AI movement",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableMovement__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableDormancy''
// EA  : 0x833657F8
// RVA : 0x013657F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableDormancy__()
{
  idCVar::idCVar(
    this: &ai_enableDormancy,
    name: "ai_enableDormancy",
    value: "1",
    flags: 1,
    description: "1 = AI that is not rendered will stop thinking",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableDormancy__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableAutoFocus''
// EA  : 0x83365850
// RVA : 0x01365850
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableAutoFocus__()
{
  idCVar::idCVar(
    this: &ai_enableAutoFocus,
    name: "ai_enableAutoFocus",
    value: "1",
    flags: 1,
    description: "0 = no auto focusing",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableAutoFocus__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableDodge''
// EA  : 0x833658A8
// RVA : 0x013658A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableDodge__()
{
  idCVar::idCVar(
    this: &ai_enableDodge,
    name: "ai_enableDodge",
    value: "1",
    flags: 1,
    description: "0 = disable diving/dodging",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableDodge__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableMovingPains''
// EA  : 0x83365900
// RVA : 0x01365900
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableMovingPains__()
{
  idCVar::idCVar(
    this: &ai_enableMovingPains,
    name: "ai_enableMovingPains",
    value: "1",
    flags: 1,
    description: "false to disable moving pains (stumbles)",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableMovingPains__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableInjuredRuns''
// EA  : 0x83365958
// RVA : 0x01365958
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableInjuredRuns__()
{
  idCVar::idCVar(
    this: &ai_enableInjuredRuns,
    name: "ai_enableInjuredRuns",
    value: "1",
    flags: 1,
    description: "false to disable injured runs",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableInjuredRuns__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugGore''
// EA  : 0x833659B0
// RVA : 0x013659B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugGore__()
{
  idCVar::idCVar(
    this: &ai_debugGore,
    name: "ai_debugGore",
    value: "0",
    flags: 1,
    description: "true to debug gore at ai level",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugGore__);
}


// ========================================================================
// `dynamic initializer for 'ai_lotsOfInjuries''
// EA  : 0x83365A08
// RVA : 0x01365A08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_lotsOfInjuries__()
{
  idCVar::idCVar(
    this: &ai_lotsOfInjuries,
    name: "ai_lotsOfInjuries",
    value: "0",
    flags: 1,
    description: "true to make AI injured whenver possible",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_lotsOfInjuries__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableScrambles''
// EA  : 0x83365A60
// RVA : 0x01365A60
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableScrambles__()
{
  idCVar::idCVar(
    this: &ai_enableScrambles,
    name: "ai_enableScrambles",
    value: "1",
    flags: 1,
    description: "true to enable AI scramble runs and transitions",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableScrambles__);
}


// ========================================================================
// `dynamic initializer for 'ai_scrambleTime''
// EA  : 0x83365AB8
// RVA : 0x01365AB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_scrambleTime__()
{
  idCVar::idCVar(
    this: &ai_scrambleTime,
    name: "ai_scrambleTime",
    value: "2000",
    flags: 2,
    description: "ms for AI to scramble after being shot at",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_scrambleTime__);
}


// ========================================================================
// `dynamic initializer for 'ai_searchToStimDist''
// EA  : 0x83365B10
// RVA : 0x01365B10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_searchToStimDist__()
{
  idCVar::idCVar(
    this: &ai_searchToStimDist,
    name: "ai_searchToStimDist",
    value: "512",
    flags: 4,
    description: "how far from a search stimulus AI will first search to that stimulus",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_searchToStimDist__);
}


// ========================================================================
// `dynamic initializer for 'ai_dontUseHintTime''
// EA  : 0x83365B68
// RVA : 0x01365B68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_dontUseHintTime__()
{
  idCVar::idCVar(
    this: &ai_dontUseHintTime,
    name: "ai_dontUseHintTime",
    value: "5000",
    flags: 2,
    description: "milliseconds to disable hint after being shot at",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_dontUseHintTime__);
}


// ========================================================================
// `dynamic initializer for 'ai_mood''
// EA  : 0x83365BC0
// RVA : 0x01365BC0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_mood__()
{
  idCVar::idCVar(
    this: &ai_mood,
    name: "ai_mood",
    value: "-1",
    flags: 2,
    description: "override's the mood of all AI for testing",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_mood__);
}


// ========================================================================
// `dynamic initializer for 'ai_attitude''
// EA  : 0x83365C18
// RVA : 0x01365C18
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_attitude__()
{
  idCVar::idCVar(
    this: &ai_attitude,
    name: "ai_attitude",
    value: "-2",
    flags: 2,
    description: "override AIs attitude towards player faction",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_attitude__);
}


// ========================================================================
// `dynamic initializer for 'ai_otherFactionAttitude''
// EA  : 0x83365C70
// RVA : 0x01365C70
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_otherFactionAttitude__()
{
  idCVar::idCVar(
    this: &ai_otherFactionAttitude,
    name: "ai_otherFactionAttitude",
    value: "-2",
    flags: 2,
    description: "override AIs attitude towards all other factions",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_otherFactionAttitude__);
}


// ========================================================================
// `dynamic initializer for 'ai_accuracy''
// EA  : 0x83365CC8
// RVA : 0x01365CC8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_accuracy__()
{
  idCVar::idCVar(
    this: &ai_accuracy,
    name: "ai_accuracy",
    value: "-1",
    flags: 2,
    description: "set to >= 0 to force all AI to a specific accuracy rating",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_accuracy__);
}


// ========================================================================
// `dynamic initializer for 'ai_lookRate''
// EA  : 0x83365D20
// RVA : 0x01365D20
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_lookRate__()
{
  idCVar::idCVar(
    this: &ai_lookRate,
    name: "ai_lookRate",
    value: "-1",
    flags: 2,
    description: "set to >= 0 to force all AI to a specific look rate",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_lookRate__);
}


// ========================================================================
// `dynamic initializer for 'ai_keepShootingNoSight''
// EA  : 0x83365D78
// RVA : 0x01365D78
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_keepShootingNoSight__()
{
  idCVar::idCVar(
    this: &ai_keepShootingNoSight,
    name: "ai_keepShootingNoSight",
    value: "6000",
    flags: 2,
    description: "number of milliseconds AI will shoot at last known enemy position",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_keepShootingNoSight__);
}


// ========================================================================
// `dynamic initializer for 'ai_showFOV''
// EA  : 0x83365DD0
// RVA : 0x01365DD0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_showFOV__()
{
  idCVar::idCVar(
    this: &ai_showFOV,
    name: "ai_showFOV",
    value: "0",
    flags: 2,
    description: "1 = show the AI's field of view, 2 = show fov and perception radius",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_showFOV__);
}


// ========================================================================
// `dynamic initializer for 'ai_weaponKick''
// EA  : 0x83365E28
// RVA : 0x01365E28
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_weaponKick__()
{
  idCVar::idCVar(
    this: &ai_weaponKick,
    name: "ai_weaponKick",
    value: "1",
    flags: 1,
    description: "true to apply weapon kick to AI aiming.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_weaponKick__);
}


// ========================================================================
// `dynamic initializer for 'ai_faceFocus''
// EA  : 0x83365E80
// RVA : 0x01365E80
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_faceFocus__()
{
  idCVar::idCVar(
    this: &ai_faceFocus,
    name: "ai_faceFocus",
    value: "0",
    flags: 1,
    description: "true to have AI always look at focus",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_faceFocus__);
}


// ========================================================================
// `dynamic initializer for 'ai_lookAtPlayer''
// EA  : 0x83365ED8
// RVA : 0x01365ED8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_lookAtPlayer__()
{
  idCVar::idCVar(
    this: &ai_lookAtPlayer,
    name: "ai_lookAtPlayer",
    value: "1",
    flags: 1,
    description: "npc looks at player when near",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_lookAtPlayer__);
}


// ========================================================================
// `dynamic initializer for 'ai_allowStaggerPain''
// EA  : 0x83365F30
// RVA : 0x01365F30
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_allowStaggerPain__()
{
  idCVar::idCVar(
    this: &ai_allowStaggerPain,
    name: "ai_allowStaggerPain",
    value: "1",
    flags: 1,
    description: "1 = allow AI to play staggering pains when appropriate",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_allowStaggerPain__);
}


// ========================================================================
// `dynamic initializer for 'ai_invulnerable''
// EA  : 0x83365F88
// RVA : 0x01365F88
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_invulnerable__()
{
  idCVar::idCVar(
    this: &ai_invulnerable,
    name: "ai_invulnerable",
    value: "0",
    flags: 1,
    description: "1 = ai's health never goes down when damaged.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_invulnerable__);
}


// ========================================================================
// `dynamic initializer for 'ai_ignoreEvents''
// EA  : 0x83365FE0
// RVA : 0x01365FE0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_ignoreEvents__()
{
  idCVar::idCVar(
    this: &ai_ignoreEvents,
    name: "ai_ignoreEvents",
    value: "0",
    flags: 1,
    description: "1 = ai will ignore events from the AI event system",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_ignoreEvents__);
}


// ========================================================================
// `dynamic initializer for 'ai_forceWalk''
// EA  : 0x83366038
// RVA : 0x01366038
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_forceWalk__()
{
  idCVar::idCVar(
    this: &ai_forceWalk,
    name: "ai_forceWalk",
    value: "0",
    flags: 2,
    description: "forces the AI's walking state to the specified value",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_forceWalk__);
}


// ========================================================================
// `dynamic initializer for 'ai_walkMod''
// EA  : 0x83366090
// RVA : 0x01366090
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_walkMod__()
{
  idCVar::idCVar(
    this: &ai_walkMod,
    name: "ai_walkMod",
    value: &byte_8200D768,
    flags: 0,
    description: "forces AI to use the specified aiWalkModifier_t state when walking",
    valueCompletion: (const char **)idCmdSystem::ArgCompletion_String<&char const * * aiWalkModifierNames,7>);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_walkMod__);
}


// ========================================================================
// `dynamic initializer for 'ai_runMod''
// EA  : 0x833660E8
// RVA : 0x013660E8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_runMod__()
{
  idCVar::idCVar(
    this: &ai_runMod,
    name: "ai_runMod",
    value: &byte_8200D768,
    flags: 0,
    description: "forces AI to use the specified aiWalkModifier_t state when walking",
    valueCompletion: (const char **)idCmdSystem::ArgCompletion_String<&char const * * aiWalkModifierNames,7>);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_runMod__);
}


// ========================================================================
// `dynamic initializer for 'ai_forceTurnRate''
// EA  : 0x83366140
// RVA : 0x01366140
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_forceTurnRate__()
{
  idCVar::idCVar(
    this: &ai_forceTurnRate,
    name: "ai_forceTurnRate",
    value: "0",
    flags: 1,
    description: "if != 0, force AI movement turn rates to ai_minTurnRate and ai_maxTurnRate.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_forceTurnRate__);
}


// ========================================================================
// `dynamic initializer for 'ai_minTurnRate''
// EA  : 0x83366198
// RVA : 0x01366198
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_minTurnRate__()
{
  idCVar::idCVar(
    this: &ai_minTurnRate,
    name: "ai_minTurnRate",
    value: "15",
    flags: 4,
    description: "minimum turn rate if turn rate is forced",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_minTurnRate__);
}


// ========================================================================
// `dynamic initializer for 'ai_maxTurnRate''
// EA  : 0x833661F0
// RVA : 0x013661F0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_maxTurnRate__()
{
  idCVar::idCVar(
    this: &ai_maxTurnRate,
    name: "ai_maxTurnRate",
    value: "360",
    flags: 4,
    description: "maximum turn rate if turn rate is forced",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_maxTurnRate__);
}


// ========================================================================
// `dynamic initializer for 'ai_moveModeLookAhead''
// EA  : 0x83366248
// RVA : 0x01366248
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_moveModeLookAhead__()
{
  idCVar::idCVar(
    this: &ai_moveModeLookAhead,
    name: "ai_moveModeLookAhead",
    value: "1",
    flags: 1,
    description: "If ai movement code should look ahead in the animation instead of back",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_moveModeLookAhead__);
}


// ========================================================================
// `dynamic initializer for 'ai_flashIfLootable''
// EA  : 0x833662A0
// RVA : 0x013662A0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_flashIfLootable__()
{
  idCVar::idCVar(
    this: &ai_flashIfLootable,
    name: "ai_flashIfLootable",
    value: "1",
    flags: 1,
    description: "if true the ai flash when lootable like the props",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_flashIfLootable__);
}


// ========================================================================
// `dynamic initializer for 'ai_lootDelay''
// EA  : 0x833662F8
// RVA : 0x013662F8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_lootDelay__()
{
  idCVar::idCVar(
    this: &ai_lootDelay,
    name: "ai_lootDelay",
    value: "1.25",
    flags: 4,
    description: "delay in seconds before dead AI can be looted",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_lootDelay__);
}


// ========================================================================
// `dynamic initializer for 'ai_interactionView_useCamera''
// EA  : 0x83366350
// RVA : 0x01366350
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_interactionView_useCamera__()
{
  idCVar::idCVar(
    this: &ai_interactionView_useCamera,
    name: "ai_interactionView_useCamera",
    value: "1",
    flags: 1,
    description: "if true we look for interaction cameras, otherwise we use code solution",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_interactionView_useCamera__);
}


// ========================================================================
// `dynamic initializer for 'ai_useStageCoverFilter''
// EA  : 0x833663A8
// RVA : 0x013663A8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useStageCoverFilter__()
{
  idCVar::idCVar(
    this: &ai_useStageCoverFilter,
    name: "ai_useStageCoverFilter",
    value: "1",
    flags: 1,
    description: "if true prune cover queries to active encounter group stage cover",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useStageCoverFilter__);
}


// ========================================================================
// `dynamic initializer for 'ai_disableWanderGreetings''
// EA  : 0x83366400
// RVA : 0x01366400
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_disableWanderGreetings__()
{
  idCVar::idCVar(
    this: &ai_disableWanderGreetings,
    name: "ai_disableWanderGreetings",
    value: "0",
    flags: 1,
    description: "if true then all wander greetings will be disabled",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_disableWanderGreetings__);
}


// ========================================================================
// `dynamic initializer for 'ai_droppedLootDistance''
// EA  : 0x83366458
// RVA : 0x01366458
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_droppedLootDistance__()
{
  idCVar::idCVar(
    this: &ai_droppedLootDistance,
    name: "ai_droppedLootDistance",
    value: "140.0f",
    flags: 4,
    description: "the max distance the dropped item can be to auto loot it",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_droppedLootDistance__);
}


// ========================================================================
// `dynamic initializer for 'ai_enableInfluenceTrails''
// EA  : 0x833664B0
// RVA : 0x013664B0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_enableInfluenceTrails__()
{
  idCVar::idCVar(
    this: &ai_enableInfluenceTrails,
    name: "ai_enableInfluenceTrails",
    value: "0",
    flags: 1,
    description: "if true will turn on influence spheres on spawn",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_enableInfluenceTrails__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugGreetingDistance''
// EA  : 0x83366508
// RVA : 0x01366508
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugGreetingDistance__()
{
  idCVar::idCVar(
    this: &ai_debugGreetingDistance,
    name: "ai_debugGreetingDistance",
    value: "0",
    flags: 1,
    description: "if true, debug info will be shown when AIs consider greeting players.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugGreetingDistance__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugPerception''
// EA  : 0x83366560
// RVA : 0x01366560
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugPerception__()
{
  idCVar::idCVar(
    this: &ai_debugPerception,
    name: "ai_debugPerception",
    value: "0",
    flags: 2,
    description: "If > 0, AI will render perception information about the player.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugPerception__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugScenePoints''
// EA  : 0x833665B8
// RVA : 0x013665B8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugScenePoints__()
{
  idCVar::idCVar(
    this: &ai_debugScenePoints,
    name: "ai_debugScenePoints",
    value: "0",
    flags: 2,
    description: "If > 0, AI will render information about current scenepoints.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugScenePoints__);
}


// ========================================================================
// `dynamic initializer for 'ai_allowCollapse''
// EA  : 0x83366610
// RVA : 0x01366610
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_allowCollapse__()
{
  idCVar::idCVar(
    this: &ai_allowCollapse,
    name: "ai_allowCollapse",
    value: "0",
    flags: 1,
    description: "1 = allow AI to play collapse animations, otherwise they will defer death until they're not in a solid.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_allowCollapse__);
}


// ========================================================================
// `dynamic initializer for 'ai_maxDeferDeathTime''
// EA  : 0x83366668
// RVA : 0x01366668
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_maxDeferDeathTime__()
{
  idCVar::idCVar(
    this: &ai_maxDeferDeathTime,
    name: "ai_maxDeferDeathTime",
    value: "250",
    flags: 2,
    description: "maximum time in millseconds that an AI's death can be defered due to them being in a solid.",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_maxDeferDeathTime__);
}


// ========================================================================
// `dynamic initializer for 'ai_pushVelocityTolerance''
// EA  : 0x833666C0
// RVA : 0x013666C0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_pushVelocityTolerance__()
{
  idCVar::idCVar(
    this: &ai_pushVelocityTolerance,
    name: "ai_pushVelocityTolerance",
    value: "15",
    flags: 4,
    description: "linear velocity tolerance for push velocity",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_pushVelocityTolerance__);
}


// ========================================================================
// `dynamic initializer for 'ai_ragdollKillLimit''
// EA  : 0x83366718
// RVA : 0x01366718
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_ragdollKillLimit__()
{
  idCVar::idCVar(
    this: &ai_ragdollKillLimit,
    name: "ai_ragdollKillLimit",
    value: "1",
    flags: 2,
    description: "AI can only kill AI when less than this number of ragdolls are active or syncing",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_ragdollKillLimit__);
}


// ========================================================================
// `dynamic initializer for 'ai_debugBleedoutCheck''
// EA  : 0x83366770
// RVA : 0x01366770
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_debugBleedoutCheck__()
{
  idCVar::idCVar(
    this: &ai_debugBleedoutCheck,
    name: "ai_debugBleedoutCheck",
    value: "0",
    flags: 2,
    description: "0 = off, 1 = only show when death triggers, 2 = show once checking starts",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_debugBleedoutCheck__);
}


// ========================================================================
// `dynamic initializer for 'ai_thinkTrace''
// EA  : 0x833667C8
// RVA : 0x013667C8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_thinkTrace__()
{
  idCVar::idCVar(
    this: &ai_thinkTrace,
    name: "ai_thinkTrace",
    value: "0",
    flags: 1,
    description: "trace AI think",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_thinkTrace__);
}


// ========================================================================
// `dynamic initializer for 'ai_useDeferredFiring''
// EA  : 0x83366820
// RVA : 0x01366820
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useDeferredFiring__()
{
  idCVar::idCVar(
    this: &ai_useDeferredFiring,
    name: "ai_useDeferredFiring",
    value: "0",
    flags: 1,
    description: "if true will use the deffered fire method for the AI fire control",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useDeferredFiring__);
}


// ========================================================================
// `dynamic initializer for 'takedownWindoMaxTime''
// EA  : 0x83366878
// RVA : 0x01366878
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__takedownWindoMaxTime__()
{
  idCVar::idCVar(
    this: &takedownWindoMaxTime,
    name: "takedownWindoMaxTime",
    value: "500",
    flags: 2,
    description: "max time the takedownwindow is open. -1 will ignore the window all together",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__takedownWindoMaxTime__);
}


// ========================================================================
// `dynamic initializer for 'takedownType''
// EA  : 0x833668D0
// RVA : 0x013668D0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__takedownType__()
{
  idCVar::idCVar(
    this: &takedownType,
    name: "takedowntype",
    value: "-1",
    flags: 2,
    description: "0 - stealth, 1 - counter, 2 - ai counters",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__takedownType__);
}


// ========================================================================
// `dynamic initializer for 'takedownID''
// EA  : 0x83366928
// RVA : 0x01366928
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__takedownID__()
{
  idCVar::idCVar(
    this: &takedownID,
    name: "takedownID",
    value: "-1",
    flags: 2,
    description: "ID in the list of the takedown category that is used (see AI template)",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__takedownID__);
}


// ========================================================================
// `dynamic initializer for 'takedownWindowDebug''
// EA  : 0x83366980
// RVA : 0x01366980
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__takedownWindowDebug__()
{
  idCVar::idCVar(
    this: &takedownWindowDebug,
    name: "takedownWindowDebug",
    value: "0",
    flags: 1,
    description: "gives clear hints of when the takedownwindow starts and ends",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__takedownWindowDebug__);
}


// ========================================================================
// `dynamic initializer for 'AIStats_v''
// EA  : 0x833669D8
// RVA : 0x013669D8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

idCommandLink *_dynamic_initializer_for__AIStats_v__()
{
  return idCommandLink::idCommandLink(
           this: &AIStats_v,
           cmdName: "AIStats",
           function: AIStats_f,
           description: " get the stats from all the active AI in this level ",
           argCompletion: nullptr);
}


// ========================================================================
// `dynamic initializer for 'ai_FadeDelay''
// EA  : 0x83366A00
// RVA : 0x01366A00
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_FadeDelay__()
{
  idCVar::idCVar(
    this: &ai_FadeDelay,
    name: "ai_FadeDelay",
    value: "0",
    flags: 2,
    description: "temp cvar for adjusting the delay on fade for skinny mutants",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_FadeDelay__);
}


// ========================================================================
// `dynamic initializer for 'ai_CoopFadeOutTime''
// EA  : 0x83366A58
// RVA : 0x01366A58
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_CoopFadeOutTime__()
{
  idCVar::idCVar(
    this: &ai_CoopFadeOutTime,
    name: "ai_CoopFadeOutTime",
    value: "4.5",
    flags: 4,
    description: "cvar for delay start",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_CoopFadeOutTime__);
}


// ========================================================================
// `dynamic initializer for 'ai_CoopFadeDelay''
// EA  : 0x83366AB0
// RVA : 0x01366AB0
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_CoopFadeDelay__()
{
  idCVar::idCVar(
    this: &ai_CoopFadeDelay,
    name: "ai_CoopFadeDelay",
    value: "5000",
    flags: 2,
    description: "coop fade delay",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_CoopFadeDelay__);
}


// ========================================================================
// `dynamic initializer for 'ai_NonPlayerOneShotChance''
// EA  : 0x83366B08
// RVA : 0x01366B08
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_NonPlayerOneShotChance__()
{
  idCVar::idCVar(
    this: &ai_NonPlayerOneShotChance,
    name: "ai_NonPlayerOneShotChance",
    value: "0.3f",
    flags: 4,
    description: "chance a non-player will cause a one shot chance",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_NonPlayerOneShotChance__);
}


// ========================================================================
// `dynamic initializer for 'ai_useAvoidForCoverFilter''
// EA  : 0x83366B60
// RVA : 0x01366B60
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_useAvoidForCoverFilter__()
{
  idCVar::idCVar(
    this: &ai_useAvoidForCoverFilter,
    name: "ai_useAvoidForCoverFilter",
    value: "1",
    flags: 1,
    description: "temp debugging",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_useAvoidForCoverFilter__);
}


// ========================================================================
// `dynamic initializer for 'ai_controlHeartBeatIntervalsMin''
// EA  : 0x83366BB8
// RVA : 0x01366BB8
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_controlHeartBeatIntervalsMin__()
{
  idCVar::idCVar(
    this: &ai_controlHeartBeatIntervalsMin,
    name: "ai_controlHeartBeatIntervalsMin",
    value: "1000",
    flags: 4,
    description: "time in MS to wait between player heartbeats",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_controlHeartBeatIntervalsMin__);
}


// ========================================================================
// `dynamic initializer for 'ai_controlHeartBeatIntervalsMax''
// EA  : 0x83366C10
// RVA : 0x01366C10
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_controlHeartBeatIntervalsMax__()
{
  idCVar::idCVar(
    this: &ai_controlHeartBeatIntervalsMax,
    name: "ai_controlHeartBeatIntervalsMax",
    value: "250",
    flags: 4,
    description: "time in MS to wait between player heartbeats",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_controlHeartBeatIntervalsMax__);
}


// ========================================================================
// `dynamic initializer for 'ai_controlTakeDownDistance''
// EA  : 0x83366C68
// RVA : 0x01366C68
// PDB : w:\tech5\tungsten\game\ai\ai2.cpp
// ========================================================================

void __noreturn _dynamic_initializer_for__ai_controlTakeDownDistance__()
{
  idCVar::idCVar(
    this: &ai_controlTakeDownDistance,
    name: "ai_controlTakeDownDistance",
    value: "80",
    flags: 4,
    description: "the length for the take down trace",
    valueCompletion: nullptr);
  atexit(func: (void (__fastcall *)())_dynamic_atexit_destructor_for__ai_controlTakeDownDistance__);
}

