From 3e314251f228564090461d2b87b97bb39f2885a3 Mon Sep 17 00:00:00 2001 From: smallmodel <15067410+smallmodel@users.noreply.github.com> Date: Sun, 15 Oct 2023 20:51:11 +0200 Subject: [PATCH] Implemented actor_badplace --- code/fgame/actor_badplace.cpp | 47 ++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/code/fgame/actor_badplace.cpp b/code/fgame/actor_badplace.cpp index 8694f906..825fb195 100644 --- a/code/fgame/actor_badplace.cpp +++ b/code/fgame/actor_badplace.cpp @@ -26,20 +26,59 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void Actor::InitBadPlace(GlobalFuncs_t *func) { - // FIXME: unimplemented + func->ThinkState = &Actor::Think_BadPlace; + func->BeginState = &Actor::Begin_BadPlace; + func->EndState = &Actor::End_BadPlace; + func->ResumeState = &Actor::Begin_BadPlace; + func->SuspendState = &Actor::End_BadPlace; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_BadPlace; + func->IsState = &Actor::IsBadPlaceState; } void Actor::Begin_BadPlace(void) { - // FIXME: unimplemented + DoForceActivate(); + + m_csMood = STRING_ALERT; + m_csIdleMood = STRING_NERVOUS; + + badplace_t& badplace = level.m_badPlaces.ObjectAt(m_iBadPlaceIndex); + + FindPathAway(badplace.m_vOrigin, origin - badplace.m_vOrigin, badplace.m_fRadius + 64); } void Actor::End_BadPlace(void) { - // FIXME: unimplemented + m_iBadPlaceIndex = 0; } void Actor::Think_BadPlace(void) { - // FIXME: unimplemented + if (m_bEnableEnemy) { + UpdateEnemy(200); + } + + m_pszDebugState = ""; + NoPoint(); + + if (!PathExists() || PathComplete() || !m_iBadPlaceIndex) { + m_iBadPlaceIndex = 0; + if (!m_Enemy || (m_Enemy->flags & FL_NOTARGET)) { + SetThinkState(THINKSTATE_IDLE, THINKLEVEL_NORMAL); + } else { + SetThinkState(THINKSTATE_ATTACK, THINKLEVEL_NORMAL); + } + } + + if (m_Enemy) { + m_pszDebugState = "badplace_shoot"; + FaceEnemyOrMotion(m_iStateTime); + Anim_RunAwayFiring(ANIM_MODE_PATH); + } else { + m_pszDebugState = "badplace_run"; + FaceMotion(); + Anim_RunToInOpen(ANIM_MODE_PATH); + } + + PostThink(false); }