How to modify unit blueprint stats with a map script

Interesting mapping tools and mapping help.

Moderator: Morax

How to modify unit blueprint stats with a map script

Postby DDDX » 08 Mar 2018, 00:49

Hi all. Quick question:

Is it possible to make a map where a unit/building has different stats, for example less HP or different cost?
Not the ones the map script spawns, but the regular ones, built by the player after the game has started.

If yes - how would one go about doing it?
It would require the customized unit BP inside the map folder,but how do I direct the game to look it up and use it and overwrite the game's native data of that unit in the UNITS.SCD?
Is this even possible, without using a mod that edits the unit?

Much obliged,
DDDX
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: How to modify unit blueprint stats with a map script

Postby Uveso » 08 Mar 2018, 04:10

Hello DDDX,

take a look here:
viewtopic.php?f=53&t=15960&start=10
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: How to modify unit blueprint stats with a map script

Postby DDDX » 09 Mar 2018, 21:37

Thanx man.
Wouldn't you know it, I got a follow-up question. Have put it in the linked topic, no sense having 2 essentially same ones.
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: How to modify unit blueprint stats with a map script

Postby DDDX » 10 Mar 2018, 11:12

Ok, so if this code does not work from inside the map script -

Code: Select all
    function EditBlueprints(self)
        for UnitID, UnitBlueprint in __blueprints do
           if (UnitID == 'xsb2401') then -- Yolona Oss
                UnitBlueprint.Intel.VisionRadius = 5
                UnitBlueprint.Defense.Health = 22000
                UnitBlueprint.Defense.MaxHealth = 22000
            end
        end
    end


Code: Select all
    __blueprints['xsb2401'].Defense.Health = 22000


does anyone here know how would one go about making the game use a custom made blueprints.lua that would come together with the map, which contained only a few units inside, those that would get edited? (ofc, cause the units.scd file is 1.04 GB large, too big for any map).

It would open up so many possibilities for map makers, being able to edit unit stats right from the blueprints.
Or has it been done already, in a certain map, that I can utilize?
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: How to modify unit blueprint stats with a map script

Postby speed2 » 10 Mar 2018, 12:21

It would also open the door for anyone who would want to sneak in some imbalance.

And that's why we won't make this possible.

You will need a sim mod to edit blueprints.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to modify unit blueprint stats with a map script

Postby DDDX » 10 Mar 2018, 13:54

well Speed2, I am asking all of this for a survival map. No imbalances there are a threat :p
But I can imagine someone being a douche and making tons of maps with the same name as existing ones, with units that boost his favorite faction, for example, then uploading to the Vault to act as standard maps, so I see your point. Ty for the answer.

The thing is, such code would have to start with "local xy = import xy, at the first few lines of the script, and that would be pretty easy to spot, and such a person to be banned. Not to mention the very blueprint file itself, inside the map folder :p

...if only people weren't douches, we'd have so many nice things :/
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: How to modify unit blueprint stats with a map script

Postby Uveso » 11 Mar 2018, 20:00

Hello DDDX,

i already tryed some programming on my own.
Sadly will will not get this to work.

The reason why it works on some values on not on others is how the game is using those blueprints.

On gamestart all blueprints are loaded and registered inside the c-engine.
If you now change some values inside the blueprint data, you only change it for the LUA side of the game.
All values that are stored inside the c-engine can't be changed.

LUA must have sim-state to change the blueprints.
And this is only possible while hooking the blueprint.lua and change blueprints BEFORE we register them inside the c-engine.

I am sorry, but this will never work :(
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest