Guest User

Untitled

a guest
Aug 5th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.07 KB | None | 0 0
  1. #****************************************************************************
  2. #**
  3. #** File : /cdimage/units/URL0001/URL0001_script.lua
  4. #** Author(s): John Comes, David Tomandl, Jessica St. Croix, Gordon Duclos, Andres Mendez
  5. #**
  6. #** Summary : Cybran Commander Unit Script
  7. #**
  8. #** Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
  9. #****************************************************************************
  10. local CWalkingLandUnit = import('/lua/cybranunits.lua').CWalkingLandUnit
  11. local CWeapons = import('/lua/cybranweapons.lua')
  12. local EffectUtil = import('/lua/EffectUtilities.lua')
  13. local Buff = import('/lua/sim/Buff.lua')
  14.  
  15. #local CAAMissileNaniteWeapon = CWeapons.CAAMissileNaniteWeapon
  16. local CCannonMolecularWeapon = CWeapons.CCannonMolecularWeapon
  17. local CIFCommanderDeathWeapon = CWeapons.CIFCommanderDeathWeapon
  18. local EffectTemplate = import('/lua/EffectTemplates.lua')
  19. local CDFHeavyMicrowaveLaserGeneratorCom = CWeapons.CDFHeavyMicrowaveLaserGeneratorCom
  20. local CDFOverchargeWeapon = CWeapons.CDFOverchargeWeapon
  21. local CANTorpedoLauncherWeapon = CWeapons.CANTorpedoLauncherWeapon
  22. local Entity = import('/lua/sim/Entity.lua').Entity
  23.  
  24. WRL0001 = Class(CWalkingLandUnit) {
  25. DeathThreadDestructionWaitTime = 2,
  26.  
  27. Weapons = {
  28. DeathWeapon = Class(CIFCommanderDeathWeapon) {},
  29. RightRipper = Class(CCannonMolecularWeapon) {},
  30. Torpedo = Class(CANTorpedoLauncherWeapon) {},
  31. MLG = Class(CDFHeavyMicrowaveLaserGeneratorCom) {
  32. DisabledFiringBones = {'Turret_Muzzle_03'},
  33.  
  34. SetOnTransport = function(self, transportstate)
  35. CDFHeavyMicrowaveLaserGeneratorCom.SetOnTransport(self, transportstate)
  36. self:ForkThread(self.OnTransportWatch)
  37. end,
  38.  
  39. OnTransportWatch = function(self)
  40. while self:GetOnTransport() do
  41. self:PlayFxBeamEnd()
  42. self:SetWeaponEnabled(false)
  43. WaitSeconds(0.3)
  44. end
  45. end,
  46. },
  47.  
  48. OverCharge = Class(CDFOverchargeWeapon) {
  49. OnCreate = function(self)
  50. CDFOverchargeWeapon.OnCreate(self)
  51. self:SetWeaponEnabled(false)
  52. self.AimControl:SetEnabled(false)
  53. self.AimControl:SetPrecedence(0)
  54. self.unit:SetOverchargePaused(false)
  55. end,
  56.  
  57. OnEnableWeapon = function(self)
  58. if self:BeenDestroyed() then return end
  59. CDFOverchargeWeapon.OnEnableWeapon(self)
  60. self:SetWeaponEnabled(true)
  61. self.unit:SetWeaponEnabledByLabel('RightRipper', false)
  62. self.unit:BuildManipulatorSetEnabled(false)
  63. self.AimControl:SetEnabled(true)
  64. self.AimControl:SetPrecedence(20)
  65. self.unit.BuildArmManipulator:SetPrecedence(0)
  66. self.AimControl:SetHeadingPitch( self.unit:GetWeaponManipulatorByLabel('RightRipper'):GetHeadingPitch() )
  67. end,
  68.  
  69. OnWeaponFired = function(self)
  70. CDFOverchargeWeapon.OnWeaponFired(self)
  71. self:OnDisableWeapon()
  72. self:ForkThread(self.PauseOvercharge)
  73. end,
  74.  
  75. OnDisableWeapon = function(self)
  76. if self.unit:BeenDestroyed() then return end
  77. self:SetWeaponEnabled(false)
  78. self.unit:SetWeaponEnabledByLabel('RightRipper', true)
  79. self.unit:BuildManipulatorSetEnabled(false)
  80. self.AimControl:SetEnabled(false)
  81. self.AimControl:SetPrecedence(0)
  82. self.unit.BuildArmManipulator:SetPrecedence(0)
  83. self.unit:GetWeaponManipulatorByLabel('RightRipper'):SetHeadingPitch( self.AimControl:GetHeadingPitch() )
  84. end,
  85.  
  86. PauseOvercharge = function(self)
  87. if not self.unit:IsOverchargePaused() then
  88. self.unit:SetOverchargePaused(true)
  89. WaitSeconds(1/self:GetBlueprint().RateOfFire)
  90. self.unit:SetOverchargePaused(false)
  91. end
  92. end,
  93.  
  94. OnFire = function(self)
  95. if not self.unit:IsOverchargePaused() and self.unit:GetAIBrain():GetEconomyStored('ENERGY') > self:GetBlueprint().EnergyRequired then
  96. CDFOverchargeWeapon.OnFire(self)
  97. end
  98. end,
  99. IdleState = State(CDFOverchargeWeapon.IdleState) {
  100. OnGotTarget = function(self)
  101. if not self.unit:IsOverchargePaused() and self.unit:GetAIBrain():GetEconomyStored('ENERGY') > self:GetBlueprint().EnergyRequired then
  102. CDFOverchargeWeapon.IdleState.OnGotTarget(self)
  103. end
  104. end,
  105. OnFire = function(self)
  106. if not self.unit:IsOverchargePaused() and self.unit:GetAIBrain():GetEconomyStored('ENERGY') > self:GetBlueprint().EnergyRequired then
  107. ChangeState(self, self.RackSalvoFiringState)
  108. end
  109. end,
  110. },
  111. RackSalvoFireReadyState = State(CDFOverchargeWeapon.RackSalvoFireReadyState) {
  112. OnFire = function(self)
  113. if not self.unit:IsOverchargePaused() and self.unit:GetAIBrain():GetEconomyStored('ENERGY') > self:GetBlueprint().EnergyRequired then
  114. CDFOverchargeWeapon.RackSalvoFireReadyState.OnFire(self)
  115. end
  116. end,
  117. },
  118. },
  119. },
  120.  
  121. # ********
  122. # Creation
  123. # ********
  124. OnCreate = function(self)
  125. CWalkingLandUnit.OnCreate(self)
  126. self:SetCapturable(false)
  127. self:HideBone('Resource_Upgrade', true)
  128. self:HideBone('Right_Upgrade', true)
  129. self:HideBone('Back_Upgrade', true)
  130. self:HideBone('Shield_Upgrade02', true)
  131. self:HideBone('Shield_Upgrade03', true)
  132. if self:GetBlueprint().General.BuildBones then
  133. self:SetupBuildBones()
  134. end
  135. # Restrict what enhancements will enable later
  136. self:AddBuildRestriction( categories.CYBRAN * (categories.BUILTBYTIER2COMMANDER + categories.BUILTBYTIER3COMMANDER) )
  137. end,
  138.  
  139.  
  140. OnPrepareArmToBuild = function(self)
  141. CWalkingLandUnit.OnPrepareArmToBuild(self)
  142. if self:BeenDestroyed() then return end
  143. self:BuildManipulatorSetEnabled(true)
  144. self.BuildArmManipulator:SetPrecedence(20)
  145. self:SetWeaponEnabledByLabel('RightRipper', false)
  146. self:SetWeaponEnabledByLabel('OverCharge', false)
  147. self.BuildArmManipulator:SetHeadingPitch( self:GetWeaponManipulatorByLabel('RightRipper'):GetHeadingPitch() )
  148. end,
  149.  
  150. OnStopCapture = function(self, target)
  151. CWalkingLandUnit.OnStopCapture(self, target)
  152. if self:BeenDestroyed() then return end
  153. self:BuildManipulatorSetEnabled(false)
  154. self.BuildArmManipulator:SetPrecedence(0)
  155. self:SetWeaponEnabledByLabel('RightRipper', true)
  156. self:SetWeaponEnabledByLabel('OverCharge', false)
  157. self:GetWeaponManipulatorByLabel('RightRipper'):SetHeadingPitch( self.BuildArmManipulator:GetHeadingPitch() )
  158. end,
  159.  
  160. OnFailedCapture = function(self, target)
  161. CWalkingLandUnit.OnFailedCapture(self, target)
  162. if self:BeenDestroyed() then return end
  163. self:BuildManipulatorSetEnabled(false)
  164. self.BuildArmManipulator:SetPrecedence(0)
  165. self:SetWeaponEnabledByLabel('RightRipper', true)
  166. self:SetWeaponEnabledByLabel('OverCharge', false)
  167. self:GetWeaponManipulatorByLabel('RightRipper'):SetHeadingPitch( self.BuildArmManipulator:GetHeadingPitch() )
  168. end,
  169.  
  170. OnStopReclaim = function(self, target)
  171. CWalkingLandUnit.OnStopReclaim(self, target)
  172. if self:BeenDestroyed() then return end
  173. self:BuildManipulatorSetEnabled(false)
  174. self.BuildArmManipulator:SetPrecedence(0)
  175. self:SetWeaponEnabledByLabel('RightRipper', true)
  176. self:SetWeaponEnabledByLabel('OverCharge', false)
  177. self:GetWeaponManipulatorByLabel('RightRipper'):SetHeadingPitch( self.BuildArmManipulator:GetHeadingPitch() )
  178. end,
  179.  
  180. OnStopBeingBuilt = function(self,builder,layer)
  181. CWalkingLandUnit.OnStopBeingBuilt(self,builder,layer)
  182. self:SetWeaponEnabledByLabel('RightRipper', true)
  183. self:SetWeaponEnabledByLabel('MLG', false)
  184. self:SetWeaponEnabledByLabel('Torpedo', false)
  185. self:SetMaintenanceConsumptionInactive()
  186. self:DisableUnitIntel('RadarStealth')
  187. self:DisableUnitIntel('SonarStealth')
  188. self:DisableUnitIntel('Cloak')
  189. self:DisableUnitIntel('Sonar')
  190. self:HideBone('Resource_Upgrade', true)
  191. self:HideBone('Right_Upgrade', true)
  192. self:HideBone('Back_Upgrade', true)
  193. self:HideBone('Shield_Upgrade02', true)
  194. self:HideBone('Shield_Upgrade03', true)
  195. self.ShieldEffectsBag2 = {}
  196. self.ShieldPowerEffectsBag2 = {}
  197. self:ForkThread(self.GiveInitialResources)
  198. end,
  199.  
  200. OnFailedToBuild = function(self)
  201. CWalkingLandUnit.OnFailedToBuild(self)
  202. if self:BeenDestroyed() then return end
  203. self:BuildManipulatorSetEnabled(false)
  204. self.BuildArmManipulator:SetPrecedence(0)
  205. self:SetWeaponEnabledByLabel('RightRipper', true)
  206. self:SetWeaponEnabledByLabel('OverCharge', false)
  207. self:GetWeaponManipulatorByLabel('RightRipper'):SetHeadingPitch( self.BuildArmManipulator:GetHeadingPitch() )
  208. end,
  209.  
  210. OnStartBuild = function(self, unitBeingBuilt, order)
  211. CWalkingLandUnit.OnStartBuild(self, unitBeingBuilt, order)
  212. self.UnitBeingBuilt = unitBeingBuilt
  213. self.UnitBuildOrder = order
  214. self.BuildingUnit = true
  215. end,
  216.  
  217. OnStopBuild = function(self, unitBeingBuilt)
  218. CWalkingLandUnit.OnStopBuild(self, unitBeingBuilt)
  219. if self:BeenDestroyed() then return end
  220. self:BuildManipulatorSetEnabled(false)
  221. self.BuildArmManipulator:SetPrecedence(0)
  222. self:SetWeaponEnabledByLabel('RightRipper', true)
  223. self:SetWeaponEnabledByLabel('OverCharge', false)
  224. self:GetWeaponManipulatorByLabel('RightRipper'):SetHeadingPitch( self.BuildArmManipulator:GetHeadingPitch() )
  225. self.UnitBeingBuilt = nil
  226. self.UnitBuildOrder = nil
  227. self.BuildingUnit = false
  228. end,
  229.  
  230. PlayCommanderWarpInEffect = function(self)
  231. self:HideBone(0, true)
  232. self:SetUnSelectable(true)
  233. self:SetBusy(true)
  234. self:SetBlockCommandQueue(true)
  235. self:ForkThread(self.WarpInEffectThread)
  236. end,
  237.  
  238. WarpInEffectThread = function(self)
  239. self:PlayUnitSound('CommanderArrival')
  240. self:CreateProjectile( '/effects/entities/UnitTeleport01/UnitTeleport01_proj.bp', 0, 1.35, 0, nil, nil, nil):SetCollision(false)
  241. WaitSeconds(2.1)
  242. self:SetMesh('/mods/BattlePack/units/WRL0001/WRL0001_PhaseShield_mesh', true)
  243. self:ShowBone(0, true)
  244. self:HideBone('Resource_Upgrade', true)
  245. self:HideBone('Right_Upgrade', true)
  246. self:HideBone('Back_Upgrade', true)
  247. self:HideBone('Shield_Upgrade02', true)
  248. self:HideBone('Shield_Upgrade03', true)
  249. self:SetUnSelectable(false)
  250. self:SetBusy(false)
  251. self:SetBlockCommandQueue(false)
  252.  
  253. local totalBones = self:GetBoneCount() - 1
  254. local army = self:GetArmy()
  255. for k, v in EffectTemplate.UnitTeleportSteam01 do
  256. for bone = 1, totalBones do
  257. CreateAttachedEmitter(self,bone,army, v)
  258. end
  259. end
  260.  
  261. WaitSeconds(6)
  262. self:SetMesh(self:GetBlueprint().Display.MeshBlueprint, true)
  263. end,
  264.  
  265. GiveInitialResources = function(self)
  266. WaitTicks(2)
  267. self:GetAIBrain():GiveResource('Energy', self:GetBlueprint().Economy.StorageEnergy)
  268. self:GetAIBrain():GiveResource('Mass', self:GetBlueprint().Economy.StorageMass)
  269. end,
  270.  
  271.  
  272.  
  273. OnScriptBitClear = function(self, bit)
  274. if bit == 0 then # shield toggle
  275. self:DisableShield()
  276. self:StopUnitAmbientSound( 'ActiveLoop' )
  277. elseif bit == 8 then # cloak toggle
  278. self:PlayUnitAmbientSound( 'ActiveLoop' )
  279. self:SetMaintenanceConsumptionActive()
  280. self:EnableUnitIntel('Cloak')
  281. self:EnableUnitIntel('RadarStealth')
  282. self:EnableUnitIntel('RadarStealthField')
  283. self:EnableUnitIntel('SonarStealth')
  284. self:EnableUnitIntel('SonarStealthField')
  285. end
  286. end,
  287.  
  288. OnScriptBitSet = function(self, bit)
  289. if bit == 0 then # shield toggle
  290. self:EnableShield()
  291. self:PlayUnitAmbientSound( 'ActiveLoop' )
  292. elseif bit == 8 then # cloak toggle
  293. self:StopUnitAmbientSound( 'ActiveLoop' )
  294. self:SetMaintenanceConsumptionInactive()
  295. self:DisableUnitIntel('Cloak')
  296. self:DisableUnitIntel('RadarStealth')
  297. self:DisableUnitIntel('RadarStealthField')
  298. self:DisableUnitIntel('SonarStealth')
  299. self:DisableUnitIntel('SonarStealthField')
  300. end
  301. end,
  302.  
  303.  
  304.  
  305. # *************
  306. # Build/Upgrade
  307. # *************
  308. CreateBuildEffects = function( self, unitBeingBuilt, order )
  309. EffectUtil.SpawnBuildBots( self, unitBeingBuilt, 5, self.BuildEffectsBag )
  310. EffectUtil.CreateCybranBuildBeams( self, unitBeingBuilt, self:GetBlueprint().General.BuildBones.BuildEffectBones, self.BuildEffectsBag )
  311. end,
  312.  
  313. CreateEnhancement = function(self, enh)
  314. CWalkingLandUnit.CreateEnhancement(self, enh)
  315. local bp = self:GetBlueprint().Enhancements[enh]
  316. if enh == 'Teleporter' then
  317. self:AddCommandCap('RULEUCC_Teleport')
  318. self:ShowBone('Back_Upgrade', true)
  319. elseif enh == 'TeleporterRemove' then
  320. RemoveUnitEnhancement(self, 'Teleporter')
  321. RemoveUnitEnhancement(self, 'TeleporterRemove')
  322. self:RemoveCommandCap('RULEUCC_Teleport')
  323. self:HideBone('Back_Upgrade', true)
  324. elseif enh == 'StealthGenerator' then
  325. self:AddToggleCap('RULEUTC_CloakToggle')
  326. if self.IntelEffectsBag then
  327. EffectUtil.CleanupEffectBag(self,'IntelEffectsBag')
  328. self.IntelEffectsBag = nil
  329. end
  330. self.CloakEnh = false
  331. self.StealthEnh = true
  332. self:EnableUnitIntel('RadarStealth')
  333. self:EnableUnitIntel('SonarStealth')
  334. self:ShowBone('Back_Upgrade', true)
  335. elseif enh == 'StealthGeneratorRemove' then
  336. self:RemoveToggleCap('RULEUTC_CloakToggle')
  337. self:DisableUnitIntel('RadarStealth')
  338. self:DisableUnitIntel('SonarStealth')
  339. self.StealthEnh = false
  340. self.CloakEnh = false
  341. self.StealthFieldEffects = false
  342. self.CloakingEffects = false
  343. self:HideBone('Back_Upgrade', true)
  344. elseif enh == 'PersonalShielding' then
  345. self:AddToggleCap('RULEUTC_ShieldToggle')
  346. self:SetEnergyMaintenanceConsumptionOverride(bp.MaintenanceConsumptionPerSecondEnergy or 0)
  347. self:SetMaintenanceConsumptionActive()
  348. self:CreatePersonalShield(bp)
  349. self:ShowBone('Shield_Upgrade02', true)
  350. self:ShowBone('Shield_Upgrade03', true)
  351. elseif enh == 'PersonalShieldingRemove' then
  352. self:DestroyShield()
  353. self:SetMaintenanceConsumptionInactive()
  354. self:RemoveToggleCap('RULEUTC_ShieldToggle')
  355. self:HideBone('Shield_Upgrade02', true)
  356. self:HideBone('Shield_Upgrade03', true)
  357. elseif enh == 'ResourceAllocation' then
  358. local bp = self:GetBlueprint().Enhancements[enh]
  359. local bpEcon = self:GetBlueprint().Economy
  360. if not bp then return end
  361. self:SetProductionPerSecondEnergy(bp.ProductionPerSecondEnergy + bpEcon.ProductionPerSecondEnergy or 0)
  362. self:SetProductionPerSecondMass(bp.ProductionPerSecondMass + bpEcon.ProductionPerSecondMass or 0)
  363. self:ShowBone('Back_Upgrade', true)
  364. elseif enh == 'ResourceAllocationRemove' then
  365. local bpEcon = self:GetBlueprint().Economy
  366. self:SetProductionPerSecondEnergy(bpEcon.ProductionPerSecondEnergy or 0)
  367. self:SetProductionPerSecondMass(bpEcon.ProductionPerSecondMass or 0)
  368. self:HideBone('Back_Upgrade', true)
  369. elseif enh == 'CloakingGenerator' then
  370. local bp = self:GetBlueprint().Enhancements[enh]
  371. if not bp then return end
  372. self.StealthEnh = false
  373. self.CloakEnh = true
  374. self:EnableUnitIntel('Cloak')
  375. if not Buffs['CybranACUCloakBonus'] then
  376. BuffBlueprint {
  377. Name = 'CybranACUCloakBonus',
  378. DisplayName = 'CybranACUCloakBonus',
  379. BuffType = 'ACUCLOAKBONUS',
  380. Stacks = 'ALWAYS',
  381. Duration = -1,
  382. Affects = {
  383. MaxHealth = {
  384. Add = bp.NewHealth,
  385. Mult = 1.0,
  386. },
  387. },
  388. }
  389. end
  390. if Buff.HasBuff( self, 'CybranACUCloakBonus' ) then
  391. Buff.RemoveBuff( self, 'CybranACUCloakBonus' )
  392. end
  393. Buff.ApplyBuff(self, 'CybranACUCloakBonus')
  394. self:ShowBone('Back_Upgrade', true)
  395. elseif enh == 'CloakingGeneratorRemove' then
  396. self:RemoveToggleCap('RULEUTC_CloakToggle')
  397. self:DisableUnitIntel('Cloak')
  398. self.CloakEnh = false
  399. self:HideBone('Back_Upgrade', true)
  400. if Buff.HasBuff( self, 'CybranACUCloakBonus' ) then
  401. Buff.RemoveBuff( self, 'CybranACUCloakBonus' )
  402. end
  403. #T2 Engineering
  404. elseif enh =='AdvancedEngineering' then
  405. local bp = self:GetBlueprint().Enhancements[enh]
  406. if not bp then return end
  407. local cat = ParseEntityCategory(bp.BuildableCategoryAdds)
  408. self:RemoveBuildRestriction(cat)
  409. if not Buffs['CybranACUT2BuildRate'] then
  410. BuffBlueprint {
  411. Name = 'CybranACUT2BuildRate',
  412. DisplayName = 'CybranACUT2BuildRate',
  413. BuffType = 'ACUBUILDRATE',
  414. Stacks = 'REPLACE',
  415. Duration = -1,
  416. Affects = {
  417. BuildRate = {
  418. Add = bp.NewBuildRate - self:GetBlueprint().Economy.BuildRate,
  419. Mult = 1,
  420. },
  421. MaxHealth = {
  422. Add = bp.NewHealth,
  423. Mult = 1.0,
  424. },
  425. Regen = {
  426. Add = bp.NewRegenRate,
  427. Mult = 1.0,
  428. },
  429. },
  430. }
  431. end
  432. Buff.ApplyBuff(self, 'CybranACUT2BuildRate')
  433. self:ShowBone('Resource_Upgrade', true)
  434. self:updateBuildRestrictions()
  435. elseif enh =='AdvancedEngineeringRemove' then
  436. local bp = self:GetBlueprint().Economy.BuildRate
  437. if not bp then return end
  438. self:RestoreBuildRestrictions()
  439. self:AddBuildRestriction( categories.CYBRAN * (categories.BUILTBYTIER2COMMANDER + categories.BUILTBYTIER3COMMANDER) )
  440. if Buff.HasBuff( self, 'CybranACUT2BuildRate' ) then
  441. Buff.RemoveBuff( self, 'CybranACUT2BuildRate' )
  442. end
  443. self:HideBone('Resource_Upgrade', true)
  444. self:updateBuildRestrictions()
  445. #T3 Engineering
  446. elseif enh =='T3Engineering' then
  447. local bp = self:GetBlueprint().Enhancements[enh]
  448. if not bp then return end
  449. local cat = ParseEntityCategory(bp.BuildableCategoryAdds)
  450. self:RemoveBuildRestriction(cat)
  451. if not Buffs['CybranACUT3BuildRate'] then
  452. BuffBlueprint {
  453. Name = 'CybranACUT3BuildRate',
  454. DisplayName = 'CybranCUT3BuildRate',
  455. BuffType = 'ACUBUILDRATE',
  456. Stacks = 'REPLACE',
  457. Duration = -1,
  458. Affects = {
  459. BuildRate = {
  460. Add = bp.NewBuildRate - self:GetBlueprint().Economy.BuildRate,
  461. Mult = 1,
  462. },
  463. MaxHealth = {
  464. Add = bp.NewHealth,
  465. Mult = 1.0,
  466. },
  467. Regen = {
  468. Add = bp.NewRegenRate,
  469. Mult = 1.0,
  470. },
  471. },
  472. }
  473. end
  474. Buff.ApplyBuff(self, 'CybranACUT3BuildRate')
  475. self:ShowBone('Resource_Upgrade', true)
  476. self:updateBuildRestrictions()
  477. elseif enh =='T3EngineeringRemove' then
  478. local bp = self:GetBlueprint().Economy.BuildRate
  479. if not bp then return end
  480. self:RestoreBuildRestrictions()
  481. if Buff.HasBuff( self, 'CybranACUT3BuildRate' ) then
  482. Buff.RemoveBuff( self, 'CybranACUT3BuildRate' )
  483. end
  484. self:AddBuildRestriction( categories.CYBRAN * ( categories.BUILTBYTIER2COMMANDER + categories.BUILTBYTIER3COMMANDER) )
  485. self:HideBone('Resource_Upgrade', true)
  486. self:updateBuildRestrictions()
  487. elseif enh =='CoolingUpgrade' then
  488. local bp = self:GetBlueprint().Enhancements[enh]
  489. local wep = self:GetWeaponByLabel('RightRipper')
  490. wep:ChangeMaxRadius(bp.NewMaxRadius or 44)
  491. wep:ChangeRateOfFire(bp.NewRateOfFire or 2)
  492. local microwave = self:GetWeaponByLabel('MLG')
  493. microwave:ChangeMaxRadius(bp.NewMaxRadius or 44)
  494. local oc = self:GetWeaponByLabel('OverCharge')
  495. oc:ChangeMaxRadius(bp.NewMaxRadius or 44)
  496. self:ShowBone('Right_Upgrade', true)
  497. elseif enh == 'CoolingUpgradeRemove' then
  498. local wep = self:GetWeaponByLabel('RightRipper')
  499. local bpDisrupt = self:GetBlueprint().Weapon[1].RateOfFire
  500. wep:ChangeRateOfFire(bpDisrupt or 1)
  501. bpDisrupt = self:GetBlueprint().Weapon[1].MaxRadius
  502. wep:ChangeMaxRadius(bpDisrupt or 22)
  503. local microwave = self:GetWeaponByLabel('MLG')
  504. microwave:ChangeMaxRadius(bpDisrupt or 22)
  505. local oc = self:GetWeaponByLabel('OverCharge')
  506. oc:ChangeMaxRadius(bpDisrupt or 22)
  507. self:HideBone('Right_Upgrade', true)
  508. elseif enh == 'MicrowaveLaserGenerator' then
  509. self:SetWeaponEnabledByLabel('MLG', true)
  510. self:HideBone('Chest_Left', true)
  511. self:HideBone('Chest_Right', true)
  512. elseif enh == 'MicrowaveLaserGeneratorRemove' then
  513. self:SetWeaponEnabledByLabel('MLG', false)
  514. self:ShowBoneone('Chest_Left', true)
  515. self:ShowBone('Chest_Right', true)
  516. elseif enh == 'NaniteTorpedoTube' then
  517. self:SetWeaponEnabledByLabel('Torpedo', true)
  518. self:EnableUnitIntel('Sonar')
  519. self:HideBone('Chest_Left', true)
  520. self:HideBone('Chest_Right', true)
  521. elseif enh == 'NaniteTorpedoTubeRemove' then
  522. self:SetWeaponEnabledByLabel('Torpedo', false)
  523. self:DisableUnitIntel('Sonar')
  524. self:ShowBone('Chest_Left', true)
  525. self:ShowBone('Chest_Right', true)
  526. end
  527. end,
  528.  
  529. # **********
  530. # Intel
  531. # **********
  532. IntelEffects = {
  533. Cloak = {
  534. {
  535. Bones = {
  536. 'Torso',
  537. },
  538. Scale = 1.5,
  539. Type = 'Cloak01',
  540. },
  541. },
  542. Field = {
  543. {
  544. Bones = {
  545. 'Torso',
  546. },
  547. Scale = 1.6,
  548. Type = 'Cloak01',
  549. },
  550. },
  551. },
  552.  
  553. CreateHeavyShield = function(self, bp)
  554. WaitTicks(1)
  555. self:CreatePersonalShield(bp)
  556. self:SetEnergyMaintenanceConsumptionOverride(bp.MaintenanceConsumptionPerSecondEnergy or 0)
  557. self:SetMaintenanceConsumptionActive()
  558. end,
  559.  
  560. OnIntelEnabled = function(self)
  561. CWalkingLandUnit.OnIntelEnabled(self)
  562. if self.CloakEnh and self:IsIntelEnabled('Cloak') then
  563. self:SetEnergyMaintenanceConsumptionOverride(self:GetBlueprint().Enhancements['CloakingGenerator'].MaintenanceConsumptionPerSecondEnergy or 0)
  564. self:SetMaintenanceConsumptionActive()
  565. if not self.IntelEffectsBag then
  566. self.IntelEffectsBag = {}
  567. self.CreateTerrainTypeEffects( self, self.IntelEffects.Cloak, 'FXIdle', self:GetCurrentLayer(), nil, self.IntelEffectsBag )
  568. end
  569. elseif self.StealthEnh and self:IsIntelEnabled('RadarStealth') and self:IsIntelEnabled('SonarStealth') then
  570. self:SetEnergyMaintenanceConsumptionOverride(self:GetBlueprint().Enhancements['StealthGenerator'].MaintenanceConsumptionPerSecondEnergy or 0)
  571. self:SetMaintenanceConsumptionActive()
  572. if not self.IntelEffectsBag then
  573. self.IntelEffectsBag = {}
  574. self.CreateTerrainTypeEffects( self, self.IntelEffects.Field, 'FXIdle', self:GetCurrentLayer(), nil, self.IntelEffectsBag )
  575. end
  576. end
  577. end,
  578.  
  579. OnIntelDisabled = function(self)
  580. CWalkingLandUnit.OnIntelDisabled(self)
  581. if self.IntelEffectsBag then
  582. EffectUtil.CleanupEffectBag(self,'IntelEffectsBag')
  583. self.IntelEffectsBag = nil
  584. end
  585. if self.CloakEnh and not self:IsIntelEnabled('Cloak') then
  586. self:SetMaintenanceConsumptionInactive()
  587. elseif self.StealthEnh and not self:IsIntelEnabled('RadarStealth') and not self:IsIntelEnabled('SonarStealth') then
  588. self:SetMaintenanceConsumptionInactive()
  589. end
  590. end,
  591.  
  592. # *****
  593. # Death
  594. # *****
  595. OnKilled = function(self, instigator, type, overkillRatio)
  596. local bp
  597. for k, v in self:GetBlueprint().Buffs do
  598. if v.Add.OnDeath then
  599. bp = v
  600. end
  601. end
  602. #if we could find a blueprint with v.Add.OnDeath, then add the buff
  603. if bp != nil then
  604. #Apply Buff
  605. self:AddBuff(bp)
  606. end
  607. #otherwise, we should finish killing the unit
  608. CWalkingLandUnit.OnKilled(self, instigator, type, overkillRatio)
  609. end,
  610.  
  611. OnPaused = function(self)
  612. CWalkingLandUnit.OnPaused(self)
  613. if self.BuildingUnit then
  614. CWalkingLandUnit.StopBuildingEffects(self, self:GetUnitBeingBuilt())
  615. end
  616. end,
  617.  
  618. OnUnpaused = function(self)
  619. if self.BuildingUnit then
  620. CWalkingLandUnit.StartBuildingEffects(self, self:GetUnitBeingBuilt(), self.UnitBuildOrder)
  621. end
  622. CWalkingLandUnit.OnUnpaused(self)
  623. end,
  624. }
  625.  
  626. TypeClass = WRL0001
Advertisement
Add Comment
Please, Sign In to add comment