AndrewofDoom

Untitled

Jun 27th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #Conditional Hooks
  2.  
  3. $State: GS_STATE_GAME_PLAY
  4.  
  5. $On Frame:
  6.  
  7. [
  8. --Rotational Compensation. For those ignorant evil things known as THENUMBERSANDRESULTSDONTMATCHUP
  9. if boolean_startRotation == true then
  10. if ship_to_rotate.Orientation["p"] > (pitch_desired+0.01) then --get it within +-.01 of the desire. An exact number may take forever...
  11. ship_to_rotate.Orientation["p"] = (ship_to_rotate.Orientation["p"] - (ship_to_rotate.Orientation["p"]/pitch_desired))
  12. elseif ship_to_rotate.Orientation["p"] < (pitch_desired-0.01) then
  13. ship_to_rotate.Orientation["p"] = (ship_to_rotate.Orientation["p"] + (ship_to_rotate.Orientation["p"]/pitch_desired))
  14. else --must be done
  15. boolean_startRotation = false
  16. end
  17. end
  18.  
  19.  
  20. --Triggers the force rotation algorithm. rotation in RADIENS
  21. --function fpo(shipName, pitch_orientation)
  22. -- ship_to_rotate = mn.Ships[shipName]
  23. -- if pitch_orientation == 0 then --if it's 0 I'm not going to bother with it due to probable division by 0 errors.
  24. -- ship_to_rotate.Orientation["p"] = 0
  25. -- else
  26. -- pitch_desired = pitch_orientation
  27. -- boolean_startRotation = true
  28. --end
  29. --end
  30.  
  31. --Triggers the force rotation algorithm. rotation in RADIENS
  32. --if boolean_direction is true, rotate clockwise, if false it rotates counterclockwise.
  33. function fpo(shipName, rotate_amount, boolean_direction)
  34. ba.print("fpo called with parameters: " + shipname + " " + rotate_amount + " " + boolean_direction + "\n")
  35. ship_to_rotate = mn.Ships[shipName]
  36. if ship_to_rotate:isValid() then
  37. ba.print("Found valid ship\n")
  38. end
  39. local vect_rotVelMax = ship_to_rotate.Physics.RotationalVelocityMax
  40. local t = rotate_amount/vect_rotVelMax["x"] --solve for the time.
  41. if boolean_direction == true then
  42. ba.print("Rotating in one direction\n")
  43. ship_to_rotate:doManeuver(t,0,100,0,true,0,0,0,false)
  44. elseif boolean_direction == false then
  45. ba.print("Rotating in other direction\n")
  46. ship_to_rotate:doManeuver(t,0,-100,0,true,0,0,0,false)
  47. else
  48. ba.print("Shit be fucked up yo\n")
  49. --nothing. If somehow this is nil then it'll go here.
  50. end
  51. end
  52.  
  53. ]
  54.  
  55. $On Death:
  56.  
  57. [
  58. local dyingShip = hv.Self
  59. if dyingShip == hv.Player or dyingShip == ship_to_rotate then --Disable when either the player or the target ship blows up.
  60. boolean_startRotation = false
  61. end
  62.  
  63. ]
  64.  
  65. $On Mission End:
  66. [
  67.  
  68. boolean_startRotation = false --force it off when a mission ends.
  69.  
  70. ]
  71.  
  72. #End
Advertisement
Add Comment
Please, Sign In to add comment