Scary text flag

Now, when the flag is active, the Guide will get scared when he reads the next inscription.

Like in TR4, but without need to be in room 70.

The flag onces the action is done, it deactivates itself.

Unlike TR4, I set that the scared face changed back to his normal one at the end of the reading animation, so builders can keep using it with his normal face.
This commit is contained in:
Adngel 2022-07-25 12:19:28 +02:00
parent e74fdb93ac
commit f3d9acf19c
4 changed files with 35 additions and 5 deletions

View file

@ -26,7 +26,8 @@ namespace TEN::Entities::TR4
GUIDE_STATE_IGNITE_TORCH = 11,
GUIDE_STATE_LOOK_BACK = 22,
GUIDE_STATE_TORCH_ATTACK = 31,
GUIDE_STATE_PICKUP_TORCH = 37
GUIDE_STATE_PICKUP_TORCH = 37,
GUIDE_STATE_READ_INSCRIPTION = 39
};
///ITEMFLAGS
@ -220,6 +221,7 @@ namespace TEN::Entities::TR4
bool flag_IgnoreLaraDistance = ((item->ItemFlags[2] & (1 << 1)) != 0) ? true : false;
bool flag_RunDefault = ((item->ItemFlags[2] & (1 << 2)) != 0) ? true : false;
bool flag_RetryNodeSearch = ((item->ItemFlags[2] & (1 << 3)) != 0) ? true : false;
bool flag_ScaryInscription = ((item->ItemFlags[2] & (1 << 4)) != 0) ? true : false;
short GoalNode = (flag_NewlBehaviour) ? item->ItemFlags[4] : Lara.Location;
@ -302,8 +304,8 @@ namespace TEN::Entities::TR4
case 0x28: //Action Read Inscription
if (laraAI.distance < pow(SECTOR(2), 2) || flag_IgnoreLaraDistance)
{
item->Animation.TargetState = 39;
item->Animation.RequiredState = 39;
item->Animation.TargetState = GUIDE_STATE_READ_INSCRIPTION;
item->Animation.RequiredState = GUIDE_STATE_READ_INSCRIPTION;
}
break;
@ -715,7 +717,7 @@ namespace TEN::Entities::TR4
break;
case 39:
case GUIDE_STATE_READ_INSCRIPTION:
if (item->Animation.FrameNumber >= g_Level.Anims[item->Animation.AnimNumber].frameBase + 20)
{
if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameBase + 20)
@ -731,12 +733,17 @@ namespace TEN::Entities::TR4
break;
}
if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameBase + 70 && item->RoomNumber == 70)
if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameBase + 70 && flag_ScaryInscription)
{
item->Animation.RequiredState = GUIDE_STATE_RUN;
item->MeshSwapBits |= 0x200000;
SoundEffect(SFX_TR4_GUIDE_SCARE, &item->Pose);
}
if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameBase + 185 && flag_ScaryInscription)
{
item->ItemFlags[2] &= ~(1 << 4); //turn off bit 4 for flag_ScaryInscription
item->MeshSwapBits &= 0xDFFFFF;
}
}
else if (enemy->Pose.Orientation.y - item->Pose.Orientation.y <= ANGLE(2.0f))
{

View file

@ -81,6 +81,7 @@ static constexpr char ScriptReserved_DoGoNextNode[] = "DoGoNextNode";
static constexpr char ScriptReserved_DoNewBehaviour[] = "DoNewBehaviour";
static constexpr char ScriptReserved_DoWaitForLara[] = "DoWaitForLara";
static constexpr char ScriptReserved_DoRunDefault[] = "DoRunDefault";
static constexpr char ScriptReserved_DoScareGuide[] = "DoScareGuide";
// Flow Functions
static constexpr char ScriptReserved_AddLevel[] = "AddLevel";

View file

@ -187,6 +187,10 @@ ScriptReserved_DoWaitForLara, & Moveable::DoWaitForLara,
// @tparam boolean value, true to make it run to the next AI node, false to restore the original behaviour. Default is false.
ScriptReserved_DoRunDefault, & Moveable::DoRunDefault,
/// The next time the guide reads an inscription, it will activate his scared routine.
// @function Moveable:DoScareGuide
// @tparam boolean value, true to activate the order, flase to cancel it. Default is true.
ScriptReserved_DoScareGuide, & Moveable::DoScareGuide,
/// Get the status of object.
// possible values:
@ -919,6 +923,23 @@ void Moveable::DoRunDefault(bool isRunDefault)
}
}
void Moveable::DoScareGuide(bool isScaryInscription)
{
if (m_item->ObjectNumber != ID_GUIDE)
{
std::string InfoStr = "The Lua function DoScareGuide hasn't got actions for the object " + m_item->LuaName + ", it only works for GUIDE objects.";
TENLog(InfoStr, LogLevel::Warning, LogConfig::All);
return;
}
if (isScaryInscription)
{
m_item->ItemFlags[2] |= (1 << 4); //turn on bit 4 for flag_ScaryInscription
}else{
m_item->ItemFlags[2] &= ~(1 << 4); //turn off bit 4 for flag_ScaryInscription
}
}
void Moveable::Invalidate()
{
// keep m_item as it is so that we can properly remove it from the moveables set when

View file

@ -86,6 +86,7 @@ public:
void DoNewBehaviour( bool isNewBehaviour = true);
void DoWaitForLara( bool isWaitForLara = true);
void DoRunDefault( bool isRunDefault = false);
void DoScareGuide(bool isScaryInscription = true);
[[nodiscard]] std::string GetOnHit() const;
void SetOnHit(std::string const &);