Forged Alliance Forever Forums
Moderator: Morax
OnStartBuild = function(self, unitBuilding, order)
AAirUnit.OnStartBuild(self, unitBuilding, order)
self.UnitBeingBuilt = unitBuilding
ChangeState(self, self.BuildingState)
end,
OnStopBuild = function(self, unitBeingBuilt)
AAirUnit.OnStopBuild(self, unitBeingBuilt)
ChangeState(self, self.FinishedBuildingState)
end,
OnFailedToBuild = function(self)
AAirUnit.OnFailedToBuild(self)
ChangeState(self, self.DroneMaintenanceState)
end,
OnWorkBegin = function(self)
AAirUnit.OnWorkBegin(self)
ChangeState(self, self.WorkingState)
end,
OnWorkEnd = function(self)
AAirUnit.OnWorkEnd(self)
ChangeState(self, self.FinishedWorkingState)
end,
OnWorkFailed = function(self)
AAirUnit.OnWorkEnd(self)
ChangeState(self, self.DroneMaintenanceState)
end,
WorkingState = State { -- needed to fix drones not being rebuilt upon enhancement obtained
Main = function(self)
while self.WorkProgress < 1 and not self.Dead do
WaitSeconds(0.1)
end
end,
OnWorkEnd = function(self, work)
self:ClearWork()
self:SetActiveConsumptionInactive()
AddUnitEnhancement(self, work)
self:CleanupEnhancementEffects(work)
self:CreateEnhancement(work)
self:PlayUnitSound('EnhanceEnd')
self:StopUnitAmbientSound('EnhanceLoop')
self:EnableDefaultToggleCaps()
--ChangeState(self, self.IdleState)
ChangeState(self, self.DroneMaintenanceState)
end,
},
OnStartBuild = function(self, unitBuilding, order) --for drones not being built when the carrier builds other stuff
AAirUnit.OnStartBuild(self, unitBuilding, order)
self.UnitBeingBuilt = unitBuilding
ChangeState(self, self.BuildingState)
-- ChangeState(self, self.DroneMaintenanceState)
end,
OnStopBuild = function(self, unitBeingBuilt)
AAirUnit.OnStopBuild(self, unitBeingBuilt)
--ChangeState(self, self.FinishedBuildingState)
ChangeState(self, self.DroneMaintenanceState)
end,
OnFailedToBuild = function(self)
AAirUnit.OnFailedToBuild(self)
ChangeState(self, self.DroneMaintenanceState)
end,
local BaseTransport = import('/lua/defaultunits.lua').BaseTransport
local AirDroneCarrier = import('/mods/BlackOpsFAF-Unleashed/lua/BlackOpsunits.lua').AirDroneCarrier -- the bit that does the actual work, take a look to see what it does and how and how it is different than individual DroneSetup in my xaa9901-5 units in my mod)
XAA9901 = Class(BaseTransport, AAirUnit, AirDroneCarrier) { --this is how we call the carrier Blackops script
-- Create drones --goes in OnStopBeingBuilt
ChangeState(self, self.DroneMaintenanceState)
AirDroneCarrier.InitDrones(self) -- this creates them via the Blackops carrier script. Place it here to have drones right away, or place it under an enhancement to activate it via an enhancement
OnDamage = function(self, instigator, amount, vector, damagetype)
AAirUnit.OnDamage(self, instigator, amount, vector, damagetype)
AirDroneCarrier.SetAttacker(self, instigator)
end,
--Drone control buttons
OnScriptBitSet = function(self, bit)
--Drone assist toggle, on
if bit == 1 then
self.DroneAssist = false
--Drone recall button
elseif bit == 7 then
self:RecallDrones()
--Pop button back up, as it's not actually a toggle
self:SetScriptBit('RULEUTC_SpecialToggle', false)
else
AAirUnit.OnScriptBitSet(self, bit)
end
end,
OnScriptBitClear = function(self, bit)
--Drone assist toggle, off
if bit == 1 then
self.DroneAssist = true
--Recall button reset, do nothing
elseif bit == 7 then
return
else
AAirUnit.OnScriptBitClear(self, bit)
end
end,
--Handles drone docking
OnTransportAttach = function(self, attachBone, unit)
self.DroneData[unit.Name].Docked = attachBone
unit:SetDoNotTarget(true)
BaseTransport.OnTransportAttach(self, attachBone, unit)
end,
--Handles drone undocking, also called when docked drones die
OnTransportDetach = function(self, attachBone, unit)
self.DroneData[unit.Name].Docked = false
unit:SetDoNotTarget(false)
if unit.Name == self.BuildingDrone then
self:CleanupDroneMaintenance(self.BuildingDrone)
end
BaseTransport.OnTransportDetach(self, attachBone, unit)
end,
OnKilled = function(self, instigator, damagetype, overkillRatio)
AAirUnit.OnKilled(self, instigator, damagetype, overkillRatio)
--Kill our heartbeat thread
KillThread(self.HeartBeatThread)
--Clean up any in-progress construction
ChangeState(self, self.DeadState)
--Immediately kill existing drones
self:KillAllDrones()
local nrofBones = self:GetBoneCount() -1
local watchBone = self:GetBlueprint().WatchBone or 0
end,
-- Set on unit death, ends production and consumption immediately
DeadState = State {
Main = function(self)
if self.gettingBuilt == false then
self:CleanupDroneMaintenance(nil, true)
end
end,
WorkingState = State { -- needed to fix drones not being rebuilt
Main = function(self)
while self.WorkProgress < 1 and not self.Dead do
WaitSeconds(0.1)
end
end,
OnWorkEnd = function(self, work)
self:ClearWork()
self:SetActiveConsumptionInactive()
AddUnitEnhancement(self, work)
self:CleanupEnhancementEffects(work)
self:CreateEnhancement(work)
self:PlayUnitSound('EnhanceEnd')
self:StopUnitAmbientSound('EnhanceLoop')
self:EnableDefaultToggleCaps()
--ChangeState(self, self.IdleState)
ChangeState(self, self.DroneMaintenanceState)
end,
OnWorkFail = function(self, work) --if you cancel an enhancement upgrade - i did not have time to test it yet
self:ClearWork()
self:SetActiveConsumptionInactive()
self:PlayUnitSound('EnhanceFail')
self:StopUnitAmbientSound('EnhanceLoop')
self:CleanupEnhancementEffects()
ChangeState(self, self.DroneMaintenanceState)
end,
},
OnStartBuild = function(self, unitBuilding, order) --same thing, but for when the carrier builds stuff
AAirUnit.OnStartBuild(self, unitBuilding, order)
self.UnitBeingBuilt = unitBuilding
ChangeState(self, self.BuildingState)
-- ChangeState(self, self.DroneMaintenanceState)
end,
OnStopBuild = function(self, unitBeingBuilt)
AAirUnit.OnStopBuild(self, unitBeingBuilt)
--ChangeState(self, self.FinishedBuildingState)
ChangeState(self, self.DroneMaintenanceState)
end,
OnFailedToBuild = function(self)
AAirUnit.OnFailedToBuild(self)
ChangeState(self, self.DroneMaintenanceState)
end,
Users browsing this forum: No registered users and 1 guest