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