A possible solution to hw2 strike crafts dock with support frigates

Since RM is using HW2 engine and this major problem haven’t been fixed:Support Frigate Issue Repairing Assault Craft
I just came up with an idea to fix it.
Preparation (take hgn_interceptor as an example):
·Add a custom code into hgn_interceptor.ship:
addCustomCode(NewShipType,<CodeFilePath>,"","Create_GroupDock","Update_GroupDock","","hgn_interceptor",1)
·Make another ship named hgn_interceptor_1, copy it from hgn_interceptor
·Set its dockfamily to Fighter_hw1
·Set its supply value to 0
·Set its build batch to 1
·Make it share hgn_interceptor’s hod file
And here’s that custom code:

UnitToLatch = "Kus_ResourceController,Kus_SupportFrigate,Tai_ResourceController,Tai_SupportFrigate"

function Create_GroupDock(CustomGroup, playerIndex, shipID)
	SobGroup_CreateIfNotExist("GroupDockTargetGroup"..shipID)
	SobGroup_CreateIfNotExist("GroupDockTempGroup"..shipID)
end

function Update_GroupDock(CustomGroup, playerIndex, shipID)
	if(SobGroup_HealthPercentage(CustomGroup)==1)and(SobGroup_Empty("GroupDockTempGroup"..shipID)==1)and(SobGroup_Empty("GroupDockTargetGroup"..shipID)==0)then
		SobGroup_Clear("GroupDockTargetGroup"..shipID)
	end
	if(SobGroup_Empty("GroupDockTargetGroup"..shipID)==1)and(SobGroup_IsDoingAbility(CustomGroup,AB_Guard)==1)then
		SobGroup_GetCommandTargets("GroupDockTargetGroup"..shipID,CustomGroup,COMMAND_Guard)
	elseif(SobGroup_HealthPercentage(CustomGroup)<1)and(SobGroup_Count("GroupDockTargetGroup"..shipID)==1)and(SobGroup_IsDoingAbility(CustomGroup,AB_Guard)==1)and(SobGroup_AreAnyOfTheseTypes("GroupDockTargetGroup"..shipID,UnitToLatch)==1)and(SobGroup_Empty("GroupDockTempGroup"..shipID)==1)then
		if(SobGroup_GetDistanceToSobGroup(CustomGroup,"GroupDockTargetGroup"..shipID)<500)and(SobGroup_AreAllInRealSpace(CustomGroup)==1)then
			SobGroup_Stop(playerIndex,CustomGroup)
			SobGroup_Despawn(CustomGroup)
			SobGroup_SetHealth(CustomGroup,1)
			local iHealth=SobGroup_HealthPercentage(CustomGroup)
			Volume_AddSphere("GroupDockSpawn"..shipID,SobGroup_GetPosition(CustomGroup),10)
			for i=1,SobGroup_Count(CustomGroup) do
				SobGroup_SpawnNewShipInSobGroup(playerIndex,CustomGroup.."_1",CustomGroup..i..shipID,"GroupDockTempGroup"..shipID,"GroupDockSpawn"..shipID)
			end
			SobGroup_SetInvulnerability("GroupDockTempGroup"..shipID, 1)
			Volume_Delete("GroupDockSpawn"..shipID)
			SobGroup_SetHealth("GroupDockTempGroup"..shipID,iHealth)
			SobGroup_DockSobGroupAndStayDocked("GroupDockTempGroup"..shipID, "GroupDockTargetGroup"..shipID)
		end
	elseif(SobGroup_Empty("GroupDockTempGroup"..shipID)==0)then
		if(SobGroup_IsDockedSobGroup("GroupDockTempGroup"..shipID,"GroupDockTargetGroup"..shipID)==1)then
			if(SobGroup_HealthPercentage("GroupDockTempGroup"..shipID)==1)then
				SobGroup_Launch("GroupDockTempGroup"..shipID,"GroupDockTargetGroup"..shipID)
			end
		elseif(SobGroup_AreAllInHyperspace(CustomGroup)==1)and(SobGroup_HealthPercentage("GroupDockTempGroup"..shipID)==1)then
			Volume_AddSphere("GroupDockSpawn"..shipID,SobGroup_GetPosition("GroupDockTempGroup"..shipID),10)
			SobGroup_Spawn(CustomGroup,"GroupDockSpawn"..shipID)
			Volume_Delete("GroupDockSpawn"..shipID)
			SobGroup_SetInvulnerability("GroupDockTempGroup"..shipID, 0)
			SobGroup_GuardSobGroup("GroupDockTempGroup"..shipID, "GroupDockTargetGroup"..shipID)
			SobGroup_MakeDead("GroupDockTempGroup"..shipID)
			SobGroup_Clear("GroupDockTargetGroup"..shipID)
		end
	end
end

function SobGroup_GetDistanceToSobGroup(sb1,sb2)
	local p1=SobGroup_GetPosition(sb1)
	local p2=SobGroup_GetPosition(sb2)
	local dis=0
	for i=1,3 do
		dis=dis+(p1[i]-p2[i])^2
	end
	return sqrt(dis)
end

Current problem with this solution:
·SobGroup_GetCommandTargets only works with attack and guard command, so strike crafts can only dock with support frigates by guarding it
·Srike crafts will be invulnerable while docking, and their HP will be averaged before docking
·Not regenerating lost units make this operation kind of useless
·Visual issues exist
·You still can’t make strike crafts remain docked on a support frigate and jump with it

1 Like

@shadowwinterknig @cloaked have you seen this?

Thanks for the heads up Dom2, and thanks for taking a stab at it HW_Lover!

Several people have attempted other solutions for this bug, but they all fall short of a ‘good solution’. So far the best solution is here (2nd bug on the list):

If anyone can fix all the affected .hods, that would be ideal.

There is a version of cfhoded that can partially open the new hod files (https://github.com/Fallen-Angel/CFHodEd) you could use that to grab the textures but i dont think it can read the mesh. Using that and the old hods is what i did to get the research ship to spin. Could do a similar thing to add launch paths.

Edit: The github page, change the branch to remastered to get the “updated” version

2 Likes