Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------
- -- File : /mods/ASF_CZAR_fix/hook/units/UAL0216/UEA0303_script.lua
- -- Author(s): Resin Smoker
- -- Summary : UEF Supersonic Fighter Script
- -- Copyright © 2014 All rights reserved.
- -----------------------------------------------------------------------------
- do
- --> Triggers all logs to report if flag set true, otherwise use the local flags within each function for specific outputs
- local masterDebug = false
- --> Localy imported files
- local TAirUnit = import('/lua/terranunits.lua').TAirUnit
- --> Weapon imported files
- local TAAGinsuRapidPulseWeapon = import('/lua/terranweapons.lua').TAAGinsuRapidPulseWeapon
- --> Custom imported files
- local OldUEA0303 = UEA0303
- UEA0303 = Class(TAirUnit) {
- Weapons = {
- RightBeam = Class(TAAGinsuRapidPulseWeapon) {
- OnStartTracking = function(self, label)
- if masterDebug then
- LOG(' OnStartTracking')
- end
- self.unit:SetRangeMod()
- TAAGinsuRapidPulseWeapon.OnStartTracking(self, label)
- end,
- OnStopTracking = function(self, label)
- if masterDebug then
- LOG(' OnStopTracking')
- end
- self.unit:EndRangeMod()
- TAAGinsuRapidPulseWeapon.OnStopTracking(self, label)
- end,
- },
- LeftBeam = Class(TAAGinsuRapidPulseWeapon) {},
- },
- OnStopBeingBuilt = function(self, builder, layer)
- TAirUnit.OnStopBeingBuilt(self, builder, layer)
- if not self:IsDead() then
- --> Global Varibles
- self.MyWeapon = self:GetWeaponByLabel('RightBeam')
- self.MyWeapon:ChangeMinRadius(10)
- self.RangeMod = false
- TAirUnit.OnStopBeingBuilt( self, builder, layer)
- end
- end,
- SetRangeMod = function(self)
- if masterDebug then
- LOG(' SetRangeMod')
- end
- --> Boolean is not already set
- if not self.RangeMod then
- --> Ensure self and target are viable
- if not self:IsDead() and self.MyWeapon:GetCurrentTarget() then
- --> Resets weapon ranges if target gained is Czar
- if self.MyWeapon:GetCurrentTarget():GetBlueprint().General.UnitName == "<LOC uaa0310_name>CZAR" then
- self:ForkThread(self.CzarCheckHeartBeat)
- else
- if masterDebug then
- LOG(' Target NOT Czar, range mod aborted')
- end
- end
- else
- if masterDebug then
- LOG(' Self or Target "is dead" ')
- end
- end
- else
- if masterDebug then
- LOG(' RangeMod already in effect')
- end
- end
- end,
- EndRangeMod = function(self)
- if masterDebug then
- LOG(' EndRangeMod')
- end
- --> Resets weapon ranges if target is lost
- if not self:IsDead() and self.RangeMod then
- self.RangeMod = false
- self:SetSpeedMult(1.0)
- self:SetTurnMult(1.0)
- end
- end,
- CzarCheckHeartBeat = function(self)
- if masterDebug then
- LOG(' CzarCheckHeartBeat')
- end
- self.RangeMod = true
- while self.RangeMod and not self:IsDead() and self.MyWeapon:GetCurrentTarget() and self.MyWeapon:GetCurrentTarget():GetBlueprint().General.UnitName == "<LOC uaa0310_name>CZAR" do
- if self:GetDistanceToCzar() <= 25 then
- self.LastTarget = {}
- table.insert( self.LastTarget, self.MyWeapon:GetCurrentTarget())
- IssueClearCommands(self)
- local x, y ,z = unpack( self:CalculateWorldPositionFromRelative({10, 0, 0}) )
- IssueMove(self, Vector(x, y, z))
- self:SetSpeedMult(1.50)
- self:SetTurnMult(1.50)
- if masterDebug then
- LOG(' Moving away from Czar')
- end
- else
- self:SetSpeedMult(1.0)
- self:SetTurnMult(1.0)
- if self.LastTaget[1] and not self.LastTaget[1]:IsDead() then
- IssueAttack(self, self.LastTaget[1])
- end
- if masterDebug then
- LOG(' Default move and turn rates')
- end
- end
- --> Short delay between checks
- WaitSeconds(1)
- end
- if masterDebug then
- LOG(' CzarCheckHeartBeat Ended')
- end
- end,
- GetDistanceToCzar = function(self)
- local tpos = self.MyWeapon:GetCurrentTarget():GetPosition()
- local mpos = self:GetPosition()
- local dist = VDist2(mpos[1], mpos[3], tpos[1], tpos[3])
- return dist
- end,
- }
- TypeClass = UEA0303
- end
Advertisement
Add Comment
Please, Sign In to add comment