Removing an ability with a reseach or script?

What up, Homeworld Buddies!

I’m trying to make a game setup where the Mothership is stationary. The CPU always leaves his stationary defenses like a dummy once he runs of resources.

I was trying to do it by using the starting units and a copies of the mothership that just don’t have the move ability, but you can’t make a renamed version of the Kushan mothership for some reason. (That’s also why the Kushan Shipyard is a Taiidan Mothership in Goliath)

Anyway, that’s not gonna work.

Then I was thinking about using automatic researches to give the Motherships a speed of 0. Which should work I guess, but it’s kinda clunky and lame. So, I figured I’d ask if anyone knows an elegant way of turning abilities off.

How’s everybody doing anyhow? :b

You could try Sobgroup_AbilityActivate setting AB_Move to 0

1 Like

Hiya,

Sorry I didn’t write back in so long! This actually totally helped, but I’ve been having some trouble with it (which I think is because the memory is getting stretched too thin) and I’ve been super busy in RL.

I ended up granting the zero movement and the other upgrades with researches:


	{ 
		Name =			"Battlestations1",
		RequiredResearch =	"hideme",                       
		RequiredSubSystems =	"",                               
		Cost = 			1,
		Time = 			1,
		DisplayedName =		"",
		DisplayPriority =	0,                                                    
		Description =		"",
		UpgradeType =		Modifier,
		TargetType =		Ship,
		TargetName = "hgn_mothership",
		UpgradeName =		"MAXSPEED",
--still shoots with 0.8 , 0,5 --doesn't with 0,1 --looks like carriers and MS doesn't shoot until they arrive to act as a collection point?
		UpgradeValue =		0, 

	},	

	{ 
		Name =			"Battlestations2",
		RequiredResearch =	"hideme",                       
		RequiredSubSystems =	"",                               
		Cost = 			1,
		Time = 			1,
		DisplayedName =		"",
		DisplayPriority =	0,                                                    
		Description =		"",
		UpgradeType =		Modifier,
		TargetType =		Ship,
		TargetName = "hgn_mothership",
		UpgradeName =		"MAXHEALTH",
		UpgradeValue =		4.16667, 

	},	

	{ 
		Name =			"Battlestations3",
		RequiredResearch =	"hideme",                       
		RequiredSubSystems =	"",                               
		Cost = 			1,
		Time = 			1,
		DisplayedName =		"",
		DisplayPriority =	0,                                                    
		Description =		"",
		UpgradeType =		Ability,
		TargetType =		Ship,
		TargetName = "hgn_mothership",
		UpgradeName =		"UseSpecialWeaponsInNormalAttack",


	},

That part about the movement values was based on the classdef. If you watch the carriers, shipyards and mothership in game, they won’t really start to defend themselves until they get to the asteroid clump that they’re trying to go to. So, by setting the Mothership’s speed to zero. It never got there and wouldn’t defend itself. Taking them out of the squadclass[eDropOff] in the classdef.lua did the trick, and now they shoot back!

I couldn’t disable hyperspacing with a reasearch though. No matter what the target is, it affects everyone on the team it gets applied to.

So I added this mothership.lua:

function Check_Hs(CustomGroup, playerIndex, shipID)

	if (Player_HasResearch(playerIndex, "Battlestations1")==1) then

		SobGroup_AbilityActivate(CustomGroup, AB_Hyperspace, 0)
		SobGroup_AbilityActivate(CustomGroup, AB_Move, 0)


	else


	end
	
	
end

The no hyperspacing seems to work so far, but stopping the movement doesn’t.

The stuff I’m still working on are conflicts when the player selects certain settings that don’t overwrite each other like they should. (except for the Hiigarans, for them it works - ugh!)

Anyway, I wanted to write back before it got to be too long, which it already is. Thanks for the help!

After a bit of testing, the following appears to work to both disable move and allow the ship to attack. If used in the CustomCode section of the ship, will need to be in the Update function.

if SobGroup_InWorldBound(CustomGroup, 1)== 1 then
	SobGroup_AbilityActivate(CustomGroup, AB_Hyperspace, 0)
	SobGroup_AbilityActivate(CustomGroup, AB_Move, 0)

	SobGroup_SetTactics(CustomGroup, AggressiveTactics)
	SobGroup_SetROE(CustomGroup, OffensiveROE)
end

SobGroup_InWorldBound
Checks to see if the ship is in active space. Without this, AB_Move seems to not disable.

SobGroup_SetTactics & SobGroup_SetROE
Sets the ships Aggressive Defensive Passive stance of the ship. I believe the default settings of some ships is a Passive stance.

Example from ‘hgn_carrier.ship’

NewShipType.defaultROE=“Defensive”
NewShipType.defaultStance=“Neutral”

1 Like