[SCRIPTING] Support Module script

(Hero Crafter 1987 (Homeworld Universal Conquest Mod)) #1

I’ve been trying to find a way to see if I can use a subsystem to increase the unit cap but have found no results. Could I get some help on this?

(Taiidan Republic Mod) #2

Could you artificially cap using custom code (i.e. restrict build our research) on your ship, then change that cap if the subsystem is detected?

(Hero Crafter 1987 (Homeworld Universal Conquest Mod)) #3

@Dom2 That’s what I thought. I have a script here:

dofilepath(“data:scripts/races/beast/deathmatch/unitcaps/normal.lua”)
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support1”) then
supplyLimit(“SupportUnits”, 60);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support2”) then
supplyLimit(“SupportUnits”, 90);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support3”) then
supplyLimit(“SupportUnits”, 120);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support4”) then
supplyLimit(“SupportUnits”, 150);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support5”) then
supplyLimit(“SupportUnits”, 180);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support6”) then
supplyLimit(“SupportUnits”, 210);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support7”) then
supplyLimit(“SupportUnits”, 240);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support8”) then
supplyLimit(“SupportUnits”, 270);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support9”) then
supplyLimit(“SupportUnits”, 300);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support10”) then
supplyLimit(“SupportUnits”, 330);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support11”) then
supplyLimit(“SupportUnits”, 360);
end
if SobGroup_HasSubSystem(CustomGroup, “Bst_Support12”) then
supplyLimit(“SupportUnits”, 400);
end

The normal.lua script is here:

supplyLimit(“SupportUnits”, 30);

I haven’t had time to test it yet…

(Taiidan Republic Mod) #4

Hmmm, what worries me about that function is that it has no player index, so if it does work, it would change the unit caps for everyone…

(Hero Crafter 1987 (Homeworld Universal Conquest Mod)) #5

How can this be fixed?

(Taiidan Republic Mod) #6

Well, I don’t think you can call supplyLimit() from inside custom code. I tried it and got an error. I was suggesting to use:

SobGroup_FillShipsByType(<sSobGroupToFillName>, <sSobGroupName>, <sShipTypeName>)
Player_RestrictBuildOption(<iPlayerIndex>, <sBuildOption>)

You can use the first one to get the number of ships of each type, then the second to prevent the player building any more ships until the module is built. When the module is built, you can use:

Player_UnRestrictBuildOption(<iPlayerIndex>, <sBuildOption>)

This will allow the player to build again.

Its not ideal, but its all I can think of…

(Hero Crafter 1987 (Homeworld Universal Conquest Mod)) #7

Thanks. I’ll try it out.

(Trebic) #8

It might be better to use Player_GetNumberOfSquadronsOfTypeAwakeOrSleeping( iPlayerIndex, sShipType ).

Also, you may want to customise Player_RestrictBuildOption/Player_UnrestrictBuildOption as a script may unrestrict, or you may unrestrict a ship that is ment to be restricted (eg hw1 research ships are at times restricted and unrestricting them can cause issues)

There is also SobGroup_RestrictBuildOption/SobGroup_UnrestrictBuildOption that may also cause issues

2 Likes
(Hero Crafter 1987 (Homeworld Universal Conquest Mod)) #9

I’ll see what I can do. Thanks for the heads up.

1 Like
(Trebic) #10

I wonder if Relic had intentions of adding a way to increase/decrease the unit caps.
Within some .ship files, there is an option ‘addedUnitCaps’. All ships that have it, it is set to 101. I don’t think it does anything though.
In /soundscripts/speechlogic/eventtext.lua there is
STATUS_UNITCAPREACHED_1 = “$5695” – Unit Limit Reached|
STATUS_UNITCAPINCREASED_1 = “$5696” – Unit Limit increased|
STATUS_UNITCAPDECREASED_1 = “$5697” – Unit Limit decreased|
the locales for these are in events.dat
Also, in the exe there is ‘supplyDesc’ (along with supplyLimit, supplyIndent and supplyShow) don’t know what it does, or it’s arguments… But yeah… Descriptions??

(GOLIATH Mod) #11

Have a look inside of the complex mod. They have a reasearch item that increases the supply limit, so maybe you can do it the same way.

1 Like
(Trebic) #12

I believe their way is thru the use of ships (adding an invisible ship to decrease the amount of available supply, then destroying the ships to increase that amount)

(GOLIATH Mod) #13

I just really played it for the first time yesterday. For modders, there’s a whole bunch of really cool stuff in there, but I kind of think they changed so much stuff that it’s a little bit unstable. I read in the comments that a lot of people have crashes, and I just tried to load a save game from a player vs. CPU skirmish and it didn’t work either. So IF you’re going to copy some of the stuff they did, I think you should also test it out one function at a time to see if it breaks your mod in some way.

[MOD] Cataclysm Remastered
(Hero Crafter 1987 (Homeworld Universal Conquest Mod)) #14

It’s a matter of shaders when people try to use their assets. Complex uses custom shaders.