Personal balance mod

Everything about mods can be found here.

Moderator: Morax

Personal balance mod

Postby PerfectWay » 31 Oct 2016, 02:47

Hi, all
I often play SC with my friends, but since we all have different skills, I decided to write a small mod that gives personal advantages (mass & energy production, build rate, maybe health points) to the player on his name.

I found the code for a simple mod with the multipliers for the economy, but the problem is that I need to apply these effects are not all units in the game, but only the player units with a certain name, for example "PlayerFirst"

Code: Select all
do
    local oldModBlueprints = ModBlueprints

    function ModBlueprints(all_bps)
       oldModBlueprints(all_bps)

        local econScale = 2.0
       
        --loop through the blueprints and adjust as desired.
        for id,bp in all_bps.Unit do
            if bp.Economy.ProductionPerSecondMass then
               bp.Economy.ProductionPerSecondMass = bp.Economy.ProductionPerSecondMass * econScale
            end
            if bp.Economy.ProductionPerSecondEnergy then
               bp.Economy.ProductionPerSecondEnergy = bp.Economy.ProductionPerSecondEnergy * econScale
            end 
        end
    end

end

I feel that it looks something like this,
Code: Select all
if (player.playerName == "PlayerFirst")
    // some code

It is also interesting to use the effects only for a one fraction, only of UEF for example, that the like
Code: Select all
if (player.playerFaction == "UEF")
    // some code

Since this is my first mod, I do not know how should look like this code to Lua.
PerfectWay
Crusader
 
Posts: 32
Joined: 12 Apr 2016, 10:51
Has liked: 6 times
Been liked: 0 time
FAF User Name: LastDragon

Re: Personal balance mod

Postby Uveso » 31 Oct 2016, 12:50

You can't modify a unit only for one player. This will desync the game.

But you can modify all units from a faction.

Use this to identify a faction:
Code: Select all
If Categories.UEF then
If Categories.AEON then
If Categories.CYBRAN then
If Categories.SERAPHIM then

(you need to build the Categories array first!)

If you need help to mod units inside the blueprints.lua file (and building the Categories-Array) , take a look here:
viewtopic.php?f=41&t=12970
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: Personal balance mod

Postby PerfectWay » 31 Oct 2016, 13:07

Ok, thank you, i'm try it.
About the desync, since we play via LAN, and I'm going to put this mod manually on both computers, I think everything should be in order, because the code will be identical
PerfectWay
Crusader
 
Posts: 32
Joined: 12 Apr 2016, 10:51
Has liked: 6 times
Been liked: 0 time
FAF User Name: LastDragon

Re: Personal balance mod

Postby PerfectWay » 31 Oct 2016, 18:25

Using the player's name was really not best idea. I decided to make a few small mods that give certain bonuses each faction and get the same effect that I wanted. For example, "Strength of the Aeon" - all damage x2, "UEF Production" - x2 mass production, "Defense of the UEF" - x2 health.
Thank you very much Uveso, your code example really works!
I still have some questions:
How to calculate the uid for mod? I can use random string of numbers?
And how to change attack rate and radar range?
PerfectWay
Crusader
 
Posts: 32
Joined: 12 Apr 2016, 10:51
Has liked: 6 times
Been liked: 0 time
FAF User Name: LastDragon

Re: Personal balance mod

Postby Uveso » 01 Nov 2016, 01:14

The GUID is a random serial number. You can use every number/text you want.
You can also use a online GUID generator:
http://www.somacon.com/p113.php

This is needed for a Radar:
Code: Select all
bp.Categories.OVERLAYRADAR -- Set overlay for radar
bp.Intel.RadarRadius -- RadarRadius :D

For attack rate you need to loop over the WEAPON array:
Code: Select all
for i, weapon in weapons do

You can now acces the rate of fire:
Code: Select all
weapon.RateOfFire

To calculate the fire rate for dps etc., use " 1.0 / weapon.RateOfFire"
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: Personal balance mod

Postby PerfectWay » 01 Nov 2016, 19:12

Thank you, all pretty intuitive :)
Change movement speed and rate of fire will not break the unit animation of movement / firing? Or it will also use the new parameters?
PerfectWay
Crusader
 
Posts: 32
Joined: 12 Apr 2016, 10:51
Has liked: 6 times
Been liked: 0 time
FAF User Name: LastDragon

Re: Personal balance mod

Postby Uveso » 03 Nov 2016, 01:58

PerfectWay wrote:Change movement speed and rate of fire will not break the unit animation of movement / firing? Or it will also use the new parameters?


That's a good question! I have no clue :D
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: Personal balance mod

Postby Sprouto » 03 Nov 2016, 02:15

There can be several animations specified in a blueprint, sometimes specifically one for the walking animation. This is usually found in 'BOT' units, like many experimentals.

If you alter the movement speed, you will need to change the animation rate in the blueprint or the unit will appear to 'skate' when it walks.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Personal balance mod

Postby Exotic_Retard » 03 Nov 2016, 09:02

the movement animation should scale with the movement speed automatically. it even appears to be affected by unit size!
however to prevent skating you might need to adjust it anyway as sprouto pointed out.
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: Personal balance mod

Postby PerfectWay » 04 Nov 2016, 11:31

Thanks to all, although I did not find the parameter animation rate in the blueprint. Using a 30% bonus to speed almost no effect on the animation (although there is a small skating of some units, or it seems to me :D ). I think for my small mod is not very critical.
PerfectWay
Crusader
 
Posts: 32
Joined: 12 Apr 2016, 10:51
Has liked: 6 times
Been liked: 0 time
FAF User Name: LastDragon

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest