Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/RPlatform.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.Raising
7
#alias Object.Value1 : Object.Timer
8
#alias Object.Value2 : Object.YPlayerFloor
9
#alias Object.Value3 : Object.YVelocity
10
#alias Object.Value4 : Object.YOriginPos
11
#alias Object.Value5 : Object.RiseTimer
12
13
// States
14
#alias 0 : RISEPLATFORM_IDLE
15
#alias 1 : RISEPLATFORM_DELAY
16
#alias 2 : RISEPLATFORM_ASCEND
17
#alias 3 : RISEPLATFORM_DELAY_2
18
#alias 4 : RISEPLATFORM_SLOW
19
#alias 5 : RISEPLATFORM_FLOAT
20
#alias 6 : RISEPLATFORM_RESET
21
22
// Priority
23
#alias 0 : PRIORITY_BOUNDS
24
#alias 1 : PRIORITY_ACTIVE
25
26
27
sub ObjectMain
28
if Object.OutOfBounds == true
29
Object.YPos = Object.YOriginPos
30
Object.State = RISEPLATFORM_RESET
31
Object.Timer = 0
32
end if
33
34
switch Object.State
35
case RISEPLATFORM_IDLE
36
Object.YPlayerFloor = 0
37
if Object.Raising == true
38
Object.State = RISEPLATFORM_DELAY
39
40
Object.Priority = PRIORITY_ACTIVE
41
42
Object.YVelocity = 0
43
Object.RiseTimer = 0
44
end if
45
break
46
47
case RISEPLATFORM_DELAY
48
Object.YPlayerFloor = Object.YVelocity
49
if Object.RiseTimer < 8
50
Object.RiseTimer++
51
else
52
Object.RiseTimer = 0
53
Object.State++
54
end if
55
break
56
57
case RISEPLATFORM_ASCEND
58
if Object.YVelocity > -0x40000
59
Object.YVelocity -= 0x1000
60
else
61
Object.State++
62
end if
63
64
Object.YPlayerFloor = Object.YVelocity
65
break
66
67
case RISEPLATFORM_DELAY_2
68
if Object.RiseTimer < 36
69
Object.RiseTimer++
70
else
71
Object.RiseTimer = 0
72
Object.State++
73
end if
74
75
Object.YPlayerFloor = Object.YVelocity
76
break
77
78
case RISEPLATFORM_SLOW
79
if Object.YVelocity < 0
80
Object.YVelocity += 0x1000
81
else
82
Object.State++
83
end if
84
Object.YPlayerFloor = Object.YVelocity
85
break
86
87
case RISEPLATFORM_FLOAT
88
if Object.Raising == true
89
if Object.Timer < 16
90
Object.Timer++
91
92
TempValue0 = Object.Timer
93
TempValue0 &= 3
94
95
if TempValue0 == 3
96
Object.YPlayerFloor = 0x10000
97
else
98
Object.YPlayerFloor = 0
99
end if
100
else
101
Object.YPlayerFloor = 0
102
end if
103
else
104
if Object.Timer > 0
105
Object.Timer--
106
107
TempValue0 = Object.Timer
108
TempValue0 &= 3
109
110
if TempValue0 == 3
111
Object.YPlayerFloor = -0x10000
112
else
113
Object.YPlayerFloor = 0
114
end if
115
else
116
Object.YPlayerFloor = 0
117
end if
118
end if
119
break
120
121
case RISEPLATFORM_RESET
122
if Object.OutOfBounds == true
123
Object.State = RISEPLATFORM_IDLE
124
Object.Priority = PRIORITY_BOUNDS
125
end if
126
break
127
128
end switch
129
Object.Raising = false
130
end sub
131
132
133
sub ObjectPlayerInteraction
134
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)
135
if CheckResult == true
136
Object.Raising = true
137
Player.YPos += Object.YPlayerFloor
138
end if
139
end sub
140
141
142
sub ObjectDraw
143
Object.YPos += Object.YPlayerFloor
144
DrawSprite(0)
145
end sub
146
147
148
sub ObjectStartup
149
LoadSpriteSheet("R3/Objects.gif")
150
151
SpriteFrame(-32, -16, 64, 32, 100, 1) // Rise Platform
152
153
ArrayPos0 = 32
154
while ArrayPos0 < 1056
155
if Object[ArrayPos0].Type == TypeName[R Platform]
156
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
157
end if
158
ArrayPos0++
159
loop
160
end sub
161
162
163
// ========================
164
// Editor Subs
165
// ========================
166
167
sub RSDKDraw
168
DrawSprite(0)
169
170
if Editor.ShowGizmos == true
171
TempValue0 = Object.iYPos
172
TempValue0 -= 420
173
TempValue0 <<= 16
174
175
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 255, 0)
176
end if
177
end sub
178
179
180
sub RSDKLoad
181
LoadSpriteSheet("R3/Objects.gif")
182
183
SpriteFrame(-32, -16, 64, 32, 100, 1) // Rise Platform
184
185
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
186
end sub
187
188