void CCSBot::ResetValues() { m_chatter.Reset(); m_gameState.Reset(); m_avoid = NULL; m_avoidTimestamp = 0.0f; m_hurryTimer.Invalidate(); m_isStuck = false; m_stuckTimestamp = 0.0f; m_wiggleTimestamp = 0.0f; m_stuckJumpTimestamp = 0.0f; m_pathLength = 0; m_pathIndex = 0; m_areaEnteredTimestamp = 0.0f; m_currentArea = NULL; m_lastKnownArea = NULL; m_avoidFriendTimer.Invalidate(); m_isFriendInTheWay = false; m_isWaitingBehindFriend = false; m_disposition = ENGAGE_AND_INVESTIGATE; m_enemy = NULL; m_isWaitingToTossGrenade = false; m_wasSafe = true; m_nearbyEnemyCount = 0; m_enemyPlace = 0; m_nearbyFriendCount = 0; m_closestVisibleFriend = NULL; m_closestVisibleHumanFriend = NULL; for (int w = 0; w < ARRAYSIZE(m_watchInfo); ++w) { m_watchInfo[w].timestamp = 0.0f; m_watchInfo[w].isEnemy = false; } m_isEnemyVisible = false; m_visibleEnemyParts = NONE; m_lastSawEnemyTimestamp = 0.0f; m_firstSawEnemyTimestamp = 0.0f; m_currentEnemyAcquireTimestamp = 0.0f; m_isLastEnemyDead = true; m_attacker = NULL; m_attackedTimestamp = 0.0f; m_enemyDeathTimestamp = 0.0f; m_lastVictimID = 0; m_isAimingAtEnemy = false; m_fireWeaponTimestamp = 0.0f; m_equipTimer.Invalidate(); m_isFollowing = false; m_leader = NULL; m_followTimestamp = 0.0f; m_allowAutoFollowTime = 0.0f; m_enemyQueueIndex = 0; m_enemyQueueCount = 0; m_enemyQueueAttendIndex = 0; m_bomber = NULL; m_lookAroundStateTimestamp = 0.0f; m_inhibitLookAroundTimestamp = 0.0f; m_lookPitch = 0.0f; m_lookPitchVel = 0.0f; m_lookYaw = 0.0f; m_lookYawVel = 0.0f; m_aimOffsetTimestamp = 0.0f; m_aimSpreadTimestamp = 0.0f; m_lookAtSpotState = NOT_LOOKING_AT_SPOT; m_spotEncounter = NULL; m_spotCheckTimestamp = 0.0f; m_peripheralTimestamp = 0.0f; m_avgVelIndex = 0; m_avgVelCount = 0; m_lastOrigin = (pev != NULL) ? pev->origin : Vector(0, 0, 0); m_lastRadioCommand = EVENT_INVALID; m_lastRadioRecievedTimestamp = 0.0f; m_lastRadioSentTimestamp = 0.0f; m_radioSubject = NULL; m_voiceFeedbackEndTimestamp = 0.0f; m_hostageEscortCount = 0; m_hostageEscortCountTimestamp = 0.0f; m_noisePosition = Vector(0, 0, 0); m_noiseTimestamp = 0.0f; m_noiseCheckTimestamp = 0.0f; m_isNoiseTravelRangeChecked = false; m_stateTimestamp = 0.0f; m_task = SEEK_AND_DESTROY; m_taskEntity = NULL; m_approachPointCount = 0; m_approachPointViewPosition = Vector(0, 0, 0); m_checkedHidingSpotCount = 0; m_isJumpCrouching = false; StandUp(); Run(); m_mustRunTimer.Invalidate(); m_repathTimer.Invalidate(); m_pathLadder = NULL; m_huntState.ClearHuntArea(); // adjust morale - if we died, our morale decreased, // but if we live, no adjustement (round win/loss also adjusts morale if (m_diedLastRound) DecreaseMorale(); m_diedLastRound = false; // IsRogue() randomly changes this m_isRogue = false; m_surpriseDelay = 0.0f; m_surpriseTimestamp = 0.0f; // even though these are EHANDLEs, they need to be NULL-ed m_goalEntity = NULL; m_avoid = NULL; m_enemy = NULL; for (int i = 0; i < MAX_ENEMY_QUEUE; ++i) { m_enemyQueue[i].player = NULL; m_enemyQueue[i].isReloading = false; m_enemyQueue[i].isProtectedByShield = false; } // start in idle state StopAttacking(); Idle(); }
void UpdateAI(const uint32 uiDiff) override { if (m_bEventMode) { if (!m_uiSpeechStep) return; if (m_uiSpeechTimer < uiDiff) { switch (m_uiSpeechStep) { case 1: DoScriptText(YELL_FENRUS, m_creature); m_creature->SetVisibility(VISIBILITY_ON); m_uiSpeechTimer = 2000; break; case 2: DoCastSpellIfCan(m_creature, SPELL_FIRE); m_uiSpeechTimer = 5000; break; case 3: if (m_pInstance) if (GameObject* pLightning = m_pInstance->GetSingleGameObjectFromStorage(GO_ARUGAL_FOCUS)) pLightning->Use(m_creature); m_uiSpeechTimer = 5000; break; case 4: m_creature->SetVisibility(VISIBILITY_OFF); m_uiSpeechTimer = 500; break; case 5: { Creature* pVoidwalker = NULL; Creature* pLeader = NULL; for (uint8 i = 0; i < 4; ++i) { pVoidwalker = m_creature->SummonCreature(NPC_VOIDWALKER, VWSpawns[i].fX, VWSpawns[i].fY, VWSpawns[i].fZ, VWSpawns[i].fO, TEMPSPAWN_DEAD_DESPAWN, 1); if (!pVoidwalker) continue; if (!i) pLeader = pVoidwalker; if (mob_arugal_voidwalkerAI* pVoidwalkerAI = dynamic_cast<mob_arugal_voidwalkerAI*>(pVoidwalker->AI())) pVoidwalkerAI->SetPosition(i, pLeader); pVoidwalker = NULL; } m_uiSpeechStep = 0; return; } default: m_uiSpeechStep = 0; return; } ++m_uiSpeechStep; } else m_uiSpeechTimer -= uiDiff; return; } // Check if we have a current target if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (GetManaPercent() < 6.0f && !m_bAttacking) { if (m_posPosition != POSITION_UPPER_LEDGE) StartAttacking(); else if (m_uiTeleportTimer > 2000) m_uiTeleportTimer = 2000; m_bAttacking = true; } else if (GetManaPercent() > 12.0f && m_bAttacking) { StopAttacking(); m_bAttacking = false; } if (m_uiYellTimer < uiDiff) { DoScriptText(YELL_COMBAT, m_creature); m_uiYellTimer = urand(34000, 68000); } else m_uiYellTimer -= uiDiff; if (m_uiCurseTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1)) DoCastSpellIfCan(pTarget, SPELL_ARUGALS_CURSE); m_uiCurseTimer = urand(20000, 35000); } else m_uiCurseTimer -= uiDiff; if (m_uiThundershockTimer < uiDiff) { if (GetVictimDistance() < 5.0f) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_THUNDERSHOCK); m_uiThundershockTimer = urand(30200, 38500); } } else m_uiThundershockTimer -= uiDiff; if (m_uiVoidboltTimer < uiDiff) { if (!m_bAttacking) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_VOID_BOLT); m_uiVoidboltTimer = urand(2900, 4800); } } else m_uiVoidboltTimer -= uiDiff; if (m_uiTeleportTimer < uiDiff) { ArugalPosition posNewPosition; if (m_posPosition == POSITION_SPAWN_LEDGE) posNewPosition = (ArugalPosition)urand(1, 2); else { posNewPosition = (ArugalPosition)urand(0, 1); if (m_posPosition == posNewPosition) posNewPosition = POSITION_STAIRS; } if (m_creature->IsNonMeleeSpellCasted(false)) m_creature->InterruptNonMeleeSpells(false); switch (posNewPosition) { case POSITION_SPAWN_LEDGE: DoCastSpellIfCan(m_creature, SPELL_SHADOW_PORT_SPAWN_LEDGE, true); break; case POSITION_UPPER_LEDGE: DoCastSpellIfCan(m_creature, SPELL_SHADOW_PORT_UPPER_LEDGE, true); break; case POSITION_STAIRS: DoCastSpellIfCan(m_creature, SPELL_SHADOW_PORT_STAIRS, true); break; } if (GetManaPercent() < 6.0f) { if (posNewPosition == POSITION_UPPER_LEDGE) { StopAttacking(); m_uiTeleportTimer = urand(2000, 2200); } else { StartAttacking(); m_uiTeleportTimer = urand(48000, 55000); } } else m_uiTeleportTimer = urand(48000, 55000); m_posPosition = posNewPosition; } else m_uiTeleportTimer -= uiDiff; if (m_bAttacking) DoMeleeAttackIfReady(); }
/** * Reset internal data to initial state */ void CCFBot::ResetValues( void ) { m_chatter.Reset(); m_gameState.Reset(); m_avoid = NULL; m_avoidTimestamp = 0.0f; m_hurryTimer.Invalidate(); m_alertTimer.Invalidate(); m_sneakTimer.Invalidate(); m_noiseBendTimer.Invalidate(); m_bendNoisePositionValid = false; m_isStuck = false; m_stuckTimestamp = 0.0f; m_wiggleTimer.Invalidate(); m_stuckJumpTimer.Invalidate(); m_pathLength = 0; m_pathIndex = 0; m_areaEnteredTimestamp = 0.0f; m_currentArea = NULL; m_lastKnownArea = NULL; m_isStopping = false; m_avoidFriendTimer.Invalidate(); m_isFriendInTheWay = false; m_isWaitingBehindFriend = false; m_isAvoidingGrenade.Invalidate(); StopPanicking(); m_disposition = ENGAGE_AND_INVESTIGATE; m_enemy = NULL; m_grenadeTossState = NOT_THROWING; m_initialEncounterArea = NULL; m_wasSafe = true; m_nearbyEnemyCount = 0; m_enemyPlace = 0; m_nearbyFriendCount = 0; m_closestVisibleFriend = NULL; m_closestVisibleHumanFriend = NULL; m_closestVisibleKO = NULL; for( int w=0; w<MAX_PLAYERS; ++w ) { m_watchInfo[w].timestamp = 0.0f; m_watchInfo[w].isEnemy = false; m_playerTravelDistance[ w ] = -1.0f; } // randomly offset each bot's timer to spread computation out m_updateTravelDistanceTimer.Start( RandomFloat( 0.0f, 0.9f ) ); m_travelDistancePhase = 0; m_isEnemyVisible = false; m_visibleEnemyParts = VIS_NONE; m_lastSawEnemyTimestamp = -999.9f; m_firstSawEnemyTimestamp = 0.0f; m_currentEnemyAcquireTimestamp = 0.0f; m_isLastEnemyDead = true; m_attacker = NULL; m_attackedTimestamp = 0.0f; m_enemyDeathTimestamp = 0.0f; m_friendDeathTimestamp = 0.0f; m_lastVictimID = 0; m_isAimingAtEnemy = false; m_fireWeaponTimestamp = 0.0f; m_equipTimer.Invalidate(); m_zoomTimer.Invalidate(); m_isFollowing = false; m_leader = NULL; m_followTimestamp = 0.0f; m_allowAutoFollowTime = 0.0f; m_enemyQueueIndex = 0; m_enemyQueueCount = 0; m_enemyQueueAttendIndex = 0; m_bomber = NULL; m_isEnemySniperVisible = false; m_sawEnemySniperTimer.Invalidate(); m_lookAroundStateTimestamp = 0.0f; m_inhibitLookAroundTimestamp = 0.0f; m_lookPitch = 0.0f; m_lookPitchVel = 0.0f; m_lookYaw = 0.0f; m_lookYawVel = 0.0f; m_aimOffsetTimestamp = 0.0f; m_aimSpreadTimestamp = 0.0f; m_lookAtSpotState = NOT_LOOKING_AT_SPOT; for( int p=0; p<MAX_PLAYERS; ++p ) { m_partInfo[p].m_validFrame = 0; } m_spotEncounter = NULL; m_spotCheckTimestamp = 0.0f; m_peripheralTimestamp = 0.0f; m_avgVelIndex = 0; m_avgVelCount = 0; m_lastOrigin = GetCentroid(); m_voiceEndTimestamp = 0.0f; m_noisePosition = Vector( 0, 0, 0 ); m_noiseTimestamp = 0.0f; m_stateTimestamp = 0.0f; m_task = SEEK_AND_DESTROY; m_taskEntity = NULL; m_approachPointCount = 0; m_approachPointViewPosition.x = 99999999999.9f; m_approachPointViewPosition.y = 0.0f; m_approachPointViewPosition.z = 0.0f; m_checkedHidingSpotCount = 0; StandUp(); Run(); m_mustRunTimer.Invalidate(); m_waitTimer.Invalidate(); m_pathLadder = NULL; m_repathTimer.Invalidate(); m_huntState.ClearHuntArea(); m_hasVisitedEnemySpawn = false; m_stillTimer.Invalidate(); // adjust morale - if we died, our morale decreased, // but if we live, no adjustement (round win/loss also adjusts morale) if (m_diedLastRound) DecreaseMorale(); m_diedLastRound = false; // IsRogue() randomly changes this m_isRogue = false; m_surpriseTimer.Invalidate(); // even though these are EHANDLEs, they need to be NULL-ed m_goalEntity = NULL; m_avoid = NULL; m_enemy = NULL; for ( int i=0; i<MAX_ENEMY_QUEUE; ++i ) { m_enemyQueue[i].player = NULL; m_enemyQueue[i].isReloading = false; m_enemyQueue[i].isProtectedByShield = false; } // start in idle state m_isOpeningDoor = false; StopAttacking(); Idle(); }