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)