View difference between Paste ID: 3SwaBqeS and Kjmzpha5
SHOW: | | - or go back to the newest paste.
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 boolean_firstFRot == true then --This is your first time starting? He he he...
11
		float_interval_amount = (rotation_desired/time_to_rotate)		
12
		boolean_firstFRot = false
13
	end	
14
	rotation_added = 0
15
	rotation_added = (rotation_added + (float_interval_amount*ba.getFrametime(false)))
16
17
	if rotation_desired < float_interval_amount then --this is likely the last interval
18
		local float_interval_amount = float_interval_amount - rotation_desired --Get what little's left and feed it to the ship.
19-
	local current_ship_orientation = ship_to_rotate.Orientation
19+
20
	local original_ship_orientation = ship_to_rotate.Orientation
21-
		current_ship_orientation["p"] = (current_ship_orientation["p"] + (float_interval_amount*ba.getFrametime(false)))
21+
22
		new_ship_orientation = ba.createOrientation(0,original_ship_orientation["b"],original_ship_orientation["h"])
23-
		current_ship_orientation["p"] = (current_ship_orientation["p"] - (float_interval_amount*ba.getFrametime(false)))
23+
		new_ship_orientation["p"] = (original_ship_orientation["p"] + rotation_added)
24
	elseif boolean_rotDirection == false then
25
		new_ship_orientation = ba.createOrientation(0,original_ship_orientation["b"],original_ship_orientation["h"])
26
		new_ship_orientation["p"] = (original_ship_orientation["p"] - rotation_added)
27
		
28-
	ship_to_rotate.Orientation = current_ship_orientation
28+
29-
	rotation_desired = rotation_desired - float_interval_amount
29+
30
	end
31
	ship_to_rotate.Orientation = new_ship_orientation
32
	rotation_desired = (rotation_desired - (float_interval_amount*ba.getFrametime(false)))
33
	
34
	if rotation_desired <= 0.0 then
35
		boolean_startRotation = false
36
	end
37
end
38
39
40
--Triggers the force rotation algorithm. rotation in RADIENS
41
--Time should be in ms.
42
--When boolean_direction is true, it goes clockwise, and counterclockwise if false.
43
function fpo(shipName, rotation_amount, time, boolean_direction)
44
	if boolean_startRotation ~= true then
45
		ship_to_rotate = mn.Ships[shipName]
46
		rotation_desired = rotation_amount
47
		time_to_rotate = time
48
		boolean_rotDirection = boolean_direction
49
		boolean_startRotation = true
50
		boolean_firstFRot = true
51
	end
52
end
53
54
]
55
56
$On Death:
57
58
[
59
local dyingShip = hv.Self
60
if dyingShip == hv.Player or dyingShip == ship_to_rotate then --Disable when either the player or the target ship blows up.
61
	boolean_startRotation = false
62
	boolean_firstFRot = false
63
end
64
65
]
66
67
$On Mission End:
68
[
69
70
boolean_startRotation = false --force it off when a mission ends.
71
boolean_firstFRot = false
72
73
]
74
75
#End