Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/FlowerPod/R6_FlowerPod.txt
1319 views
1
//---------------Sonic CD Flower Pod 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
// PodSeed Aliases
9
#alias Object.Value1 : Object.ParentPod
10
#alias Object.Value2 : Object.XVelocity
11
#alias Object.Value3 : Object.YVelocity
12
13
// States
14
#alias 0 : FLOWERPOD_IDLE
15
#alias 1 : FLOWERPOD_EXPLOSION
16
#alias 2 : FLOWERPOD_VANISH
17
#alias 3 : FLOWERPOD_TRIGGER_ACTFINISH
18
#alias 4 : FLOWERPOD_CONTROL_PLAYER
19
20
// Control Modes
21
#alias -1 : CONTROLMODE_NONE
22
23
// Ink Effects
24
#alias 2 : INK_ALPHA
25
26
// Gravity
27
#alias 0 : GRAVITY_GROUND
28
29
// Global SFX
30
#alias 22 : SFX_G_EXPLOSION
31
32
// Priority
33
#alias 1 : PRIORITY_ACTIVE
34
35
// Pod Seed Property Values
36
#alias 1 : TRIGGER_RESULTS
37
38
39
sub ObjectMain
40
switch Object.State
41
case FLOWERPOD_IDLE
42
TempValue0 = Object.YPos
43
TempValue0 += 0x40005A
44
if Player.YPos < TempValue0
45
Stage.NewXBoundary1 = Object.XPos
46
Stage.NewXBoundary1 >>= 16
47
Stage.NewXBoundary1 -= Screen.CenterX
48
49
Stage.NewXBoundary2 = Object.XPos
50
Stage.NewXBoundary2 >>= 16
51
Stage.NewXBoundary2 += Screen.CenterX
52
end if
53
54
if Object.Timer < 60
55
Object.Frame = 1
56
else
57
TempValue0 = Object.Timer
58
TempValue0 -= 60
59
TempValue0 >>= 1
60
switch TempValue0
61
case 0
62
Object.Frame = 2
63
break
64
case 1
65
case 2
66
Object.Frame = 1
67
break
68
case 3
69
Object.Frame = 2
70
break
71
case 4
72
case 5
73
Object.Frame = 1
74
break
75
case 6
76
Object.Frame = 2
77
break
78
end switch
79
end if
80
81
Object.Timer++
82
if Object.Timer == 74
83
Object.Timer = 0
84
end if
85
break
86
87
case FLOWERPOD_EXPLOSION
88
if Object.Timer < 120
89
Object.Timer++
90
91
TempValue0 = Object.Timer
92
TempValue0 &= 3
93
if TempValue0 == 3
94
Rand(TempValue0, 64)
95
TempValue0 -= 32
96
TempValue0 <<= 16
97
TempValue0 += Object.XPos
98
99
Rand(TempValue1, 40)
100
TempValue1 -= 40
101
TempValue1 <<= 16
102
TempValue1 += Object.YPos
103
104
CreateTempObject(TypeName[Explosion], 0, TempValue0, TempValue1)
105
PlaySfx(SFX_G_EXPLOSION, false)
106
end if
107
else
108
Object.State = FLOWERPOD_VANISH
109
Object.Timer = 256
110
Object.InkEffect = INK_ALPHA
111
Object.Alpha = 255
112
113
114
// Create all the Seeds that burst out of the Pod
115
116
// Starting point is 3 pixels left and 24 pixels up from the Flower Pod's position
117
TempValue0 = Object.XPos
118
TempValue0 -= 0x30000
119
TempValue1 = Object.YPos
120
TempValue1 -= 0x180000
121
122
// Create the leading seed, note its Property Value of 1 to signify that it should start level results upon landing
123
CreateTempObject(TypeName[Pod Seed], TRIGGER_RESULTS, TempValue0, TempValue1)
124
Object[TempObjectPos].XVelocity = -0x20000
125
Object[TempObjectPos].YVelocity = -0x60000
126
Object[TempObjectPos].ParentPod = Object.EntityNo
127
128
TempValue0 += 0x10000
129
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
130
Object[TempObjectPos].XVelocity = -0x15554
131
Object[TempObjectPos].YVelocity = -0x60000
132
133
TempValue0 += 0x10000
134
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
135
Object[TempObjectPos].XVelocity = -0xAAAA
136
Object[TempObjectPos].YVelocity = -0x60000
137
138
TempValue0 += 0x10000
139
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
140
Object[TempObjectPos].XVelocity = 0
141
Object[TempObjectPos].YVelocity = -0x60000
142
143
TempValue0 += 0x10000
144
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
145
Object[TempObjectPos].XVelocity = 0xAAAA
146
Object[TempObjectPos].YVelocity = -0x60000
147
148
TempValue0 += 0x10000
149
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
150
Object[TempObjectPos].XVelocity = 0x15554
151
Object[TempObjectPos].YVelocity = -0x60000
152
153
TempValue0 += 0x10000
154
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
155
Object[TempObjectPos].XVelocity = 0x20000
156
Object[TempObjectPos].YVelocity = -0x60000
157
end if
158
break
159
160
case FLOWERPOD_VANISH
161
if Object.Timer > 0
162
Object.Timer -= 16
163
Object.Alpha = Object.Timer
164
end if
165
break
166
167
case FLOWERPOD_TRIGGER_ACTFINISH
168
if Player.ControlMode == CONTROLMODE_NONE
169
Player.Left = false
170
Player.Right = true
171
Player.Up = false
172
Player.Down = false
173
Player.JumpHold = false
174
end if
175
176
TempValue0 = Object.XPos
177
TempValue0 += 0xA00000
178
if Player.XPos > TempValue0
179
PlayMusic(1)
180
Object.State = FLOWERPOD_CONTROL_PLAYER
181
Object[30].Type = TypeName[ActFinish]
182
Object[30].DrawOrder = 6
183
Object[30].Priority = PRIORITY_ACTIVE
184
end if
185
break
186
187
case FLOWERPOD_CONTROL_PLAYER
188
if Player.ControlMode == CONTROLMODE_NONE
189
Player.Right = true
190
end if
191
break
192
end switch
193
end sub
194
195
196
sub ObjectPlayerInteraction
197
if Object.State == FLOWERPOD_IDLE
198
// if Player.Animation == ANI_JUMPING // Standalone/Preplus check
199
200
CheckResult = false
201
if Player.Animation == ANI_JUMPING
202
CheckResult = true
203
end if
204
#platform: Use_Origins
205
if Stage.PlayerListPos == PLAYER_KNUCKLES
206
if Player.Animation == ANI_GLIDING
207
CheckResult = true
208
end if
209
if Player.Animation == ANI_GLIDING_STOP
210
CheckResult = true
211
end if
212
end if
213
if Stage.PlayerListPos == PLAYER_AMY
214
if Player.Animation == ANI_HAMMER_DASH
215
CheckResult = true
216
end if
217
if Player.Animation == ANI_HAMMER_JUMP
218
CheckResult = true
219
end if
220
end if
221
#endplatform
222
if CheckResult == true
223
#platform: Use_Origins
224
PlayerObjectCollision(C_ENEMY, -28, -46, 28, 6)
225
#endplatform
226
#platform: Use_Standalone
227
PlayerObjectCollision(C_TOUCH, -28, -46, 28, 6)
228
#endplatform
229
if CheckResult == true
230
Stage.TimeEnabled = false
231
232
Object.State = FLOWERPOD_EXPLOSION
233
Object.Frame = 3
234
Object.Timer = 0
235
236
Player.YVelocity >>= 1
237
FlipSign(Player.YVelocity)
238
239
#platform: Use_Haptics
240
HapticEffect(55, 0, 0, 0)
241
#endplatform
242
243
#platform: Use_Origins
244
// Tell HE2 that the boss fight ended
245
game.callbackParam0 = true
246
EngineCallback(NOTIFY_BOSS_END)
247
#endplatform
248
end if
249
end if
250
end if
251
TempValue0 = Screen.CenterX
252
TempValue0 += 40
253
TempValue0 <<= 16
254
255
TempValue1 = Object.XPos
256
TempValue1 += TempValue0
257
258
if Player.XPos > TempValue1
259
Player.XPos = TempValue1
260
Player.Speed = 0
261
Player.XVelocity = 0
262
if Player.Gravity == GRAVITY_GROUND
263
Player.YVelocity = 0
264
end if
265
end if
266
end sub
267
268
269
sub ObjectDraw
270
if Object.State < FLOWERPOD_VANISH
271
DrawSprite(0)
272
DrawSprite(Object.Frame)
273
else
274
DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)
275
DrawSpriteFX(Object.Frame, FX_INK, Object.XPos, Object.YPos)
276
end if
277
end sub
278
279
280
sub ObjectStartup
281
LoadSpriteSheet("R6/Objects2.gif")
282
283
SpriteFrame(-32, 6, 64, 42, 1, 55) // #0 - FlowerPod Stem
284
SpriteFrame(-32, -48, 64, 54, 1, 1) // #1 - FlowerPod Bulb
285
SpriteFrame(-32, -48, 64, 54, 1, 98) // #2 - FlowerPod Bulb Flash
286
SpriteFrame(-32, -10, 64, 16, 1, 153) // #3 - FlowerPod Bulb Destroyed
287
288
ArrayPos0 = 32
289
while ArrayPos0 < 1056
290
if Object[ArrayPos0].Type == TypeName[Flower Pod]
291
TempValue0 = Screen.CenterX
292
TempValue0 -= 160
293
TempValue0 <<= 16
294
Object[ArrayPos0].XPos -= TempValue0
295
end if
296
ArrayPos0++
297
loop
298
end sub
299
300
301
// ========================
302
// Editor Subs
303
// ========================
304
305
sub RSDKDraw
306
DrawSprite(0)
307
DrawSprite(1)
308
end sub
309
310
311
sub RSDKLoad
312
LoadSpriteSheet("R6/Objects2.gif")
313
314
SpriteFrame(-32, 6, 64, 42, 1, 55) // #0 - FlowerPod Stem
315
SpriteFrame(-32, -48, 64, 54, 1, 1) // #1 - FlowerPod Bulb
316
317
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
318
end sub
319
320