-------------------------------------------------------------------------------------------
-- TRANSPORTING
-------------------------------------------------------------------------------------------
OnStartTransportBeamUp = function(self, transport, bone)
--Ensures bone availability
if transport.slotsFree[bone] == false then
IssueClearCommands({self})
IssueClearCommands({transport})
return
else
self:DestroyIdleEffects()
self:DestroyMovementEffects()
local army = self:GetArmy()
table.insert( self.TransportBeamEffectsBag, AttachBeamEntityToEntity(self, -1, transport, bone, army, EffectTemplate.TTransportBeam01))
table.insert( self.TransportBeamEffectsBag, AttachBeamEntityToEntity( transport, bone, self, -1, army, EffectTemplate.TTransportBeam02))
table.insert( self.TransportBeamEffectsBag, CreateEmitterAtBone( transport, bone, army, EffectTemplate.TTransportGlow01) )
self:TransportAnimation()
end
end,
OnStopTransportBeamUp = function(self)
self:DestroyIdleEffects()
self:DestroyMovementEffects()
for k, v in self.TransportBeamEffectsBag do
v:Destroy()
end
--Reset weapons to ensure torso centres and unit survives drop
for i = 1, self:GetWeaponCount() do
local wep = self:GetWeapon(i)
wep:ResetTarget()
end
end,
OnTransportAborted = function(self)
end,
OnTransportOrdered = function(self)
end,
MarkWeaponsOnTransport = function(self, unit, transport)
--Mark the weapons on a transport
if unit then
for i = 1, unit:GetWeaponCount() do
local wep = unit:GetWeapon(i)
wep:SetOnTransport(transport)
end
end
end,
DestroyedOnTransport = function(self)
end,
DestroyedOnTransport = function(self)
end,
OnTransportAttach = function(self, attachBone, unit)
--Protect units boarding a shielded Transport if the shield is up
if self:ShieldIsOn() then
unit:SetCanTakeDamage(false)
end
self:PlayUnitSound('Load')
self:MarkWeaponsOnTransport(unit, true)
if unit:ShieldIsOn() then
unit:DisableShield()
unit:DisableDefaultToggleCaps()
end
if not EntityCategoryContains(categories.PODSTAGINGPLATFORM, self) then
self:RequestRefreshUI()
end
--Added by brute51
unit:OnAttachedToTransport(self, attachBone)
self:DoUnitCallbacks( 'OnTransportAttach', unit )
end,
OnTransportDetach = function(self, attachBone, unit)
self:PlayUnitSound('Unload')
self:MarkWeaponsOnTransport(unit, false)
unit:SetCanTakeDamage(true) --Ensure any protected units are made vulnerable again
unit:EnableShield()
unit:EnableDefaultToggleCaps()
if not EntityCategoryContains(categories.PODSTAGINGPLATFORM, self) then
self:RequestRefreshUI()
end
unit:TransportAnimation(-1)
unit:OnDetachedToTransport(self)
self:DoUnitCallbacks( 'OnTransportDetach', unit )
end,
--This function is called from Shield.lua to tell the unit when the protection status changes
IsTransportProtected = function(self, value)
self.transportProtected = value
end,
OnStartTransportLoading = function(self)
end,
OnStopTransportLoading = function(self)
end,
OnAddToStorage = function(self, unit)
if EntityCategoryContains(categories.CARRIER, unit) then
self:MarkWeaponsOnTransport(self, true)
self:HideBone(0, true)
self:SetCanTakeDamage(false)
self:SetReclaimable(false)
self:SetCapturable(false)
if EntityCategoryContains(categories.TRANSPORTATION, self) then
local cargo = self:GetCargo()
if table.getn(cargo) > 0 then
for k, v in cargo do
v:MarkWeaponsOnTransport(self, true)
v:HideBone(0, true)
v:SetCanTakeDamage(false)
v:SetReclaimable(false)
v:SetCapturable(false)
end
end
end
end
end,
OnRemoveFromStorage = function(self, unit)
if EntityCategoryContains(categories.CARRIER, unit) then
self:SetCanTakeDamage(true)
self:SetReclaimable(true)
self:SetCapturable(true)
self:ShowBone(0, true)
self:MarkWeaponsOnTransport(self, false)
if EntityCategoryContains(categories.TRANSPORTATION, self) then
local cargo = self:GetCargo()
if table.getn(cargo) > 0 then
for k, v in cargo do
v:MarkWeaponsOnTransport(self, false)
v:ShowBone(0, true)
v:SetCanTakeDamage(true)
v:SetReclaimable(true)
v:SetCapturable(true)
end
end
end
end
end,
GetTransportClass = function(self)
local bp = self:GetBlueprint().Transport
return bp.TransportClass
end,
TransportAnimation = function(self, rate)
self:ForkThread( self.TransportAnimationThread, rate )
end,
TransportAnimationThread = function(self,rate)
local bp = self:GetBlueprint().Display.TransportAnimation
if rate and rate < 0 and self:GetBlueprint().Display.TransportDropAnimation then
bp = self:GetBlueprint().Display.TransportDropAnimation
rate = -rate
end
WaitSeconds(.5)
if bp then
local animBlock = self:ChooseAnimBlock( bp )
if animBlock.Animation then
if not self.TransAnimation then
self.TransAnimation = CreateAnimator(self)
self.Trash:Add(self.TransAnimation)
end
self.TransAnimation:PlayAnim(animBlock.Animation)
rate = rate or 1
self.TransAnimation:SetRate(rate)
WaitFor(self.TransAnimation)
end
end
end,
-------------------------------------------------------------------------------------------
Statistics: Posted by Ithilis_Quo — 24 May 2015, 14:53