Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/LampPost.txt
1319 views
1
//-----------------Sonic CD Lamp Post 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
8
// Player Aliases
9
#alias Player.Value0 : Player.Rings
10
11
//HUD alias
12
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
13
14
// States
15
#alias 0 : LAMPPOST_IDLE
16
#alias 1 : LAMPPOST_ROTATE
17
#alias 2 : LAMPPOST_USED
18
19
// Collision Sides
20
#alias 1 : CSIDE_LWALL
21
#alias 2 : CSIDE_RWALL
22
23
#alias 9 : SFX_G_LAMPPOST
24
25
// Time Periods
26
#alias 0 : TIME_PRESENT
27
28
29
sub ObjectPlayerInteraction
30
31
if Object.State == LAMPPOST_IDLE
32
33
PlayerObjectCollision(C_TOUCH, -8, -32, 8, 32)
34
if CheckResult == true
35
LampPost.Check = Object.EntityNo
36
37
if Player.XPos < Object.XPos
38
LampPost.Side = -0x180000
39
40
// Code to avoid getting stuck in a wall it seems?
41
ObjectTileCollision(CSIDE_RWALL, -24, 0, 0)
42
if CheckResult == true
43
LampPost.Side = 0
44
end if
45
46
else
47
LampPost.Side = 0x180000
48
49
ObjectTileCollision(CSIDE_LWALL, 24, 0, 0) // Code to avoid getting stuck in a wall i guess?
50
if CheckResult == true
51
LampPost.Side = 0
52
end if
53
54
end if
55
56
// Record a bunch of values
57
#platform: Use_Origins
58
recStage = Stage.ListPos
59
recScore = Player.Score
60
recRing = Player.Rings
61
#endplatform
62
63
Rec_Milliseconds = Stage.MilliSeconds
64
Rec_Seconds = Stage.Seconds
65
Rec_Minutes = Stage.Minutes
66
67
#platform: Use_Origins
68
StatsUsabilityParam1 = StageStatsUsabilityParam1
69
StatsUsabilityParam2 = StageStatsUsabilityParam2
70
StatsUsabilityParam3 = StageStatsUsabilityParam3
71
StatsUsabilityParam4 = StageStatsUsabilityParam4
72
StatsUsabilityParam5 = StageStatsUsabilityParam5
73
#endplatform
74
75
Object.State = LAMPPOST_ROTATE
76
Object.Timer = 384
77
PlaySfx(SFX_G_LAMPPOST, false)
78
79
#platform: Use_Haptics
80
HapticEffect(20, 0, 0, 0)
81
#endplatform
82
83
#platform: Use_Origins
84
// Let the Engine know if we've hit a checkpoint
85
if Options.AttractMode == false
86
EngineCallback(NOTIFY_TOUCH_CHECKPOINT)
87
end if
88
#endplatform
89
90
end if
91
92
end if
93
end sub
94
95
96
sub ObjectDraw
97
98
switch Object.State
99
case LAMPPOST_IDLE
100
DrawSprite(0)
101
break
102
103
case LAMPPOST_ROTATE
104
DrawSprite(1)
105
106
Cos(TempValue0, Object.Timer)
107
TempValue0 <<= 10
108
Sin(TempValue1, Object.Timer)
109
TempValue1 <<= 10
110
111
TempValue0 += Object.XPos
112
TempValue1 += Object.YPos
113
TempValue1 -= 0x180000
114
DrawSpriteXY(2, TempValue0, TempValue1)
115
116
Object.Timer += 16
117
if Object.Timer > 896
118
Object.Timer = 0
119
Object.State = LAMPPOST_USED
120
end if
121
break
122
123
case LAMPPOST_USED
124
DrawSprite(1)
125
Object.Timer++
126
if Object.Timer == 8
127
Object.Timer = 0
128
end if
129
130
TempValue0 = Object.YPos
131
TempValue0 -= 0x200000
132
if Object.Timer > 3
133
DrawSpriteXY(4, Object.XPos, TempValue0)
134
else
135
DrawSpriteXY(3, Object.XPos, TempValue0)
136
end if
137
break
138
end switch
139
end sub
140
141
142
sub ObjectStartup
143
144
LoadSpriteSheet("Global/Items.gif")
145
146
SpriteFrame(-8, -40, 16, 64, 1, 137) // #0 - Lamp Post Idle
147
SpriteFrame(-8, -24, 16, 48, 1, 153) // #1 - Lamp Post Body
148
SpriteFrame(-8, -8, 16, 16, 1, 137) // #2 - Lamp Post Blue Head
149
SpriteFrame(-8, -8, 16, 16, 1, 236) // #3 - Lamp Post Yellow Head
150
SpriteFrame(-8, -8, 16, 16, 18, 236) // #4 - Lamp Post Red Head
151
152
#platform: Use_Origins
153
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
154
if LampPost.Check > 31
155
ArrayPos0 = LampPost.Check
156
Player.XPos = Object[ArrayPos0].XPos
157
Player.XPos += LampPost.Side
158
Player.YPos = Object[ArrayPos0].YPos
159
160
Object[ArrayPos0].State = LAMPPOST_USED
161
162
Player.Score = recScore
163
164
if Player.deadResetRings == true
165
Player.Rings = 0
166
Player.deadResetRings = false
167
else
168
Player.Rings = recRing
169
end if
170
171
Ring.ExtraLife = 100
172
Ring.ExtraLife += Player.Rings
173
174
TempValue0 = Player.Rings
175
TempValue0 %= 100
176
177
Ring.ExtraLife -= TempValue0
178
if Ring.ExtraLife > 300
179
Ring.ExtraLife = 1000
180
end if
181
182
Stage.MilliSeconds = Rec_Milliseconds
183
Stage.Seconds = Rec_Seconds
184
Stage.Minutes = Rec_Minutes
185
end if
186
else
187
if Warp.XPos == 0
188
if HUD.CurrentTimePeriod == TIME_PRESENT
189
if LampPost.Check > 31
190
ArrayPos0 = LampPost.Check
191
Player.XPos = Object[ArrayPos0].XPos
192
Player.XPos += LampPost.Side
193
Player.YPos = Object[ArrayPos0].YPos
194
195
Object[ArrayPos0].State = LAMPPOST_USED
196
197
Player.Score = recScore
198
if Player.deadResetRings == true
199
Player.Rings = 0
200
Player.deadResetRings = false
201
else
202
Player.Rings = recRing
203
end if
204
205
Ring.ExtraLife = 100
206
Ring.ExtraLife += Player.Rings
207
208
TempValue0 = Player.Rings
209
TempValue0 %= 100
210
211
Ring.ExtraLife -= TempValue0
212
if Ring.ExtraLife > 300
213
Ring.ExtraLife = 1000
214
end if
215
216
Stage.MilliSeconds = Rec_Milliseconds
217
Stage.Seconds = Rec_Seconds
218
Stage.Minutes = Rec_Minutes
219
else
220
game.timeOver = false
221
end if
222
end if
223
end if
224
end if
225
226
if StageStatsUsabilityParam5 == 0
227
StageStatsUsabilityParam1 = StatsUsabilityParam1
228
StageStatsUsabilityParam2 = StatsUsabilityParam2
229
StageStatsUsabilityParam3 = StatsUsabilityParam3
230
StageStatsUsabilityParam4 = StatsUsabilityParam4
231
StageStatsUsabilityParam5 = StatsUsabilityParam5
232
end if
233
StageStatsUsabilityParam5 = 0
234
#endplatform
235
236
#platform: Use_Standalone
237
if Warp.XPos == 0
238
if HUD.CurrentTimePeriod == TIME_PRESENT
239
if LampPost.Check > 31
240
ArrayPos0 = LampPost.Check
241
Player.XPos = Object[ArrayPos0].XPos
242
Player.XPos += LampPost.Side
243
Player.YPos = Object[ArrayPos0].YPos
244
245
Object[ArrayPos0].State = LAMPPOST_USED
246
247
Stage.MilliSeconds = Rec_Milliseconds
248
Stage.Seconds = Rec_Seconds
249
Stage.Minutes = Rec_Minutes
250
end if
251
end if
252
end if
253
254
#endplatform
255
end sub
256
257
258
// ========================
259
// Editor Subs
260
// ========================
261
262
sub RSDKDraw
263
DrawSprite(0)
264
end sub
265
266
267
sub RSDKLoad
268
LoadSpriteSheet("Global/Items.gif")
269
SpriteFrame(-8, -40, 16, 64, 1, 137) // #0 - Lamp Post Idle
270
271
// unused, BUT there are values in the editor which suggest it's "lampPostID"
272
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
273
end sub
274
275