Exported conversation behaviors

This commit is contained in:
nashmuhandes 2025-01-13 11:53:53 +08:00 committed by Ricardo Luís Vaz Silva
parent 7b30f9350c
commit 92dbdd3f39
2 changed files with 34 additions and 14 deletions

View file

@ -5705,6 +5705,35 @@ void R_OffsetView(FRenderViewpoint& viewPoint, const DVector3& dir, const double
//
//==========================================================================
static int CanTalk(AActor *self)
{
return self->Conversation != nullptr;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, CanTalk, CanTalk)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(CanTalk(self));
}
static int NativeStartConversation(AActor *self, AActor *player, bool faceTalker, bool saveAngle)
{
if (self->health <= 0 || (self->flags4 & MF4_INCOMBAT) || self->Conversation == nullptr)
return false;
self->ConversationAnimation(0);
P_StartConversation(self, player, faceTalker, saveAngle);
return true;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, StartConversation, NativeStartConversation)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(player, AActor);
PARAM_BOOL(faceTalker);
PARAM_BOOL(saveAngle);
ACTION_RETURN_BOOL(NativeStartConversation(self, player, faceTalker, saveAngle));
}
bool P_TalkFacing(AActor *player)
{
static const double angleofs[] = { 0, 90./16, -90./16 };
@ -5713,19 +5742,8 @@ bool P_TalkFacing(AActor *player)
for (double angle : angleofs)
{
P_AimLineAttack(player, player->Angles.Yaw + DAngle::fromDeg(angle), TALKRANGE, &t, DAngle::fromDeg(35.), ALF_FORCENOSMART | ALF_CHECKCONVERSATION | ALF_PORTALRESTRICT);
if (t.linetarget != NULL)
{
if (t.linetarget->health > 0 && // Dead things can't talk.
!(t.linetarget->flags4 & MF4_INCOMBAT) && // Fighting things don't talk either.
t.linetarget->Conversation != NULL)
{
// Give the NPC a chance to play a brief animation
t.linetarget->ConversationAnimation(0);
P_StartConversation(t.linetarget, player, true, true);
return true;
}
return false;
}
if (t.linetarget != nullptr)
return NativeStartConversation(t.linetarget, player, true, true);
}
return false;
}

View file

@ -699,7 +699,9 @@ class Actor : Thinker native
native clearscope int GetRenderStyle() const;
native clearscope bool CheckKeys(int locknum, bool remote, bool quiet = false);
protected native void CheckPortalTransition(bool linked = true);
native clearscope bool CanTalk() const;
native bool StartConversation(Actor player, bool faceTalker = true, bool saveAngle = true);
native clearscope string GetTag(string defstr = "") const;
native clearscope string GetCharacterName() const;
native void SetTag(string defstr = "");