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