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,
},
--
},