- added ACS and DECORATE setter functions for named translations.

This commit is contained in:
Christoph Oelckers 2016-10-02 14:09:45 +02:00
parent a505e91032
commit 0bce6e3925
5 changed files with 58 additions and 1 deletions

View File

@ -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))

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);