Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. local turret = piece "turret"
  2. local launchpad = piece "launchpad"
  3. local flares = ({piece "flare1", piece "flare2", piece "flare3"})
  4. local missiles = ({piece "missile1", piece "missile2", piece "missile3"})
  5. local radarmount = piece "radarmount"
  6. local barrelsn = 3
  7. local shotfrom = 1
  8. local canshot = true
  9. local lasttargetID = -1
  10.  
  11. function script.Create()
  12.     Spin (radarmount, y_axis, 1)
  13. end
  14.  
  15.  
  16. --SHOOTING
  17. function script.QueryWeapon1() return flares[shotfrom] end
  18.  
  19. function script.AimFromWeapon1() return launchpad end
  20.  
  21. function script.AimWeapon1( heading, pitch )   
  22.     Signal(SIG_AIM)
  23.     SetSignalMask(SIG_AIM)
  24.     Turn(turret, y_axis, heading, math.rad(180))
  25.     if (math.deg(pitch) < -10) then pitch = math.rad(-10) end
  26.     Turn(launchpad, x_axis, -pitch, math.rad(180))
  27.     WaitForTurn(turret, y_axis)
  28.     WaitForTurn(launchpad, x_axis)
  29.     --StartThread(RestoreAfterDelay)   
  30.     return canshot
  31. end
  32.  
  33. function script.FireWeapon1()
  34. --  EmitSfx(flare, orc_machinegun_flash)
  35. -- 
  36.     --Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "maxSpeed", 0.5)
  37.     --Spring.MoveCtrl.SetGroundMoveTypeData(unitID, "turnRate", 0.1)
  38.     --EmitSfx(flares[shotfrom], muzzleflash)
  39.     --Move (barrels[shotfrom], z_axis, -5)
  40.         --Move (barrels[shotfrom], z_axis, 0, 20)  
  41.    
  42.    
  43.     Hide (missiles[shotfrom])
  44.     shotfrom=shotfrom+1
  45.     if (shotfrom > barrelsn) then
  46.         --canshot= false
  47.         shotfrom = 1
  48.         --Sleep (1000)
  49.         --Spring.AddUnitDamage (unitID, math.huge)
  50.     end
  51.     --StartThread(RestoreAfterDelay)
  52.     --RestoreAfterDelay()  
  53. end
  54.  
  55.  
  56.  
  57. function script.BlockShot1 (targetID, userTarget )
  58.     if (targetID==nil) then return false end    --shooting at ground
  59.     --Spring.Echo ("blockshot() targetID " .. targetID .. " its a " .. type (targetID) )
  60.     --Spring.Echo ("blockshot() lasttargetID " .. lasttargetID)
  61.     --Spring.Echo ("blockshot() userTarget  " .. userTarget)
  62.     if (targetID==lasttargetID) then
  63.         --Spring.Echo ("lol denied, retarget!")
  64.         Spring.UnitScript.SetUnitValue(COB.CHANGE_TARGET, 0)
  65.         return true
  66.     end
  67.    
  68.     return false
  69. end
  70.  
  71.  
  72.  
  73. function script.TargetWeight1 (targetID)
  74.     Spring.Echo ("TargetWeight() targetID " .. targetID)
  75.     Spring.Echo ("TargetWeight() lasttargetID " .. lasttargetID)
  76.     if (targetID==lasttargetID) then Spring.Echo ("same target as last time") Spring.UnitScript.SetUnitValue(COB.CHANGE_TARGET, 0) return 90000 end
  77.     lasttargetID = targetID
  78.     Spring.Echo ("not same target")
  79.     return 0
  80. end
  81.  
  82.  
  83. function script.Killed(recentDamage, maxHealth)
  84.     Spring.UnitScript.Explode (turret, SFX.FALL)
  85.     Spring.UnitScript.Explode (launchpad, SFX.FALL)
  86.     Sleep(30)
  87. end
  88.  
  89.  
  90. -------Transporting-----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement