Need another perspective: Personal Shield enhancements, what's wrong here ?
-
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
-
Forgot to add a copy of one of the units.
ual0108.zip -
I don't see a
CreatePersonalShield
in FAF code, did you meanCreateShield
? -
@nomander I'm not calling it directly, the create enhancement is. Same as how the commander does when it enhances itself.
Also create shield from unit.lua contains the following...
CreateShield = function(self, bpShield) -- Copy the shield template so we don't alter the blueprint table. local bpShield = table.deepcopy(bpShield) self:DestroyShield() if bpShield.PersonalShield then self.MyShield = PersonalShield(bpShield, self) elseif bpShield.AntiArtilleryShield then self.MyShield = AntiArtilleryShield(bpShield, self) elseif bpShield.PersonalBubble then self.MyShield = PersonalBubble(bpShield, self) elseif bpShield.TransportShield then self.MyShield = TransportShield(bpShield, self) else self.MyShield = Shield(bpShield, self) end self:SetFocusEntity(self.MyShield) self.Trash:Add(self.MyShield) end,
Thus when create shield is called, the type of shield is later chosen.
-
self:CreatePersonalShield(bp)
is a function only in the Steam version. You have to useself:CreateShield(bp)
in FAF. -
It's working...