FANDOM


InfoEdit

This page is for you to post any mods you are having trouble with. Anyone can post problems and anyone can help, just please don't solve your own problem; just remove it if you've solved it. To add a problem, just create a new section, and detail your problem modding. If it's a code problem, please post the code and the problem after it.

A little armor troubleEdit

BackgroundEdit

I was looking around in the lua SCD when I spotted a file called armordefinitions.lua. It looked very interesting as it defined all the possible types of armor that a unit can have. I thought: "There's some possibilities here..." and after some work, I came up with this piece of code:

    local function ChangeArmor(bp)
        while bp.Defense.ArmorType do
            if bp.Defense.ArmorType == Normal or
            bp.Defense.ArmorType == Default then
                if bp.Defense.Health >= bp.Defense.MaxHealth * 0.25 then
                    OnDamage = function(self,instigator,amount,vector,type)
                        local absorbed = Self:OnGetDamageAbsorption(instigator,amount,type)
                        self:AdjustHealth(instigator, -(absorbed * .25))
                    end
                else
                    OnDamage = function(self,instigator,amount,vector,type)
                        local absorbed = Self:OnGetDamageAbsorption(instigator,amount,type)
                        self:AdjustHealth(instigator, -absorbed)
                    end
                end
            elseif bp.Defense.ArmorType == Light then
                if bp.Defense.Health >= bp.Defense.MaxHealth * 0.75 then
                    OnDamage = function(self,instigator,amount,vector,type)
                        local absorbed = Self:OnGetDamageAbsorption(instigator,amount,type)
                        self:AdjustHealth(instigator, -(absorbed * 1.5))
                    end
                else
                    OnDamage = function(self,instigator,amount,vector,type)
                        local absorbed = Self:OnGetDamageAbsorption(instigator,amount,type)
                        self:AdjustHealth(instigator, -absorbed)
                    end
                end
            elseif bp.Defense.ArmorType == Commander then
                if bp.Defense.Health >= bp.Defense.MaxHealth * 0.5 then
                    OnDamage = function(self,instigator,amount,vector,type)
                        local absorbed = Self:OnGetDamageAbsorption(instigator,amount,type)
                        self:AdjustHealth(instigator, -(absorbed * 0.5))
                    end
                else
                    OnDamage = function(self,instigator,amount,vector,type)
                        local absorbed = Self:OnGetDamageAbsorption(instigator,amount,type)
                        self:AdjustHealth(instigator, -absorbed)
                    end
                end
            end
        end
    end

do
    local OldModBlueprints = ModBlueprints

    function ModBlueprints(all_bps)
        OldModBlueprints(all_bps)
        local i = 1
        for id,bp in all_bps do
            ChangeArmor(bp)
        end
    end
end

(if you want to try it, use a copy of the ResourceRich mod, with this going in the Blueprints.lua file)

ProblemEdit

The problem is, the mod doesn't change anything! I want it to make different types of armor make units absorb different amounts of damage, but it doesn't do anything! If anyone has some idea of how to fix it, please help. could the problem be me not defining the "bp" variable that I passed to my function? I think I have solved it but I still have to test it, any suggestions are still welcome.


Response:

hook the armordefinition.lua file into your mod, and have ONLY this code in it. Then, tell your units to use the Armor Types listed that have the A_ArmorName, and tell the units to use the damage types D_DamageName. Read the comments in this file for more help


armordefinition = {

    {   # Armor Type Name
        'Default',


        # Armor Definition
        'Normal 1.0',

    },


    {   # Armor Type Name
        'Normal',


        # Armor Definition
        'Normal 1.0',

    },


    {   # Armor Type Name
        'Light',

        # Armor Definition
        'Normal 1.0',

    },

    {   # Armor Type Name

        'Commander',


        # Armor Definition

        'Normal 1.0',

        'Overcharge 0.01',

    },

    {   # Armor Type Name
        'Structure',


        # Armor Definition
        'Normal 0.01',
        'Overcharge 0.041666',

    },

    {

        # Armor Type name
        'Experimental',

        

        # Armor Definition
        'ExperimentalFootfall 0.0',        

    },


--this will define an armor type named D_Explosive.
--it will take 1.0x damage for someone dealing Normal damage



    {   # Armor Type Name
        'D_Explosive',
        # Armor Definition

'Normal 1.0',
},

    {   # Armor Type Name

        'D_Energy',

        # Armor Definition

'Normal 1.0',

},

{   # Armor Type Name

        'D_Projectile',

        # Armor Definition

'Normal 1.0',

},

--this will define an armor type named A_Hardened
--it will take 0.34x damage for someone dealing D_Explosive damage.
--So now you can make your own damage types and armor types (they are the same thing actually)

    {   # Armor Type Name
        'A_Hardened',
        # Armor Definition
        'D_Explosive 0.34',
    },
    {   # Armor Type Name
        'A_Plated',
        # Armor Definition
        'D_Projectile 0.34',
    },
    {   # Armor Type Name
        'A_Ionized',
        # Armor Definition
        'D_Energy 0.34',
    },
	
	
	{   # Armor Type Name
        'A_Light',
        # Armor Definition
        'D_Explosive 1.0',
		'D_Projectile 1.0',
		'D_Energy 1.0',
    },
}

Get A List of Units Edit

Problem/Question Edit

I have a unit instance and would like to get a list of units of the player owning that unit, or even better a direct list of only his experimental units.

For these interested, I'm trying to encourage playing with standard Tec3 Units by increasing the cost of experimentals as the player has more(No experimental spamming). I'm trying to acomblish that with the game.lua function "GetConstructEconomyModel(builder, targetData)", which calculates the cost of a building.

Thank you in advance.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.