I've several 4DC units I'm working on that can self enhance to have personal shields. For all intensive purposes in comparison with the FAF client UAL0101 (Aeon commanders scripts & bp) these units should be setup correctly. However, what I am seeing is that the units can perform the enhancement but upon completions throw the following error...
WARNING: Error running /lua/sim/tasks/EnhanceTask.lua script in CScriptObject at 1974e8f0: ...alliance\mods\4dfaf\units\ual0108\ual0108_script.lua(28): attempt to call method `CreatePersonalShield' (a nil value)
stack traceback:
...alliance\mods\4dfaf\units\ual0108\ual0108_script.lua(28): in function `CreateEnhancement'- ...gramdata\faforever\gamedata\lua.nx2\lua\sim\unit.lua(4306): in function `OnWorkEnd'
...rever\gamedata\lua.nx2\lua\sim\tasks\enhancetask.lua(85): in function <...rever\gamedata\lua.nx2\lua\sim\tasks\enhancetask.lua:59>
I've gone over this unit with a fine tooth comb, checking and rechecking the pathing and verifying the structure of the enhancement in comparison with the Aeon commanders UAL0101 (FAF Client version).
Unit Script
-----------------------------------------------------------------------------
-- File : /units/ual0108/ual0108_script.lua
--
-- Author(s): EbolaSoup, Resin Smoker, Optimus Prime, Vissroid
--
-- Summary : Aeon light assault walker
--
-- Copyright © 2024 4DFAF, All rights reserved.
-----------------------------------------------------------------------------
local AWalkingLandUnit = import('/lua/aeonunits.lua').AWalkingLandUnit
local ADFLaserLightWeapon = import('/lua/aeonweapons.lua').ADFLaserLightWeapon
local AAAZealotMissileWeapon = import('/lua/aeonweapons.lua').AAAZealotMissileWeapon
ual0108 = Class(AWalkingLandUnit) {
Weapons = {
MainGun = Class(ADFLaserLightWeapon) {},
RocketBackpack = Class(AAAZealotMissileWeapon) {},
},
CreateEnhancement = function(self, enh)
AWalkingLandUnit.CreateEnhancement(self, enh)
local bp = self:GetBlueprint().Enhancements[enh]
if enh == 'PersonalShield' then
self:AddToggleCap('RULEUTC_ShieldToggle')
self:SetEnergyMaintenanceConsumptionOverride(bp.MaintenanceConsumptionPerSecondEnergy or 0)
self:SetMaintenanceConsumptionActive()
self:CreatePersonalShield(bp)
elseif enh == 'PersonalShieldRemove' then
self:DestroyShield()
self:SetMaintenanceConsumptionInactive()
self:RemoveToggleCap('RULEUTC_ShieldToggle')
end
end,
}
TypeClass = ual0108
Unit Blueprint snippet
Enhancements = {
Slots = {
Back = {
name = '<LOC _Back>',
x = -2,
y = -5,
},
},
PersonalShield = {
BuildCostEnergy = 200,
BuildCostMass = 40,
BuildTime = 167,
Icon = 'ptsg',
ImpactEffects = 'AeonShieldHit01',
MaintenanceConsumptionPerSecondEnergy = 5,
Name = '<LOC enhancements_0014>Personal Shield Generator',
OwnerShieldMesh = '/mods/4DFAF/units/ual0108/ual0108_PersonalShield_mesh',
PersonalShield = true,
RegenAssistMult = 10,
ShieldEnergyDrainRechargeTime = 5,
ShieldMaxHealth = 150,
ShieldRechargeTime = 5,
ShieldRegenRate = 10,
ShieldRegenStartTime = 0.1,
Slot = 'Back',
UpgradeUnitAmbientBones = {
'bodyBase',
},
UpgradeEffectBones = {
'bodyBase',
},
},
PersonalShieldRemove = {
BuildCostEnergy = 1,
BuildCostMass = 1,
BuildTime = 0.1,
Icon = 'ptsg',
Name = '<LOC enhancements_0017>Remove Personal Shield',
Prerequisite = 'PersonalShield',
RemoveEnhancements = {
'PersonalShield',
'PersonalShieldRemove',
},
Slot = 'Back',
},
},
My unit path is /mods/4DFAF/units/ual0108....
Can anyone spot what i may be missing from the enhancement process to throw the error posted above?
Thanks in advance!
Resin