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