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/EHZ/SpiralPath.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Spiral Path Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value1 : object.activePlayers
13
14
// Player Aliases
15
private alias object.state : player.state
16
private alias object.xpos : player.xpos
17
private alias object.ypos : player.ypos
18
private alias object.xvel : player.xvel
19
private alias object.yvel : player.yvel
20
private alias object.speed : player.speed
21
private alias object.rotation : player.rotation
22
private alias object.angle : player.angle
23
private alias object.direction : player.direction
24
private alias object.gravity : player.gravity
25
private alias object.frame : player.frame
26
private alias object.prevAnimation : player.prevAnimation
27
private alias object.animationSpeed : player.animationSpeed
28
private alias object.animation : player.animation
29
private alias object.collisionBottom : player.collisionBottom
30
private alias object.value42 : player.prevGravity
31
32
33
// ========================
34
// Tables
35
// ========================
36
37
// Used to determine which frame the player should use when corkscrewing
38
private table SpiralPath_spriteTable
39
6, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7
40
end table
41
42
// Values for the small player Y Pos offset when corkscrewing
43
// This is just a cosine table with an amplitude of 32 - same as the original ROM - so it's not much special
44
private table SpiralPath_offsetTable
45
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
46
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31
47
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30
48
30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, 28, 28, 27
49
27, 27, 27, 26, 26, 26, 25, 25, 25, 24, 24, 24, 23, 23, 22, 22
50
21, 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14, 13, 12, 12
51
11, 10, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1
52
0, -1, -2, -2, -3, -4, -4, -5, -6, -7, -7, -8, -9, -9, -10, -10
53
-11, -11, -12, -12, -13, -14, -14, -15, -15, -16, -16, -17, -17, -18, -18, -19
54
-19, -19, -20, -21, -21, -22, -22, -23, -23, -24, -24, -25, -25, -26, -26, -27
55
-27, -28, -28, -28, -29, -29, -30, -30, -30, -31, -31, -31, -32, -32, -32, -33
56
-33, -33, -33, -34, -34, -34, -35, -35, -35, -35, -35, -35, -35, -35, -36, -36
57
-36, -36, -36, -36, -36, -36, -36, -37, -37, -37, -37, -37, -37, -37, -37, -37
58
-37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37
59
-37, -37, -37, -37, -36, -36, -36, -36, -36, -36, -36, -35, -35, -35, -35, -35
60
-35, -35, -35, -34, -34, -34, -33, -33, -33, -33, -32, -32, -32, -31, -31, -31
61
-30, -30, -30, -29, -29, -28, -28, -28, -27, -27, -26, -26, -25, -25, -24, -24
62
-23, -23, -22, -22, -21, -21, -20, -19, -19, -18, -18, -17, -16, -16, -15, -14
63
-14, -13, -12, -11, -11, -10, -9, -8, -7, -7, -6, -5, -4, -3, -2, -1
64
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 13
65
13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21
66
21, 22, 22, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26
67
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29
68
29, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31
69
31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
70
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
71
end table
72
73
74
// ========================
75
// Events
76
// ========================
77
78
event ObjectUpdate
79
// Make this object always active, it's larger than the screen is normally so we can't depend on the normal priority system
80
object.priority = PRIORITY_ACTIVE
81
82
temp2 = 0
83
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
84
temp0 = player[currentPlayer].xpos
85
temp0 -= object.xpos
86
87
GetBit(temp3, object.activePlayers, temp2)
88
if temp3 == false
89
if player[currentPlayer].prevGravity == GRAVITY_GROUND
90
BoxCollisionTest(C_TOUCH, object.entityPos, -192, 8, 192, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
91
92
if checkResult == true
93
SetBit(object.activePlayers, temp2, true)
94
player[currentPlayer].yvel = 0
95
end if
96
end if
97
else
98
temp0 += 0xD00000
99
temp1 = player[currentPlayer].xvel
100
Abs(temp1)
101
CheckLower(temp1, 0x60000)
102
103
temp3 = checkResult
104
CheckLower(player[currentPlayer].yvel, -0x40000)
105
temp3 |= checkResult
106
CheckLower(temp0, 0)
107
temp3 |= checkResult
108
CheckGreater(temp0, 0x19FFFFF)
109
temp3 |= checkResult
110
111
if temp3 == true
112
SetBit(object.activePlayers, temp2, false)
113
if player[currentPlayer].prevGravity == GRAVITY_AIR
114
if player[currentPlayer].yvel >= 0
115
if player[currentPlayer].state != Player_State_Carried
116
if player[currentPlayer].animation != ANI_SKIDDING
117
player[currentPlayer].animation = ANI_TWIRL
118
player[currentPlayer].angle = 0
119
end if
120
end if
121
end if
122
end if
123
else
124
player[currentPlayer].yvel = 0
125
126
temp0 >>= 16
127
128
GetTableValue(player[currentPlayer].ypos, temp0, SpiralPath_offsetTable)
129
130
player[currentPlayer].ypos -= player[currentPlayer].collisionBottom
131
player[currentPlayer].ypos += 19
132
player[currentPlayer].ypos <<= 16
133
player[currentPlayer].ypos += object.ypos
134
135
#platform: USE_ORIGINS
136
if player[currentPlayer].state == Player_State_HammerDash
137
player[currentPlayer].state = Player_State_Ground
138
end if
139
#endplatform
140
141
if player[currentPlayer].state == Player_State_Ground
142
if player[currentPlayer].gravity == GRAVITY_AIR
143
144
// We're setting prevAnimation too because we don't want frame number to be reset
145
player[currentPlayer].prevAnimation = ANI_TWIRL
146
player[currentPlayer].animation = ANI_TWIRL
147
player[currentPlayer].animationSpeed = 0
148
player[currentPlayer].direction = FACING_RIGHT
149
150
temp1 = object.xpos
151
temp1 -= 0xC40000
152
temp0 = player[currentPlayer].xpos
153
temp0 -= temp1
154
temp0 >>= 21
155
temp0 %= 12
156
157
if player[currentPlayer].speed > 0
158
player[currentPlayer].frame = temp0
159
player[currentPlayer].rotation = 0
160
else
161
GetTableValue(player[currentPlayer].frame, temp0, SpiralPath_spriteTable)
162
player[currentPlayer].rotation = 256 // flipY
163
end if
164
end if
165
end if
166
167
player[currentPlayer].gravity = GRAVITY_GROUND
168
end if
169
end if
170
171
temp2++
172
next
173
174
if object.outOfBounds == true
175
object.priority = PRIORITY_BOUNDS
176
177
temp0 = false
178
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
179
// Check if any players are still on the Spiral Path
180
BoxCollisionTest(C_TOUCH, object.entityPos, -192, 8, 192, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
181
temp0 |= checkResult
182
next
183
184
if temp0 == false
185
// If there aren't any players on it, then reset
186
object.activePlayers = 0
187
end if
188
end if
189
end event
190
191
192
// ========================
193
// Editor Events
194
// ========================
195
196
event RSDKDraw
197
DrawSprite(0)
198
199
if editor.showGizmos == true
200
editor.drawingOverlay = true
201
202
// Draw the movement path
203
temp0 = 0
204
while temp0 < 384
205
temp1 = temp0
206
temp1 -= 192
207
temp1 <<= 16
208
temp1 += object.xpos
209
GetTableValue(temp2, temp0, SpiralPath_offsetTable)
210
temp2 <<= 16
211
temp2 += object.ypos
212
213
DrawRectWorld(temp1, temp2, 2, 2, 255, 255, 255, 255)
214
temp0++
215
loop
216
217
editor.drawingOverlay = false
218
end if
219
end event
220
221
222
event RSDKLoad
223
LoadSpriteSheet("Global/Display.gif")
224
SpriteFrame(-16, -16, 32, 32, 1, 143)
225
226
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
227
end event
228
229