[SOLVED] Unique unit

Everything about mods can be found here.

Moderator: Morax

[SOLVED] Unique unit

Postby Mavr390 » 16 May 2020, 20:34

Hi all!
Maybe someone knows how to make sure that after the ACU/SCU/engineer builds an experimental unit, he no longer appears on the construction list before he is destroyed?
Last edited by Mavr390 on 20 May 2020, 05:30, edited 1 time in total.
Mavr390
Crusader
 
Posts: 25
Joined: 26 Oct 2019, 07:54
Has liked: 8 times
Been liked: 0 time
FAF User Name: Mavr390

Re: Unique unit

Postby DDDX » 17 May 2020, 00:10

sure. easy to do.
There are a couple of ways to do this

You could do it with the map script, make the map scan through all your units, or just the unique category of that unit (you can put anything in its category list), or you can list the unit by blueprint id. This is more CPU intensive, but works nicely.
Then if it is found, you can add restrictions to building it into your ACU, or whatever. if it's not there, nothing happens life goes on

Another way would be with a mod, to modify that unit's script file so that it kills any specific units that are over a total number (of 1, in your case)
Third way, again through a mod, with that unit's script file, would be to use the units OnStartBeingBuilt and OnCreate functions to immediately restrict further building when you start or when you complete building that unit.

2 things though, if you use OnStartBeingBuilt function, then you need to finish the unit completely, if you stop constructing or if it gets killed before being finished, you will not be able to make another one, or continue constructing that one. That's because SupCom does not even allow you to assist building of units you don't have available for building...
And if you use OnCreate function then nothing prevents you to start making 20 before you finish the 1.st one.
But that can be contered with the script that kills any unit over a total number (of 1). or you could make the build time 1 second, but require to have insane mass and energy in storages in order to build it instantly.

Check my mod called "Survival Mayhem&BO balance".
In it there is a series of hero units that can build limited numbers of improved turrets, and some OP minibosses. For example, check the unit XSL9905, that's a final level (out of 5) Seraphim hero, and check xac1101 or sxslew0001u (both are very OP units, max 1 allowed of either one of the other, you cannot have both). Those 2 are not in the units folder, but in the hook folder, find them there.

And if you have any questions, let me know.
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Unique unit

Postby Mavr390 » 17 May 2020, 13:19

DDDX wrote:OnStartBeingBuilt and OnCreate

How to do using this?
Mavr390
Crusader
 
Posts: 25
Joined: 26 Oct 2019, 07:54
Has liked: 8 times
Been liked: 0 time
FAF User Name: Mavr390

Re: Unique unit

Postby DDDX » 17 May 2020, 23:49

I told you where to look in the previous message. Everything is there, already made for you to simply copy-paste :p
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Unique unit

Postby Mavr390 » 18 May 2020, 21:48

DDDX, I tried copy and paste, but there is no effect. Perhaps because I am making a mod for the retail version of the game, that is, not a FAF and not a steam version of the game.
Mavr390
Crusader
 
Posts: 25
Joined: 26 Oct 2019, 07:54
Has liked: 8 times
Been liked: 0 time
FAF User Name: Mavr390

Re: Unique unit

Postby DDDX » 19 May 2020, 00:31

what do you mean, there is no effect? Which error in the log file did you get?
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Unique unit

Postby Mavr390 » 19 May 2020, 05:34

DDDX, I found an error due to which it did not work.
But your code only removes the unit from the construction list. How to make sure that a unit appears on the ACU construction list after destruction?

Code: Select all
    OnStartBeingBuilt = function(self,builder,layer)   
        TLandUnit.OnStartBeingBuilt(self,builder,layer)
   for i, Army in ListArmies() do
       if (Army == "ARMY_1") then                 
      local army = self:GetArmy();                 
      List = GetArmyBrain(army):GetListOfUnits(categories.COMMAND, false, true)
      for k, unit in List do 
          if (unit:GetUnitId() == 'uel0001') then
         unit:AddBuildRestriction( categories.UNIQUE )
          end
      end
       end
   end
    end,
Mavr390
Crusader
 
Posts: 25
Joined: 26 Oct 2019, 07:54
Has liked: 8 times
Been liked: 0 time
FAF User Name: Mavr390

Re: Unique unit

Postby DDDX » 20 May 2020, 01:12

for that you need a similar code for OnDestroyed.
So that whe it's destroyed,you RemoveBuildRestriction(...)
Check the same mod, unit sxsc1901 for example. Or any turret that the hero from xsl9905 can make, they al work on the same principle
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Unique unit

Postby Mavr390 » 20 May 2020, 05:29

DDDX, Perfect!! Works!!!
GREAT THANKS!!!
Mavr390
Crusader
 
Posts: 25
Joined: 26 Oct 2019, 07:54
Has liked: 8 times
Been liked: 0 time
FAF User Name: Mavr390


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest