-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsssv.lua
More file actions
428 lines (355 loc) · 11.4 KB
/
sssv.lua
File metadata and controls
428 lines (355 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
if type(ScriptHawk) ~= "table" then
print("This script is not designed to run by itself");
print("Please run ScriptHawk.lua from the parent directory instead");
print("Thanks for using ScriptHawk :)");
return;
end
local Game = {
squish_memory_table = true,
Memory = { -- Version order: USA N64, Europe N64
current_animal_list_index = {0x3D5534, 0x3D5624},
animal_list_pointer_base = {0x1DDD88, 0x1DDDA8},
map_index = {0x3F2D39, 0x3F2E29},
},
rot_speed = 10,
max_rot_units = 360,
speedy_speeds = { .001, .01, .1, 1, 5, 10, 20, 50, 100 },
speedy_index = 7,
takeMeThereType = "Checkbox",
};
local max_health = 0x82;
local max_A_skill = 0x400;
local max_B_skill = 0x400;
-----------------------------
-- Animal Variable Offsets --
-----------------------------
local animal_variable_offsets = {
x_position = 0x04,
z_position = 0x08,
y_position = 0x0C,
x_velocity = 0x1C,
z_velocity = 0x20,
y_velocity = 0x24,
y_rotation = 0x2C,
health = 0x14C,
A_skill_energy = 0x2E0,
B_skill_energy = 0x2E4
};
---------------------------
-- Animal Struct Offsets --
---------------------------
local animal_struct_offsets = {
animal_type = 0x9C,
};
function Game.getCurrentAnimalIndex()
return mainmemory.read_u16_be(Game.Memory.current_animal_list_index);
end
function Game.getAnimalVariablePointer(levelAnimalIndex)
return dereferencePointer(levelAnimalIndex * 0x08 + Game.Memory.animal_list_pointer_base + 0x04);
end
function Game.getCurrentAnimalVariablePointer()
return Game.getAnimalVariablePointer(Game.getCurrentAnimalIndex());
end
function Game.getAnimalInfoPointer(levelAnimalIndex)
local animalObjectPointer = dereferencePointer(levelAnimalIndex * 0x08 + Game.Memory.animal_list_pointer_base);
if isRDRAM(animalObjectPointer) then
return animalObjectPointer;
end
end
function Game.getCurrentAnimalInfoPointer()
return Game.getAnimalInfoPointer(Game.getCurrentAnimalIndex());
end
-----------------
-- Animal Type --
-----------------
local animalTypes = {
[0x00] = "Seagull",
[0x01] = "Lion",
[0x02] = "Hippo",
[0x04] = "Racing Dog",
[0x05] = "Flying Dog",
[0x0A] = "Rabbit",
[0x0B] = "Heli-Rabbit",
[0x0D] = "King Rat",
[0x0E] = "Parrot",
[0x12] = "Racing Mouse",
[0x16] = "Bear",
[0x18] = "Racing Bear",
[0x1A] = "Racing Fox",
[0x1B] = "Tortoise Tank",
[0x1C] = "Racing Tortoise",
[0x1E] = "Piranha",
[0x1F] = "Dog",
[0x20] = "Rat",
[0x21] = "Sheep",
[0x22] = "Ram",
[0x23] = "Spring Sheep",
[0x24] = "Spring Ram",
[0x25] = "Penguin",
[0x26] = "Polar Bear",
[0x27] = "Polar Tank",
[0x28] = "Husky",
[0x2A] = "Ski Husky",
[0x2C] = "Walrus",
[0x2D] = "Vulture",
[0x2E] = "Camel",
[0x2F] = "Cannon Camel",
[0x31] = "Pogo Kangaroo",
[0x32] = "Boxing Kangaroo",
[0x33] = "Desert Fox",
[0x34] = "Armed Desert Fox",
[0x35] = "Scorpion",
[0x36] = "Gorilla",
[0x38] = "Elephant",
[0x39] = "Hyena",
[0x3B] = "Chameleon",
[0x3D] = "EVO (Chip)",
[0x3F] = "EVO (Transfer)",
[0x40] = "King Penguin",
[0x42] = "Cool Cod",
[0x43] = "Evo Robot",
};
function Game.getAnimalType(levelAnimalIndex)
local animalType = Game.getAnimalInfoPointer(levelAnimalIndex);
if isRDRAM(animalType) then
animalType = mainmemory.read_u16_be(animalType + animal_struct_offsets.animal_type);
return animalTypes[animalType] or "Unknown ("..toHexString(animalType)..")";
else
return " ";
end
end
function Game.getCurrentAnimalType()
return Game.getAnimalType(Game.getCurrentAnimalIndex());
end
--------------
-- Position --
--------------
-- Player Specific
function Game.getXPosition()
return Game.getAnimalXPosition(Game.getCurrentAnimalIndex());
end
function Game.getYPosition()
return Game.getAnimalYPosition(Game.getCurrentAnimalIndex());
end
function Game.getZPosition()
return Game.getAnimalZPosition(Game.getCurrentAnimalIndex());
end
function Game.setXPosition(value)
return Game.setAnimalXPosition(value, Game.getCurrentAnimalIndex());
end
function Game.setYPosition(value)
return Game.setAnimalYPosition(value, Game.getCurrentAnimalIndex());
end
function Game.setZPosition(value)
return Game.setAnimalZPosition(value, Game.getCurrentAnimalIndex());
end
-- Current map animals
function Game.getAnimalXPosition(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u32_be(animalPointer + animal_variable_offsets.x_position) / 0x10000;
end
return 0;
end
function Game.getAnimalYPosition(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u32_be(animalPointer + animal_variable_offsets.y_position) / 0x10000;
end
return 0;
end
function Game.getAnimalZPosition(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u32_be(animalPointer + animal_variable_offsets.z_position) / 0x10000;
end
return 0;
end
function Game.setAnimalXPosition(value,levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.x_position, value * 0x10000);
end
end
function Game.setAnimalYPosition(value,levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.y_position, value * 0x10000);
Game.setAnimalYVelocity(0, levelAnimalIndex);
end
end
function Game.setAnimalZPosition(value,levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.z_position, value * 0x10000);
end
end
--------------
-- Rotation --
--------------
-- Player specific
function Game.getYRotation()
return Game.getAnimalYRotation(Game.getCurrentAnimalIndex());
end
function Game.setYRotation(value)
return Game.setAnimalYRotation(value, Game.getCurrentAnimalIndex());
end
-- Current map animals
function Game.getAnimalYRotation(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u16_be(animalPointer + animal_variable_offsets.y_rotation);
end
return 0;
end
function Game.setAnimalYRotation(value, levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
mainmemory.write_u16_be(animalPointer + animal_variable_offsets.y_rotation, value);
end
end
--------------
-- Velocity --
--------------
-- Player specific
function Game.getXVelocity()
return Game.getAnimalXVelocity(Game.getCurrentAnimalIndex());
end
function Game.getYVelocity()
return Game.getAnimalYVelocity(Game.getCurrentAnimalIndex());
end
function Game.getZVelocity()
return Game.getAnimalZVelocity(Game.getCurrentAnimalIndex());
end
function Game.setXVelocity(value)
return Game.setAnimalXVelocity(value, Game.getCurrentAnimalIndex());
end
function Game.setYVelocity(value)
return Game.setAnimalYVelocity(value, Game.getCurrentAnimalIndex());
end
function Game.setZVelocity(value)
return Game.setAnimalZVelocity(value, Game.getCurrentAnimalIndex());
end
function Game.getVelocity() -- Calculated vXZ
return Game.getAnimalVelocity(Game.getCurrentAnimalIndex());
end
-- Current map animals
function Game.getAnimalXVelocity(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u16_be(animalPointer + animal_variable_offsets.x_velocity) / 0x10000;
end
return 0;
end
function Game.getAnimalYVelocity(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u16_be(animalPointer + animal_variable_offsets.y_velocity) / 0x10000;
end
return 0;
end
function Game.getAnimalZVelocity(levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
return mainmemory.read_u16_be(animalPointer + animal_variable_offsets.z_velocity) / 0x10000;
end
return 0;
end
function Game.setAnimalXVelocity(value, levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.x_velocity, value * 0x10000);
end
end
function Game.setAnimalYVelocity(value, levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
animalPointer = animalPointer + animal_variable_offsets.y_velocity;
mainmemory.write_u32_be(animalPointer, value * 0x10000);
end
end
function Game.setAnimalZVelocity(value, levelAnimalIndex)
local animalPointer = Game.getAnimalVariablePointer(levelAnimalIndex);
if isRDRAM(animalPointer) then
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.z_velocity, value * 0x10000);
end
end
function Game.getAnimalVelocity(levelAnimalIndex) -- Calculated vXZ
local vX = Game.getAnimalXVelocity(levelAnimalIndex);
local vZ = Game.getAnimalZVelocity(levelAnimalIndex);
return math.sqrt(vX*vX + vZ*vZ);
end
------------
-- Events --
------------
Game.maps = {
[0x01] = "Smashing Start",
[0x02] = "Have A Nice Day",
[0x03] = "Honeymoon Lagoon",
[0x04] = "The Battery Farm",
[0x05] = "The Engine Room",
[0x06] = "Fat Bear Mountain",
[0x07] = "Rocky Hard Place",
[0x08] = "Stinky Sewer",
[0x09] = "Rat-O-Matic",
[0x0A] = "Give A Dog A Bonus",
[0x0B] = "Snow Joke",
[0x0C] = "Ice 'n' Easy Does It",
[0x0D] = "Penguin Playpen",
[0x0E] = "Pinball Blizzard",
[0x0F] = "Hoppa Choppa",
[0x10] = "Something Fishy",
[0x11] = "Walrace 64",
[0x12] = "Jungle Japes",
[0x13] = "Jungle Doldrums",
[0x14] = "Swamp Of Eternal Stench",
[0x15] = "Weight For It!",
[0x16] = "Jungle Jumps",
[0x17] = "Evo's Escape",
[0x18] = "Fun In The Sun",
[0x19] = "Hot Cross Buns",
[0x1A] = "Sting In The Tail",
[0x1B] = "Borassic Park",
[0x1C] = "Whirlwind Tour",
[0x1D] = "Shifting Sands",
[0x1E] = "Punch up Pyramid",
[0x1F] = "Big Celebration Parade",
[0x20] = "!Unknown 0x20",
[0x21] = "GLITCH LEVEL #1",
[0x22] = "GLITCH LEVEL #2",
[0x23] = "Credits",
[0x24] = "Intro",
};
function Game.setMap(index)
mainmemory.writebyte(Game.Memory.map_index, index);
end
function Game.applyInfinites()
local animalPointer = Game.getCurrentAnimalVariablePointer();
if isRDRAM(animalPointer) then
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.health, max_health * 0x10000);
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.A_skill_energy, max_A_skill * 0x10000);
mainmemory.write_u32_be(animalPointer + animal_variable_offsets.B_skill_energy, max_B_skill * 0x10000);
end
end
Game.OSD = {
{"Animal", Game.getCurrentAnimalType, category="animal"},
{"Separator"},
{"X", category="position"},
{"Y", category="position"},
{"Z", category="position"},
{"Separator"},
{"Y Velocity", Game.getYVelocity, category="speed"},
{"Velocity", Game.getVelocity, category="speed"},
{"Separator"},
{"dY", category="positionStats"},
{"dXZ", category="positionStats"},
{"Separator"},
{"Max dY", category="positionStatsMore"},
{"Max dXZ", category="positionStatsMore"},
{"Odometer", category="positionStatsMore"},
{"Separator"},
--{"Rot. X", Game.getXRotation, category="angleMore"},
{"Facing", Game.getYRotation, category="angle"},
--{"Rot. Z", Game.getZRotation, category="angleMore"},
};
return Game;