Skip to content

Commit

Permalink
Added HasConversation
Browse files Browse the repository at this point in the history
  • Loading branch information
nashmuhandes committed Jan 17, 2025
1 parent 5948abb commit 81ba080
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/playsim/p_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5704,7 +5704,7 @@ void R_OffsetView(FRenderViewpoint& viewPoint, const DVector3& dir, const double

static int CanTalk(AActor *self)
{
return self->Conversation != nullptr;
return self->Conversation != nullptr && self->health > 0 && !(self->flags4 & MF4_INCOMBAT);
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, CanTalk, CanTalk)
Expand All @@ -5713,10 +5713,22 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, CanTalk, CanTalk)
ACTION_RETURN_BOOL(CanTalk(self));
}

static int HasConversation(AActor *self)
{
return self->Conversation != nullptr;
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, HasConversation, HasConversation)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_BOOL(HasConversation(self));
}

static int NativeStartConversation(AActor *self, AActor *player, bool faceTalker, bool saveAngle)
{
if (self->health <= 0 || (self->flags4 & MF4_INCOMBAT) || self->Conversation == nullptr)
if (!CanTalk(self))
return false;

self->ConversationAnimation(0);
P_StartConversation(self, player, faceTalker, saveAngle);
return true;
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/actors/actor.zs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ 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 HasConversation() const;
native clearscope bool CanTalk() const;
native bool StartConversation(Actor player, bool faceTalker = true, bool saveAngle = true);

Expand Down

0 comments on commit 81ba080

Please sign in to comment.