Logic has nothing to do with it when hw1 and hw2 are two totally different beasts (they would not have so much problems incorporating functionalities from hw1 to hw2 if that was not the case ^^).
Note that I would totally agree with you if the two were somewhat similar in design, or if hw2 was based on hw1 with some modifications/upgrades, but that’s clearly not the case here.
I understand your concern though, and hope that they can help you with it
Wow, yeah this system is more than a little bit rigid. I need to look into how it is used, but it would make WAY more sense to me to have the subtitle themes in the Races folders (and a default central folder), and refer to a specific theme by name, not number. That may or may not be possible… So no promises. But I will look at it in the coming days.
This bug affects Taiidan too - not just mods. Player vs CPU > Homeworld 1 Deathmatch > Play as Taiidan and you’ll get the Vaygr voice actor.
Taiidan and Vaygr share race ID 2, due to the game type filters… This causes the raceHelper() function to work incorrectly in soundscripts/speechlogic/commands.lua
I’m currently trying to fix this behavior in the default game. Whats the best workaround?
Run the following function in every game rule’s OnStartOrLoad() function:
function LW_SpeechRaceHelper()
if (writeto("raceid.lua")) then
local RaceCount = Race_GetCount()
write("Race_ID = \n{\n")
for i = 1,RaceCount-1 do
write("\t\""..Race_GetName(i).."\",\n")
end
write("}")
writeto()
end
end
This will output all races name and their race_id in current match to a file.
And edit raceHelper() function in soundscripts\speechlogic\commands.lua to something like this:
function raceHelper()
if not bRaceID then
bRaceID = 1
_ALERT("Reading Race ID From raceid.lua")
dofilepath("player:raceid.lua")
local output = "\n-----------------\nRaceID\tRaceName\n"
for index, value in Race_ID do
output = output..index.."\t"..value.."\n"
end
output = output.."-----------------"
_ALERT(output)
end
if (Race_ID[currentRace] == "Vaygr") then
return NameMakaan
elseif (Race_ID[currentRace] == "Taiidan")or(Race_ID[currentRace] == "Turanic")or(Race_ID[currentRace] == "Bentusi") then
return NameEmperor
elseif (Race_ID[currentRace] == "Keeper") then
return NameKeeper
elseif (Race_ID[currentRace] == "Hiigaran") then
return NameFleetHW2C
else
return NameFleetCommand
end
end
-- Race IDs
Race_ID =
{
"Bentusi",
"Hiigaran",
"Kadesh",
"Keeper",
"Kushan",
"Taiidan",
"Turanic",
"Vaygr",
}
bRaceID = nil
This will let the game read the file written by game rule and look for the right voice by the race name instead of its race id. Notice that I’ve provided with a default Race_ID table, in case if you forget to write raceid.lua, we still has a default table so the game won’t crash.
function OnStartOrLoad()
-- Write race list
LW_SpeechRaceHelper()
end
scripts\scar\scar_util.lua
function LW_SpeechRaceHelper()
if (writeto("racelist.lua")) then
local RaceCount = Race_GetCount()
write("Race_ID = \n{\n")
for i = 1,RaceCount-1 do
write("\t\""..Race_GetName(i).."\",\n")
end
write("}")
writeto()
end
end
soundscripts\speechlogic\commands.lua
function raceHelper()
if not bRaceID then
bRaceID = 1
dofilepath("player:racelist.lua")
end
if (Race_ID[currentRace] == "Vaygr") then
return NameMakaan
elseif (Race_ID[currentRace] == "Taiidan") then
return NameEmperor
else
return NameFleetCommand
end
end
-- Race IDs
Race_ID =
{
"Hiigaran",
"Vaygr",
"Keeper",
"Bentusi",
"Kushan",
"Taiidan",
"Turanic Raiders",
"Kadeshi",
"P3",
}
bRaceID = nil
You will want to check your spelling as i believe it’s case sensitive. taiidan does not equal Taiidan.
Quick way to check if your code is all correct is in the scar_util.lua file, add a print statement to the for loop.
for i = 1,RaceCount-1 do
write("\t\""..Race_GetName(i).."\","\n")
print("Race Name '"..Race_GetName(i).."'")
end
You could also add a print statement to the beginning of the raceHelper function to see what the currentRace number is
print("currentRace = "..currentRace)
print("RaceName = "..Race_ID[currentRace]) --If this causes an error, the Race Name doesn't exist in the Race_ID list created from LW_SpeechRaceHelper
Just to note, this second code will be run a fair few times (Pretty much everytime a voice is played)
Good to know. I see OnStartOrLoad() in the mission#.lua files, however deathmatch.lua only has OnInit(), so I take it the function must be added. Edit: this works!
I finally got this to work! In addition to the raceID file generation code from @Cloaked :
I needed to add the following to my *\soundscripts\speechlogic\commands.lua file
FederationCommand = "fed_computer"
KlingonCommand = "kng_fleetcommand"
RomulanCommand = "rom_fleetcommand"
GornCommand = nil
CardassianCommand = "car_fleetcommand"
DominionCommand = nil
BorgCommand = "brg_drone"
function raceHelper()
dofilepath("player:raceid.lua")
if (Race_ID[currentRace] == "Federation") then
return FederationCommand
elseif (Race_ID[currentRace] == "Klingon") then
return KlingonCommand
elseif (Race_ID[currentRace] == "Romulan") then
return RomulanCommand
elseif (Race_ID[currentRace] == "Borg") then
return BorgCommand
elseif (Race_ID[currentRace] == "Cardassian") then
return CardassianCommand
elseif (Race_ID[currentRace] == "Gorn") then
return GornCommand
elseif (Race_ID[currentRace] == "Dominion") then
return DominionCommand
else
return FederationCommand
end
end
This then needed to be referenced from the playVoiceoverSpeech() function like so
function playVoiceoverSpeech(soundFile)
if( raceHelper() ~= nil ) then
playSpeechActor(soundFile, raceHelper(), 0, Frequency_Command)
end
end
And now the Gorn don’t have a Cardassian voice over! When I do get something sorted for them I’ll be able to slot that right in no trouble, and any extra races
It’s only taken 3 years (since this thread was open), but this issue is resolved
To be fair, I saw your thread first while bashing my head on this last night, but declaring what was returned from the helper function instead of just returning the value you wanted took longer to… appreciate