Guest User

Untitled

a guest
May 1st, 2014
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.17 KB | None | 0 0
  1. -- Arm Medium Tank (Stumpy)
  2. -- //Arm Medium Tank (Stumpy)
  3.  
  4. --piece base,flare,turret;
  5. local base, flare, turret = piece "base", piece "flare", piece "turret"
  6.  
  7. --static-var restore_delay;
  8. local restore_delay = Spring.UnitScript.GetLongestReloadTime(unitID) * 2
  9.  
  10. --#define SIG_AIM 2
  11. local SIG_AIM = 2
  12. --#define SMOKEPIECE1 base
  13.  
  14. --#include "smokeunit.h"
  15. --#include "exptype.h"
  16. --#include "rockunit.h"
  17. function script.RockUnit(unitID, x, z) return GG.UnitScript.RockUnit(unitID, x, z, base)
  18. --#include "hitweap.h"
  19. function script.HitByWeapon(unitID, x, z) return GG.UnitScript.HitByWeapon(unitID, x, z, base)
  20.  
  21. --[[Create()
  22.     {
  23.     hide flare;
  24.     restore_delay=3000;
  25.     start-script SmokeUnit();
  26.     }]]
  27. function script.Create(unitID)
  28.     Hide(unitID, flare)
  29.     StartThread(unitID, GG.UnitScript.SmokeUnit)
  30. end
  31.  
  32. --[[SetMaxReloadTime(time)
  33.     {
  34.     restore_delay = time * 2;
  35.     }]]
  36.  
  37. --[[RestoreAfterDelay()
  38.     {
  39.     sleep restore_delay;
  40.     turn turret to y-axis 0 speed <90>;
  41.     turn barrel to x-axis 0 speed <50>;
  42.     }]]
  43. local function RestoreAfterDelay()
  44.     Sleep(unitID, restore_delay)
  45.     Turn(unitID, turret, y_axis, 0, math.rad(90))
  46.     Turn(unitID, barrel, x_axis, 0, math.rad(50))
  47. end
  48.  
  49. --[[AimPrimary(heading,pitch)
  50.     {
  51.     signal SIG_AIM;
  52.     set-signal-mask SIG_AIM;
  53.     turn turret to y-axis heading speed <90>;
  54.     turn barrel to x-axis (0-pitch) speed <50>;
  55.     wait-for-turn turret around y-axis;
  56.     wait-for-turn barrel around x-axis;
  57.     start-script RestoreAfterDelay();
  58.     return(TRUE);
  59.     }]]
  60. function script.AimWeapon1(unitID, heading, pitch)
  61.     Signal(unitID, SIG_AIM)
  62.     SetSignalMask(unitID, SIG_AIM)
  63.     Turn(unitID, turret, y_axis, heading, math.rad(90))
  64.     Turn(unitID, barrel, x_axis, -pitch, math.rad(50))
  65.     WaitForTurn(unitID, turret, y_axis)
  66.     WaitForTurn(unitID, barrel, x_axis)
  67.     StartThread(unitID, RestoreAfterDelay)
  68.     return true
  69. end
  70.  
  71. --[[FirePrimary()
  72.     {
  73.     show flare;
  74.     move barrel to z-axis [-2.4] speed [500];
  75.     sleep 150;
  76.     hide flare;
  77.     wait-for-move barrel along z-axis;
  78.     move barrel to z-axis [0] speed [3.0];
  79.     }]]
  80. function script.FireWeapon1(unitID)
  81.     Show(unitID, flare)
  82.     Move(unitID, barrel, z_axis, -2.4, 500) -- move rates are not actually a direct conversion, if you are using OTA linear constant
  83.     Sleep(unitID, 150)
  84.     Hide(unitID, flare)
  85.     WaitForMove(unitID, barrel, z_axis)
  86.     Move(unitID, barrel, z_axis, 0, 3)
  87. end
  88.  
  89. --[[AimFromPrimary(piecenum)
  90.     {
  91.     piecenum=turret;
  92.     }]]
  93. function script.AimFromWeapon1() return turret end
  94.  
  95. --[[QueryPrimary(piecenum)
  96.     {
  97.     piecenum=flare;
  98.     }]]
  99. function script.QueryWeapon1() return flare end
  100.  
  101. --[[SweetSpot(piecenum)
  102.     {
  103.     piecenum=base;
  104.     }]]
  105.  
  106. --[[Killed( severity, corpsetype )
  107.     {
  108.     hide flare;
  109.     if (severity <= 25)
  110.         {
  111.         corpsetype = 1;
  112.         explode barrel type BITMAPONLY | BITMAP1;
  113.         explode base type   BITMAPONLY | BITMAP2;
  114.         explode flare type  BITMAPONLY | BITMAP3;
  115.         explode turret type BITMAPONLY | BITMAP4;
  116.         return( 0 );
  117.         }
  118.  
  119.     if (severity <= 50)
  120.         {
  121.         corpsetype = 2;
  122.         explode barrel type FALL | BITMAP1;
  123.         explode base type   BITMAPONLY | BITMAP2;
  124.         explode flare type  FALL | BITMAP3;
  125.         explode turret type SHATTER | BITMAP4;
  126.         return( 0 );
  127.         }
  128.  
  129.     if (severity <= 99)
  130.         {
  131.         corpsetype = 3;
  132.         explode barrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
  133.         explode base type   BITMAPONLY | BITMAP2;
  134.         explode flare type  FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
  135.         explode turret type SHATTER | BITMAP4;
  136.         return( 0 );
  137.         }
  138.  
  139.     corpsetype = 3;
  140.     explode barrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
  141.     explode base type   BITMAPONLY | BITMAP2;
  142.     explode flare type  FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
  143.     explode turret type SHATTER | EXPLODE_ON_HIT | BITMAP4;
  144.     return( 0 );
  145.     }]]
  146.    
  147. function script.Killed(unitID, recentDamage, maxHealth)
  148.     local severity = recentDamage / maxHealth * 100
  149.     Hide(unitID, flare)
  150.     if severity <= 25 then
  151.         --Explode(unitID, barrel, BITMAPONLY | BITMAP1)
  152.         return 1
  153.     elseif severity <= 50 then
  154.         --Explode(unitID, barrel, FALL | BITMAP1)
  155.         return 2
  156.     elseif severity <= 99 then
  157.         --Explode(unitID, barrel, FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1)
  158.         return 3
  159.     else
  160.         --Explode(unitID, barrel, FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1)
  161.         return 3
  162.     end
  163. end
Advertisement
Add Comment
Please, Sign In to add comment