Race index values are not all unique if you have race restrictions

I really don’t know how you can tell that this info is in subtitle.h when nobody here has ever see the hw2 source code (as already said in the past, the subtitle.h file you referred before is from hw1 source code, not hw2 :wink: )

1 Like

Yes, but, i supposed is the same file, is not logical to change the name of this file, they have same function > define all about subtitle you see in the screen in the game <

And it’s the same as HW2, in the Classic version, the limit is 16, in the HWRM, GBX increased this limit to 32. This file is not really important for the game, so the change between version is really a minor change … We have a thing which works perfectly, thus we go not quite changed…

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 :slight_smile:

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.

2 Likes

It’s really a good news to hear …

Theme by races. In SSC mod we have to plan more than 100+ theme so … we are just limit actually xD

Thanks in advanced … Take the time to make this modification … :wink:

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?

There’s a workaround we use in FX:Galaxy MOD:

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.

3 Likes

Where is the raceid.lua file and all the edit locations at?

Once you add the code and start a game, the file will be created in your bin/profiles/Profile# folder.

I while back I tweaked Lone Wolf’s code from the FX mod, to apply a bit better to the base game:

scripts\rules\deathmatch\deathmatch.lua
scripts\rules\deathmatchhw1\deathmatchhw1.lua
scripts\rules\deathmatchhw2\deathmatchhw2.lua

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

This got my custom voice to work but now the Emperor voice wont work.
It’s like it was replaced by the Fleet voice.

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)

It’s still not doing the Emperor voice.

You may need to explain as of how taiidan does not = Taiidan.

if ("taiidan" == "Taiidan") then print("True") else print("False") end

The above code will return False. This is due to them have different uppercase/lowercase letters.

No, you shouldn’t put it under OnInit. You should put it in OnStartOrLoad(), or it can mess up when player read a saved game.

1 Like

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 :smiley:

It’s only taken 3 years (since this thread was open), but this issue is resolved :stuck_out_tongue:

5 Likes

I feel like I was going in this direction about a year ago…

1 Like

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 :sweat_smile:

1 Like

Fixed it. I already had a race list file there. I deleted it and the game fixed itself.