openmohaa/code/fgame/actor_balcony.cpp

391 lines
7.4 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_balcony.cpp
#include "actor.h"
2023-04-29 21:56:38 +02:00
#include "scriptexception.h"
2016-03-27 11:49:47 +02:00
void Actor::InitBalconyIdle
(
GlobalFuncs_t *func
)
{
func->ThinkState = &Actor::Think_Idle;
func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle;
func->Pain = &Actor::Pain_Balcony;
func->Killed = &Actor::Killed_Balcony;
func->IsState = &Actor::IsIdleState;
}
void Actor::InitBalconyCurious
(
GlobalFuncs_t *func
)
{
func->ThinkState = &Actor::Think_Curious;
func->BeginState = &Actor::Begin_Curious;
func->EndState = &Actor::End_Curious;
func->ResumeState = &Actor::Resume_Curious;
func->SuspendState = &Actor::Suspend_Curious;
func->FinishedAnimation = &Actor::FinishedAnimation_Curious;
func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Curious;
func->IsState = &Actor::IsCuriousState;
func->Pain = &Actor::Pain_Balcony;
func->Killed = &Actor::Killed_Balcony;
}
void Actor::InitBalconyAttack
(
GlobalFuncs_t *func
)
{
func->ThinkState = &Actor::Think_BalconyAttack;
func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack;
func->BeginState = &Actor::Begin_BalconyAttack;
func->FinishedAnimation = &Actor::FinishedAnimation_BalconyAttack;
func->Pain = &Actor::Pain_Balcony;
func->Killed = &Actor::Killed_Balcony;
func->IsState = &Actor::IsAttackState;
func->PostShoot = &Actor::State_Balcony_PostShoot;
}
void Actor::InitBalconyDisguise
(
GlobalFuncs_t *func
)
{
func->IsState = &Actor::IsDisguiseState;
}
void Actor::InitBalconyGrenade
(
GlobalFuncs_t *func
)
{
func->IsState = &Actor::IsGrenadeState;
}
void Actor::InitBalconyPain
(
GlobalFuncs_t *func
)
{
func->BeginState = &Actor::Begin_Pain;
func->ThinkState = &Actor::Think_Pain;
func->FinishedAnimation = &Actor::FinishedAnimation_Pain;
func->Pain = &Actor::Pain_Balcony;
func->Killed = &Actor::Killed_Balcony;
func->IsState = &Actor::IsPainState;
}
void Actor::InitBalconyKilled
(
GlobalFuncs_t *func
)
{
func->BeginState = &Actor::Begin_BalconyKilled;
func->EndState = &Actor::End_BalconyKilled;
func->ThinkState = &Actor::Think_BalconyKilled;
func->FinishedAnimation = &Actor::FinishedAnimation_BalconyKilled;
func->IsState = &Actor::IsKilledState;
}
void Actor::Pain_Balcony
(
Event *ev
)
{
2018-09-05 16:55:10 +02:00
SetThink( THINKSTATE_PAIN, THINK_BALCONY_PAIN);
2016-03-27 11:49:47 +02:00
HandlePain( ev );
}
void Actor::Killed_Balcony
(
Event *ev,
bool bPlayDeathAnim
)
{
ClearStates();
2018-09-05 16:55:10 +02:00
SetThink( THINKSTATE_KILLED, THINK_BALCONY_KILLED);
2016-03-27 11:49:47 +02:00
HandleKilled( ev, true );
if( !bPlayDeathAnim )
ScriptError( "cannot do 'bedead' on balcony guys" );
}
void Actor::Begin_BalconyAttack
(
void
)
{
2019-06-30 23:03:24 +02:00
TransitionState(200, 0);
2016-03-27 11:49:47 +02:00
}
void Actor::State_Balcony_PostShoot
(
void
)
{
if( m_Enemy )
{
2019-06-30 23:03:24 +02:00
TransitionState(201, 0);
2016-03-27 11:49:47 +02:00
}
}
void Actor::State_Balcony_FindEnemy
(
void
)
{
m_bHasDesiredLookAngles = false;
Anim_Aim();
if( CanSeeEnemy( 200 ) )
{
2019-06-30 23:03:24 +02:00
TransitionState(201, 0);
2016-03-27 11:49:47 +02:00
}
}
void Actor::State_Balcony_Target
(
void
)
{
Anim_Aim();
2018-09-17 23:50:38 +02:00
AimAtTargetPos();
2016-03-27 11:49:47 +02:00
if( level.inttime > m_iStateTime + 1000 )
{
if( CanSeeEnemy( 0 ) && CanShootEnemy( 0 ) )
{
2019-06-30 23:03:24 +02:00
TransitionState(202, 0);
2016-03-27 11:49:47 +02:00
}
else
{
ClearPath();
2019-06-30 23:03:24 +02:00
TransitionState(200, 0);
2016-03-27 11:49:47 +02:00
}
}
}
void Actor::State_Balcony_Shoot
(
void
)
{
Anim_Shoot();
2018-09-17 23:50:38 +02:00
AimAtTargetPos();
2016-03-27 11:49:47 +02:00
}
void Actor::Think_BalconyAttack
(
void
)
{
if( !RequireThink() )
return;
UpdateEyeOrigin();
UpdateEnemy( 500 );
if( !m_Enemy )
{
2018-09-05 16:55:10 +02:00
SetThinkState( THINKSTATE_IDLE, THINKLEVEL_NORMAL);
2016-03-27 11:49:47 +02:00
IdleThink();
return;
}
NoPoint();
if( m_State == 201 )
{
m_pszDebugState = "target";
State_Balcony_Target();
}
else if( m_State == 202 )
{
m_pszDebugState = "shoot";
State_Balcony_Shoot();
}
2018-09-05 16:55:10 +02:00
else if( m_State == 200 )
2016-03-27 11:49:47 +02:00
{
m_pszDebugState = "findenemy";
State_Balcony_FindEnemy();
}
else
{
Com_Printf( "Actor::Think_BalconyAttack: invalid think state %i\n", m_State );
assert( 0 );
}
PostThink( true );
}
void Actor::FinishedAnimation_BalconyAttack
(
void
)
{
2018-09-05 16:55:10 +02:00
if( m_State == 202 )
2016-03-27 11:49:47 +02:00
State_Balcony_PostShoot();
}
void Actor::Begin_BalconyKilled
(
void
)
{
ClearPath();
ResetBoneControllers();
PostEvent( EV_Actor_DeathEmbalm, 0.05f );
if( CalcFallPath() )
2019-06-30 23:03:24 +02:00
TransitionState(800, 0);
2016-03-27 11:49:47 +02:00
else
2019-06-30 23:03:24 +02:00
TransitionState(806, 0);
2016-03-27 11:49:47 +02:00
}
void Actor::End_BalconyKilled
(
void
)
{
if( m_pFallPath )
{
2018-09-17 23:50:38 +02:00
gi.Free(m_pFallPath);
2016-03-27 11:49:47 +02:00
m_pFallPath = NULL;
}
}
void Actor::Think_BalconyKilled
(
void
)
{
int animnum;
Unregister( STRING_ANIMDONE );
2018-09-05 16:55:10 +02:00
if( m_State == 805 )
2016-03-27 11:49:47 +02:00
{
m_pszDebugState = "end";
}
else
{
NoPoint();
m_bHasDesiredLookAngles = false;
2019-08-18 22:06:49 +02:00
StopTurning();
2016-03-27 11:49:47 +02:00
switch( m_State )
{
case 800:
m_bNextForceStart = true;
m_eNextAnimMode = 7;
m_pszDebugState = "begin";
2018-09-05 16:55:10 +02:00
m_csNextAnimString = STRING_ANIM_NO_KILLED_SCR;
2018-09-17 23:50:38 +02:00
animnum = gi.Anim_NumForName(edict->tiki, "death_balcony_intro");
2016-03-27 11:49:47 +02:00
ChangeMotionAnim();
2018-09-17 23:50:38 +02:00
m_bMotionAnimSet = true;
m_iMotionSlot = GetMotionSlot(0);
m_weightType[m_iMotionSlot] = 1;
m_weightCrossBlend[m_iMotionSlot] = 0.0;
m_weightBase[m_iMotionSlot] = 1.0;
NewAnim( animnum, m_iMotionSlot );
2016-03-27 11:49:47 +02:00
SetTime( m_iMotionSlot, m_pFallPath->startTime );
UpdateNormalAnimSlot( m_iMotionSlot );
2019-06-30 23:03:24 +02:00
TransitionState(801, 0);
2016-03-27 11:49:47 +02:00
break;
case 801:
m_bNextForceStart = false;
m_pszDebugState = "intro";
m_eNextAnimMode = 7;
m_csNextAnimString = STRING_ANIM_NO_KILLED_SCR;
break;
case 802:
m_pszDebugState = "loop";
Anim_FullBody( STRING_DEATH_BALCONY_LOOP, 7 );
break;
case 803:
2019-06-30 23:03:24 +02:00
TransitionState(804, 0);
2016-03-27 11:49:47 +02:00
StopAllAnimating();
case 804:
m_pszDebugState = "outtro";
Anim_FullBody( STRING_DEATH_BALCONY_OUTTRO, 1 );
2018-09-05 16:55:10 +02:00
break;
2016-03-27 11:49:47 +02:00
case 806:
m_pszDebugState = "normal";
Anim_Killed();
break;
default:
Com_Printf( "Actor::Think_BalconyKilled: invalid think state %i\n", m_State );
assert( 0 );
}
PostThink( false );
if( m_State >= 800 )
{
2018-09-05 16:55:10 +02:00
if( m_State == 801 )
2016-03-27 11:49:47 +02:00
{
if( m_pFallPath->currentPos >= m_pFallPath->length )
{
2019-06-30 23:03:24 +02:00
TransitionState(803, 0);
2016-03-27 11:49:47 +02:00
}
2018-09-05 16:55:10 +02:00
else if (m_pFallPath->currentPos >= m_pFallPath->loop)
2016-03-27 11:49:47 +02:00
{
2019-06-30 23:03:24 +02:00
TransitionState(802, 0);
2016-03-27 11:49:47 +02:00
}
}
2018-09-05 16:55:10 +02:00
else if( m_State == 802 )
2016-03-27 11:49:47 +02:00
{
2018-09-05 16:55:10 +02:00
if (m_pFallPath->currentPos >= m_pFallPath->length)
2016-03-27 11:49:47 +02:00
{
2019-06-30 23:03:24 +02:00
TransitionState(803, 0);
2016-03-27 11:49:47 +02:00
}
}
}
}
}
void Actor::FinishedAnimation_BalconyKilled
(
void
)
{
if( m_State == 804 || m_State == 806 )
{
BecomeCorpse();
2019-06-30 23:03:24 +02:00
TransitionState(805, 0);
2016-03-27 11:49:47 +02:00
}
else if( m_State == 801 )
{
2019-06-30 23:03:24 +02:00
TransitionState(802, 0);
2016-03-27 11:49:47 +02:00
StopAllAnimating();
}
}