SHARE
TWEET

Untitled

a guest Aug 25th, 2016 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ----------------------------------------------------------------------------
  2. --
  3. --  File     :  /cdimage/units/XEA3204/XEA3204_script.lua
  4. --  Author(s):  Dru Staltman
  5. --
  6. --  Summary  :  UEF CDR Pod Script
  7. --
  8. --  Copyright © 2005 Gas Powered Games, Inc.  All rights reserved.
  9. ----------------------------------------------------------------------------
  10.  
  11. local TConstructionUnit = import('/lua/terranunits.lua').TConstructionUnit
  12. local EffectTemplate = import('/lua/EffectTemplates.lua')
  13.  
  14. BROAT1ENGINEERDRONE = Class(TConstructionUnit) {
  15.  
  16.     OnCreate = function(self)
  17.         TConstructionUnit.OnCreate(self)
  18.         self.docked = true
  19.         self.returning = false
  20.                     self:CreatTheEffects()
  21.     end,
  22.  
  23.     SetParent = function(self, parent, podName)
  24.         self.Parent = parent
  25.         self.PodName = podName
  26.         self:SetCreator(parent)
  27.     end,
  28.  
  29.     CreatTheEffects = function(self)
  30.         local army =  self:GetArmy()
  31.         for k, v in EffectTemplate['SIFInainoPlumeFxTrails01'] do
  32.             CreateAttachedEmitter(self, 'AttachPoint', army, v):ScaleEmitter(0.22)
  33.         end
  34.     end,
  35.  
  36.     OnKilled = function(self, instigator, type, overkillRatio)
  37.         if self.Parent and not self.Parent:IsDead() then
  38.             self.Parent:NotifyOfPodDeath(self.PodName)
  39.             self.Parent = nil
  40.         end
  41.         TConstructionUnit.OnKilled(self, instigator, type, overkillRatio)
  42.     end,
  43.  
  44.     OnStartBuild = function(self, unitBeingBuilt, order )
  45.         TConstructionUnit.OnStartBuild(self, unitBeingBuilt, order )
  46.         self.returning = false
  47.     end,
  48.  
  49.     OnStopBuild = function(self, unitBuilding)
  50.         TConstructionUnit.OnStopBuild(self, unitBuilding)
  51.         self.ReturnHome(self)
  52.     end,
  53.  
  54.     OnFailedToBuild = function(self)
  55.         TConstructionUnit.OnFailedToBuild(self)
  56.         self.ReturnHome(self)
  57.     end,
  58.  
  59.     OnMotionHorzEventChange = function( self, new, old )
  60.         if self and not self:IsDead() then
  61.             if self.Parent and not self.Parent:IsDead() then
  62.                 local myPosition = self:GetPosition()
  63.                 local parentPosition = self.Parent:GetPosition(self.Parent.PodData[self.PodName].PodAttachpoint)
  64.                 local distSq = VDist2Sq(myPosition[1], myPosition[3], parentPosition[1], parentPosition[3])
  65.                 if self.docked and distSq > 0 and not self.returning then
  66.                     self.docked = false
  67.                     self.Parent:ForkThread(self.Parent.NotifyOfPodStartBuild)
  68.                     --LOG("Leaving dock! " .. distSq)
  69.                 elseif not self.docked and distSq < 2 and self.returning then
  70.                     self.docked = true
  71.                     self.Parent:ForkThread(self.Parent.NotifyOfPodStopBuild)
  72.                     --LOG("Docked again " .. distSq)
  73.                 elseif distSq > 2 and new == 'Stopped' then
  74.                     self.ReturnHome(self)
  75.                 end
  76.             end
  77.         end
  78.     end,
  79.  
  80.     ReturnHome = function(self)
  81.         local parentPosition = self.Parent:GetPosition(self.Parent.PodData[self.PodName].PodAttachpoint)
  82.         self.returning = true
  83.         IssueClearCommands({self})
  84.         IssueMove( {self}, parentPosition )
  85.     end,
  86.  
  87. }
  88.  
  89. TypeClass = BROAT1ENGINEERDRONE
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top