Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.98 KB | None | 0 0
  1. -----------------------------------------------------------------------------
  2. --  File     : /units/ueb2102/ueb2102_script.lua
  3. --
  4. --  Author(s): EbolaSoup, Resin Smoker, Optimus Prime, Vissroid
  5. --
  6. --  Summary  : UEF Basic Land Mine Script
  7. --
  8. --  Copyright © 2011 4DC_V0.8  All rights reserved.
  9. -----------------------------------------------------------------------------
  10.  
  11. local TStructureUnit = import('/lua/terranunits.lua').TStructureUnit
  12. local util = import('/lua/utilities.lua')
  13. local EffectTemplate = import('/lua/EffectTemplates.lua')
  14. local Custom_4D_EffectTemplate = import('/mods/4DC_V0.8/lua/4D_EffectTemplates.lua')
  15. local KamikazeWeapon = import('/lua/sim/DefaultWeapons.lua').KamikazeWeapon
  16.  
  17. ueb2102 = Class(TStructureUnit) {
  18.     DestroyOnKilled = false,
  19.     Weapons = {
  20.         Mine = Class(KamikazeWeapon) {      
  21.             OnFire = function(self)
  22.                 if not self.unit.AlreadyDetonated then
  23.                     -- Disable death weapon after initial firing
  24.                     self.unit.AlreadyDetonated = true
  25.                     self.unit:MineDetonation()                    
  26.                     KamikazeWeapon.OnFire(self)
  27.                 end
  28.             end,
  29.         },
  30.     },
  31.  
  32.     OnCreate = function(self,builder,layer)
  33.         TStructureUnit.OnCreate(self)
  34.          -- Global Booleans
  35.         self.AlreadyDetonated = false      
  36.         self:SetCollisionShape('Sphere', 0, 0, 0, 0.3)
  37.         -- Enable cloaking and stealth
  38.         self:EnableIntel('Cloak')
  39.         self:EnableIntel('RadarStealth')
  40.     end,
  41.    
  42.     OnStopBeingBuilt = function(self,builder,layer)
  43.         TStructureUnit.OnStopBeingBuilt(self,builder,layer)
  44.        
  45.         --[[
  46.             i created a temp spec Blueprint here for the unit sensor..
  47.             sensors can be created like this for instance as an enhancement OR
  48.             we can create a UnitSensor table in the units actual blueprint.
  49.             the unit also has to have 'UNITSENSOR', in its categories table
  50.             only if the unit wants a unit sensor when it is created.
  51.         --]]
  52.        
  53.         local spec = {
  54.             Owner = self,
  55.             Radius = 3,
  56.             OffSet = -.5,
  57.             AlertFriendly = false,
  58.             MaintenanceConsumptionPerSecondEnergy = 0,
  59.             ParentAttachBone = -1,
  60.             ShowMesh = false,
  61.             Mesh = false,
  62.             DefaultToggle = false,
  63.         }
  64.        
  65.         self:CreateUnitSensor(spec)
  66.        
  67.     end,
  68.    
  69.     UnitDetected = function(self, other, distance)
  70.         TStructureUnit.UnitDetected(self, other, distance)
  71.        
  72.         --when a unit is detected.. BOOM!!!!
  73.         self:Kill()
  74.     end,
  75.    
  76.     MineDetonation = function(self)
  77.         -- Detonation FX
  78.         self:PlayUnitSound('Detonate')
  79.         local pos = self:GetPosition()
  80.         local army = self:GetArmy()                
  81.         local ran = util.GetRandomFloat(0.75, 1.0)
  82.         for k, v in EffectTemplate.TAPDSHit01 do                  
  83.             CreateEmitterAtEntity( self, army, v ):ScaleEmitter(ran * 0.5):OffsetEmitter(0,0.1,0)                
  84.         end          
  85.         for k, v in Custom_4D_EffectTemplate.Mine01 do                  
  86.             CreateEmitterAtEntity( self, army, v ):ScaleEmitter(ran):OffsetEmitter(0,0.1,0)                
  87.         end                    
  88.         CreateDecal( pos, util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_001_normals', '', 'Alpha Normals', 1 + ran, 1 + ran, 150, 60, army )
  89.         CreateDecal( pos, util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_002_albedo', '', 'Albedo', 2 + ran, 2 + ran, 150, 60, army )
  90.         self:ShakeCamera(3, 1.0, 0.5, 1)        
  91.         DamageArea(self, pos, 2, 1, 'Force', false)
  92.     end,
  93.    
  94.     OnKilled = function(self, instigator, type, overkillRatio)
  95.         if not self.AlreadyDetonated and not self:BeenDestroyed() then
  96.             self:GetWeaponByLabel('Mine'):FireWeapon()
  97.         end
  98.         TStructureUnit.OnKilled(self, instigator, type, overkillRatio)
  99.     end,        
  100.  
  101.     DeathThread = function(self)
  102.         -- Override the normal death event to prevent a corpse from being created
  103.         self:Destroy()
  104.     end,
  105. }
  106. TypeClass = ueb2102
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement