From 0bce6e39256c7054918dfe0302b83b574051e034 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Oct 2016 14:09:45 +0200 Subject: [PATCH] - added ACS and DECORATE setter functions for named translations. --- src/actor.h | 3 +++ src/p_acs.cpp | 23 ++++++++++++++++++++++- src/p_mobj.cpp | 17 +++++++++++++++++ src/thingdef/thingdef_codeptr.cpp | 15 +++++++++++++++ wadsrc/static/actors/actor.txt | 1 + 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/actor.h b/src/actor.h index dbb308258..3f7c1178e 100644 --- a/src/actor.h +++ b/src/actor.h @@ -755,6 +755,9 @@ public: // What species am I? virtual FName GetSpecies(); + // set translation + void SetTranslation(const char *trname); + double GetBobOffset(double ticfrac = 0) const { if (!(flags2 & MF2_FLOATBOB)) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1b52f5a93..0a2ccddac 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4379,10 +4379,11 @@ enum EACSFunctions ACSF_CheckClass = 200, ACSF_DamageActor, // [arookas] ACSF_SetActorFlag, + ACSF_SetTranslation, // ZDaemon ACSF_GetTeamScore = 19620, // (int team) - ACSF_SetTeamScore, // (int team, int value) + ACSF_SetTeamScore, // (int team, int value }; int DLevelScript::SideFromID(int id, int side) @@ -6002,6 +6003,26 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) return count; } + case ACSF_SetTranslation: + { + int tid = args[0]; + const char *trname = FBehavior::StaticLookupString(args[1]); + if (tid == 0) + { + if (activator != nullptr) + activator->SetTranslation(trname); + } + else + { + FActorIterator it(tid); + while ((actor = it.Next()) != nullptr) + { + actor->SetTranslation(trname); + } + } + return 1; + } + default: break; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index e39a07b2d..496f52e86 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6525,6 +6525,23 @@ int AActor::ApplyDamageFactor(FName damagetype, int damage) const } +void AActor::SetTranslation(const char *trname) +{ + if (*trname == 0) + { + // an empty string resets to the default + Translation = GetDefault()->Translation; + return; + } + + int tnum = R_FindCustomTranslation(trname); + if (tnum >= 0) + { + Translation = tnum; + } + // silently ignore if the name does not exist, this would create some insane message spam otherwise. +} + //---------------------------------------------------------------------------- // // DropItem handling diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index ee64df4d0..3b4e6203e 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -7412,3 +7412,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetVisibleRotation) ACTION_RETURN_BOOL(true); } + +//========================================================================== +// +// +// +//========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTranslation) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_STRING(trname); + + self->SetTranslation(trname); + return 0; +} diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 713e1497f..c82be96cd 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -344,6 +344,7 @@ ACTOR Actor native //: Thinker action native bool A_SetSpriteAngle(float angle = 0, int ptr = AAPTR_DEFAULT); action native bool A_SetSpriteRotation(float angle = 0, int ptr = AAPTR_DEFAULT); action native bool A_SetVisibleRotation(float anglestart = 0, float angleend = 0, float pitchstart = 0, float pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + native void A_SetTranslation(string transname); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0);