Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/CNZ/TriBumper.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Tri Bumper Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Types
13
private alias 0 : TRIBUMPER_SMALL_L
14
private alias 1 : TRIBUMPER_SMALL_R
15
private alias 2 : TRIBUMPER_LARGE_U
16
private alias 3 : TRIBUMPER_LARGE_D
17
private alias 4 : TRIBUMPER_LARGE_L
18
private alias 5 : TRIBUMPER_LARGE_R
19
20
// Player Aliases
21
private alias object.state : player.state
22
private alias object.xpos : player.xpos
23
private alias object.ypos : player.ypos
24
private alias object.xvel : player.xvel
25
private alias object.yvel : player.yvel
26
private alias object.speed : player.speed
27
private alias object.gravity : player.gravity
28
private alias object.animation : player.animation
29
private alias object.tileCollisions : player.tileCollisions
30
31
private alias object.value1 : player.timer
32
private alias object.value36 : player.flyCarryTimer // Tails assist lockout timer
33
34
35
// ========================
36
// Function Declarations
37
// ========================
38
39
reserve function TriBumper_SetPlayerVelocity
40
reserve function TriBumper_HandleBump
41
42
43
// ========================
44
// Function Definitions
45
// ========================
46
47
private function TriBumper_SetPlayerVelocity
48
ATan2(temp0, player[currentPlayer].xvel, player[currentPlayer].yvel)
49
temp0 -= temp3
50
temp1 = temp0
51
Abs(temp1)
52
FlipSign(temp0)
53
temp0 += 256
54
temp0 += temp3
55
temp0 &= 255
56
if temp1 >= 56
57
temp0 = temp3
58
end if
59
Cos256(player[currentPlayer].xvel, temp0)
60
player[currentPlayer].xvel *= -0xA00
61
Sin256(player[currentPlayer].yvel, temp0)
62
player[currentPlayer].yvel *= -0xA00
63
end function
64
65
66
private function TriBumper_HandleBump
67
if player[currentPlayer].state == Player_State_Carried
68
player[1].flyCarryTimer = 30
69
end if
70
71
CheckEqual(player[currentPlayer].animation, ANI_GLIDING)
72
temp2 = checkResult
73
CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)
74
temp2 |= checkResult
75
CheckEqual(player[currentPlayer].animation, ANI_FLYING)
76
temp2 |= checkResult
77
CheckEqual(player[currentPlayer].state, Player_State_TubeRoll)
78
temp2 |= checkResult
79
CheckEqual(player[currentPlayer].state, Player_State_TubeAirRoll)
80
temp2 |= checkResult
81
if player[currentPlayer].animation != ANI_GLIDING
82
player[currentPlayer].speed = player[currentPlayer].xvel
83
player[currentPlayer].timer = 0
84
end if
85
86
if temp2 == false
87
#platform: USE_STANDALONE
88
player[currentPlayer].state = Player_State_Air
89
#endplatform
90
#platform: USE_ORIGINS
91
player[currentPlayer].state = Player_State_Air_NoDropDash
92
#endplatform
93
// Bug Details:
94
// This code wasn't updated in Origins Plus to include ANI_HAMMER_JUMP, so
95
// Amy will always start walking if she hits a Bumper with her hammer out
96
if player[currentPlayer].animation != ANI_JUMPING
97
if player[currentPlayer].animation != ANI_RUNNING
98
player[currentPlayer].animation = ANI_WALKING
99
end if
100
end if
101
end if
102
player[currentPlayer].gravity = GRAVITY_AIR
103
player[currentPlayer].tileCollisions = true
104
PlaySfx(SfxName[CNZ Bumper], false)
105
end function
106
107
108
// ========================
109
// Events
110
// ========================
111
112
event ObjectUpdate
113
switch object.propertyValue
114
case TRIBUMPER_SMALL_L
115
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
116
BoxCollisionTest(C_TOUCH, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
117
if checkResult == true
118
temp0 = object.ypos
119
temp0 -= player[currentPlayer].ypos
120
FlipSign(temp0)
121
if temp0 >= 0x200000
122
player[currentPlayer].yvel = 0xA0000
123
CallFunction(TriBumper_HandleBump)
124
else
125
temp0 = object.xpos
126
temp0 -= player[currentPlayer].xpos
127
FlipSign(temp0)
128
if temp0 >= 0x200000
129
player[currentPlayer].xvel = 0xA0000
130
CallFunction(TriBumper_HandleBump)
131
else
132
temp0 = object.xpos
133
temp0 -= player[currentPlayer].xpos
134
if temp0 >= 0x200000
135
temp0 = 0x200000
136
end if
137
temp0 += object.ypos
138
temp0 -= 0x80000
139
temp1 = player[currentPlayer].ypos
140
temp1 += 0xE0000
141
temp0 -= temp1
142
if temp0 < 0
143
temp3 = 32
144
CallFunction(TriBumper_SetPlayerVelocity)
145
CallFunction(TriBumper_HandleBump)
146
end if
147
end if
148
end if
149
end if
150
next
151
break
152
153
case TRIBUMPER_SMALL_R
154
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
155
BoxCollisionTest(C_TOUCH, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
156
if checkResult == true
157
temp0 = object.ypos
158
temp0 -= player[currentPlayer].ypos
159
FlipSign(temp0)
160
if temp0 >= 0x200000
161
player[currentPlayer].yvel = 0xA0000
162
CallFunction(TriBumper_HandleBump)
163
else
164
temp0 = object.xpos
165
temp0 -= player[currentPlayer].xpos
166
if temp0 >= 0x200000
167
player[currentPlayer].xvel = -0xA0000
168
CallFunction(TriBumper_HandleBump)
169
else
170
temp0 = object.xpos
171
temp0 -= player[currentPlayer].xpos
172
FlipSign(temp0)
173
if temp0 >= 0x200000
174
temp0 = 0x200000
175
end if
176
temp0 += object.ypos
177
temp0 -= 0x80000
178
temp1 = player[currentPlayer].ypos
179
temp1 += 0xE0000
180
temp0 -= temp1
181
if temp0 < 0
182
temp3 = 96
183
CallFunction(TriBumper_SetPlayerVelocity)
184
CallFunction(TriBumper_HandleBump)
185
end if
186
end if
187
end if
188
end if
189
next
190
break
191
192
case TRIBUMPER_LARGE_U
193
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
194
BoxCollisionTest(C_TOUCH, object.entityPos, -64, -8, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
195
if checkResult == true
196
temp0 = object.ypos
197
temp0 -= player[currentPlayer].ypos
198
FlipSign(temp0)
199
if temp0 >= 0x80000
200
player[currentPlayer].yvel = 0xA00
201
CallFunction(TriBumper_HandleBump)
202
else
203
temp0 = object.xpos
204
temp0 -= player[currentPlayer].xpos
205
if temp0 >= 0x400000
206
player[currentPlayer].xvel = -0xA0000
207
CallFunction(TriBumper_HandleBump)
208
else
209
FlipSign(temp0)
210
if temp0 >= 0x400000
211
player[currentPlayer].xvel = 0xA0000
212
CallFunction(TriBumper_HandleBump)
213
else
214
if temp0 < 0
215
temp3 = 56
216
else
217
temp3 = 72
218
end if
219
CallFunction(TriBumper_SetPlayerVelocity)
220
CallFunction(TriBumper_HandleBump)
221
end if
222
end if
223
end if
224
end if
225
next
226
break
227
228
case TRIBUMPER_LARGE_D
229
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
230
BoxCollisionTest(C_TOUCH, object.entityPos, -64, -8, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
231
if checkResult == true
232
temp0 = object.ypos
233
temp0 -= player[currentPlayer].ypos
234
if temp0 >= 0x80000
235
player[currentPlayer].yvel = -0xA0000
236
CallFunction(TriBumper_HandleBump)
237
else
238
temp0 = object.xpos
239
temp0 -= player[currentPlayer].xpos
240
if temp0 >= 0x400000
241
player[currentPlayer].xvel = -0xA0000
242
CallFunction(TriBumper_HandleBump)
243
else
244
FlipSign(temp0)
245
if temp0 >= 0x400000
246
player[currentPlayer].xvel = 0xA0000
247
CallFunction(TriBumper_HandleBump)
248
else
249
if temp0 < 0
250
temp3 = 200
251
else
252
temp3 = 184
253
end if
254
CallFunction(TriBumper_SetPlayerVelocity)
255
CallFunction(TriBumper_HandleBump)
256
end if
257
end if
258
end if
259
end if
260
next
261
break
262
263
case TRIBUMPER_LARGE_L
264
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
265
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -64, 8, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
266
if checkResult == true
267
temp0 = object.xpos
268
temp0 -= player[currentPlayer].xpos
269
FlipSign(temp0)
270
if temp0 >= 0x80000
271
player[currentPlayer].xvel = 0xA0000
272
CallFunction(TriBumper_HandleBump)
273
else
274
temp0 = object.ypos
275
temp0 -= player[currentPlayer].ypos
276
if temp0 >= 0x400000
277
player[currentPlayer].yvel = -0xA0000
278
CallFunction(TriBumper_HandleBump)
279
else
280
FlipSign(temp0)
281
if temp0 >= 0x400000
282
player[currentPlayer].yvel = 0xA0000
283
CallFunction(TriBumper_HandleBump)
284
else
285
if temp0 < 0
286
temp3 = 8
287
else
288
temp3 = 248
289
end if
290
CallFunction(TriBumper_SetPlayerVelocity)
291
CallFunction(TriBumper_HandleBump)
292
end if
293
end if
294
end if
295
end if
296
next
297
break
298
299
case TRIBUMPER_LARGE_R
300
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
301
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -64, 8, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
302
if checkResult == true
303
temp0 = object.xpos
304
temp0 -= player[currentPlayer].xpos
305
if temp0 >= 0x80000
306
player[currentPlayer].xvel = 0xA0000
307
CallFunction(TriBumper_HandleBump)
308
else
309
temp0 = object.ypos
310
temp0 -= player[currentPlayer].ypos
311
if temp0 >= 0x400000
312
player[currentPlayer].yvel = -0xA0000
313
CallFunction(TriBumper_HandleBump)
314
else
315
FlipSign(temp0)
316
if temp0 >= 0x400000
317
player[currentPlayer].yvel = 0xA0000
318
CallFunction(TriBumper_HandleBump)
319
else
320
if temp0 < 0
321
temp3 = 120
322
else
323
temp3 = 136
324
end if
325
CallFunction(TriBumper_SetPlayerVelocity)
326
CallFunction(TriBumper_HandleBump)
327
end if
328
end if
329
end if
330
end if
331
next
332
break
333
334
end switch
335
end event
336
337
338
// ========================
339
// Editor Events
340
// ========================
341
342
event RSDKEdit
343
if editor.returnVariable == true
344
switch editor.variableID
345
case EDIT_VAR_PROPVAL // property value
346
checkResult = object.propertyValue
347
break
348
349
case 0 // type
350
checkResult = object.propertyValue
351
checkResult %= 6
352
break
353
354
end switch
355
else
356
switch editor.variableID
357
case EDIT_VAR_PROPVAL // property value
358
object.propertyValue = editor.variableValue
359
break
360
361
case 0 // type
362
editor.variableValue %= 6
363
object.propertyValue = editor.variableValue
364
break
365
366
end switch
367
end if
368
end event
369
370
371
event RSDKDraw
372
DrawSprite(0)
373
end event
374
375
376
event RSDKLoad
377
LoadSpriteSheet("Global/Display.gif")
378
SpriteFrame(-16, -16, 32, 32, 1, 143)
379
380
AddEditorVariable("type")
381
SetActiveVariable("type")
382
AddEnumVariable("Small (Facing Left)", TRIBUMPER_SMALL_L)
383
AddEnumVariable("Small (Facing Right)", TRIBUMPER_SMALL_R)
384
AddEnumVariable("Large (Facing Up)", TRIBUMPER_LARGE_U)
385
AddEnumVariable("Large (Facing Down)", TRIBUMPER_LARGE_D)
386
AddEnumVariable("Large (Facing Left)", TRIBUMPER_LARGE_L)
387
AddEnumVariable("Large (Facing Right)", TRIBUMPER_LARGE_R)
388
end event
389
390