Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/ConveyorBelt.txt
1319 views
1
//----------------Sonic CD ConveyorBelt 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.BeltFrame
8
// HUD Alias
9
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
10
11
// Tile Aliases
12
#alias 1 : TILE_CONVEYORBELT
13
14
// Gravity
15
#alias 0 : GRAVITY_GROUND
16
17
// Time Periods
18
#alias 0 : TIME_PRESENT
19
#alias 1 : TIME_PAST
20
#alias 2 : TIME_GOOD_FUTURE
21
#alias 3 : TIME_BAD_FUTURE
22
23
// Priority
24
#alias 1 : PRIORITY_ACTIVE
25
26
// Tile Info
27
#alias 8 : TILEINFO_ANGLEB
28
29
30
sub ObjectPlayerInteraction
31
32
// Only affect the Player if they're on the Ground
33
if Player.Gravity == GRAVITY_GROUND
34
35
// The Tunnel state makes Players intangible to Conveyor Belts
36
if Player.State != Player_State_TubeRoll
37
38
// Get the X Position of the tile on the Player's right side
39
TempValue1 = Player.XPos
40
TempValue1 >>= 16
41
TempValue1 += Player.CollisionRight
42
43
// Get the Y Position of the tile right underneath tthe Player
44
TempValue2 = Player.YPos
45
TempValue2 >>= 16
46
TempValue2 += Player.CollisionBottom
47
TempValue2 += 2
48
49
// Get the B Angle/Flags value of the Tile at the specified positions
50
Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)
51
52
// See if it's a Conveyor Belt tile
53
if TempValue0 == TILE_CONVEYORBELT
54
55
// If it is, then move the Player in the corresponding direction and at the corresponding rate
56
if ConveyorBelt_Flag == FACING_RIGHT
57
Player.XPos += ConveyorBelt_Speed
58
else
59
Player.XPos -= ConveyorBelt_Speed
60
end if
61
62
else
63
64
// If the right tile did't have anything, then check the one to the Player's left
65
TempValue1 = Player.XPos
66
TempValue1 >>= 16
67
TempValue1 += Player.CollisionLeft
68
69
Get16x16TileInfo(TempValue0, TempValue1, TempValue2, TILEINFO_ANGLEB)
70
71
if TempValue0 == TILE_CONVEYORBELT
72
73
// If this one is a Conveyer tile, then convey the player
74
if ConveyorBelt_Flag == FACING_RIGHT
75
Player.XPos += ConveyorBelt_Speed
76
else
77
Player.XPos -= ConveyorBelt_Speed
78
end if
79
80
end if
81
end if
82
end if
83
84
end if
85
86
end sub
87
88
89
sub ObjectDraw
90
91
// Some palette cycling to make the Conveyer Belts look like they're moving
92
93
Object.Timer++
94
if Object.Timer == 5
95
Object.Timer = 0
96
Object.BeltFrame++
97
Object.BeltFrame %= 3
98
end if
99
100
TempValue0 = Object.BeltFrame
101
TempValue0 += ConveyorBelt_Flag
102
103
SetActivePalette(TempValue0, 0, 240)
104
105
end sub
106
107
108
sub ObjectStartup
109
110
// Place a ConveyorBelt Object into the scene
111
Object[19].Type = TypeName[ConveyorBelt]
112
113
// Make it active, because Conveyor Belts should always be pushing the Player
114
Object[19].Priority = PRIORITY_ACTIVE
115
116
// And give it a low Draw Order as well, but not too low!
117
// That's because, this Object's Draw Order has to be above the one used by the R5A Glow Effect!
118
// They both do palette trickery, so they have separate draw orders to make sure they don't interfere with each other
119
Object[19].DrawOrder = 1
120
121
// Setup the alternate palettes for the Conveyer Belt
122
CopyPalette(0, 1)
123
CopyPalette(0, 2)
124
CopyPalette(0, 3)
125
CopyPalette(0, 4)
126
CopyPalette(0, 5)
127
128
TempValue0 = 0
129
TempValue1 = 0
130
TempValue2 = 16
131
132
ConveyorBelt_Flag = 0
133
ConveyorBelt_Frame = 0
134
135
// Some Conveyor Belt properties that are different between time period
136
switch HUD.CurrentTimePeriod
137
case TIME_PRESENT
138
139
// Give the Conveyer Belts a speed of 1 pixel per frame
140
ConveyorBelt_Speed = 0x10000
141
142
// Setup the palette cycle for them, using the R5A bank
143
while TempValue0 < 6
144
LoadPalette("R5A_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)
145
TempValue1 += 16
146
TempValue2 += 16
147
148
LoadPalette("R5A_PalCycle.act", TempValue0, 192, TempValue1, TempValue2)
149
TempValue1 += 16
150
TempValue2 += 16
151
TempValue0++
152
loop
153
break
154
155
case TIME_PAST
156
157
// In the Past, technology wasn't as developed, so give the Conveyer Belts a slower speed of 0.5 pixels per frame
158
ConveyorBelt_Speed = 0x8000
159
160
// The Past's palette cycle should pull from the R5B palette bank
161
while TempValue0 < 6
162
LoadPalette("R5B_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)
163
TempValue1 += 16
164
TempValue2 += 16
165
TempValue0++
166
loop
167
break
168
169
case TIME_GOOD_FUTURE
170
171
// Technology is pretty advanced in the future, the Conveyer Belts have grown so much to have a speed of 2 pixels per frame now!
172
ConveyorBelt_Speed = 0x20000
173
174
// The Good Future uses the R5C bank
175
while TempValue0 < 6
176
LoadPalette("R5C_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)
177
TempValue1 += 16
178
TempValue2 += 16
179
TempValue0++
180
loop
181
break
182
183
case TIME_BAD_FUTURE
184
185
// Even after taking over the world, Eggman was kind enough to let Conveyer Belt innovations still continue!
186
// What a kind man, Conveyer Belts still go at a speed of 2 pixels per frame now!
187
ConveyorBelt_Speed = 0x20000
188
189
// Bad Future pulls from the R5D bank
190
while TempValue0 < 6
191
LoadPalette("R5D_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)
192
TempValue1 += 16
193
TempValue2 += 16
194
TempValue0++
195
loop
196
break
197
198
end switch
199
200
end sub
201
202
203
// ========================
204
// Editor Subs
205
// ========================
206
207
sub RSDKDraw
208
DrawSprite(0)
209
end sub
210
211
212
sub RSDKLoad
213
LoadSpriteSheet("Global/Display.gif")
214
SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon
215
216
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
217
end sub
218
219