Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/RisePlatform2.txt
1319 views
1
//--------------Sonic CD Rise Platform 2 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 : RISEPLATFORM2_AWAITPLAYER
15
#alias 1 : RISEPLATFORM2_PRELAUNCH
16
#alias 2 : RISEPLATFORM2_LAUNCH
17
#alias 3 : RISEPLATFORM2_RISE
18
#alias 4 : RISEPLATFORM2_HALT
19
#alias 5 : RISEPLATFORM2_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 RISEPLATFORM2_AWAITPLAYER
30
// Waiting for the Player to step on it to Launch
31
32
Object.ChangeY = 0
33
34
if Object.Pressed == true
35
// If the Player's stepped onto the Platform, then get ready to launch
36
Object.State = RISEPLATFORM2_PRELAUNCH
37
38
Object.Priority = PRIORITY_ACTIVE
39
40
Object.YVelocity = 0
41
Object.Timer = 0
42
end if
43
break
44
45
case RISEPLATFORM2_PRELAUNCH
46
// Pausing for a moment before Launching
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 RISEPLATFORM2_LAUNCH
59
60
// If the Object hasn't yet reached a speed of 4px per frame, then make it go faster by 0.0625 more per frame
61
if Object.YVelocity > -0x40000
62
Object.YVelocity -= 0x1000
63
else
64
// Sufficient speed reached, go to the next timer-based State
65
Object.State++
66
end if
67
68
Object.ChangeY = Object.YVelocity
69
break
70
71
case RISEPLATFORM2_RISE
72
// Just rise for a brief moment
73
74
if Object.Timer < 14
75
Object.Timer++
76
else
77
// Time's up, start slowing down...
78
Object.Timer = 0
79
Object.State++
80
end if
81
82
Object.ChangeY = Object.YVelocity
83
break
84
85
case RISEPLATFORM2_HALT
86
87
// Until the Object is fully stopped, decelerate it at a speed of 0.0625 pixels per frame
88
if Object.YVelocity < 0
89
Object.YVelocity += 0x1000
90
else
91
// Special Delivery!
92
Object.State++
93
end if
94
95
Object.ChangeY = Object.YVelocity
96
break
97
98
case RISEPLATFORM2_ARRIVED
99
// Now, the Object just acts as a standard Platform
100
101
if Object.Pressed == true
102
if Object.PlatformY < 16
103
Object.PlatformY++
104
TempValue0 = Object.PlatformY
105
TempValue0 &= 3
106
if TempValue0 == 3
107
Object.ChangeY = 0x10000
108
else
109
Object.ChangeY = 0
110
end if
111
else
112
Object.ChangeY = 0
113
end if
114
else
115
if Object.PlatformY > 0
116
Object.PlatformY--
117
TempValue0 = Object.PlatformY
118
TempValue0 &= 3
119
if TempValue0 == 3
120
Object.ChangeY = -0x10000
121
else
122
Object.ChangeY = 0
123
end if
124
else
125
Object.ChangeY = 0
126
end if
127
end if
128
break
129
130
end switch
131
132
// If the Object is Out Of Bounds, check to see if it's origin Position is OOB too before moving it back
133
if Object.OutOfBounds == true
134
135
TempValue0 = Object.YPos
136
Object.YPos = Object.StartPosY
137
138
if Object.OutOfBounds == true
139
Object.PlatformY = 0
140
Object.State = RISEPLATFORM2_AWAITPLAYER
141
else
142
Object.YPos = TempValue0
143
end if
144
145
end if
146
147
Object.Pressed = false
148
149
end sub
150
151
152
sub ObjectPlayerInteraction
153
154
PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)
155
156
if CheckResult == true
157
Object.Pressed = true
158
Player.YPos += Object.ChangeY
159
end if
160
161
end sub
162
163
164
sub ObjectDraw
165
166
Object.YPos += Object.ChangeY
167
DrawSprite(0)
168
169
end sub
170
171
172
sub ObjectStartup
173
174
LoadSpriteSheet("R5/Objects.gif")
175
176
// Large Platform Frame
177
SpriteFrame(-48, -16, 96, 32, 1, 84)
178
179
// Cycle through every Rise Platform 2 Object in the Scene
180
ArrayPos0 = 32
181
while ArrayPos0 < 1056
182
if Object[ArrayPos0].Type == TypeName[Rise Platform 2]
183
184
// Store the Object's Starting Position
185
Object[ArrayPos0].StartPosY = Object[ArrayPos0].YPos
186
187
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
188
189
end if
190
191
ArrayPos0++
192
loop
193
194
end sub
195
196
197
// ========================
198
// Editor Subs
199
// ========================
200
201
sub RSDKDraw
202
DrawSprite(0)
203
204
if Editor.ShowGizmos == true
205
// Draw the Platform's destination
206
207
TempValue0 = Object.YPos
208
TempValue0 -= 20971520
209
210
Editor.DrawingOverlay = true
211
212
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 255)
213
214
Editor.DrawingOverlay = false
215
end if
216
end sub
217
218
219
sub RSDKLoad
220
LoadSpriteSheet("R5/Objects.gif")
221
SpriteFrame(-48, -16, 96, 32, 1, 84)
222
223
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
224
end sub
225
226