Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Conditional Hooks
- $State: GS_STATE_GAME_PLAY
- $On Frame:
- [
- --Rotational Compensation. For those ignorant evil things known as THENUMBERSANDRESULTSDONTMATCHUP
- if boolean_startRotation == true then
- if ship_to_rotate.Orientation["p"] > (pitch_desired+0.01) then --get it within +-.01 of the desire. An exact number may take forever...
- ship_to_rotate.Orientation["p"] = (ship_to_rotate.Orientation["p"] - (ship_to_rotate.Orientation["p"]/pitch_desired))
- elseif ship_to_rotate.Orientation["p"] < (pitch_desired-0.01) then
- ship_to_rotate.Orientation["p"] = (ship_to_rotate.Orientation["p"] + (ship_to_rotate.Orientation["p"]/pitch_desired))
- else --must be done
- boolean_startRotation = false
- end
- end
- --Triggers the force rotation algorithm. rotation in RADIENS
- --function fpo(shipName, pitch_orientation)
- -- ship_to_rotate = mn.Ships[shipName]
- -- if pitch_orientation == 0 then --if it's 0 I'm not going to bother with it due to probable division by 0 errors.
- -- ship_to_rotate.Orientation["p"] = 0
- -- else
- -- pitch_desired = pitch_orientation
- -- boolean_startRotation = true
- --end
- --end
- --Triggers the force rotation algorithm. rotation in RADIENS
- --if boolean_direction is true, rotate clockwise, if false it rotates counterclockwise.
- function fpo(shipName, rotate_amount, boolean_direction)
- ba.print("fpo called with parameters: " + shipname + " " + rotate_amount + " " + boolean_direction + "\n")
- ship_to_rotate = mn.Ships[shipName]
- if ship_to_rotate:isValid() then
- ba.print("Found valid ship\n")
- end
- local vect_rotVelMax = ship_to_rotate.Physics.RotationalVelocityMax
- local t = rotate_amount/vect_rotVelMax["x"] --solve for the time.
- if boolean_direction == true then
- ba.print("Rotating in one direction\n")
- ship_to_rotate:doManeuver(t,0,100,0,true,0,0,0,false)
- elseif boolean_direction == false then
- ba.print("Rotating in other direction\n")
- ship_to_rotate:doManeuver(t,0,-100,0,true,0,0,0,false)
- else
- ba.print("Shit be fucked up yo\n")
- --nothing. If somehow this is nil then it'll go here.
- end
- end
- ]
- $On Death:
- [
- local dyingShip = hv.Self
- if dyingShip == hv.Player or dyingShip == ship_to_rotate then --Disable when either the player or the target ship blows up.
- boolean_startRotation = false
- end
- ]
- $On Mission End:
- [
- boolean_startRotation = false --force it off when a mission ends.
- ]
- #End
Advertisement
Add Comment
Please, Sign In to add comment