AlliedModders Donor
Join Date: Jul 2014
Location: Houston, TX
|
12-20-2015
, 13:47
[SNIPPET] Per-boss basis ability translations.
|
#1
|
Considering the limitations of using translations files for boss ability HUD texts, i came up with this system instead, to allow customizing the HUD texts on a per-boss basis AND allow multi-language support at the same time.
As we all know, using the standard translations files for HUD text doesn't really allow any customization of the texts on a per-boss basis, as the same text is used for every boss sharing the same ability.
This was inspired by sarysa's use of HUD texts as ability args as opposed to being translations file phrases on a translations file.
So here it is:
Code:
#define INCREMENT 100 // Arg offset - ideal values are powers of 10.
#define MAXARGINCREMENT 1000 // Must be multiples of what INCREMENT is defined as!
stock int Client_GetLanguageArgOffset(int client, int boss, const char[] ability_name)
{
char text[16], language[16];
GetLanguageInfo(GetClientLanguage(client), language, 8, text, 8);
Format(language, sizeof(language), "%s", language);
for(int argument=0;argument<=MAXARGINCREMENT;argument+=INCREMENT)
{
FF2_GetAbilityArgumentString(boss, this_plugin_name, ability_name, argument+1, text, sizeof(text)); // arg1 - language code (same as translations file)
if(text[0] && StrEqual(language, text, false))
{
return argument;
}
}
return 0;
}
An example of it in use:
Code:
if(FF2_HasAbility(bossIdx, this_plugin_name, "blitzkrieg_phrases"))
{
for(int client=1; client<=MaxClients; client++)
{
if(!IsValidClient(client))
continue;
int arg=Client_GetLanguageArgOffset(client, bossIdx, "blitzkrieg_phrases");
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+28, BHS_BossHud[client]);
if(!BHS_BossHud[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 28, BHS_BossHud[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", MaxClientRevives>0 ? arg+29 : arg+30, BHS_ClientHUD[client]);
if(!BHS_ClientHUD[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", MaxClientRevives>0 ? 29 : 30, BHS_ClientHUD[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+31, BHS_Easy[client]);
if(!BHS_Easy[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 31, BHS_Easy[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+32, BHS_Normal[client]);
if(!BHS_Normal[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 32, BHS_Normal[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+33, BHS_Intermediate[client]);
if(!BHS_Intermediate[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 33, BHS_Intermediate[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+34, BHS_Difficult[client]);
if(!BHS_Difficult[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 34, BHS_Difficult[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+35, BHS_Lunatic[client]);
if(!BHS_Lunatic[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 35, BHS_Lunatic[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+36, BHS_Insane[client]);
if(!BHS_Insane[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 36, BHS_Insane[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+37, BHS_Godlike[client]);
if(!BHS_Godlike[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 37, BHS_Godlike[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+38, BHS_RocketHell[client]);
if(!BHS_RocketHell[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 38, BHS_RocketHell[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+39, BHS_TotalBlitzkrieg[client]);
if(!BHS_TotalBlitzkrieg[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 39, BHS_TotalBlitzkrieg[client]);
}
ReadCenterText(bossIdx, "blitzkrieg_phrases", arg+40, BHS_RNGDisplay[client]);
if(!BHS_RNGDisplay[client][0])
{
ReadCenterText(bossIdx, "blitzkrieg_phrases", 40, BHS_RNGDisplay[client]);
}
}
}
Sample config:
Code:
"ability11"
{
"name" "blitzkrieg_phrases" // The purpose of this is to allow customization on a per-boss basis, such as the Donut Steel variant from VS Ponyville
"arg1" "en"
"arg28" "Difficulty: %s" // HUD - Difficulty - Boss
"arg29" "Difficulty: %s\nRevives: %i of %i" // HUD - Difficulty (with revive limit)
"arg30" "Difficulty: %s" // HUD - Difficulty (unlimited revives)
"arg31" "Easy" // HUD - Easy
"arg32" "Normal" // HUD - Normal
"arg33" "Intermediate" // HUD - Intermediate
"arg34" "Difficult" // HUD - Difficult
"arg35" "Lunatic" // HUD - Lunatic
"arg36" "Insane" // HUD - Insane
"arg37" "Godlike" // HUD - Godlike
"arg38" "Rocket Hell" // HUD - Rocket Hell
"arg39" "Total Blitzkrieg" // HUD - Total Blitzkrieg
"arg40" "RNG Level: %i" // HUD - RNG Level
"arg101" "es" // Español
"arg128" "Nivel: %s"
"arg129" "Nivel: %s\nVeces Revivido: %i de %i"
"arg130" "Nivel: %s"
"arg131" "Facil"
"arg132" "Normal"
"arg133" "intermedio"
"arg134" "Difícil"
"arg135" "Lunatico"
"arg136" "Brutal"
"arg137" "Imposible"
"arg138" "Infierno"
"arg139" "Blitzkrieg Total"
"arg140" "Nivel: %i"
"arg201" "ko" // 조선말
"arg228" "난이도: %s"
"arg229" "난이도: %s\n소생 횟수: %i / %i"
"arg230" "난이도: %s"
"arg231" "쉬움"
"arg232" "보통"
"arg233" "중간"
"arg234" "어려움"
"arg235" "루나틱"
"arg236" "광기의"
"arg237" "신급의"
"arg238" "로켓지옥"
"arg239" "대학살 그 자체"
"arg240" "RNG 레벨: %i"
}
__________________
Last edited by 93SHADoW; 12-20-2015 at 14:02.
|
|