Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/RisePlatform.txt
1319 views
1
//---------------Sonic CD Rise Platform Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Pressed
7
#alias Object.Value1 : Object.PlatformY
8
#alias Object.Value2 : Object.ChangeY
9
#alias Object.Value3 : Object.YVelocity
10
#alias Object.Value4 : Object.StartPosY
11
#alias Object.Value5 : Object.Timer
12
13
// States
14
#alias 0 : RISEPLATFORM_AWAITPLAYER
15
#alias 1 : RISEPLATFORM_PRELAUNCH
16
#alias 2 : RISEPLATFORM_LAUNCH
17
#alias 3 : RISEPLATFORM_RISE
18
#alias 4 : RISEPLATFORM_HALT
19
#alias 5 : RISEPLATFORM_ARRIVED
20
21
// Priority
22
#alias 1 : PRIORITY_ACTIVE
23
#alias 3 : PRIORITY_XBOUNDS
24
25
26
sub ObjectMain
27
28
switch Object.State
29
case RISEPLATFORM_AWAITPLAYER
30
Object.ChangeY = 0
31
32
if Object.Pressed == true
33
// If the Player's stepped onto the Platform, then get ready
34
35
Object.State = RISEPLATFORM_PRELAUNCH
36
37
// Make the Object always active, needed for its respawn restoring method
38
Object.Priority = PRIORITY_ACTIVE
39
40
Object.YVelocity = 0
41
Object.Timer = 0
42
end if
43
break
44
45
case RISEPLATFORM_PRELAUNCH
46
// Dip for a moment before taking off
47
48
Object.ChangeY = Object.YVelocity
49
50
if Object.Timer < 8
51
Object.Timer++
52
else
53
Object.Timer = 0
54
Object.State++
55
end if
56
break
57
58
case RISEPLATFORM_LAUNCH
59
60
// If the Object hasn't yet reached a speed of 5 pixels per frame, then...
61
if Object.YVelocity > -0x50000
62
// Speed it up at a rate of 0.0625 pixels per frame upwards
63
Object.YVelocity -= 0x1000
64
else
65
// Ideal Velocity reached, switch to the timer-based State now
66
Object.State++
67
end if
68
69
Object.ChangeY = Object.YVelocity
70
break
71
72
case RISEPLATFORM_RISE
73
if Object.Timer < 80
74
// Just rise for about a second and some
75
Object.Timer++
76
else
77
Object.Timer = 0
78
Object.State++
79
end if
80
81
Object.ChangeY = Object.YVelocity
82
break
83
84
case RISEPLATFORM_HALT
85
86
// Until the Object's fully stopped, decelerate at a rate of 0.0625 pixels per frame
87
if Object.YVelocity < 0
88
Object.YVelocity += 0x1000
89
else
90
// Ding! - And now we've arrived!
91
Object.State++
92
end if
93
94
Object.ChangeY = Object.YVelocity
95
break
96
97
case RISEPLATFORM_ARRIVED
98
// From here, the Object just acts as a normal Platform
99
100
if Object.Pressed == true
101
if Object.PlatformY < 16
102
Object.PlatformY++
103
TempValue0 = Object.PlatformY
104
TempValue0 &= 3
105
if TempValue0 == 3
106
Object.ChangeY = 0x10000
107
else
108
Object.ChangeY = 0
109
end if
110
else
111
Object.ChangeY = 0
112
end if
113
else
114
if Object.PlatformY > 0
115
Object.PlatformY--
116
TempValue0 = Object.PlatformY
117
TempValue0 &= 3
118
if TempValue0 == 3
119
Object.ChangeY = -0x10000
120
else
121
Object.ChangeY = 0
122
end if
123
else
124
Object.ChangeY = 0
125
end if
126
end if
127
break
128
129
end switch
130
131
// If the Object is Out Of Bounds, then...
132
if Object.OutOfBounds == true
133
134
// First, backup the object's current Y Position
135
TempValue0 = Object.YPos
136
137
// Then, move the Object back to its starting Y Position
138
Object.YPos = Object.StartPosY
139
140
// See if this new, original position is Out Of Bounds too
141
if Object.OutOfBounds == true
142
143
// If it is, then restore the Object to its original state (incl. keeping it at its starting position, from above)
144
Object.PlatformY = 0
145
Object.State = RISEPLATFORM_AWAITPLAYER
146
147
else
148
149
// That spot is still in bounds, so in order to prevent teleporting in front of the Player,
150
// Move the Platform back to its current Y Position
151
Object.YPos = TempValue0
152
153
end if
154
end if
155
156
// Reset for next frame
157
Object.Pressed = false
158
159
end sub
160
161
162
sub ObjectPlayerInteraction
163
164
PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)
165
166
if CheckResult == true
167
// If the Player is on the Platform, then move the Player along with it and let the Platform Object know
168
Object.Pressed = true
169
Player.YPos += Object.ChangeY
170
end if
171
172
end sub
173
174
175
sub ObjectDraw
176
177
// Movement is done here rather than ObjectMain because of the ObjectPlayerInteraction inbetween
178
Object.YPos += Object.ChangeY
179
180
// And now just draw the Platform at its Position, no DrawSpriteXY needed here or anything!
181
DrawSprite(0)
182
183
end sub
184
185
186
sub ObjectStartup
187
LoadSpriteSheet("R5/Objects.gif")
188
189
// Small Platform Frame
190
SpriteFrame(-16, -16, 32, 32, 1, 51)
191
192
// Cycle through all Rise Platform Objects in the Stage
193
ArrayPos0 = 32
194
while ArrayPos0 < 1056
195
if Object[ArrayPos0].Type == TypeName[Rise Platform]
196
197
// Store the Platform's starting Y Position
198
Object[ArrayPos0].StartPosY = Object[ArrayPos0].YPos
199
200
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
201
202
end if
203
204
ArrayPos0++
205
loop
206
207
end sub
208
209
210
// ========================
211
// Editor Subs
212
// ========================
213
214
sub RSDKDraw
215
DrawSprite(0)
216
217
if Editor.ShowGizmos == true
218
Editor.DrawingOverlay = true
219
220
// Draw the Platform's destination
221
222
TempValue0 = Object.YPos
223
TempValue0 -= 53084160
224
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 255)
225
226
Editor.DrawingOverlay = false
227
end if
228
end sub
229
230
231
sub RSDKLoad
232
LoadSpriteSheet("R5/Objects.gif")
233
SpriteFrame(-16, -16, 32, 32, 1, 51)
234
235
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
236
end sub
237
238