Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/Escalator.txt
1319 views
1
//----------------Sonic CD Escalator Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.OnObject
8
#alias Object.Value2 : Object.Speed
9
#alias Object.Value3 : Object.TimerSet
10
11
// HUD alias
12
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
13
14
// States
15
#alias 0 : ESCALATOR_IDLE
16
#alias 1 : ESCALATOR_ASCEND
17
#alias 2 : ESCALATOR_STOPPED
18
#alias 3 : ESCALATOR_RESTORE
19
20
// Player Collision
21
#alias 1 : PLAYER_COL_FLOOR
22
23
// Time Periods
24
#alias 0 : TIME_PRESENT
25
#alias 1 : TIME_PAST
26
#alias 2 : TIME_GOOD_FUTURE
27
#alias 3 : TIME_BAD_FUTURE
28
29
// Priority
30
#alias 0 : PRIORITY_BOUNDS
31
#alias 1 : PRIORITY_ACTIVE
32
33
34
35
sub ObjectMain
36
switch Object.State
37
case ESCALATOR_ASCEND
38
if Object.Timer > 0
39
Object.Timer--
40
Object.XPos += Object.Speed
41
Object.YPos -= Object.Speed
42
else
43
Object.State++
44
end if
45
break
46
47
case ESCALATOR_STOPPED
48
if Object.OutOfBounds == true
49
Object.State = ESCALATOR_RESTORE
50
Object.XPos -= 0xA00000
51
Object.YPos += 0xA00000
52
end if
53
break
54
55
case ESCALATOR_RESTORE
56
if Object.OutOfBounds == true
57
Object.State = ESCALATOR_IDLE
58
Object.Priority = PRIORITY_BOUNDS
59
end if
60
break
61
end switch
62
end sub
63
64
65
sub ObjectPlayerInteraction
66
switch Object.State
67
case ESCALATOR_IDLE
68
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
69
if CheckResult == PLAYER_COL_FLOOR
70
Object.State = ESCALATOR_ASCEND
71
Object.Timer = Object.TimerSet
72
Object.Priority = PRIORITY_ACTIVE
73
74
Player.TileCollisions = false
75
76
Object.OnObject = true
77
else
78
if Object.OnObject == true
79
Player.TileCollisions = true
80
end if
81
82
Object.OnObject = false
83
end if
84
break
85
86
case ESCALATOR_ASCEND
87
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
88
if CheckResult == PLAYER_COL_FLOOR
89
Player.XPos += Object.Speed
90
91
Player.TileCollisions = false
92
93
Object.OnObject = true
94
95
PlayerObjectCollision(C_BOX, 20, -32, 32, -16)
96
Player.Pushing = false
97
else
98
if Object.OnObject == true
99
Player.TileCollisions = true
100
end if
101
102
Object.OnObject = false
103
end if
104
break
105
106
case ESCALATOR_STOPPED
107
Player.Pushing = false
108
PlayerObjectCollision(C_BOX, -16, -16, 16, 16)
109
if CheckResult == PLAYER_COL_FLOOR
110
Player.TileCollisions = false
111
112
Object.OnObject = true
113
else
114
if Object.OnObject == true
115
Player.TileCollisions = true
116
end if
117
Object.OnObject = false
118
end if
119
break
120
121
end switch
122
end sub
123
124
125
sub ObjectDraw
126
if Object.State < ESCALATOR_RESTORE
127
DrawSprite(0)
128
end if
129
end sub
130
131
132
sub ObjectStartup
133
switch HUD.CurrentTimePeriod
134
case TIME_PRESENT
135
case TIME_PAST
136
LoadSpriteSheet("R4/Objects.gif")
137
SpriteFrame(-16, -16, 32, 32, 130, 1) // #0 - Escalator
138
break
139
140
case TIME_GOOD_FUTURE
141
LoadSpriteSheet("R4/Objects3.gif")
142
SpriteFrame(-16, -16, 32, 32, 1, 150) // #0 - Escalator
143
break
144
145
case TIME_BAD_FUTURE
146
LoadSpriteSheet("R4/Objects3.gif")
147
SpriteFrame(-16, -16, 32, 32, 1, 183) // #0 - Escalator
148
break
149
150
end switch
151
152
ArrayPos0 = 32
153
while ArrayPos0 < 1056
154
if Object[ArrayPos0].Type == TypeName[Escalator]
155
if HUD.CurrentTimePeriod < 2 // aka present or past
156
Object[ArrayPos0].Speed = 0x10000
157
Object[ArrayPos0].TimerSet = 160
158
else
159
Object[ArrayPos0].Speed = 0x20000
160
Object[ArrayPos0].TimerSet = 80
161
end if
162
end if
163
ArrayPos0++
164
loop
165
end sub
166
167
168
// ========================
169
// Editor Subs
170
// ========================
171
172
sub RSDKDraw
173
DrawSprite(0)
174
end sub
175
176
177
sub RSDKLoad
178
CallFunction(EditorHelpers_FindTimePeriod)
179
switch CheckResult
180
case TIME_PRESENT
181
case TIME_PAST
182
LoadSpriteSheet("R4/Objects.gif")
183
SpriteFrame(-16, -16, 32, 32, 130, 1) // #0 - Escalator
184
break
185
186
case TIME_GOOD_FUTURE
187
LoadSpriteSheet("R4/Objects3.gif")
188
SpriteFrame(-16, -16, 32, 32, 1, 150) // #0 - Escalator
189
break
190
191
case TIME_BAD_FUTURE
192
LoadSpriteSheet("R4/Objects3.gif")
193
SpriteFrame(-16, -16, 32, 32, 1, 183) // #0 - Escalator
194
break
195
196
end switch
197
198
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
199
end sub
200
201