1+ if type (ScriptHawk ) ~= " table" then
2+ print (" This script is not designed to run by itself" );
3+ print (" Please run ScriptHawk.lua from the parent directory instead" );
4+ print (" Thanks for using ScriptHawk :)" );
5+ return ;
6+ end
7+
8+ local Game = {
9+ speedy_speeds = { .001 , .01 , .1 , .2 , .3 , .5 , .75 , 1 , 5 },
10+ speedy_index = 5 ,
11+ speedy_invert_xz = true ,
12+ max_rot_units = 360 ,
13+ Memory = {
14+ x_position = 0x1CFF64 , -- Float
15+ y_position = 0x1CFF6C , -- Float
16+ z_position = 0x1CFF68 , -- Float
17+ x_velocity = 0x1CFED4 , -- Float
18+ y_velocity = 0x1CFEDC , -- Float
19+ z_velocity = 0x1CFED8 , -- Float
20+ rot_sine = 0x1CFF34 , -- TODO: This rotation stuff is kinda borked still, just copy pasted from the Rayman 2 module, figure it out properly
21+ -- rot_sine_mirror = 0x1CFF38,
22+ rot_cosine = 0x1CFF44 ,
23+ -- rot_cosine_inverse = 0x1CFF48,
24+ },
25+ };
26+
27+ function Game .getXPosition ()
28+ return mainmemory .readfloat (Game .Memory .x_position , true );
29+ end
30+
31+ function Game .setXPosition (value )
32+ mainmemory .writefloat (Game .Memory .x_position , value , true );
33+ end
34+
35+ function Game .getYPosition ()
36+ return mainmemory .readfloat (Game .Memory .y_position , true );
37+ end
38+
39+ function Game .setYPosition (value )
40+ mainmemory .writefloat (Game .Memory .y_position , value , true );
41+ end
42+
43+ function Game .getZPosition ()
44+ return mainmemory .readfloat (Game .Memory .z_position , true );
45+ end
46+
47+ function Game .setZPosition (value )
48+ mainmemory .writefloat (Game .Memory .z_position , value , true );
49+ end
50+
51+ function Game .getXVelocity ()
52+ return mainmemory .readfloat (Game .Memory .x_velocity , true );
53+ end
54+
55+ function Game .getYVelocity ()
56+ return mainmemory .readfloat (Game .Memory .y_velocity , true );
57+ end
58+
59+ function Game .getZVelocity ()
60+ return mainmemory .readfloat (Game .Memory .z_velocity , true );
61+ end
62+
63+ function Game .getVelocity () -- Calculated VXZ
64+ local vX = Game .getXVelocity ();
65+ local vZ = Game .getZVelocity ();
66+ return math.sqrt (vX * vX + vZ * vZ );
67+ end
68+
69+ ---- ----------
70+ -- Rotation --
71+ ---- ----------
72+
73+ function Game .getYRotation ()
74+ local currentSine = mainmemory .readfloat (Game .Memory .rot_sine , true );
75+ local currentCosine = mainmemory .readfloat (Game .Memory .rot_cosine , true );
76+ if currentSine > 0 then
77+ return math.deg (math.acos (currentCosine ));
78+ end
79+ return 360 - math.deg (math.acos (currentCosine ));
80+ end
81+
82+ function Game .setYRotation (value )
83+ local sineValue = math.sin (math.rad (value ));
84+ local cosineValue = math.cos (math.rad (value ));
85+
86+ -- Set the sine values
87+ mainmemory .writefloat (Game .Memory .rot_sine , sineValue , true );
88+ -- mainmemory.writefloat(Game.Memory.rot_sine_mirror, sineValue, true);
89+
90+ -- Set the cosine values
91+ mainmemory .writefloat (Game .Memory .rot_cosine , cosineValue , true );
92+ -- mainmemory.writefloat(Game.Memory.rot_cosine_inverse, cosineValue * -1, true);
93+ end
94+
95+ Game .OSD = {
96+ {" X" },
97+ {" Y" },
98+ {" Z" },
99+ {" Separator" },
100+ -- {"X Velocity", Game.getXVelocity},
101+ {" Y Velocity" , Game .getYVelocity },
102+ -- {"Z Velocity", Game.getZVelocity},
103+ {" Velocity" , Game .getVelocity },
104+ {" Separator" },
105+ {" dY" },
106+ {" dXZ" },
107+ {" Separator" },
108+ {" Facing" , Game .getYRotation },
109+ };
110+
111+ return Game ;
0 commit comments