New Modder - Need help with weapon "reassignment"

Everything about mods can be found here.

Moderator: Morax

New Modder - Need help with weapon "reassignment"

Postby Lex Ryder » 18 Feb 2016, 11:32

Greetings, everyone. I recently got into doing some simple unit modifications (I.e.: Health, speed, etc.) through individual script & BluePrint editing. I am now looking to have certain units fire projectiles and do damage that other weapons would do. An example would be like UEF T2 Artillery firing a Monkeylord laser. Can anyone help me with what info I have to move around and swap to do such a thing?
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: New Modder - Need help with weapon "reassignment"

Postby Uveso » 23 Feb 2016, 02:25

Hello Lex Ryder,

Actually you can't use the Monkeylord Gun at the Arty. Because the MonkeyLord gun needs an anchorpoint (Center_Turret_Barrel) that is not present at the arty. It's hardcoded, so you can't change it from unitscripts. So i use the Cybran T2 Cerberus Pointdefence as example.

Let's first take a look at the UEF T2 Artillery (UEB2303_script.lua)

Code: Select all
local TStructureUnit = import('/lua/terranunits.lua').TStructureUnit
local TIFArtilleryWeapon = import('/lua/terranweapons.lua').TIFArtilleryWeapon

UEB2303 = Class(TStructureUnit) {

    Weapons = {
        MainGun = Class(TIFArtilleryWeapon) {
        },
    },

    OnStopBeingBuilt = function(self,builder,layer)
        TStructureUnit.OnStopBeingBuilt(self,builder,layer)
        local bp = self:GetBlueprint()
        if bp.Audio.Activate then
            self:PlaySound(bp.Audio.Activate)
        end
    end,

}

TypeClass = UEB2303

Inside the Weapon array you can see the weapon name (MainGun) and the weapon class (TIFArtilleryWeapon)

The class (TIFArtilleryWeapon) is linked in the line:
Code: Select all
local TIFArtilleryWeapon = import('/lua/terranweapons.lua').TIFArtilleryWeapon

And the weapon name (MainGun) points to the weaponarray inside the unitblueprint (UEB2303_unit.bp)
(search for the line "Label = 'MainGun',")
Code: Select all
    Weapon = {
        {
            AboveWaterTargetsOnly = true,
            ArtilleryShieldBlocks = true,
            Audio = {
                Fire = Sound {
                    Bank = 'UELWeapon',
                    Cue = 'UEB2303_Artillery_APDS',
                    LodCutoff = 'Weapon_LodCutoff',
                },
            },
            BallisticArc = 'RULEUBA_LowArc',
            CollideFriendly = false,
            Damage = 2000,
            DamageFriendly = true,
            DamageRadius = 3,
            DamageType = 'Normal',
            DisplayName = 'APDS Artillery',
            EnergyDrainPerSecond = 100,
            EnergyRequired = 1000,
            FireTargetLayerCapsTable = {
                Land = 'Land|Water|Seabed',
                Water = 'Land|Water|Seabed',
            },
            FiringRandomness = 2,
            FiringTolerance = 1,
            Label = 'MainGun',
            MaxRadius = 128,
            MinRadius = 5,
            MuzzleSalvoDelay = 0,
            MuzzleSalvoSize = 1,
            MuzzleVelocity = 26.13,
            ProjectileId = '/projectiles/TIFArtillery01/TIFArtillery01_proj.bp',
            ProjectilesPerOnFire = 1,
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle',
                    },
                    RackBone = 'Turret_Recoil',
                },
            },
            RackFireTogether = false,
            RackRecoilDistance = -2.5,
            RackReloadTimeout = 14,
            RackSalvoChargeTime = 0,
            RackSalvoReloadTime = 0,
            RackSalvoSize = 1,
            RackSlavedToTurret = false,
            RangeCategory = 'UWRC_IndirectFire',
            RateOfFire = 0.05,
            RenderFireClock = true,
            TargetCheckInterval = 5,
            TargetPriorities = {
                'SPECIALHIGHPRI',
                'SPECIALLOWPRI',
                'ALLUNITS',
            },
            TargetRestrictDisallow = 'UNTARGETABLE',
            TurretBoneMuzzle = 'Turret_Muzzle',
            TurretBonePitch = 'Turret_Barrel',
            TurretBoneYaw = 'Turret',
            TurretDualManipulators = false,
            TurretPitch = 30,
            TurretPitchRange = 60,
            TurretPitchSpeed = 6,
            TurretYaw = 0,
            TurretYawRange = 180,
            TurretYawSpeed = 6,
            Turreted = true,
            WeaponCategory = 'Artillery',
            WeaponRepackTimeout = 0,
            WeaponUnpacks = false,
        },
    },

Important: The place where the weapon is mounted is saved here:
(Wee need to change/copy that later)
Code: Select all
...
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle',
                    },
                    RackBone = 'Turret_Recoil',
                },
            },
...
            TurretBoneMuzzle = 'Turret_Muzzle',
            TurretBonePitch = 'Turret_Barrel',
            TurretBoneYaw = 'Turret',
...

If we now take a look at the Cerberus Point Defense (URB2301_script.lua)

Code: Select all
local CStructureUnit = import('/lua/cybranunits.lua').CStructureUnit
local CDFLaserHeavyWeapon = import('/lua/cybranweapons.lua').CDFLaserHeavyWeapon


URB2301 = Class(CStructureUnit) {
   
    Weapons = {
        MainGun = Class(CDFLaserHeavyWeapon) {
        FxMuzzleFlash = {'/effects/emitters/particle_cannon_muzzle_02_emit.bp'},
    }
    },
}

TypeClass = URB2301

As u can see, there is also a gun named "MainGun".
And the gun is using the class CDFLaserHeavyWeapon.

If we now search for the (MainGun) inside the blueprint file (URB2301_unit.bp) we'll find:
Code: Select all
        {
            AboveWaterTargetsOnly = true,
            Audio = {
                Fire = Sound {
                    Bank = 'URLWeapon',
                    Cue = 'URB2301_Cannon_Sgl',
                    LodCutoff = 'Weapon_LodCutoff',
                },
            },
            BallisticArc = 'RULEUBA_LowArc',
            CollideFriendly = false,
            Damage = 10,
            DamageType = 'Normal',
            DisplayName = 'Particle Cannon',
            FireTargetLayerCapsTable = {
                Land = 'Land|Water|Seabed',
                Water = 'Land|Water|Seabed',
            },
            FiringTolerance = 2,
            Label = 'MainGun',
            MaxRadius = 50,
            MuzzleSalvoDelay = 0,
            MuzzleSalvoSize = 2,
            MuzzleVelocity = 100,
            ProjectileId = '/projectiles/CDFLaserHeavy02/CDFLaserHeavy02_proj.bp',
            ProjectileLifetimeUsesMultiplier = 1.15,
            ProjectilesPerOnFire = 1,
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle01',
                        'Turret_Muzzle02',
                        'Turret_Muzzle03',
                    },
                    RackBone = 'Turret_B02',
                },
            },
            RackFireTogether = false,
            RackRecoilDistance = -1,
            RackReloadTimeout = 10,
            RackSalvoChargeTime = 0,
            RackSalvoReloadTime = 0,
            RackSalvoSize = 1,
            RackSlavedToTurret = false,
            RangeCategory = 'UWRC_DirectFire',
            RateOfFire = 3,
            ReTargetOnMiss = true,
            TargetCheckInterval = 0.16,
            TargetPriorities = {
                'SPECIALHIGHPRI',
                'MOBILE',
                'STRUCTURE DEFENSE',
                'SPECIALLOWPRI',
                'ALLUNITS',
            },
            TargetRestrictDisallow = 'UNTARGETABLE',
            TrackingRadius = 1.15,
            TurretBoneMuzzle = 'Turret_Muzzle01',
            TurretBonePitch = 'Turret_B02',
            TurretBoneYaw = 'Turret_B01',
            TurretDualManipulators = false,
            TurretPitch = 10,
            TurretPitchRange = 55,
            TurretPitchSpeed = 60,
            TurretYaw = 0,
            TurretYawRange = 180,
            TurretYawSpeed = 60,
            Turreted = true,
            WeaponCategory = 'Direct Fire',
        },


If you now want to use the CDFLaserHeavyWeapon on the arty;

Copy the MainGun array from the Cerberus Point Defense blueprint over the Data from the MainGun inside the arty blueprint.

Now change the Weapon anchorpoint from the Cerberus to the anchorpoint of the arty.

Search for:
Code: Select all
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle01',
                        'Turret_Muzzle02',
                        'Turret_Muzzle03',
                    },
                    RackBone = 'Turret_B02',
                },
            },

And change it to:
Code: Select all
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle',
                    },
                    RackBone = 'Turret_Recoil',
                },
            },

Now change the Turret Bones from:
Code: Select all
            TurretBoneMuzzle = 'Turret_Muzzle01',
            TurretBonePitch = 'Turret_B02',
            TurretBoneYaw = 'Turret_B01',

to:
Code: Select all
            TurretBoneMuzzle = 'Turret_Muzzle',
            TurretBonePitch = 'Turret_Barrel',
            TurretBoneYaw = 'Turret',

Inside the Arty script (UEB2303_script.lua) change the maingun class:

Code: Select all
MainGun = Class(TIFArtilleryWeapon)

to
Code: Select all
MainGun = Class(CDFLaserHeavyWeapon)

Now wee need to tell the script, where the classdata for the CDFLaserHeavyWeapon is.

copy this line from URB2301_script.lua to UEB2303_script.lua:
Code: Select all
local CDFLaserHeavyWeapon = import('/lua/cybranweapons.lua').CDFLaserHeavyWeapon


At last we can delete the old and unneeded local for the ArtyWeapon.
Delete:
Code: Select all
local TIFArtilleryWeapon = import('/lua/terranweapons.lua').TIFArtilleryWeapon




Well done, the UEF T2 Artillery is now using the Cybran Particle Cannon.

Here is the complete script and Blueprint for the UEF T2 Artillery:

UEB2303_script.lua:
Code: Select all
#****************************************************************************
#**
#**  File     :  /cdimage/units/UEB2303/UEB2303_script.lua
#**  Author(s):  John Comes, David Tomandl, Jessica St. Croix
#**
#**  Summary  :  UEF Light Artillery Script
#**
#**  Copyright © 2005 Gas Powered Games, Inc.  All rights reserved.
#****************************************************************************

local TStructureUnit = import('/lua/terranunits.lua').TStructureUnit
local CDFLaserHeavyWeapon = import('/lua/cybranweapons.lua').CDFLaserHeavyWeapon

UEB2303 = Class(TStructureUnit) {

    OnStopBeingBuilt = function(self,builder,layer)
        TStructureUnit.OnStopBeingBuilt(self,builder,layer)
        local bp = self:GetBlueprint()
        if bp.Audio.Activate then
            self:PlaySound(bp.Audio.Activate)
        end
    end,

    Weapons = {
        MainGun = Class(CDFLaserHeavyWeapon) {
        },
    },
}

TypeClass = UEB2303


UEB2303_unit.bp:
Code: Select all
UnitBlueprint {
    AI = {
        TargetBones = {
            'Target01',
            'Target02',
        },
    },
    Audio = {
        Destroyed = Sound {
            Bank = 'UELDestroy',
            Cue = 'UEB_Destroy_Huge',
            LodCutoff = 'UnitMove_LodCutoff',
        },
        DoneBeingBuilt = Sound {
            Bank = 'UEB',
            Cue = 'UEB2303_Activate',
            LodCutoff = 'UnitMove_LodCutoff',
        },
        UISelection = Sound {
            Bank = 'Interface',
            Cue = 'UEF_Select_Gun',
            LodCutoff = 'UnitMove_LodCutoff',
        },
    },
    Buffs = {
        Regen = {
            Level1 = 2,
            Level2 = 4,
            Level3 = 6,
            Level4 = 8,
            Level5 = 10,
        },
    },
    BuildIconSortPriority = 140,
    Categories = {
        'PRODUCTSC1',
        'SELECTABLE',
        'BUILTBYTIER2ENGINEER',
        'BUILTBYTIER3ENGINEER',
        'BUILTBYTIER2COMMANDER',
        'BUILTBYTIER3COMMANDER',
        'UEF',
        'STRUCTURE',
        'STRATEGIC',
        'TECH2',
        'INDIRECTFIRE',
        'ARTILLERY',
        'DRAGBUILD',
        'SIZE4',
        'VISIBLETORECON',
        'RECLAIMABLE',
        'SHOWATTACKRETICLE',
        'OVERLAYINDIRECTFIRE',
        'SORTSTRATEGIC',
    },
    CollisionOffsetY = -0.25,
    Defense = {
        AirThreatLevel = 0,
        ArmorType = 'Structure',
        EconomyThreatLevel = 30,
        Health = 3600,
        MaxHealth = 3600,
        RegenRate = 0,
        SubThreatLevel = 0,
        SurfaceThreatLevel = 54,
    },
    Description = '<LOC ueb2303_desc>Artillery Installation',
    Display = {
        Mesh = {
            IconFadeInZoom = 130,
            LODs = {
                {
                    LODCutoff = 120,
                    ShaderName = 'Unit',
                },
                {
                    AlbedoName = 'ueb2303_lod1_albedo.dds',
                    LODCutoff = 215,
                    ShaderName = 'Unit',
                    SpecularName = 'ueb2303_lod1_specteam.dds',
                },
            },
        },
        PlaceholderMeshName = 'UXB0004',
        SpawnRandomRotation = true,
        Tarmacs = {
            {
                Albedo = 'Tarmacs/Tar6x_01_albedo',
                DeathLifetime = 300,
                FadeOut = 150,
                Length = 6.4,
                Normal = 'Tarmacs/Tar6x_01_normals',
                Orientations = {
                    0,
                    90,
                    180,
                    270,
                },
                RemoveWhenDead = false,
                Width = 6.4,
            },
        },
        UniformScale = 0.35,
    },
    Economy = {
        BuildCostEnergy = 18000,
        BuildCostMass = 2520,
        BuildTime = 1800,
        RebuildBonusIds = {
            'ueb2303',
        },
    },
    Footprint = {
        SizeX = 1,
        SizeZ = 1,
    },
    General = {
        Category = 'Strategic',
        Classification = 'RULEUC_Weapon',
        CommandCaps = {
            RULEUCC_Attack = true,
            RULEUCC_CallTransport = false,
            RULEUCC_Capture = false,
            RULEUCC_Guard = false,
            RULEUCC_Move = false,
            RULEUCC_Nuke = false,
            RULEUCC_Patrol = false,
            RULEUCC_Reclaim = false,
            RULEUCC_Repair = false,
            RULEUCC_RetaliateToggle = true,
            RULEUCC_Stop = true,
            RULEUCC_Transport = false,
        },
        FactionName = 'UEF',
        Icon = 'land',
        SelectionPriority = 5,
        TechLevel = 'RULEUTL_Advanced',
        UnitName = '<LOC ueb2303_name>Klink Hammer',
        UnitWeight = 1,
    },
    Intel = {
        VisionRadius = 28,
    },
    Interface = {
        HelpText = '<LOC ueb2303_help>Artillery Installation',
    },
    LifeBarHeight = 0.075,
    LifeBarOffset = 0.8,
    LifeBarSize = 1.25,
    Physics = {
        BankingSlope = 0,
        BuildOnLayerCaps = {
            LAYER_Air = false,
            LAYER_Land = true,
            LAYER_Orbit = false,
            LAYER_Seabed = false,
            LAYER_Sub = false,
            LAYER_Water = false,
        },
        DragCoefficient = 0.2,
        FlattenSkirt = true,
        MaxSteerForce = 0,
        MeshExtentsX = 2,
        MeshExtentsY = 1.65,
        MeshExtentsZ = 4,
        MinSpeedPercent = 0,
        MotionType = 'RULEUMT_None',
        SkirtOffsetX = -0.5,
        SkirtOffsetZ = -0.5,
        SkirtSizeX = 2,
        SkirtSizeZ = 2,
        TurnRate = 0,
    },
    SelectionCenterOffsetZ = -0.4,
    SelectionSizeX = 0.9,
    SelectionSizeZ = 0.9,
    SelectionThickness = 0.47,
    SizeX = 1,
    SizeY = 1.7,
    SizeZ = 1,
    StrategicIconName = 'icon_structure2_artillery',
    StrategicIconSortPriority = 180,
    Veteran = {
        Level1 = 15,
        Level2 = 30,
        Level3 = 45,
        Level4 = 60,
        Level5 = 75,
    },
    Weapon = {
        {
            AboveWaterTargetsOnly = true,
            Audio = {
                Fire = Sound {
                    Bank = 'URLWeapon',
                    Cue = 'URB2301_Cannon_Sgl',
                    LodCutoff = 'Weapon_LodCutoff',
                },
            },
            BallisticArc = 'RULEUBA_LowArc',
            CollideFriendly = false,
            Damage = 10,
            DamageType = 'Normal',
            DisplayName = 'Particle Cannon',
            FireTargetLayerCapsTable = {
                Land = 'Land|Water|Seabed',
                Water = 'Land|Water|Seabed',
            },
            FiringTolerance = 2,
            Label = 'MainGun',
            MaxRadius = 50,
            MuzzleSalvoDelay = 0,
            MuzzleSalvoSize = 2,
            MuzzleVelocity = 100,
            ProjectileId = '/projectiles/CDFLaserHeavy02/CDFLaserHeavy02_proj.bp',
            ProjectileLifetimeUsesMultiplier = 1.15,
            ProjectilesPerOnFire = 1,
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle',
                    },
                    RackBone = 'Turret_Recoil',
                },
            },
            RackFireTogether = false,
            RackRecoilDistance = -1,
            RackReloadTimeout = 10,
            RackSalvoChargeTime = 0,
            RackSalvoReloadTime = 0,
            RackSalvoSize = 1,
            RackSlavedToTurret = false,
            RangeCategory = 'UWRC_DirectFire',
            RateOfFire = 3,
            ReTargetOnMiss = true,
            TargetCheckInterval = 0.16,
            TargetPriorities = {
                'SPECIALHIGHPRI',
                'MOBILE',
                'STRUCTURE DEFENSE',
                'SPECIALLOWPRI',
                'ALLUNITS',
            },
            TargetRestrictDisallow = 'UNTARGETABLE',
            TrackingRadius = 1.15,
            TurretBoneMuzzle = 'Turret_Muzzle',
            TurretBonePitch = 'Turret_Barrel',
            TurretBoneYaw = 'Turret',
            TurretDualManipulators = false,
            TurretPitch = 10,
            TurretPitchRange = 55,
            TurretPitchSpeed = 60,
            TurretYaw = 0,
            TurretYawRange = 180,
            TurretYawSpeed = 60,
            Turreted = true,
            WeaponCategory = 'Direct Fire',
        },
    },
    Wreckage = {
        Blueprint = '/props/DefaultWreckage/DefaultWreckage_prop.bp',
        EnergyMult = 0,
        HealthMult = 0.9,
        MassMult = 0.9,
        ReclaimTimeMultiplier = 1,
        WreckageLayers = {
            Air = false,
            Land = true,
            Seabed = false,
            Sub = false,
            Water = false,
        },
    },
}


Greetings Uveso.
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: New Modder - Need help with weapon "reassignment"

Postby biass » 20 Apr 2016, 11:09

Hello, i thought i might add, that anchorpoints are normally seen in modelling programs such as 3DSMAX, prehaps changing the anchorpoint name to something that will accomodate the laser if Uveso cannot give you a good solution <3
Map thread: https://bit.ly/2PBsa5H

Petricpwnz wrote:biass on his campaign to cleanse and remake every single map of FAF because he is an untolerating reincarnation of mapping hitler
User avatar
biass
Contributor
 
Posts: 2239
Joined: 03 Dec 2015, 07:54
Has liked: 598 times
Been liked: 662 times
FAF User Name: biass

Re: New Modder - Need help with weapon "reassignment"

Postby nine2 » 20 Apr 2016, 12:42

That answer would have taken forever +1 karma
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: New Modder - Need help with weapon "reassignment"

Postby Uveso » 20 Apr 2016, 14:55

Hello biass,

because Lex Ryder is new to moding, i tryed to make a simple answer.

To explain the problem with the Monkey laser, we can take a short look into the cybranweapons.lua:

At line 203 we find a normal Lasergun; used by the cybran point defense:

Code: Select all
CDFLaserHeavyWeapon = Class(DefaultProjectileWeapon) {
    FxMuzzleFlash = EffectTemplate.CLaserMuzzleFlash02,
}

There is no problem with porting this weapon to other units.

Now let's take a look at the monkey Laser:

Code: Select all
CDFHeavyMicrowaveLaserGenerator = Class(DefaultBeamWeapon) {
    BeamType = CollisionBeamFile.MicrowaveLaserCollisionBeam01,
    FxMuzzleFlash = {},
    FxChargeMuzzleFlash = {},
    FxUpackingChargeEffects = EffectTemplate.CMicrowaveLaserCharge01,
    FxUpackingChargeEffectScale = 1,

    IdleState = State(DefaultBeamWeapon.IdleState) {
        Main = function(self)
            if self.RotatorManip then
                self.RotatorManip:SetTargetSpeed(0)
                self.RotatorManip:SetAccel(90)
            end
            if self.SliderManip then
                self.SliderManip:SetGoal(0,0,0)
                self.SliderManip:SetSpeed(2)
            end
            DefaultBeamWeapon.IdleState.Main(self)
        end,
    },

    CreateProjectileAtMuzzle = function(self, muzzle)
        if not self.SliderManip then
            self.SliderManip = CreateSlider(self.unit, 'Center_Turret_Barrel')
            self.unit.Trash:Add(self.SliderManip)
        end
        if not self.RotatorManip then
            self.RotatorManip = CreateRotator(self.unit, 'Center_Turret_Barrel', 'z')
            self.unit.Trash:Add(self.RotatorManip)
        end
        self.RotatorManip:SetTargetSpeed(500)
        self.RotatorManip:SetAccel(200)
        self.SliderManip:SetPrecedence(11)
        self.SliderManip:SetGoal(0, 0, -1)
        self.SliderManip:SetSpeed(-1)
        DefaultBeamWeapon.CreateProjectileAtMuzzle(self, muzzle)
    end,

    PlayFxWeaponUnpackSequence = function( self )
        if not self.ContBeamOn then
            local army = self.unit:GetArmy()
            local bp = self:GetBlueprint()
            for k, v in self.FxUpackingChargeEffects do
                for ek, ev in bp.RackBones[self.CurrentRackSalvoNumber].MuzzleBones do
                    CreateAttachedEmitter(self.unit, ev, army, v):ScaleEmitter(self.FxUpackingChargeEffectScale)
                end
            end
            if self.RotatorManip then
                self.RotatorManip:SetTargetSpeed(179)
            end
            DefaultBeamWeapon.PlayFxWeaponUnpackSequence(self)
        end
    end,
}

As you can see there are slider and rotator created on the Center_Turret_Barrel inside the CreateProjectileAtMuzzle function and there is also a WeaponUnpackSequence function.
In this case you cant simply change the name of the anchor point.

So, no. I can't give a good solution for the Monkeylord Laser. 8-)
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: New Modder - Need help with weapon "reassignment"

Postby Lex Ryder » 20 Apr 2016, 19:58

Right, apologies for not having replied to this before. I attempted this work at a time, but I suppose I'd gotten distracted and hadn't come back until a couple nights ago.

So, the Monkeylord laser is clearly not going to be usable for my idea. Oh, well. Is that the only one with this issue or can my idea with the GC Eye-Laser work? I applied your tutorial above (to the best of my ability) with this idea and ran into the problems mentioned in the newer post. Or perhaps a way to edit together a thicker laser 'image' to be applied to what fires out of my weapon if I have to use a tiny, thin one.

I know this seems like a lot to explain, but it is definitely appreciated when it is.
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: New Modder - Need help with weapon "reassignment"

Postby Lex Ryder » 20 Apr 2016, 21:47

This is what I have down so far with a beam from the Seraphim T2 Point Defense to fire from a UEF T2 Artillery:

Script-
Code: Select all
local TStructureUnit = import('/lua/terranunits.lua').TStructureUnit
local SDFUltraChromaticBeamGenerator = import('/lua/seraphimweapons.lua').SDFUltraChromaticBeamGenerator

UEB6000 = Class(TStructureUnit) {

    Weapons = {
        Weapons = {
            MainGun = Class(SDFUltraChromaticBeamGenerator) {}
    },
}

TypeClass = UEB6000


.bp-

Code: Select all
Weapon = {
        {
            AboveWaterTargetsOnly = true,
            Audio = {
                BeamLoop = Sound {
                    Bank = 'XSB_Weapon',
                    Cue = 'XSB2301_Ultrachromatic_Beam',
                    LodCutoff = 'Weapon_LodCutoff',
                },
                BeamStart = Sound {
                    Bank = 'XSB_Weapon',
                    Cue = 'XSB2301_Ultrachromatic_Beam_Start',
                    LodCutoff = 'Weapon_LodCutoff',
                },
                BeamStop = Sound {
                    Bank = 'XSB_Weapon',
                    Cue = 'XSB2301_Ultrachromatic_Beam_Stop',
                    LodCutoff = 'Weapon_LodCutoff',
                },
            },
            BallisticArc = 'RULEUBA_None',
            BeamCollisionDelay = 0.3,
            BeamLifetime = 0.9,
            CollideFriendly = false,
            Damage = 8000,
            DamageRadius = 0,
            DamageType = 'Normal',
            DisplayName = 'Ultrachromatic Beam Generator',
            FireTargetLayerCapsTable = {
                Land = 'Land|Water|Seabed',
                Water = 'Land|Water|Seabed',
            },
            FiringRandomness = 0,
            FiringTolerance = 0,
            Label = 'MainGun',
            LeadTarget = false,
            MaxRadius = 35,
            MuzzleChargeDelay = 0,
            MuzzleSalvoDelay = 0,
            MuzzleSalvoSize = 1,
            ProjectileLifetimeUsesMultiplier = 1.15,
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle',
                    },
                    RackBone = 'Turret_Recoil',
                },
            },
             RackFireTogether = false,
            RackRecoilDistance = -1,
            RackReloadTimeout = 10,
            RackSalvoChargeTime = 0,
            RackSalvoFiresAfterCharge = false,
            RackSalvoReloadTime = 0,
            RackSalvoSize = 1,
            RackSlavedToTurret = false,
            RangeCategory = 'UWRC_DirectFire',
            RateOfFire = 0.25,
            TargetCheckInterval = 1,
            TargetPriorities = {
                'SPECIALHIGHPRI',
                'MOBILE',
                'STRUCTURE DEFENSE',
                'SPECIALLOWPRI',
                'ALLUNITS',
            },
            TargetRestrictDisallow = 'UNTARGETABLE',
            TurretBoneMuzzle = 'Turret_Muzzle',
            TurretBonePitch = 'Turret_Barrel',
            TurretBoneYaw = 'Turret',
            TurretDualManipulators = false,
            TurretPitch = 30,
            TurretPitchRange = 60,
            TurretPitchSpeed = 6,
            TurretYaw = 0,
            TurretYawRange = 180,
            TurretYawSpeed = 6,
            Turreted = true,
            WeaponCategory = 'Direct Fire',
            WeaponUnpacks = false,
        },
    },
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: New Modder - Need help with weapon "reassignment"

Postby Uveso » 21 Apr 2016, 06:53

Your Weaponscript from last posting is working. I tested it with the T2 UEF Arty.

Ok, i said you can't use the original Monkey Lord Laser. But we can create our own weapon.

At first, let us open the file "cybranweapons.lua" and search the Monkey laser named "CDFHeavyMicrowaveLaserGenerator".
We will find this weaponclass:

Code: Select all
-- SPIDER BOT WEAPON!
CDFHeavyMicrowaveLaserGenerator = Class(DefaultBeamWeapon) {
    BeamType = CollisionBeamFile.MicrowaveLaserCollisionBeam01,
    FxMuzzleFlash = {},
    FxChargeMuzzleFlash = {},
    FxUpackingChargeEffects = EffectTemplate.CMicrowaveLaserCharge01,
    FxUpackingChargeEffectScale = 1,

    IdleState = State(DefaultBeamWeapon.IdleState) {
        Main = function(self)
            if self.RotatorManip then
                self.RotatorManip:SetTargetSpeed(0)
                self.RotatorManip:SetAccel(90)
            end
            if self.SliderManip then
                self.SliderManip:SetGoal(0,0,0)
                self.SliderManip:SetSpeed(2)
            end
            DefaultBeamWeapon.IdleState.Main(self)
        end,
    },

    CreateProjectileAtMuzzle = function(self, muzzle)
        if not self.SliderManip then
            self.SliderManip = CreateSlider(self.unit, 'Center_Turret_Barrel')
            self.unit.Trash:Add(self.SliderManip)
        end
        if not self.RotatorManip then
            self.RotatorManip = CreateRotator(self.unit, 'Center_Turret_Barrel', 'z')
            self.unit.Trash:Add(self.RotatorManip)
        end
        self.RotatorManip:SetTargetSpeed(500)
        self.RotatorManip:SetAccel(200)
        self.SliderManip:SetPrecedence(11)
        self.SliderManip:SetGoal(0, 0, -1)
        self.SliderManip:SetSpeed(-1)
        DefaultBeamWeapon.CreateProjectileAtMuzzle(self, muzzle)
    end,

    PlayFxWeaponUnpackSequence = function( self )
        if not self.ContBeamOn then
            local army = self.unit:GetArmy()
            local bp = self:GetBlueprint()
            for k, v in self.FxUpackingChargeEffects do
                for ek, ev in bp.RackBones[self.CurrentRackSalvoNumber].MuzzleBones do
                    CreateAttachedEmitter(self.unit, ev, army, v):ScaleEmitter(self.FxUpackingChargeEffectScale)
                end
            end
            if self.RotatorManip then
                self.RotatorManip:SetTargetSpeed(179)
            end
            DefaultBeamWeapon.PlayFxWeaponUnpackSequence(self)
        end
    end,
}

There are many lines only related to the Monkeylord.
If we delete all functions an their variables, this will left:

Code: Select all
CDFHeavyMicrowaveLaserGenerator = Class(DefaultBeamWeapon) {
    BeamType = CollisionBeamFile.MicrowaveLaserCollisionBeam01,
{


Now we have to tell the game our new weapon.
We are going to hook the "cybranweapons.lua" and inject our weapon there.

Create a directory named "hook" inside your mod folder. All files inside the hook directory will be loaded from the game, if there are at the right place.
Means; all files have to be in their original directory structure.
The original "cybranweapons.lua" is inside the "lua" directory.
So we crate a dir named "lua" inside the "hook" folder.
At last we create an empty text document inside the "lua" dir and name it "cybranweapons.lua".

We should have now an empty textfile with this directory path:
/mods/YOURMODNAME/hook/lua/cybranweapons.lua

The game will load this file and add it to the original cybranweapons.lua file.
It will replace functions with the same name, and add unknown functions like our new weapon.
(Thats wat hooking means.)

Now we paste our Weapon inside our new "cybranweapons.lua" hook file.
Because we won't overwrite the original Monkey Laser we will rename our own Laser from "CDFHeavyMicrowaveLaserGenerator " to "HeavyLexinatorLaser" 8-)
Copy the following script to our cybranweapons.lua:

Code: Select all
HeavyLexinatorLaser = Class(DefaultBeamWeapon) {
    BeamType = CollisionBeamFile.MicrowaveLaserCollisionBeam01,
}


Perfect. Now the game knows a new Weapon.
But no one is using it... :o

Back to the T2 Arty.
Open the arty_script.lua and change the mainweapon:

First we have to tell the script, where it can find our weapon. because we hooked the cybranweapons.lua, our weapon will be in there.
The link to our Weapon looks like this:

Code: Select all
local HeavyLexinatorLaser = import('/lua/cybranweapons.lua').HeavyLexinatorLaser

We changed the name of our weapon, so we have to change the definition inside the Unitclass:

Code: Select all
Weapons = {
        MainGun = Class(HeavyLexinatorLaser) {
        },
    },


At last we change the weapon inside Unit blueprint, and insert the Monkey laser data:
(dont forget to change the anchorpoints)

Code: Select all
Weapon = {
        {
            AboveWaterFireOnly = true,
            AboveWaterTargetsOnly = true,
            AimsStraightOnDisable = true,
            Audio = {
                BeamLoop = Sound {
                    Bank = 'URLWeapon',
                    Cue = 'URL0402_Beam_Loop',
                    LodCutoff = 'Weapon_LodCutoff',
                },
                BeamStart = Sound {
                    Bank = 'URLWeapon',
                    Cue = 'URL0402_Beam_Start',
                    LodCutoff = 'Weapon_LodCutoff',
                },
                BeamStop = Sound {
                    Bank = 'URLWeapon',
                    Cue = 'URL0402_Beam_Stop',
                    LodCutoff = 'Weapon_LodCutoff',
                },
                Unpack = Sound {
                    Bank = 'URLWeapon',
                    Cue = 'URL0402_Beam_Charge',
                    LodCutoff = 'Weapon_LodCutoff',
                },
            },
            AutoInitiateAttackCommand = false,
            BallisticArc = 'RULEUBA_None',
            BeamCollisionDelay = 0.1,
            BeamLifetime = 0,
            CollideFriendly = false,
            ContinuousBeam = true,
            Damage = 800,
            DamageRadius = 0.5,
            DamageType = 'Normal',
            DisplayName = 'Heavy Microwave Laser',
            FireTargetLayerCapsTable = {
                Land = 'Land|Water|Seabed',
                Seabed = 'Land|Water|Seabed',
                Water = 'Land|Water|Seabed',
            },
            FiringTolerance = 2,
            Label = 'MainGun',
            LeadTarget = false,
            MaxRadius = 30,
            MinRadius = 4,
            MuzzleSalvoDelay = 0,
            MuzzleSalvoSize = 1,
            NotExclusive = true,
            RackBones = {
                {
                    MuzzleBones = {
                        'Turret_Muzzle',
                    },
                    RackBone = 'Turret_Recoil',
                },
            },
            RackFireTogether = false,
            RackRecoilDistance = 0,
            RackReloadTimeout = 10,
            RackSalvoChargeTime = 0,
            RackSalvoReloadTime = 0,
            RackSalvoSize = 1,
            RackSlavedToTurret = false,
            RangeCategory = 'UWRC_DirectFire',
            RateOfFire = 3,
            TargetCheckInterval = 0.5,
            TargetPriorities = {
                'SPECIALHIGHPRI',
                'TECH3 MOBILE',
                'TECH2 MOBILE',
                'TECH1 MOBILE',
                'STRUCTURE DEFENSE',
                'SPECIALLOWPRI',
                'ALLUNITS',
            },
            TargetRestrictDisallow = 'UNTARGETABLE',
            TurretBoneMuzzle = 'Turret_Muzzle',
            TurretBonePitch = 'Turret_Barrel',
            TurretBoneYaw = 'Turret',
            TurretDualManipulators = false,
            TurretPitch = -20,
            TurretPitchRange = 90,
            TurretPitchSpeed = 20,
            TurretYaw = 0,
            TurretYawRange = 180,
            TurretYawSpeed = 40,
            Turreted = true,
            WeaponCategory = 'Direct Fire Experimental',
            WeaponRepackTimeout = 0,
            WeaponUnpacks = false,
        },
    },


Here is our T2 Arty with Monkey Laser :)

BUT! The T2 Arty is an artillery with indirect fire. Now we hava a Pointdefense with direct fire!
We have to change this inside the unitblueprint.

Modify the Categories array:
Change: 'ARTILLERY', to 'DEFENSE',
Change: 'INDIRECTFIRE', to 'DIRECTFIRE',
Change: 'SORTSTRATEGIC', to 'SORTDEFENSE',
Delete: 'SHOWATTACKRETICLE',
Delete: 'OVERLAYINDIRECTFIRE',

Modify the General array:
Change: Category = 'Strategic', to Category = 'Defense',
Change: StrategicIconName = 'icon_structure2_artillery', to StrategicIconName = 'icon_structure2_directfire',

Optional you could change the name of our Pointdefense here:
Description = '<LOC ueb2303_desc>Artillery Installation',
UnitName = '<LOC ueb2303_name>Klink Hammer',
HelpText = '<LOC ueb2303_help>Artillery Installation',

Now; Here is our T2 Arty with Monkey Laser :D

BUT! The AI will not build you custom unit without a little help.

You are still here? Cool.
Please create a directory inside you Modfolder and name it "lua"
Now create a directory named "customunits" inside the lua folder.
And create a empty text file and name it "LexPointDefense.lua"

Copy this into "LexPointDefense.lua" lua:
(lex2303 is the unitid in my case)
(50 means, if the AI is building a T2GroundDefense it will be to 50% your unit)
Code: Select all
UnitList = {
   T2GroundDefense = {
      UEF = {'lex2303', 50}, -- Pointdefense from lex
   },
}

Thats all!

Finaly; Here is our T2 Arty with Monkey Laser and Sorian-AI support :mrgreen:

greetings uveso.

PS: here is a small mod with the T2 Arty and all changes from this post:
http://faforever.uveso.de/forum/Debug_LexRyder.rar
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: New Modder - Need help with weapon "reassignment"

Postby Lex Ryder » 21 Apr 2016, 09:41

Wow! That's great! Thanks a lot for taking the time to help me here. Like I said, these forums work wonders. Now I have a new monster weapon to attach to my new Monster Experimental I am building. Or two. OR THREE! THREE MONSTER LASERS!

Nah, but thanks again. I stumbled into SC1 as an Xb360 gift from my Father from the Best Buy clearance bin. Over the years (save for Halo and any Star Wars game) SC is now easily my favorite game and I love playing around with it. Just this week I finished my first main, simple, cheap mods. Nuclear Bomber, EMP Bomber, and EMP Tac. Missile. You really gotta appreciate the little things in life. :)
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: New Modder - Need help with weapon "reassignment"

Postby Uveso » 21 Apr 2016, 11:12

During your Monster Experimental first enemy kill, make a photo and post it! :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

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest