openmohaa/code/fgame/actor_disguise_common.cpp

198 lines
3.8 KiB
C++
Raw Normal View History

2016-03-27 11:49:47 +02:00
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// actor_disguise_common.cpp
#include "actor.h"
void Actor::InitDisguiseNone
(
GlobalFuncs_t *func
)
{
func->IsState = &Actor::IsDisguiseState;
}
void Actor::State_Disguise_Wait
(
void
)
{
2018-08-29 14:41:48 +02:00
vec2_t vDelta;
float fDistSquared;
VectorSub2D(origin, m_Enemy->origin, vDelta);
m_eNextAnimMode = 1;
m_csNextAnimString = STRING_ANIM_DISGUISE_WAIT_SCR;
m_bNextForceStart = false;
fDistSquared = VectorLength2DSquared(vDelta);
if (m_fMaxDisguiseDistSquared > fDistSquared * 4)
{
2019-06-30 23:03:24 +02:00
TransitionState(1, 0);
2018-08-29 14:41:48 +02:00
}
else
{
if (level.inttime > m_iStateTime + 3000)
{
if (fDistSquared <= 65536)
{
2019-06-30 23:03:24 +02:00
TransitionState(1, 0);
2018-08-29 14:41:48 +02:00
}
else
{
2018-09-05 16:55:10 +02:00
SetThinkState(THINKSTATE_IDLE, THINKLEVEL_NORMAL);
2018-08-29 14:41:48 +02:00
}
}
}
2016-03-27 11:49:47 +02:00
}
void Actor::State_Disguise_Papers
(
void
)
{
2018-08-29 14:41:48 +02:00
vec2_t vDelta;
m_csNextAnimString = STRING_ANIM_DISGUISE_PAPERS_SCR;
m_eNextAnimMode = 1;
m_bNextForceStart = false;
if (m_iEnemyShowPapersTime < m_Enemy->m_ShowPapersTime)
{
2018-09-05 16:55:10 +02:00
if (level.m_iPapersLevel < m_iDisguiseLevel)
2018-08-29 14:41:48 +02:00
{
m_State = 5;
}
else
{
if (m_DisguiseAcceptThread.IsSet())
m_DisguiseAcceptThread.Execute(this);
2019-06-30 23:03:24 +02:00
TransitionState(2, 0);
2018-08-29 14:41:48 +02:00
}
}
else
{
if (level.inttime > m_iStateTime + 12000)
{
2019-06-30 23:03:24 +02:00
TransitionState(3, 0);
2018-08-29 14:41:48 +02:00
}
else
{
VectorSub2D(origin, m_Enemy->origin, vDelta);
if (VectorLength2DSquared(vDelta) > 65536)
{
2019-06-30 23:03:24 +02:00
TransitionState(4, 0);
2018-08-29 14:41:48 +02:00
}
}
}
2016-03-27 11:49:47 +02:00
}
void Actor::State_Disguise_Fake_Papers
(
void
)
{
2018-08-29 14:41:48 +02:00
vec2_t vDelta;
m_csNextAnimString = STRING_ANIM_DISGUISE_PAPERS_SCR;
m_eNextAnimMode = 1;
m_bNextForceStart = false;
if (m_iEnemyShowPapersTime < m_Enemy->m_ShowPapersTime || level.inttime > m_iStateTime + 12000)
{
2019-06-30 23:03:24 +02:00
TransitionState(3, 0);
2018-08-29 14:41:48 +02:00
}
else
{
VectorSub2D(origin, m_Enemy->origin, vDelta);
if (VectorLength2DSquared(vDelta) > 65536)
{
2019-06-30 23:03:24 +02:00
TransitionState(4, 0);
2018-08-29 14:41:48 +02:00
}
}
2016-03-27 11:49:47 +02:00
}
void Actor::State_Disguise_Enemy
(
void
)
{
2018-08-29 14:41:48 +02:00
m_eNextAnimMode = 1;
m_csNextAnimString = STRING_ANIM_DISGUISE_ENEMY_SCR;
m_bNextForceStart = false;
if (level.inttime > m_iStateTime + 3000 && !m_Enemy->IsSubclassOfActor())
{
2018-09-05 16:55:10 +02:00
SetThinkState(THINKSTATE_ATTACK, THINKLEVEL_NORMAL);
2018-08-29 14:41:48 +02:00
}
2016-03-27 11:49:47 +02:00
}
void Actor::State_Disguise_Halt
(
void
)
{
2018-08-29 14:41:48 +02:00
m_eNextAnimMode = 1;
m_csNextAnimString = STRING_ANIM_DISGUISE_HALT_SCR;
m_bNextForceStart = false;
if (level.inttime > m_iStateTime + 1500 && !m_Enemy->IsSubclassOfActor())
{
2018-09-05 16:55:10 +02:00
SetThinkState(THINKSTATE_ATTACK, THINKLEVEL_NORMAL);
2018-08-29 14:41:48 +02:00
}
2016-03-27 11:49:47 +02:00
}
void Actor::State_Disguise_Accept
(
void
)
{
2018-08-29 14:41:48 +02:00
m_eNextAnimMode = 1;
m_csNextAnimString = STRING_ANIM_DISGUISE_ACCEPT_SCR;
m_bNextForceStart = false;
if (level.inttime > m_iStateTime + 3000 )
{
2018-09-05 16:55:10 +02:00
SetThinkState(THINKSTATE_IDLE, THINKLEVEL_NORMAL);
SetThink(THINKSTATE_DISGUISE, THINK_DISGUISE_SALUTE);
2018-08-29 14:41:48 +02:00
}
2016-03-27 11:49:47 +02:00
}
void Actor::State_Disguise_Deny
(
void
)
{
2018-08-29 14:41:48 +02:00
m_eNextAnimMode = 1;
m_csNextAnimString = STRING_ANIM_DISGUISE_DENY_SCR;
m_bNextForceStart = false;
if (level.inttime > m_iStateTime + 3000)
{
2018-09-05 16:55:10 +02:00
SetThinkState(THINKSTATE_IDLE, THINKLEVEL_NORMAL);
2018-08-29 14:41:48 +02:00
}
2016-03-27 11:49:47 +02:00
}