openmohaa/code/fgame/actor_animapi.cpp

224 lines
5.4 KiB
C++
Raw Normal View History

2016-03-27 11:49:47 +02:00
/*
===========================================================================
2023-10-12 18:19:22 +02:00
Copyright (C) 2023 the OpenMoHAA team
2016-03-27 11:49:47 +02:00
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_animapi.cpp: Base actor animation script
#include "actor.h"
2023-10-19 23:15:57 +02:00
#include "scriptthread.h"
2016-03-27 11:49:47 +02:00
2023-10-12 18:19:22 +02:00
const_str SimpleActor::GetRunAnim(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
if (m_csCurrentPosition == STRING_PRONE) {
2023-10-12 18:19:22 +02:00
return STRING_ANIM_CROUCH_RUN_SCR;
}
2023-10-19 23:15:57 +02:00
if (m_csCurrentPosition >= STRING_PRONE && m_csCurrentPosition <= STRING_CROUCHRUN && m_csCurrentPosition >= STRING_CROUCH) {
return STRING_ANIM_CROUCH_RUN_SCR;
} else {
return STRING_ANIM_RUN_SCR;
}
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
const_str SimpleActor::GetWalkAnim(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
if (m_csCurrentPosition == STRING_PRONE) {
2023-10-12 18:19:22 +02:00
return STRING_ANIM_CROUCH_WALK_SCR;
}
2023-10-19 23:15:57 +02:00
if (m_csCurrentPosition >= STRING_PRONE && m_csCurrentPosition <= STRING_CROUCHRUN && m_csCurrentPosition >= STRING_CROUCH) {
return STRING_ANIM_CROUCH_WALK_SCR;
} else {
return STRING_ANIM_WALK_SCR;
}
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Attack(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, m_AttackHandler);
2016-03-27 11:49:47 +02:00
}
2023-10-12 19:57:46 +02:00
void SimpleActor::Anim_Suppress(void)
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_SUPPRESS_SCR);
2023-10-12 19:57:46 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Sniper(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, m_SniperHandler);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Aim(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_AIM_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Shoot(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_SHOOT_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Idle(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_IDLE_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Crouch(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_CROUCH_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Prone(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_PRONE_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Stand(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_STAND_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Cower(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_COWER_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Killed(void)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
DesiredAnimation(ANIM_MODE_NORMAL, m_DeathHandler);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_StartPain(void)
2016-03-27 11:49:47 +02:00
{
2023-10-15 14:01:48 +02:00
StartAnimation(ANIM_MODE_NORMAL, m_PainHandler);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Pain(void)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
ContinueAnimation();
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_CrouchRunTo(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_CROUCH_RUN_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_CrouchWalkTo(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_CROUCH_WALK_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_StandRunTo(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUN_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_StandWalkTo(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_WALK_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunTo(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, GetRunAnim());
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunAwayFiring(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNAWAYFIRING_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToShooting(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUN_SHOOT_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToAlarm(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_ALARM_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToCasual(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_CASUAL_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToCover(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_COVER_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToDanger(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_DANGER_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToDive(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_DIVE_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToFlee(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_FLEE_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_RunToInOpen(int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
DesiredAnimation(eAnimMode, STRING_ANIM_RUNTO_INOPEN_SCR);
2016-03-27 11:49:47 +02:00
}
2023-10-19 23:15:57 +02:00
void SimpleActor::Anim_WalkTo(int eAnimMode)
{
DesiredAnimation(eAnimMode, GetWalkAnim());
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Emotion(eEmotionMode eEmotMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
m_eEmotionMode = eEmotMode;
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_Say(const_str csSayAnimScript, int iMinTimeSinceLastSay, bool bCanInterrupt)
2016-03-27 11:49:47 +02:00
{
2023-10-19 23:15:57 +02:00
if (m_bSayAnimSet && !bCanInterrupt) {
return;
}
2016-03-27 11:49:47 +02:00
2023-10-19 23:15:57 +02:00
if (level.inttime <= iMinTimeSinceLastSay + m_iVoiceTime) {
return;
2023-10-12 18:19:22 +02:00
}
2023-10-19 23:15:57 +02:00
ScriptThreadLabel label;
label.TrySetScript(csSayAnimScript);
label.Create(this)->Execute();
2016-03-27 11:49:47 +02:00
}
2023-10-12 18:19:22 +02:00
void SimpleActor::Anim_FullBody(const_str csFullBodyAnim, int eAnimMode)
2016-03-27 11:49:47 +02:00
{
2023-10-12 18:19:22 +02:00
if (m_csAnimName == csFullBodyAnim) {
DesiredAnimation(eAnimMode, STRING_ANIM_FULLBODY_SCR);
} else {
m_csAnimName = csFullBodyAnim;
StartAnimation(eAnimMode, STRING_ANIM_FULLBODY_SCR);
}
2016-03-27 11:49:47 +02:00
}