Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.75 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.  
  19.     OnCreate = function(self,builder,layer)
  20.         TStructureUnit.OnCreate(self)
  21.          -- Global Booleans
  22.         self:SetCollisionShape('Sphere', 0, 0, 0, 0.3)
  23.        
  24.         -- Enable cloaking and stealth
  25.         self:EnableIntel('Cloak')
  26.         self:EnableIntel('RadarStealth')
  27.     end,
  28.    
  29.     OnStopBeingBuilt = function(self,builder,layer)
  30.         TStructureUnit.OnStopBeingBuilt(self,builder,layer)
  31.        
  32.         --[[
  33.             i created a temp spec Blueprint here for the unit sensor..
  34.             sensors can be created like this for instance as an enhancement OR
  35.             we can create a UnitSensor table in the units actual blueprint.
  36.             the unit also has to have 'UNITSENSOR', in its categories table
  37.             only if the unit wants a unit sensor when it is created.
  38.         --]]
  39.        
  40.         local spec = {
  41.             Owner = self,
  42.             Radius = 4,
  43.             OffSet = -.5,
  44.             AlertFriendly = false,
  45.             MaintenanceConsumptionPerSecondEnergy = 0,
  46.             ParentAttachBone = -1,
  47.             ShowMesh = false,
  48.             Mesh = false,
  49.             DefaultToggle = false,
  50.         }
  51.        
  52.         self:CreateUnitSensor(spec)
  53.        
  54.     end,
  55.    
  56.     UnitDetected = function(self, other, distance)
  57.         TStructureUnit.UnitDetected(self, other, distance)
  58.        
  59.         --when a unit is detected.. BOOM!!!!
  60.         self:MineDetonation()
  61.     end,
  62.    
  63.     MineDetonation = function(self)
  64.         -- Detonation FX
  65.         self:PlayUnitSound('Detonate')
  66.         local pos = self:GetPosition()
  67.         local army = self:GetArmy()                
  68.         local ran = util.GetRandomFloat(0.75, 1.0)
  69.         for k, v in EffectTemplate.TAPDSHit01 do                  
  70.             CreateEmitterAtEntity( self, army, v ):ScaleEmitter(ran * 0.5):OffsetEmitter(0,0.1,0)                
  71.         end          
  72.         for k, v in Custom_4D_EffectTemplate.Mine01 do                  
  73.             CreateEmitterAtEntity( self, army, v ):ScaleEmitter(ran):OffsetEmitter(0,0.1,0)                
  74.         end                    
  75.         CreateDecal( pos, util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_001_normals', '', 'Alpha Normals', 1 + ran, 1 + ran, 150, 60, army )
  76.         CreateDecal( pos, util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_002_albedo', '', 'Albedo', 2 + ran, 2 + ran, 150, 60, army )
  77.         self:ShakeCamera(3, 1.0, 0.5, 1)        
  78.         DamageArea(self, pos, 2, 1, 'Force', false)
  79.        
  80.        
  81.         --[[
  82.             after looking at the mines.. there is no need to add a weapon..
  83.             we can just smack this minespec table in the mines blueprint
  84.             and call the values for the damage area..
  85.            
  86.             clean and clear with no weapons..
  87.            
  88.             it makes it alot easier now to manually detonate the mines.. with say a toggle..
  89.             we just call detonate mine when the toggle is clicked.. :)
  90.         --]]
  91.         local MineSpec = {
  92.             Damage = 500,
  93.             DamageFriendly = false,
  94.             DamageRadius = 2.0,
  95.             DamageType = 'Normal',
  96.         }
  97.        
  98.         DamageArea(self, self:GetPosition(), MineSpec.DamageRadius, MineSpec.Damage, MineSpec.DamageType or 'Normal', MineSpec.DamageFriendly or false)
  99.         self:Destroy()
  100.     end,
  101. }
  102. TypeClass = ueb2102
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement