anim-clip -- sequence selection by afx effects

This commit is contained in:
Marc Chapman 2017-07-27 00:31:43 +01:00
parent 8c65467697
commit ab88b8f489
6 changed files with 511 additions and 14 deletions

View file

@ -20,6 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "platform/platform.h"
#include "T3D/aiPlayer.h"
@ -97,6 +102,9 @@ AIPlayer::AIPlayer()
mMoveSlowdown = true;
mMoveState = ModeStop;
// This new member saves the movement state of the AI so that
// it can be restored after a substituted animation is finished.
mMoveState_saved = -1;
mAimObject = 0;
mAimLocationSet = false;
mTargetInLOS = false;
@ -547,23 +555,27 @@ bool AIPlayer::getAIMove(Move *movePtr)
mMoveState = ModeMove;
}
if (mMoveStuckTestCountdown > 0)
--mMoveStuckTestCountdown;
else
{
// We should check to see if we are stuck...
F32 locationDelta = (location - mLastLocation).len();
// Don't check for ai stuckness if animation during
// an anim-clip effect override.
if (mDamageState == Enabled && !(anim_clip_flags & ANIM_OVERRIDDEN) && !isAnimationLocked()) {
if (mMoveStuckTestCountdown > 0)
--mMoveStuckTestCountdown;
else
{
// We should check to see if we are stuck...
F32 locationDelta = (location - mLastLocation).len();
if (locationDelta < mMoveStuckTolerance && mDamageState == Enabled)
{
// If we are slowing down, then it's likely that our location delta will be less than
// our move stuck tolerance. Because we can be both slowing and stuck
// we should TRY to check if we've moved. This could use better detection.
if ( mMoveState != ModeSlowing || locationDelta == 0 )
{
mMoveState = ModeStuck;
onStuck();
}
}
{
mMoveState = ModeStuck;
onStuck();
}
}
}
}
}
}
@ -626,6 +638,7 @@ bool AIPlayer::getAIMove(Move *movePtr)
}
#endif // TORQUE_NAVIGATION_ENABLED
if (!(anim_clip_flags & ANIM_OVERRIDDEN) && !isAnimationLocked())
mLastLocation = location;
return true;
@ -1415,6 +1428,47 @@ DefineEngineMethod( AIPlayer, clearMoveTriggers, void, ( ),,
object->clearMoveTriggers();
}
// These changes coordinate with anim-clip mods to parent class, Player.
// New method, restartMove(), restores the AIPlayer to its normal move-state
// following animation overrides from AFX. The tag argument is used to match
// the latest override and prevents interruption of overlapping animation
// overrides. See related anim-clip changes in Player.[h,cc].
void AIPlayer::restartMove(U32 tag)
{
if (tag != 0 && tag == last_anim_tag)
{
if (mMoveState_saved != -1)
{
mMoveState = (MoveState) mMoveState_saved;
mMoveState_saved = -1;
}
bool is_death_anim = ((anim_clip_flags & IS_DEATH_ANIM) != 0);
last_anim_tag = 0;
anim_clip_flags &= ~(ANIM_OVERRIDDEN | IS_DEATH_ANIM);
if (mDamageState != Enabled)
{
if (!is_death_anim)
{
// this is a bit hardwired and desperate,
// but if he's dead he needs to look like it.
setActionThread("death10", false, false, false);
}
}
}
}
// New method, saveMoveState(), stores the current movement state
// so that it can be restored when restartMove() is called.
void AIPlayer::saveMoveState()
{
if (mMoveState_saved == -1)
mMoveState_saved = (S32) mMoveState;
}
F32 AIPlayer::getTargetDistance(GameBase* target, bool _checkEnabled)
{
if (!isServerObject()) return false;