Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/MovingSpikes.txt
1319 views
1
//---------------Sonic CD Moving Spikes 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.OffSet
8
9
// Player Aliases
10
#alias Player.Value4 : Player.InvincibleTimer
11
12
// Gravity
13
#alias 1 : GRAVITY_AIR
14
15
// States
16
#alias 0 : MOVINGSPIKES_IDLE
17
#alias 1 : MOVINGSPIKES_RETRIEVE
18
#alias 2 : MOVINGSPIKES_HIDE
19
#alias 3 : MOVINGSPIKES_REVEAL
20
21
// Property Values
22
#alias 0 : MOVINGSPIKES_DIRECTION_UP
23
#alias 1 : MOVINGSPIKES_DIRECTION_RIGHT
24
#alias 2 : MOVINGSPIKES_DIRECTION_LEFT
25
#alias 3 : MOVINGSPIKES_DIRECTION_DOWN
26
27
// Stage SFX
28
#alias 4 : SFX_S_SPIKES
29
30
31
sub ObjectMain
32
switch Object.State
33
case MOVINGSPIKES_IDLE
34
if Object.Timer < 60
35
Object.Timer++
36
else
37
Object.State = MOVINGSPIKES_RETRIEVE
38
Object.Timer = 0
39
PlayStageSfx(SFX_S_SPIKES, false)
40
end if
41
break
42
43
case MOVINGSPIKES_RETRIEVE
44
if Object.OffSet < 0x200000
45
Object.OffSet += 0x80000
46
else
47
Object.State = MOVINGSPIKES_HIDE
48
end if
49
break
50
51
case MOVINGSPIKES_HIDE
52
if Object.Timer < 60
53
Object.Timer++
54
else
55
Object.State = MOVINGSPIKES_REVEAL
56
Object.Timer = 0
57
58
PlayStageSfx(SFX_S_SPIKES, false)
59
end if
60
break
61
62
case MOVINGSPIKES_REVEAL
63
if Object.OffSet > 0
64
Object.OffSet -= 0x80000
65
else
66
Object.State = MOVINGSPIKES_IDLE
67
end if
68
break
69
70
end switch
71
end sub
72
73
74
sub ObjectPlayerInteraction
75
TempValue0 = Object.OffSet
76
TempValue0 >>= 16
77
TempValue0 -= 16
78
TempValue1 = TempValue0
79
TempValue1 += 32
80
81
switch Object.PropertyValue
82
case MOVINGSPIKES_DIRECTION_UP
83
if Player.State != Player_State_Hurt
84
PlayerObjectCollision(C_BOX, -16, TempValue0, 16, TempValue1)
85
end if
86
87
if Object.State != MOVINGSPIKES_HIDE
88
if Player.YVelocity > -1
89
if Player.InvincibleTimer == 0
90
PlayerObjectCollision(C_TOUCH, -15, -18, 15, -12)
91
if CheckResult == true
92
Player.State = Player_State_GotHit
93
Player.Gravity = GRAVITY_AIR
94
95
Player.YPos -= 0x10000
96
if Player.XPos > Object.XPos
97
Player.Speed = 0x20000
98
else
99
Player.Speed = -0x20000
100
end if
101
end if
102
end if
103
end if
104
end if
105
break
106
107
case MOVINGSPIKES_DIRECTION_RIGHT
108
FlipSign(TempValue0)
109
FlipSign(TempValue1)
110
111
PlayerObjectCollision(C_BOX, TempValue1, -16, TempValue0, 16)
112
if Object.State != MOVINGSPIKES_HIDE
113
if Player.InvincibleTimer == 0
114
115
PlayerObjectCollision(C_TOUCH, 8, -15, 18, 15)
116
if CheckResult == true
117
Player.State = Player_State_GotHit
118
119
Player.Speed = 0x20000
120
end if
121
end if
122
end if
123
break
124
125
case MOVINGSPIKES_DIRECTION_LEFT
126
PlayerObjectCollision(C_BOX, TempValue0, -16, TempValue1, 16)
127
if Object.State != MOVINGSPIKES_HIDE
128
if Player.InvincibleTimer == 0
129
130
PlayerObjectCollision(C_TOUCH, -18, -15, -8, 15)
131
if CheckResult == true
132
Player.State = Player_State_GotHit
133
134
Player.Speed = -0x20000
135
end if
136
end if
137
end if
138
break
139
140
case MOVINGSPIKES_DIRECTION_DOWN
141
FlipSign(TempValue0)
142
FlipSign(TempValue1)
143
PlayerObjectCollision(C_BOX, -16, TempValue1, 16, TempValue0)
144
if Object.State != MOVINGSPIKES_HIDE
145
if Player.YVelocity < 1
146
if Player.InvincibleTimer == 0
147
148
PlayerObjectCollision(C_TOUCH, -14, 12, 14, 18)
149
if CheckResult == true
150
Player.State = Player_State_GotHit
151
if Player.XPos > Object.XPos
152
Player.Speed = 0x20000
153
else
154
Player.Speed = -0x20000
155
end if
156
end if
157
end if
158
end if
159
end if
160
break
161
end switch
162
end sub
163
164
165
sub ObjectDraw
166
switch Object.PropertyValue
167
case MOVINGSPIKES_DIRECTION_UP
168
TempValue0 = Object.YPos
169
TempValue0 += Object.OffSet
170
DrawSpriteXY(Object.PropertyValue, Object.XPos, TempValue0)
171
break
172
173
case MOVINGSPIKES_DIRECTION_RIGHT
174
TempValue0 = Object.XPos
175
TempValue0 -= Object.OffSet
176
DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)
177
break
178
179
case MOVINGSPIKES_DIRECTION_LEFT
180
TempValue0 = Object.XPos
181
TempValue0 += Object.OffSet
182
DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)
183
break
184
185
case MOVINGSPIKES_DIRECTION_DOWN
186
TempValue0 = Object.YPos
187
TempValue0 -= Object.OffSet
188
DrawSpriteXY(Object.PropertyValue, Object.XPos, TempValue0)
189
break
190
191
end switch
192
end sub
193
194
195
sub ObjectStartup
196
LoadSpriteSheet("Global/Items3.gif")
197
198
SpriteFrame(-16, -16, 32, 32, 50, 1) // #0 - Spikes facing up
199
SpriteFrame(-16, -16, 32, 32, 50, 34) // #1 - Spikes facing right
200
SpriteFrame(-16, -16, 32, 32, 50, 67) // #2 - Spikes facing left
201
SpriteFrame(-16, -16, 32, 32, 50, 100) // #3 - Spikes facing down
202
end sub
203
204
205
// ========================
206
// Editor Subs
207
// ========================
208
209
sub RSDKEdit
210
if Editor.ReturnVariable == true
211
switch Editor.VariableID
212
case EDIT_VAR_PROPVAL // Property Value
213
CheckResult = Object.PropertyValue
214
break
215
case 0 // Orientation
216
CheckResult = Object.PropertyValue
217
break
218
end switch
219
else
220
switch Editor.VariableID
221
case EDIT_VAR_PROPVAL // Property Value
222
Object.PropertyValue = Editor.VariableValue
223
break
224
case 0 // Orientation
225
Object.PropertyValue = Editor.VariableValue
226
break
227
end switch
228
end if
229
end sub
230
231
232
sub RSDKDraw
233
DrawSprite(Object.PropertyValue)
234
end sub
235
236
237
sub RSDKLoad
238
LoadSpriteSheet("Global/Items3.gif")
239
SpriteFrame(-16, -16, 32, 32, 50, 1) // #0 - Spikes facing up
240
SpriteFrame(-16, -16, 32, 32, 50, 34) // #1 - Spikes facing right
241
SpriteFrame(-16, -16, 32, 32, 50, 67) // #2 - Spikes facing left
242
SpriteFrame(-16, -16, 32, 32, 50, 100) // #3 - Spikes facing down
243
244
AddEditorVariable("Orientation")
245
SetActiveVariable("Orientation")
246
AddEnumVariable("Up", 0)
247
AddEnumVariable("Right", 1)
248
AddEnumVariable("Left", 2)
249
AddEnumVariable("Down", 3)
250
end sub
251
252