I have a question about creating mods for units. The basic intention of my mod is to change all non-stealth submarines to become stealthed when stationary and not firing. For this behaviour I have copied the Seraphim combat scout behaviour. Which I have found uses a script instead of blueprint parameters to control its visibility status.
The modified script for the UEF T1 submarine should be as follows:
- Code: Select all
#****************************************************************************
#**
#** File : /cdimage/units/UES0203/UES0203_script.lua
#** Author(s): John Comes, David Tomandl, Jessica St. Croix
#**
#** Summary : UEF Attack Sub Script
#**
#** Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
#** Modified by Hawkei 2014
#****************************************************************************
local TSubUnit = import('/lua/terranunits.lua').TSubUnit
local TANTorpedoAngler = import('/lua/terranweapons.lua').TANTorpedoAngler
local TDFLightPlasmaCannonWeapon = import('/lua/terranweapons.lua').TDFLightPlasmaCannonWeapon
UES0203 = Class(TSubUnit) {
PlayDestructionEffects = true,
DeathThreadDestructionWaitTime = 0,
Weapons = {
Torpedo01 = Class(TANTorpedoAngler) {
OnWeaponFired = function(self, target)
SDFPhasicAutoGunWeapon.OnWeaponFired(self, target)
ChangeState( self.unit, self.unit.VisibleState )
end,
OnLostTarget = function(self)
SDFPhasicAutoGunWeapon.OnLostTarget(self)
if self.unit:IsIdleState() then
ChangeState( self.unit, self.unit.InvisState )
end
end,},
PlasmaGun = Class(TDFLightPlasmaCannonWeapon) {}
},
OnStopBeingBuilt = function(self, builder, layer)
#These start enabled, so before going to InvisState, disabled them.. they'll be reenabled shortly
self:DisableUnitIntel('SonarStealth')
self.Stealthed = false
ChangeState( self, self.InvisState ) # If spawned in we want the unit to be invis, normally the unit will immediately start moving
end,
InvisState = State() {
Main = function(self)
self.Stealthed = false
local bp = self:GetBlueprint()
if bp.Intel.StealthWaitTime then
WaitSeconds( bp.Intel.StealthWaitTime )
end
self:EnableUnitIntel('SonarStealth')
self.Stealthed = true
end,
OnMotionHorzEventChange = function(self, new, old)
if new != 'Stopped' then
ChangeState( self, self.VisibleState )
end
},
VisibleState = State() {
Main = function(self)
if self.Cloaked then
self:DisableUnitIntel('SonarStealth')
end
end,
OnMotionHorzEventChange = function(self, new, old)
if new == 'Stopped' then
ChangeState( self, self.InvisState )
end
},
}
TypeClass = UES0203
So my question is this: Is it possible to merge or overwrite the existing script for the UES0203? Or do I need to create an entirely new unit?