how move sera regen(+new max hp) aura on units?

Everything about mods can be found here.

Moderator: Morax

how move sera regen(+new max hp) aura on units?

Postby Ithilis_Quo » 17 May 2015, 00:18

Hellou, i would like to ask, if someone can help me.

My plan is have units (carrier) with similar aura as have seraphin ACU (new max hp and some regeneration), but because its on ACU on Enchancment part i dont know how and where i can copypast it. (And because i want this aura consumption some energy with toggle, would like for toggle use same symbol aura on acu upgrade, but dont know where i must add new toggle, and also where i can found sera aura icon)

Can someone give me advice how to do it ? (advice can be on very basic programing level :) )
"Fixed in Equilibrium" Washy
User avatar
Ithilis_Quo
Supreme Commander
 
Posts: 1390
Joined: 29 Dec 2012, 15:55
Location: Slovakia
Has liked: 395 times
Been liked: 181 times
FAF User Name: Ithilis

Re: how move sera regen(+new max hp) aura on units?

Postby quark036 » 18 May 2015, 03:02

The code you need is lines 256-269 and 292-313 in the sera commander _script file (XSL0001_script.lua). The first part is the code for applying the regen and maxhp, the second part is for making the unit actually use it. The second part is basically adding to the unit blueprint, so you could get the same effect by editing the unit blueprint (I believe under the "buffs" section).

I'm not sure about the energy toggle, sorry. You could probably copy code from things like the stealth on cybran fighters. That would be fairly similar-energy for an ability.
quark036
Avatar-of-War
 
Posts: 165
Joined: 11 Mar 2015, 03:17
Has liked: 10 times
Been liked: 26 times
FAF User Name: Quark036

Re: how move sera regen(+new max hp) aura on units?

Postby Ithilis_Quo » 18 May 2015, 21:55

hmmm it would be more complicate.. i do what you suggest, and.. nothing happend. but imho it must be more complicate.

what i do in code. on units script on end i add this code (its copypast from xsl0001 script):

Code: Select all
################### CARRIER BUFF ###############
   
   RegenBuffThread = function(self)
        local bp = self:GetBlueprint().Enhancements.RegenAura
        local unitCat = ParseEntityCategory( bp.UnitCategory or 'BUILTBYTIER3FACTORY + BUILTBYQUANTUMGATE + NEEDMOBILEBUILD')

        while not self:IsDead() do
            #Get friendly units in the area (including self)
            local units = AIUtils.GetOwnUnitsAroundPoint(self:GetAIBrain(), unitCat, self:GetPosition(), bp.Radius)
           
            #Give them a 5 second regen buff
            for _,unit in units do
                Buff.ApplyBuff(unit, 'SeraphimACURegenAura')
            end
           
            #Wait 5 seconds
            WaitSeconds(5)
        end
    end,
   
   
   CreateEnhancement = function(self, enh)
        SWalkingLandUnit.CreateEnhancement(self, enh)

        local bp = self:GetBlueprint().Enhancements[enh]
       
        # Regenerative Aura
        if enh == 'RegenAura' then

            if not Buffs['SeraphimACURegenAura'] then   # AURA BUFF
                BuffBlueprint {
                    Name = 'SeraphimACURegenAura',
                    DisplayName = 'SeraphimACURegenAura',
                    BuffType = 'COMMANDERAURA',
                    Stacks = 'REPLACE',
                    Duration = 5,
                    Affects = {
                        RegenPercent = {
                            Add = 0,
                            Mult = bp.RegenPerSecond or 0.1,
                            Ceil = bp.RegenCeiling,
                            Floor = bp.RegenFloor,
                        },
                    },
                }
            end


on blue print under buff section add this:

Code: Select all
BuffFields = {
        RegenField = 'SeraphimACURegenBuffField',
    },


It was nothing say about concrete buff, so i was think it would found data from another file what define bufffield what is on unit.lua. because nothing happend, so i also add this section, and put it under buffFields:
Code: Select all
   RegenAura = {
            ACUAddHealth = 1000,         #added
            BuildCostEnergy = 4500,
            BuildCostMass = 600,
            BuildTime = 600,
            Icon = 'nrf',
            Name = '<LOC enhancements_0125>Restoration Field',
            Radius = 22, # 15
            RegenCeiling = 15, # 75
            RegenFloor = 0,
            RegenPerSecond = 0.02, # 0.0055555555
            UnitCategory = 'BUILTBYTIER3FACTORY, BUILTBYQUANTUMGATE, NEEDMOBILEBUILD',      #added
        },



but still nothing happend. This was loking too easy, and dont work, or i do something dumb :/
on maintance, i probably need new toggle for new function. or use old toggle that loks similar I know how to set maintance, problem is that dont know how to set new function, to work, and where in .bp add new section about this function.
"Fixed in Equilibrium" Washy
User avatar
Ithilis_Quo
Supreme Commander
 
Posts: 1390
Joined: 29 Dec 2012, 15:55
Location: Slovakia
Has liked: 395 times
Been liked: 181 times
FAF User Name: Ithilis

Re: how move sera regen(+new max hp) aura on units?

Postby quark036 » 20 May 2015, 02:23

Well, one thing is that it looks like you are creating the functions to do the buff, but not actually calling them (ie, createEnhancement will never be called from a carrier).
I'm not sure where the call would be, which was why I was trying to figure out how to add it to the blueprint, but I don't really know much about the blueprint, so I would ask resin_smoker or crotalus or coding_squirrel
quark036
Avatar-of-War
 
Posts: 165
Joined: 11 Mar 2015, 03:17
Has liked: 10 times
Been liked: 26 times
FAF User Name: Quark036

Re: how move sera regen(+new max hp) aura on units?

Postby RavenCurow » 02 Jun 2015, 07:31

I may be able to help with this. I've made a structure with the regen buff so lets see if it works here.

Script
Code: Select all
AmbientEffects = 'ST2PowerAmbient',
       ShieldEffects = {
        '/effects/emitters/seraphim_regenerative_aura_01_emit.bp',
       },
       
    --OnStopBeingBuilt = function(self,builder,layer)
   --    SStructureUnit.OnCreate(self,builder,layer)
   --    self:DisableUnitIntel('CloakField')
   -- end,


    # Copy of XSL0001_script's RegenBuffThread with slight alterations (Enhancement and RegenField)
    RegenBuffThread = function(self)
        while not self:IsDead() do
            # Get friendly units in the area (including self)
            local units = AIUtils.GetOwnUnitsAroundPoint(self:GetAIBrain(), categories.ALLUNITS, self:GetPosition(), self:GetBlueprint().RegenAura.RegenRadius)

            # Give them a 5 second regen buff
            for _,unit in units do
                Buff.ApplyBuff(unit, 'SeraphimRegenFieldMoo')
            end

            #Wait 5 seconds
            WaitSeconds(5)
        end
    end,




    OnStopBeingBuilt = function(self)

        SStructureUnit.OnStopBeingBuilt(self)
      self:SetMaintenanceConsumptionActive()
      self:DisableUnitIntel('CloakField')
        if not self.ShieldEffectsBag then
            self.ShieldEffectsBag = {}
        end
        self.ShieldEffectsBag = {}
        local army =  self:GetArmy()
        if self.AmbientEffects then
            for k, v in EffectTemplate[self.AmbientEffects] do
            CreateAttachedEmitter(self, 'XSC2201', army, v):ScaleEmitter(0)
            end
        end
               
        local bp = self:GetBlueprint().RegenAura

        if not Buffs['SeraphimRegenFieldMoo'] then
            BuffBlueprint {
                Name = 'SeraphimRegenFieldMoo',
                DisplayName = 'SeraphimRegenFieldMoo',
                BuffType = 'COMMANDERAURA',
                Stacks = 'REPLACE',
                Duration = 5,
                Affects = {
                    RegenPercent = {
                        Add = 0,
                        Mult = bp.RegenPerSecond or 0.1,
                        Ceil = bp.RegenCeiling,
                        Floor = bp.RegenFloor,
                    },
                    #MaxHealth = {
                    #    Add = 0,
                    #    Mult = bp.MaxHealthFactor or 1.0,
                    #    DoNoFill = true,
                    #},                       
                },
            }
        end

        table.insert( self.ShieldEffectsBag, CreateAttachedEmitter( self, 'XSC2201', self:GetArmy(), '/effects/emitters/seraphim_regenerative_aura_01_emit.bp' ) )
        self.RegenThreadHandle = self:ForkThread(self.RegenBuffThread)

    end,

The disable unit intel line is because I used a cloak field radius line in the bp to act as a visual representation of the regen field radius.

Now you may have to tailor this to your unit script as this is for a structure and not a naval unit.

In the bp I added this into the physics lines

Code: Select all
RegenAura = {
        RegenRadius    = 10,
        RegenCeiling   = 200,
        RegenFloor     = 0,
        RegenPerSecond = 0.1,
        MaxHealthFactor = 1.1,
    },
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: how move sera regen(+new max hp) aura on units?

Postby Ithilis_Quo » 04 Jun 2015, 13:49

on units it was not working :( didnt you add something else on blue print?

On with mod you wan making this building, its seems interesting, and if its done would like see it in all in reality,, and thx for reply also imagine sera building with this ability.
"Fixed in Equilibrium" Washy
User avatar
Ithilis_Quo
Supreme Commander
 
Posts: 1390
Joined: 29 Dec 2012, 15:55
Location: Slovakia
Has liked: 395 times
Been liked: 181 times
FAF User Name: Ithilis

Re: how move sera regen(+new max hp) aura on units?

Postby RavenCurow » 05 Jun 2015, 00:56

Found a mod that does what you want already. Its an old mod called the QAI Mod Bundle by Normalius.

Here is the script and bp for the ship.

Code: Select all
local SSeaUnit = import('/lua/seraphimunits.lua').SSeaUnit
local Buff                 = import('/lua/sim/Buff.lua')

local EffectTemplate       = import('/lua/EffectTemplates.lua')
local Entity               = import('/lua/sim/Entity.lua').Entity
local AIUtils              = import('/lua/AI/aiutilities.lua')


tcss0201 = Class(SSeaUnit) {

    ShieldEffects = {
        '/effects/emitters/seraphim_regenerative_aura_01_emit.bp',
    },


    # Copy of XSL0001_script's RegenBuffThread with slight alterations (Enhancement and RegenField)
    RegenBuffThread = function(self)
        while not self:IsDead() do
            # Get friendly units in the area (including self)
            local units = AIUtils.GetOwnUnitsAroundPoint(self:GetAIBrain(), categories.ALLUNITS, self:GetPosition(), self:GetBlueprint().RegenAura.RegenRadius)

            # Give them a 5 second regen buff
            for _,unit in units do
                Buff.ApplyBuff(unit, 'SeraphimRegenFieldMoo')
            end

            #Wait 5 seconds
            WaitSeconds(5)
        end
    end,


    OnStopBeingBuilt = function( self, builder, layer )

        SSeaUnit.OnStopBeingBuilt( self, builder, layer )

   self.ShieldEffectsBag = {}
    end,


    OnCreate = function(self)

        SSeaUnit.OnCreate(self)

        if not self.ShieldEffectsBag then
            self.ShieldEffectsBag = {}
        end
               
        local bpRA = self:GetBlueprint().RegenAura

        if not Buffs['SeraphimRegenFieldMoo'] then
            BuffBlueprint {
                Name        = 'SeraphimRegenFieldMoo',
                DisplayName = 'SeraphimRegenFieldMoo',
                BuffType    = 'COMMANDERAURA',
                Stacks      = 'REPLACE',
                Duration    = 5,
                Affects     = {
                    RegenPercent = {
                        Add   = 0,
                        Mult  = bpRA.RegenPerSecond or 0.1,
                        Ceil  = bpRA.RegenCeiling,
                        Floor = bpRA.RegenFloor,
                    },
                },
            }
        end

        table.insert( self.ShieldEffectsBag, CreateAttachedEmitter( self, 'XSS0304', self:GetArmy(), '/effects/emitters/seraphim_regenerative_aura_01_emit.bp' ) )
        self.RegenThreadHandle = self:ForkThread(self.RegenBuffThread)

    end,

}


Code: Select all
UnitBlueprint {
    AI = {
        GuardRadius = 10,
        TargetBones = {
            'XSS0304',
        },
    },
    Audio = {
        AmbientMove = Sound {
            Bank = 'XSL',
            Cue = 'XSL0307_Move_Loop',
            LodCutoff = 'UnitMove_LodCutoff',
        },
        Destroyed = Sound {
            Bank = 'XSL_Destroy',
            Cue = 'XSL_Destroy_Land_Lrg',
            LodCutoff = 'UnitMove_LodCutoff',
        },
        StartMove = Sound {
            Bank = 'XSL',
            Cue = 'XSL0307_Move_Start',
            LodCutoff = 'UnitMove_LodCutoff',
        },
        StopMove = Sound {
            Bank = 'XSL',
            Cue = 'XSL0307_Move_Stop',
            LodCutoff = 'UnitMove_LodCutoff',
        },
        UISelection = Sound {
            Bank = 'SeraphimSelect',
            Cue = 'Seraphim_Select_Naval',
            LodCutoff = 'UnitMove_LodCutoff',
        },
    },
    Buffs = {
        Regen = {
            Level1 = 1,
            Level2 = 2,
            Level3 = 4,
            Level4 = 6,
            Level5 = 8,
        },
    },
    BuildIconSortPriority = 50,
    Categories = {
      'PRODUCTFA',
        'SELECTABLE',
        'BUILTBYTIER2FACTORY',
        'BUILTBYTIER3FACTORY',
        'SERAPHIM',
        'MOBILE',
        'SHIELD',
      'DEFENSE',
        'NAVAL',
        'TECH2',
        'VISIBLETORECON',
        'RECLAIMABLE',
        'OVERLAYMISC',
      'DEFENSIVEBOAT',
    },
    Defense = {
        AirThreatLevel = 0,
        ArmorType = 'Normal',
        EconomyThreatLevel = 0,
        Health = 3000,
        MaxHealth = 3000,
        RegenRate = 30,
        SubThreatLevel = 0,
        SurfaceThreatLevel = 9,
    },
    Description = '<LOC tcss0201_desc>Regen Field Generator',
    Display = {
        Abilities = {
            '<LOC ability_regeneration>Regeneration Field',
        },
        IdleEffects = {
            Water = {
                Effects = {
                    {
                        Bones = {
                            'XSS0304',
                        },
                        Scale = 0.5,
                        Type = 'SeaIdle01',
                    },
                },
            },
        },
        Mesh = {
            IconFadeInZoom = 130,
            LODs = {
                {
                    LODCutoff = 120,
                    LookupName = '/textures/environment/Falloff_seraphim_lookup.dds',
                    Scrolling = true,
                    ShaderName = 'Seraphim',
                },
                {
                    AlbedoName = 'tcss0201_lod1_albedo.dds',
                    LODCutoff = 180,
                    LookupName = '/textures/environment/Falloff_seraphim_lookup.dds',
                    ShaderName = 'Seraphim',
                    SpecularName = 'tcss0201_lod1_specteam.dds',
                },
            },
        },
        MovementEffects = {
            Water = {
                Effects = {
                    {
                        Bones = {
                            'XSS0304',
                        },
                        Offset = {
                            0,
                            0,
                            -0.5,
                        },
                        Scale = 0.9,
                        Type = 'BackWake',
                    },
                },
            },
        },
        PlaceholderMeshName = 'UXL0009',
        SpawnRandomRotation = true,
        UniformScale = 0.04,
    },
    Economy = {
        BuildCostEnergy = 12000,
        BuildCostMass = 1000,
        BuildTime = 3200,
        MaintenanceConsumptionPerSecondEnergy = 200,
        TeleportEnergyMod = 0.15,
        TeleportMassMod = 1,
        TeleportTimeMod = 0.01,
    },
   CollisionOffsetY = -0,
    General = {
        Category = 'Ship',
        Classification = 'RULEUC_MilitaryShip',
        CommandCaps = {
            RULEUCC_Attack = false,
            RULEUCC_CallTransport = false,
            RULEUCC_Capture = false,
            RULEUCC_Guard = true,
            RULEUCC_Move = true,
            RULEUCC_Nuke = false,
            RULEUCC_Patrol = true,
            RULEUCC_Pause = false,
            RULEUCC_Reclaim = false,
            RULEUCC_Repair = false,
            RULEUCC_RetaliateToggle = false,
            RULEUCC_Stop = true,
            RULEUCC_Transport = false,
        },
        FactionName = 'Seraphim',
        Icon = 'sea',
        TechLevel = 'RULEUTL_Advanced',
        UnitName = '<LOC tcss0201_name>Ztheris-ioz',
        UnitWeight = 1,
    },
    Intel = {
        VisionRadius = 32,
      WaterVisionRadius = 32,
    },
    Interface = {
        HelpText = '<LOC tcss0201_help>Regen Field Generator',
    },
    LifeBarHeight = 0.075,
    LifeBarOffset = 1.5,
    LifeBarSize = 0.75,
    Physics = {
        BackUpDistance = 5,
        BankingSlope = 0,
        BuildOnLayerCaps = {
            LAYER_Air = false,
            LAYER_Land = false,
            LAYER_Orbit = false,
            LAYER_Seabed = false,
            LAYER_Sub = false,
            LAYER_Water = true,
        },
        CatchUpAcc = 10,
        DragCoefficient = 0.2,
        MaxAcceleration = 7,
        MaxBrake = 7,
        MaxSpeed = 7,
        MaxSpeedReverse = 7,
        MaxSteerForce = 5,
        MeshExtentsX = 2.25,
        MeshExtentsY = 2,
        MeshExtentsZ = 12,
        MinSpeedPercent = 0,
        MotionType = 'RULEUMT_Water',
        TurnRadius = 10,
        TurnRate = 60,
    },
    RegenAura = {
        RegenRadius    = 36,
        RegenCeiling   = 600,
        RegenFloor     = 0,
        RegenPerSecond = 0.005,
    },
    SelectionSizeX = 0.6,
    SelectionSizeZ = 1.8,
    SelectionThickness = 0.37,
    SizeX = 1,
    SizeY = 0.8,
    SizeZ = 2.6,
    StrategicIconName = 'icon_ship2_shield',
    StrategicIconSortPriority = 125,
}




Enjoy!

Edit: Oh, and my mod with the Regen Field building is already done. I tried to upload it to the vault, but I'm not sure if it took right. Its called CiviliansV2. Its a mod that adds the civilian buildings to multiplayer with various modifications.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest