SHARE
TWEET

FLOZi

a guest Dec 15th, 2009 94 Never
  1. -- Arm Medium Tank (Stumpy)
  2. local base, flare, turret = piece ("base", "flare", "turret")
  3.  
  4. -- constants
  5. local SIG_AIM = 2
  6. local RESTORE_DELAY = Spring.UnitScript.GetLongestReloadTime(unitID) * 2
  7.  
  8. -- includes
  9. include "rockunit.lua"
  10. include "smokeunit.lua"
  11.  
  12. function script.Create(unitID)
  13.         Hide(flare)
  14.         StartThread(SmokeUnit)
  15. end
  16.  
  17. local function RestoreAfterDelay(unitID)
  18.         Sleep(RESTORE_DELAY)
  19.         Turn(turret, y_axis, 0, math.rad(90))
  20.         Turn(barrel, x_axis, 0, math.rad(50))
  21. end
  22.  
  23. function script.AimWeapon(weaponID, heading, pitch)
  24.         Signal(SIG_AIM)
  25.         SetSignalMask(SIG_AIM)
  26.         Turn(turret, y_axis, heading, math.rad(90))
  27.         Turn(barrel, x_axis, -pitch, math.rad(50))
  28.         WaitForTurn(turret, y_axis)
  29.         WaitForTurn(barrel, x_axis)
  30.         StartThread(RestoreAfterDelay)
  31.         return true
  32. end
  33.  
  34. function script.FireWeapon(weaponID)
  35.         Show(flare)
  36.         Move(barrel, z_axis, -2.4, 500)
  37.         Sleep(150)
  38.         Hide(flare)
  39.         WaitForMove(barrel, z_axis)
  40.         Move(barrel, z_axis, 0, 3)
  41. end
  42.  
  43. function script.AimFromWeapon() return turret end
  44.  
  45. function script.QueryWeapon() return flare end
  46.        
  47. function script.Killed(recentDamage, maxHealth)
  48.         local severity = recentDamage / maxHealth * 100
  49.         Hide(flare)
  50.         if severity <= 25 then
  51.                 Explode(barrel, math.bit_or({SFX.BITMAPONLY, SFX.BITMAP1}))
  52.                 return 1
  53.         elseif severity <= 50 then
  54.                 Explode(barrel, math.bit_or({SFX.FALL, SFX.BITMAP1}))
  55.                 return 2
  56.         else
  57.                 Explode(barrel, math.bit_or({SFX.FALL, SFX.SMOKE, SFX.FIRE, SFX.EXPLODE_ON_HIT, SFX.BITMAP1}))
  58.                 return 3
  59.         end
  60. end
RAW Paste Data
Top