Raised This Month: $32 Target: $400
 8% 

FF2 [SNIPPET] Per-boss basis ability translations.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
93SHADoW
AlliedModders Donor
Join Date: Jul 2014
Location: Houston, TX
Old 12-20-2015 , 13:47   [SNIPPET] Per-boss basis ability translations.
Reply With Quote #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.
93SHADoW is offline
Send a message via AIM to 93SHADoW Send a message via Skype™ to 93SHADoW
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 12-20-2015 , 16:48   Re: [SNIPPET] Per-boss basis ability translations.
Reply With Quote #2

maybe it'd be easier to point like arg1 to phrases.bossname.txt and make the boss load translations from there

that way you only need one arg and the boss maker can use translations in the format they normally are
__________________

Last edited by Chdata; 12-20-2015 at 16:49.
Chdata is offline
93SHADoW
AlliedModders Donor
Join Date: Jul 2014
Location: Houston, TX
Old 12-20-2015 , 17:07   Re: [SNIPPET] Per-boss basis ability translations.
Reply With Quote #3

Quote:
Originally Posted by Chdata View Post
maybe it'd be easier to point like arg1 to phrases.bossname.txt and make the boss load translations from there

that way you only need one arg and the boss maker can use translations in the format they normally are
I was originally going to go that route, but iirc, the language would need to be enabled from languages.cfg, making that redundant if they didn't enable said language on their SM install.
And this method skips the need to enable the language from languages.cfg anyway (you'll see this method of loading a different translations file being used in an update for Saxtoner's charge_salmon).

Same way how ff2's description_<language> bypasses the need to enable the desired language from languages.cfg

Also for some reason, if the translations file is approximately 350+ lines, it starts spitting out errors stating it can't find any phrases after said line number, despite being formatted correctly.
__________________

Last edited by 93SHADoW; 12-21-2015 at 10:54.
93SHADoW is offline
Send a message via AIM to 93SHADoW Send a message via Skype™ to 93SHADoW
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode