mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-30 16:00:55 +00:00
Add GetCharacterName() to retrieve an NPC's name as defined in its dialogue script, if it exists. Otherwise it will just return the same output as GetTag().
This commit is contained in:
parent
45c1cc8c08
commit
b28e5cb917
4 changed files with 28 additions and 0 deletions
|
@ -950,6 +950,7 @@ public:
|
|||
bool IsSentient() const;
|
||||
const char *GetTag(const char *def = NULL) const;
|
||||
void SetTag(const char *def);
|
||||
const char *GetCharacterName() const;
|
||||
|
||||
// Triggers SECSPAC_Exit/SECSPAC_Enter and related events if oldsec != current sector
|
||||
void CheckSectorTransition(sector_t *oldsec);
|
||||
|
|
|
@ -7399,6 +7399,19 @@ void AActor::SetTag(const char *def)
|
|||
else Tag = mStringPropertyData.Alloc(def);
|
||||
}
|
||||
|
||||
const char *AActor::GetCharacterName() const
|
||||
{
|
||||
if (Conversation && Conversation->SpeakerName.Len() != 0)
|
||||
{
|
||||
const char *cname = Conversation->SpeakerName.GetChars();
|
||||
if (cname[0] == '$')
|
||||
{
|
||||
return GStrings(cname + 1);
|
||||
}
|
||||
else return cname;
|
||||
}
|
||||
return GetTag();
|
||||
}
|
||||
|
||||
void AActor::ClearCounters()
|
||||
{
|
||||
|
|
|
@ -814,6 +814,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetTag, GetTag)
|
|||
ACTION_RETURN_STRING(res);
|
||||
}
|
||||
|
||||
static void GetCharacterName(AActor *self, FString *result)
|
||||
{
|
||||
*result = self->GetCharacterName();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetCharacterName, GetCharacterName)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
FString res;
|
||||
GetCharacterName(self, &res);
|
||||
ACTION_RETURN_STRING(res);
|
||||
}
|
||||
|
||||
static void SetTag(AActor *self, const FString &def)
|
||||
{
|
||||
if (def.IsEmpty()) self->Tag = nullptr;
|
||||
|
|
|
@ -619,6 +619,7 @@ class Actor : Thinker native
|
|||
protected native void CheckPortalTransition(bool linked = true);
|
||||
|
||||
native clearscope string GetTag(string defstr = "") const;
|
||||
native clearscope string GetCharacterName() const;
|
||||
native void SetTag(string defstr = "");
|
||||
native clearscope double GetBobOffset(double frac = 0) const;
|
||||
native void ClearCounters();
|
||||
|
|
Loading…
Reference in a new issue