Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/FlowerPod/R3_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
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
TempValue0 = Object.XPos
114
TempValue0 -= 0x30000
115
TempValue1 = Object.YPos
116
TempValue1 -= 0x180000
117
CreateTempObject(TypeName[Pod Seed], TRIGGER_RESULTS, TempValue0, TempValue1)
118
Object[TempObjectPos].XVelocity = -0x20000
119
Object[TempObjectPos].YVelocity = -0x60000
120
Object[TempObjectPos].ParentPod = Object.EntityNo
121
122
TempValue0 += 0x10000
123
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
124
Object[TempObjectPos].XVelocity = -0x15554
125
Object[TempObjectPos].YVelocity = -0x60000
126
127
TempValue0 += 0x10000
128
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
129
Object[TempObjectPos].XVelocity = -0xAAAA
130
Object[TempObjectPos].YVelocity = -0x60000
131
132
TempValue0 += 0x10000
133
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
134
Object[TempObjectPos].XVelocity = 0
135
Object[TempObjectPos].YVelocity = -0x60000
136
137
TempValue0 += 0x10000
138
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
139
Object[TempObjectPos].XVelocity = 0xAAAA
140
Object[TempObjectPos].YVelocity = -0x60000
141
142
TempValue0 += 0x10000
143
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
144
Object[TempObjectPos].XVelocity = 0x15554
145
Object[TempObjectPos].YVelocity = -0x60000
146
147
TempValue0 += 0x10000
148
CreateTempObject(TypeName[Pod Seed], 0, TempValue0, TempValue1)
149
Object[TempObjectPos].XVelocity = 0x20000
150
Object[TempObjectPos].YVelocity = -0x60000
151
end if
152
break
153
154
case FLOWERPOD_VANISH
155
if Object.Timer > 0
156
Object.Timer -= 16
157
Object.Alpha = Object.Timer
158
end if
159
break
160
161
case FLOWERPOD_TRIGGER_ACTFINISH
162
if Player.ControlMode == CONTROLMODE_NONE
163
Player.Left = false
164
Player.Right = true
165
Player.Up = false
166
Player.Down = false
167
Player.JumpHold = false
168
end if
169
170
TempValue0 = Object.XPos
171
TempValue0 += 0xA00000
172
173
if Player.XPos > TempValue0
174
PlayMusic(1)
175
Object.State = FLOWERPOD_CONTROL_PLAYER
176
Object[30].Type = TypeName[ActFinish]
177
Object[30].DrawOrder = 6
178
Object[30].Priority = PRIORITY_ACTIVE
179
end if
180
break
181
182
case FLOWERPOD_CONTROL_PLAYER
183
if Player.ControlMode == CONTROLMODE_NONE
184
Player.Right = true
185
end if
186
break
187
end switch
188
end sub
189
190
191
sub ObjectPlayerInteraction
192
if Object.State == FLOWERPOD_IDLE
193
// if Player.Animation == ANI_JUMPING // Standalone/Preplus check
194
195
CheckResult = false
196
if Player.Animation == ANI_JUMPING
197
CheckResult = true
198
end if
199
#platform: Use_Origins
200
if Stage.PlayerListPos == PLAYER_KNUCKLES
201
if Player.Animation == ANI_GLIDING
202
CheckResult = true
203
end if
204
if Player.Animation == ANI_GLIDING_STOP
205
CheckResult = true
206
end if
207
end if
208
if Stage.PlayerListPos == PLAYER_AMY
209
if Player.Animation == ANI_HAMMER_DASH
210
CheckResult = true
211
end if
212
if Player.Animation == ANI_HAMMER_JUMP
213
CheckResult = true
214
end if
215
end if
216
#endplatform
217
if CheckResult == true
218
#platform: Use_Origins
219
PlayerObjectCollision(C_ENEMY, -28, -46, 28, 6)
220
#endplatform
221
#platform: Use_Standalone
222
PlayerObjectCollision(C_TOUCH, -28, -46, 28, 6)
223
#endplatform
224
if CheckResult == true
225
Stage.TimeEnabled = false
226
227
Object.State = FLOWERPOD_EXPLOSION
228
Object.Frame = 3
229
Object.Timer = 0
230
231
Player.YVelocity >>= 1
232
FlipSign(Player.YVelocity)
233
234
#platform: Use_Haptics
235
HapticEffect(55, 0, 0, 0)
236
#endplatform
237
238
#platform: Use_Origins
239
// Tell HE2 that the boss fight ended
240
game.callbackParam0 = true
241
EngineCallback(NOTIFY_BOSS_END)
242
#endplatform
243
end if
244
end if
245
end if
246
TempValue0 = Screen.CenterX
247
TempValue0 += 40
248
TempValue0 <<= 16
249
250
TempValue1 = Object.XPos
251
TempValue1 += TempValue0
252
253
if Player.XPos > TempValue1
254
Player.XPos = TempValue1
255
Player.Speed = 0
256
Player.XVelocity = 0
257
if Player.Gravity == GRAVITY_GROUND
258
Player.YVelocity = 0
259
end if
260
end if
261
end sub
262
263
264
sub ObjectDraw
265
if Object.State < FLOWERPOD_VANISH
266
DrawSprite(0)
267
DrawSprite(Object.Frame)
268
else
269
DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)
270
DrawSpriteFX(Object.Frame, FX_INK, Object.XPos, Object.YPos)
271
end if
272
end sub
273
274
275
sub ObjectStartup
276
LoadSpriteSheet("R3/Objects3.gif")
277
278
SpriteFrame(-32, 6, 64, 42, 1, 55) // #0 - FlowerPod Stem
279
SpriteFrame(-32, -48, 64, 54, 1, 1) // #1 - FlowerPod Bulb
280
SpriteFrame(-32, -48, 64, 54, 1, 98) // #2 - FlowerPod Bulb Flash
281
SpriteFrame(-32, -10, 64, 16, 1, 153) // #3 - FlowerPod Bulb Destroyed
282
283
ArrayPos0 = 32
284
while ArrayPos0 < 1056
285
if Object[ArrayPos0].Type == TypeName[Flower Pod]
286
TempValue0 = Screen.CenterX
287
TempValue0 -= 160
288
TempValue0 <<= 16
289
Object[ArrayPos0].XPos -= TempValue0
290
end if
291
ArrayPos0++
292
loop
293
end sub
294
295
296
// ========================
297
// Editor Subs
298
// ========================
299
300
sub RSDKDraw
301
DrawSprite(0)
302
DrawSprite(1)
303
end sub
304
305
306
sub RSDKLoad
307
LoadSpriteSheet("R3/Objects3.gif")
308
309
SpriteFrame(-32, 6, 64, 42, 1, 55) // #0 - FlowerPod Stem
310
SpriteFrame(-32, -48, 64, 54, 1, 1) // #1 - FlowerPod Bulb
311
312
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
313
end sub
314
315