Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------
- -- File : /units/ueb2102/ueb2102_script.lua
- --
- -- Author(s): EbolaSoup, Resin Smoker, Optimus Prime, Vissroid
- --
- -- Summary : UEF Basic Land Mine Script
- --
- -- Copyright © 2011 4DC_V0.8 All rights reserved.
- -----------------------------------------------------------------------------
- local TStructureUnit = import('/lua/terranunits.lua').TStructureUnit
- local util = import('/lua/utilities.lua')
- local EffectTemplate = import('/lua/EffectTemplates.lua')
- local Custom_4D_EffectTemplate = import('/mods/4DC_V0.8/lua/4D_EffectTemplates.lua')
- local KamikazeWeapon = import('/lua/sim/DefaultWeapons.lua').KamikazeWeapon
- ueb2102 = Class(TStructureUnit) {
- DestroyOnKilled = false,
- Weapons = {
- Mine = Class(KamikazeWeapon) {
- OnFire = function(self)
- if not self.unit.AlreadyDetonated then
- -- Disable death weapon after initial firing
- self.unit.AlreadyDetonated = true
- self.unit:MineDetonation()
- KamikazeWeapon.OnFire(self)
- end
- end,
- },
- },
- OnCreate = function(self,builder,layer)
- TStructureUnit.OnCreate(self)
- -- Global Booleans
- self.AlreadyDetonated = false
- self:SetCollisionShape('Sphere', 0, 0, 0, 0.3)
- -- Enable cloaking and stealth
- self:EnableIntel('Cloak')
- self:EnableIntel('RadarStealth')
- end,
- OnStopBeingBuilt = function(self,builder,layer)
- TStructureUnit.OnStopBeingBuilt(self,builder,layer)
- --[[
- i created a temp spec Blueprint here for the unit sensor..
- sensors can be created like this for instance as an enhancement OR
- we can create a UnitSensor table in the units actual blueprint.
- the unit also has to have 'UNITSENSOR', in its categories table
- only if the unit wants a unit sensor when it is created.
- --]]
- local spec = {
- Owner = self,
- Radius = 3,
- OffSet = -.5,
- AlertFriendly = false,
- MaintenanceConsumptionPerSecondEnergy = 0,
- ParentAttachBone = -1,
- ShowMesh = false,
- Mesh = false,
- DefaultToggle = false,
- }
- self:CreateUnitSensor(spec)
- end,
- UnitDetected = function(self, other, distance)
- TStructureUnit.UnitDetected(self, other, distance)
- --when a unit is detected.. BOOM!!!!
- self:Kill()
- end,
- MineDetonation = function(self)
- -- Detonation FX
- self:PlayUnitSound('Detonate')
- local pos = self:GetPosition()
- local army = self:GetArmy()
- local ran = util.GetRandomFloat(0.75, 1.0)
- for k, v in EffectTemplate.TAPDSHit01 do
- CreateEmitterAtEntity( self, army, v ):ScaleEmitter(ran * 0.5):OffsetEmitter(0,0.1,0)
- end
- for k, v in Custom_4D_EffectTemplate.Mine01 do
- CreateEmitterAtEntity( self, army, v ):ScaleEmitter(ran):OffsetEmitter(0,0.1,0)
- end
- CreateDecal( pos, util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_001_normals', '', 'Alpha Normals', 1 + ran, 1 + ran, 150, 60, army )
- CreateDecal( pos, util.GetRandomFloat(0,2*math.pi), 'nuke_scorch_002_albedo', '', 'Albedo', 2 + ran, 2 + ran, 150, 60, army )
- self:ShakeCamera(3, 1.0, 0.5, 1)
- DamageArea(self, pos, 2, 1, 'Force', false)
- end,
- OnKilled = function(self, instigator, type, overkillRatio)
- if not self.AlreadyDetonated and not self:BeenDestroyed() then
- self:GetWeaponByLabel('Mine'):FireWeapon()
- end
- TStructureUnit.OnKilled(self, instigator, type, overkillRatio)
- end,
- DeathThread = function(self)
- -- Override the normal death event to prevent a corpse from being created
- self:Destroy()
- end,
- }
- TypeClass = ueb2102
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement