Forged Alliance Forever Forged Alliance Forever Forums 2018-03-12T20:51:41+02:00 /feed.php?f=53&t=15960 2018-03-12T20:51:41+02:00 2018-03-12T20:51:41+02:00 /viewtopic.php?t=15960&p=161719#p161719 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
the function from the 2nd post in this topic is maybe helpfull for unitcap/UnitWeight

Code:
if UnitBlueprint.CategoriesHash.TECH1 then
     UnitBlueprint.General.UnitWeight = 1
end

But i don't know if this works in a map file.


@Speed2:

"DamageArea()" is an c-engine function to calculate NUKE AOE damage.
FAF already adds a hook (file DamageArea.lua) to patch this function. (Nuke AOE damage is no longer blocked from shield HP)

Statistics: Posted by Uveso — 12 Mar 2018, 20:51


]]>
2018-03-12T19:54:32+02:00 2018-03-12T19:54:32+02:00 /viewtopic.php?t=15960&p=161716#p161716 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
What do you mean by not working? Throwing error, not doing the damage?

I see you're hooking some function DamageArea, (I dont know where you're hooking it from), but you're not really calling it.

What you probably need, (or how I'd do it) is to ForkThread a new function that will periodically call the function that does the damage.

Statistics: Posted by speed2 — 12 Mar 2018, 19:54


]]>
2018-03-12T16:33:52+02:00 2018-03-12T16:33:52+02:00 /viewtopic.php?t=15960&p=161711#p161711 <![CDATA[Re: How to alter values of unitweights by scripting?]]> Hello!speed2:

I am tring to create a damagearea where all mobile units will suffer damage over time until they get out. The following are the whole codes that I modified from yours. Can you check them and find out the reason for not-working?

Code:
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')

function OnPopulate()
   ScenarioUtils.InitializeArmies()
   ScenarioFramework.SetPlayableArea('AREA_1', false)


local oldDamageArea = DamageArea
local radius = 25
local self = import('/lua/sim/Entity.lua').Entity()
local damage = 30
   for k = 1, 1 do
      local DAMAGEAREAName = 'DAMAGEAREA_' .. k
      local location = ScenarioUtils.MarkerToPosition(DAMAGEAREAName)
           local px, py, pz = unpack(location)
        end
end




DamageArea = function(instigator, location, radius, damage, type, damageAllies, damageSelf, brain, army)
    local army = ListArmies()
    local rect = Rect(px-radius, pz-radius, px+radius, pz+radius)
    local units = GetUnitsInRect(rect) or {}
    local damageAllies = true
    local damageSelf = true   
    for _, u in units do
        if table.find(u:GetBlueprint().Categories,'MOBILE') then
           continue
        end
        if VDist3(u:GetPosition(), location) > radius then
           continue
        end
        if instigator == u then
            if damageSelf then
                local vector = import('/lua/utilities.lua').GetDirectionVector(location, u:GetPosition())
                -- need this ugliness due to Damage() refuse to damage when instigator == u
                instigator:OnDamage(instigator, damage, vector, 'Reclaimed')
            end
        elseif damageAllies or not IsAlly(army, u:GetArmy()) then
            Damage(instigator, location, u, damage, 'Reclaimed')
        end
    end

    local reclaim = GetReclaimablesInRect(rect) or {}
    for _, r in reclaim do
        if IsProp(r) and VDist3(r:GetPosition(), location) <= radius then
            Damage(instigator, location, r, damage, 'Reclaimed')
        end
    end

     -- Get rid of trees
     oldDamageArea(instigator, location, radius, 1, 'Reclaimed', false, false)
    end


function OnStart(self)
end

Statistics: Posted by Ghoustaq — 12 Mar 2018, 16:33


]]>
2018-03-11T10:32:52+02:00 2018-03-11T10:32:52+02:00 /viewtopic.php?t=15960&p=161679#p161679 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
speed2 wrote:
These are all the engine functions available http://supcom.wikia.com/wiki/LUADOC_1.5.3599

I wrote bit of documentation for some of them here https://github.com/FAForever/fa/tree/develop/engine

Those are what I need. Thank you very much. :D

Statistics: Posted by Ghoustaq — 11 Mar 2018, 10:32


]]>
2018-03-11T09:51:37+02:00 2018-03-11T09:51:37+02:00 /viewtopic.php?t=15960&p=161677#p161677 <![CDATA[Re: How to alter values of unitweights by scripting?]]> http://supcom.wikia.com/wiki/LUADOC_1.5.3599

I wrote bit of documentation for some of them here https://github.com/FAForever/fa/tree/develop/engine

Statistics: Posted by speed2 — 11 Mar 2018, 09:51


]]>
2018-03-11T09:27:39+02:00 2018-03-11T09:27:39+02:00 /viewtopic.php?t=15960&p=161675#p161675 <![CDATA[Re: How to alter values of unitweights by scripting?]]> I'm sorry. I think I didn't make it clear.

I know that unitcap means the Maximum quantity of units which I can own. If I have a unitcap of 100, that means I can own 100 units at most.

I personally define unitcapcost as the cost of unitcap for all units I have owned. If I have built 30 units, that means I must cost 30 unitcap to build units, so the unitcapcost is 30, but I can still build 70 units at most,'cause unitcap which have not been cost remains 70(100-30=70). Though I'm not sure whether the concept of unitcapcost does exist or not.

unitcap can be altered for sure, by the codes that you offered to me. Now I wonder if unitcapcost can be alterd too?

In general, one unit costs 1 unitcap. What I want is that every Tech1unit costs 1 unitcap, Tech2unit costs 2, Tech3unit costs 3, experimentalunit costs 10, like this.

Statistics: Posted by Ghoustaq — 11 Mar 2018, 09:27


]]>
2018-03-11T02:46:09+02:00 2018-03-11T02:46:09+02:00 /viewtopic.php?t=15960&p=161669#p161669 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
I am a little bit confused. You wrote it was working:
viewtopic.php?f=53&t=15932&p=161202#p161202

BTW, there was no command like this:
Code:
GetArmyUnitCapCost()

This is the right command (no "cost" word at the end):
Code:
GetArmyUnitCap()

Also the second command is wrong:
Code:
SetArmyUnitCapCost()

This is the correct one:
Code:
SetArmyUnitCap()


ScenarioInfo.Options.UnitCap is a game option set by host before the game starts.

If you change the cap with SetArmyUnitCapCost(), then ScenarioInfo.Options.UnitCap has still the old start value stored, not the new unitcap.

So you can reset the unitcap to default with this:
Code:
SetArmyUnitCap( brain:GetArmyIndex() , ScenarioInfo.Options.UnitCap )

Statistics: Posted by Uveso — 11 Mar 2018, 02:46


]]>
2018-03-10T20:48:02+02:00 2018-03-10T20:48:02+02:00 /viewtopic.php?t=15960&p=161655#p161655 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
To obtain the overall unit cap of the map use this;

local initialCap = tonumber(ScenarioInfo.Options.UnitCap)

This will give you the initial unit cap that all players will be using. It should be available during the map script.

You've got the right code for setting an army's unit cap but I'm not sure if the armies are initialized at the time of map script execution. However, if the function to set individual armies unit cap is unavailable, then perhaps your script could adjust the ScenarioInfo value before the normal code gets hold of it - that way you could enforce a unit cap of your choice on the map. Try it and see.

In the LOUD project, we use it to increase an armies unit cap as they attain veterancy and it works well - allowing games that have fairly low starting unit caps. We've had some discussions in the past about tying unit cap to the ownership of mass points as a tool for encouraging players to play the entire map (and de-emphasize turtling) - but as of yet we have not attempted to implement it. Having said that, we do feel it could be an effective 'nudge' in that regard. Let us know how your own work progresses.

Statistics: Posted by Sprouto — 10 Mar 2018, 20:48


]]>
2018-03-10T18:23:41+02:00 2018-03-10T18:23:41+02:00 /viewtopic.php?t=15960&p=161653#p161653 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
Hello Sprouto,

Do you know what is the right code to get current capcost and to reset capcost in the game?

CurrentCapCost = GetArmyUnitCapCost(INDEX)?

and

SetArmyUnitCapCost(INDEX, NewCapCost)?

I'm not sure whether the both are correct or not. They haven't work via my mapscript so far. :?

Statistics: Posted by Ghoustaq — 10 Mar 2018, 18:23


]]>
2018-03-10T00:42:34+02:00 2018-03-10T00:42:34+02:00 /viewtopic.php?t=15960&p=161635#p161635 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
But why?
It your prior code was able to edit vision radius of units (and i saw for myself that it does, on a lonely pgen t1) then obviously it can be done from a map script... blueprint got edited

anyways, thank you for your reply. At least u tried :(

Statistics: Posted by DDDX — 10 Mar 2018, 00:42


]]>
2018-03-09T23:55:36+02:00 2018-03-09T23:55:36+02:00 /viewtopic.php?t=15960&p=161633#p161633 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
UnitID's are lowercase ;)

But also with lower case ID its not working.

This would be the right syntax for the function (maybe you can use it outside a map script file):
Code:
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


Also not working from a map file, but if you only want to change a singe blueprint, then you can access it with the unitID:
Code:
__blueprints['xsb2401'].Defense.Health = 22000

Statistics: Posted by Uveso — 09 Mar 2018, 23:55


]]>
2018-03-09T23:17:42+02:00 2018-03-09T23:17:42+02:00 /viewtopic.php?t=15960&p=161631#p161631 <![CDATA[Re: How to alter values of unitweights by scripting?]]> Statistics: Posted by DDDX — 09 Mar 2018, 23:17


]]>
2018-03-09T23:10:40+02:00 2018-03-09T23:10:40+02:00 /viewtopic.php?t=15960&p=161630#p161630 <![CDATA[Re: How to alter values of unitweights by scripting?]]> Statistics: Posted by Sprouto — 09 Mar 2018, 23:10


]]>
2018-03-09T21:35:41+02:00 2018-03-09T21:35:41+02:00 /viewtopic.php?t=15960&p=161625#p161625 <![CDATA[Re: How to alter values of unitweights by scripting?]]> How would one go about changing specific unit stats? Let's say I wanted, for example, Yolo to have 10k more hp.
What's missing from this code?

Code:
function OnStart(self)

LOG("----- Survival MOD: Initializing game start sequence...");
   ForkThread(Survival_Tick);

   EditBlueprints(self)
end

function EditBlueprints(self)

    for UnitID, UnitBlueprint in __blueprints do

       if (UnitID == 'XSB2401') then      -- Yolona

             XSB2401_unit.bp.Defense.Health = 22000;  -- tried with UnitBlueprint.Defense.Health etc, nope
             XSB2401_unit.bp.Defense.MaxHealth = 22000;
       end           
    end
end


I bet it's something very simple, tried to figure it out by myself from your vision-by-tech-level example, but am not knowlegeable enough to do it :(
Much obliged!!!!!

Statistics: Posted by DDDX — 09 Mar 2018, 21:35


]]>
2018-03-08T04:08:04+02:00 2018-03-08T04:08:04+02:00 /viewtopic.php?t=15960&p=161569#p161569 <![CDATA[Re: How to alter values of unitweights by scripting?]]>
i viewed your script with intel radius and found 1-2 errors :)

Here is a copy & paste ready script for your MAP_script.lua:
(Vision radius is set to 1 for tech 1 units etc, just for testing)
Code:
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')

function OnPopulate()
    ScenarioUtils.InitializeArmies()
end

function OnStart(self)
    EditBlueprints(self)
end

function EditBlueprints(self)
    for UnitID, UnitBlueprint in __blueprints do
        -- If we have no Categories then skip this unit and continue with the next unit
        if not UnitBlueprint.Categories then
            continue
        end
        -- Generate the CategoriesHash for non FAF game
        UnitBlueprint.CategoriesHash = {}
        for _, cat in UnitBlueprint.Categories do
            UnitBlueprint.CategoriesHash[cat] = true
        end
        -- fist check if we have a UnitBlueprint.Intel table, then check if we have a VisionRadius table inside UnitBlueprint.Intel
        if UnitBlueprint.Intel and UnitBlueprint.Intel.VisionRadius then
            LOG('Unit '..UnitID..' has a value of '..UnitBlueprint.Intel.VisionRadius..' as VisionRadius')
            if UnitBlueprint.CategoriesHash.TECH1 then
                LOG('Unit '..UnitID..' is a TECH1 unit. Seting VisionRadius to 1')
                UnitBlueprint.Intel.VisionRadius = 1
            end
            if UnitBlueprint.CategoriesHash.TECH2 then
                LOG('Unit '..UnitID..' is a TECH2 unit. Seting VisionRadius to 2')
                UnitBlueprint.Intel.VisionRadius = 2
            end
            if UnitBlueprint.CategoriesHash.TECH3 then
                LOG('Unit '..UnitID..' is a TECH3 unit. Seting VisionRadius to 3')
                UnitBlueprint.Intel.VisionRadius = 3
            end
            if UnitBlueprint.CategoriesHash.HYDROCARBON then
                LOG('Unit '..UnitID..' is a HYDROCARBON unit. Seting VisionRadius to 5')
                UnitBlueprint.Intel.VisionRadius = 5
            end
        else
            LOG('Unit '..UnitID..' don\'t has a VisionRadius')
        end
    end
end


I tested this also in multiplayer with 2 PC and it is NOT desyncing the game.

Statistics: Posted by Uveso — 08 Mar 2018, 04:08


]]>