Raised This Month: $51 Target: $400
 12% 

[TF2] Replacing voice lines for a class, modifying Be The Robot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlphaBlaster
Member
Join Date: Nov 2014
Location: California
Old 08-20-2022 , 21:40   [TF2] Replacing voice lines for a class, modifying Be The Robot
Reply With Quote #1

I'm a newbie to working with sourcepawn and I'm making a modification of Be The Robot that will function similarly by allowing Soldier to become the Mercenary from Open Fortress. Everything about this process is extremely straightforward, however I am confused looking at the code MasterOfTheXP used to change the classes' voiceover to that of their MvM counterparts, and how I can adapt this to do something similar, but instead replace "soldier" with "mercenary" as the structure and location of Mercenary's voiceover will be the same. (eg. vo/soldier_medic01 -> vo/mercenary_medic01)

The following is not my code, and is from Be The Robot. I am asking how I can adapt this to instead replace the Soldier player's voicelines with that of Mercenary's as mentioned above.

Code:
public Action:SoundHook(clients[64], &numClients, String:sound[PLATFORM_MAX_PATH], &Ent, &channel, &Float:volume, &level, &pitch, &flags)
{
	if (!GetConVarBool(cvarSounds)) return Plugin_Continue;
	if (volume == 0.0 || volume == 0.9997) return Plugin_Continue;
	if (!IsValidClient(Ent)) return Plugin_Continue;
	new client = Ent;
	new TFClassType:class = TF2_GetPlayerClass(client);
	if (Status[client] == RobotStatus_Robot)
	{
		if (StrContains(sound, "player/footsteps/", false) != -1 && class != TFClass_Medic && GetConVarBool(cvarFootsteps))
		{
			new rand = GetRandomInt(1,18);
			Format(sound, sizeof(sound), "mvm/player/footsteps/robostep_%s%i.wav", (rand < 10) ? "0" : "", rand);
			pitch = GetRandomInt(95, 100);
			EmitSoundToAll(sound, client, _, _, _, 0.25, pitch);
			return Plugin_Changed;
		}
		if (StrContains(sound, "vo/", false) == -1) return Plugin_Continue;
		if (StrContains(sound, "announcer", false) != -1) return Plugin_Continue;
		if (volume == 0.99997) return Plugin_Continue;
		ReplaceString(sound, sizeof(sound), "vo/", "vo/mvm/norm/", false);
		ReplaceString(sound, sizeof(sound), ".wav", ".mp3", false);
		new String:classname[10], String:classname_mvm[15];
		TF2_GetNameOfClass(class, classname, sizeof(classname));
		Format(classname_mvm, sizeof(classname_mvm), "%s_mvm", classname);
		ReplaceString(sound, sizeof(sound), classname, classname_mvm, false);
		new String:soundchk[PLATFORM_MAX_PATH];
		Format(soundchk, sizeof(soundchk), "sound/%s", sound);
		if (!FileExists(soundchk, true) && GetConVarBool(cvarFileExists)) return Plugin_Continue;
		PrecacheSound(sound);
		return Plugin_Changed;
	}
	return Plugin_Continue;
}
(And yes, I will give proper credit for use of Be The Robot, I figure it's not a problem seeing as Be The Skeleton exists)
Attached Files
File Type: sp Get Plugin or Get Source (bethemercenary.sp - 31 views - 13.1 KB)
File Type: inc bethemercenary.inc (1.8 KB, 22 views)

Last edited by AlphaBlaster; 08-20-2022 at 21:42.
AlphaBlaster is offline
Reply



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 00:13.


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