Beam weapons

Everything about mods can be found here.

Moderator: Morax

Beam weapons

Postby Franck83 » 18 Jul 2018, 11:03

Hi all commanders,

Maybe someone can help me.

I created a beam weapon for all ACU.
This code is working pretty nice for Aeon, the Cybran and the SERAPHIM ACU.

Strangely, the UEF ACU send me an error when the unit start firing with the beam.

WARNING: Error running OnGotTarget script in CScriptObject at 1c5de490: ...amdata\faforever\gamedata\lua.nx2\lua\sim\weapon.lua(226): attempt to perform arithmetic on field `NumTargets' (a nil value)
stack traceback:
...amdata\faforever\gamedata\lua.nx2\lua\sim\weapon.lua(226): in function <...amdata\faforever\gamedata\lua.nx2\lua\sim\weapon.lua:220>


IS there any particularities with the UEF ACU ? Where am i wrong.

unit.bp

Code: Select all
        {
            AboveWaterFireOnly = true,
            AboveWaterTargetsOnly = 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',
                },
            },
            BallisticArc = 'RULEUBA_None',
            BeamCollisionDelay = 0,
            BeamLifetime = 0,
            CanFireFromTransport = true,
            CollideFriendly = false,
            ContinuousBeam = true,
            Damage = 200,
            DamageRadius = 0.5,
            DamageType = 'Normal',
            DisplayName = 'Cold Beam',
            EnergyChargeForFirstShot = false,
            FireTargetLayerCapsTable = {
                Land = 'Land|Water|Seabed',
                Water = 'Land|Water|Seabed',
                Seabed = 'Land|Water|Seabed',
            },
            FiringTolerance = 0.25,
            HeadingArcCenter = 0,
            HeadingArcRange = 180,
            Label = 'ColdBeam',
            MaxRadius = 22,
            MuzzleChargeDelay = 0,
            MuzzleSalvoDelay = 0,
            MuzzleSalvoSize = 1,
            PrefersPrimaryWeaponTarget = true,
            ProjectilesPerOnFire = 1,
            RackBones = {
                {
                    MuzzleBones = {
                        'Left_Turret_Muzzle',
                    },
                    RackBone = 'Left_Turret_Muzzle',
                },
            },
            RackFireTogether = false,
            RackRecoilDistance = 0,
            RackReloadTimeout = 1,
            RackSalvoChargeTime = 0,
            RackSalvoReloadTime = 0,
            RackSalvoSize = 1,
            RackSlavedToTurret = false,
            RangeCategory = 'UWRC_DirectFire',
            RateOfFire = 10,
            TargetCheckInterval = 0.1,
            TargetPriorities = {
                'SPECIALHIGHPRI',
                'MOBILE',
                'STRUCTURE DEFENSE',
                'SPECIALLOWPRI',
                'ALLUNITS',
            },
            TargetRestrictDisallow = 'UNTARGETABLE',
            TrackingRadius = 1.15,
            TurretBoneMuzzle = 'Left_Turret_Muzzle',
            TurretBonePitch = 'Left_Turret_Muzzle',
            TurretBoneYaw = 'Left_Turret_Muzzle',
            TurretDualManipulators = false,
            TurretPitch = 0,
            TurretPitchRange = 80,
            TurretPitchSpeed = 90,
            TurretYaw = 0,
            TurretYawRange = 10,
            TurretYawSpeed = 110,
            Turreted = true,
            UseFiringSolutionInsteadOfAimBone = true,
            WeaponCategory = 'Direct Fire',
            WeaponRepackTimeout = 0,
            WeaponUnpacks = false,
        },


unit script

Code: Select all
UAL0001 = Class(ACUUnit) {
    Weapons = {
        DeathWeapon = Class(DeathNukeWeapon) {},
        RightDisruptor = Class(ADFDisruptorCannonWeapon) {},
        ChronoDampener = Class(ADFChronoDampener) {},
        OverCharge = Class(ADFOverchargeWeapon) {},
        AutoOverCharge = Class(ADFOverchargeWeapon) {},
       -- Alliance of Heroes weapons
      ColdBeam = Class(HeavyColdBeam) {
         OnWeaponFired = function(self)
                  local id = self.unit:GetEntityId()
            DM.IncProperty(id, 'Stamina', -1)
            if DM.GetProperty(id, 'Stamina') < 5  then
               self:SetWeaponEnabled(false)
               if DM.GetProperty(id, 'ColdBeam'..'_AutoCast') == 1 then
                  self:ForkThread(self.OnWeaponCapacitorRegen)
               end
            end
            end,
         OnWeaponCapacitorRegen = function(self)
            LOG('inc thread')
            local id = self.unit:GetEntityId()
            while DM.GetProperty(id, 'Stamina') <= 20 do
                    self:SetWeaponEnabled(false)
                    WaitSeconds(0.3)
                end
            self:SetWeaponEnabled(true)
         end,
         OnDisableWeapon = function(self)
                if self.unit:BeenDestroyed() then return end
            LOG('Disabling')
            end,
            SetOnTransport = function(self, transportstate)
                HeavyColdBeam.SetOnTransport(self, transportstate)
                self:ForkThread(self.OnTransportWatch)
            end,
            OnTransportWatch = function(self)
                while self:GetOnTransport() do
                    self:PlayFxBeamEnd()
                    self:SetWeaponEnabled(false)
                    WaitSeconds(0.3)
                end
            end,
        },
      --
   },
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Beam weapons

Postby Franck83 » 18 Jul 2018, 14:08

Ok, it works now. I needed to use the units.nx2 package from gamedata FAF. I was using the wrong package.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Beam weapons

Postby Uveso » 19 Jul 2018, 01:58

Hey Franck83,

nice to see you answering your own help requests :)
Please tell yourself to post a game.log next time ^^^ :mrgreen: ^^^

Btw, thank's for reporting it!
I was almost starting my code editor :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


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest