Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/FPlatform.txt
1319 views
1
//---------------Sonic CD Fall Platform Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Falling
7
#alias Object.Value1 : Object.Timer
8
#alias Object.Value2 : Object.YPlayerFloor
9
#alias Object.Value3 : Object.FallTimer
10
#alias Object.Value4 : Object.YVelocity
11
#alias Object.Value5 : Object.YOriginPos
12
13
// States
14
#alias 0 : FALLPLATFORM_IDLE
15
#alias 1 : FALLPLATFORM_CRUMBLE
16
#alias 2 : FALLPLATFORM_FALL
17
#alias 3 : FALLPLATFORM_RESTORE
18
19
// Property Values
20
#alias 0 : FALLING_PLATFORM
21
#alias 1 : STATIC_PLATFORM
22
23
// Priority
24
#alias 0 : PRIORITY_BOUNDS
25
#alias 1 : PRIORITY_ACTIVE
26
27
28
sub ObjectMain
29
if Object.Falling == true
30
31
if Object.State == FALLPLATFORM_IDLE
32
Object.State = FALLPLATFORM_CRUMBLE
33
end if
34
35
if Object.Timer < 16
36
Object.Timer++
37
38
TempValue0 = Object.Timer
39
TempValue0 &= 3
40
41
if TempValue0 == 3
42
Object.YPlayerFloor = 0x10000
43
else
44
Object.YPlayerFloor = 0
45
end if
46
47
else
48
Object.YPlayerFloor = 0
49
end if
50
51
else
52
if Object.Timer > 0
53
Object.Timer--
54
55
TempValue0 = Object.Timer
56
TempValue0 &= 3
57
58
if TempValue0 == 3
59
Object.YPlayerFloor = -0x10000
60
else
61
Object.YPlayerFloor = 0
62
end if
63
64
else
65
Object.YPlayerFloor = 0
66
end if
67
68
end if
69
Object.Falling = false
70
71
if Object.PropertyValue == FALLING_PLATFORM
72
switch Object.State
73
case FALLPLATFORM_CRUMBLE
74
if Object.FallTimer < 30
75
Object.FallTimer++
76
else
77
Object.YVelocity = 0
78
Object.FallTimer = 0
79
Object.State = FALLPLATFORM_FALL
80
Object.Priority = PRIORITY_ACTIVE
81
end if
82
break
83
84
case FALLPLATFORM_FALL
85
if Object.YVelocity < 0x40000
86
Object.YVelocity += 0x2000
87
end if
88
Object.YPlayerFloor += Object.YVelocity
89
if Object.OutOfBounds == true
90
Object.YPos = Object.YOriginPos
91
Object.State = FALLPLATFORM_RESTORE
92
Object.YVelocity = 0
93
end if
94
break
95
96
case FALLPLATFORM_RESTORE
97
if Object.OutOfBounds == true
98
Object.State = FALLPLATFORM_IDLE
99
Object.Priority = PRIORITY_BOUNDS
100
end if
101
break
102
end switch
103
end if
104
end sub
105
106
107
sub ObjectPlayerInteraction
108
if Object.State < FALLPLATFORM_RESTORE
109
PlayerObjectCollision(C_PLATFORM, -32, -9, 32, 12)
110
if CheckResult == true
111
Object.Falling = true
112
Player.YPos += Object.YPlayerFloor
113
end if
114
end if
115
end sub
116
117
118
sub ObjectDraw
119
Object.YPos += Object.YPlayerFloor
120
if Object.State < FALLPLATFORM_RESTORE
121
DrawSprite(0)
122
end if
123
end sub
124
125
126
sub ObjectStartup
127
LoadSpriteSheet("R1/Objects.gif")
128
129
SpriteFrame(-32, -16, 64, 32, 101, 109) // #0 - Fall Platform
130
131
ArrayPos0 = 32
132
while ArrayPos0 < 1056
133
if Object[ArrayPos0].Type == TypeName[Fall Platform]
134
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
135
end if
136
ArrayPos0++
137
loop
138
end sub
139
140
141
// ========================
142
// Editor Subs
143
// ========================
144
145
sub RSDKEdit
146
if Editor.ReturnVariable == true
147
switch Editor.VariableID
148
case EDIT_VAR_PROPVAL // Property Value
149
CheckResult = Object.PropertyValue
150
CheckResult &= 1
151
break
152
case 0 // type
153
CheckResult = Object.PropertyValue
154
CheckResult &= 1
155
break
156
end switch
157
else
158
switch Editor.VariableID
159
case EDIT_VAR_PROPVAL // Property Value
160
Object.PropertyValue = Editor.VariableValue
161
Object.PropertyValue &= 1
162
break
163
case 0 // type
164
Object.PropertyValue = Editor.VariableValue
165
Object.PropertyValue &= 1
166
break
167
end switch
168
end if
169
end sub
170
171
172
sub RSDKDraw
173
DrawSprite(0)
174
end sub
175
176
177
sub RSDKLoad
178
LoadSpriteSheet("R1/Objects.gif")
179
SpriteFrame(-32, -16, 64, 32, 101, 109) // #0 - Fall Platform
180
181
AddEditorVariable("type")
182
SetActiveVariable("type")
183
AddEnumVariable("Falling Platform", 0)
184
AddEnumVariable("Static Platform", 1)
185
end sub
186
187