Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/FlowerPod/R7_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
// Game Mode Aliases
24
#alias 2 : MODE_TIMEATTACK
25
26
// Ink Effects
27
#alias 2 : INK_ALPHA
28
29
// Player
30
#alias 0 : PLAYER_SONIC_A
31
32
// Gravity
33
#alias 0 : GRAVITY_GROUND
34
35
// Global SFX
36
#alias 22 : SFX_G_EXPLOSION
37
38
// Priority
39
#alias 1 : PRIORITY_ACTIVE
40
41
// Pod Seed Property Values
42
#alias 1 : TRIGGER_RESULTS
43
44
45
sub ObjectMain
46
switch Object.State
47
case FLOWERPOD_IDLE
48
if Object.Timer < 60
49
Object.Frame = 1
50
else
51
TempValue0 = Object.Timer
52
TempValue0 -= 60
53
TempValue0 >>= 1
54
switch TempValue0
55
case 0
56
Object.Frame = 2
57
break
58
case 1
59
case 2
60
Object.Frame = 1
61
break
62
case 3
63
Object.Frame = 2
64
break
65
case 4
66
case 5
67
Object.Frame = 1
68
break
69
case 6
70
Object.Frame = 2
71
break
72
end switch
73
end if
74
75
Object.Timer++
76
if Object.Timer == 74
77
Object.Timer = 0
78
end if
79
break
80
81
case FLOWERPOD_EXPLOSION
82
if Object.Timer < 120
83
Object.Timer++
84
85
TempValue0 = Object.Timer
86
TempValue0 &= 3
87
if TempValue0 == 3
88
Rand(TempValue0, 64)
89
TempValue0 -= 32
90
TempValue0 <<= 16
91
TempValue0 += Object.XPos
92
93
Rand(TempValue1, 40)
94
TempValue1 -= 40
95
TempValue1 <<= 16
96
TempValue1 += Object.YPos
97
98
CreateTempObject(TypeName[Explosion], 0, TempValue0, TempValue1)
99
PlaySfx(SFX_G_EXPLOSION, false)
100
end if
101
else
102
Object.State = FLOWERPOD_VANISH
103
Object.Timer = 256
104
Object.InkEffect = INK_ALPHA
105
Object.Alpha = 255
106
107
108
// Create all the Seeds that burst out of the Pod
109
110
// Starting point is 3 pixels left and 24 pixels up from the Flower Pod's position
111
TempValue0 = Object.XPos
112
TempValue0 -= 0x30000
113
TempValue1 = Object.YPos
114
TempValue1 -= 0x180000
115
116
// Create the leading seed, note its Property Value of 1 to signify that it should start level results upon landing
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 = false
165
Player.Up = false
166
Player.Down = false
167
Player.JumpHold = false
168
PlayMusic(1)
169
Object.State = FLOWERPOD_CONTROL_PLAYER
170
Object[30].Type = TypeName[ActFinish]
171
Object[30].DrawOrder = 6
172
Object[30].Priority = PRIORITY_ACTIVE
173
end if
174
break
175
176
case FLOWERPOD_CONTROL_PLAYER
177
if Player.ControlMode == CONTROLMODE_NONE
178
Player.Right = false
179
end if
180
break
181
end switch
182
end sub
183
184
185
sub ObjectPlayerInteraction
186
if Object.State == FLOWERPOD_IDLE
187
// if Player.Animation == ANI_JUMPING // Standalone/Preplus check
188
189
CheckResult = false
190
if Player.Animation == ANI_JUMPING
191
CheckResult = true
192
end if
193
#platform: Use_Origins
194
if Stage.PlayerListPos == PLAYER_KNUCKLES
195
if Player.Animation == ANI_GLIDING
196
CheckResult = true
197
end if
198
if Player.Animation == ANI_GLIDING_STOP
199
CheckResult = true
200
end if
201
end if
202
if Stage.PlayerListPos == PLAYER_AMY
203
if Player.Animation == ANI_HAMMER_DASH
204
CheckResult = true
205
end if
206
if Player.Animation == ANI_HAMMER_JUMP
207
CheckResult = true
208
end if
209
end if
210
#endplatform
211
if CheckResult == true
212
#platform: Use_Origins
213
PlayerObjectCollision(C_ENEMY, -28, -46, 28, 6)
214
#endplatform
215
#platform: Use_Standalone
216
PlayerObjectCollision(C_TOUCH, -28, -46, 28, 6)
217
#endplatform
218
if CheckResult == true
219
Stage.TimeEnabled = false
220
221
Object.State = FLOWERPOD_EXPLOSION
222
Object.Frame = 3
223
Object.Timer = 0
224
225
Player.YVelocity >>= 1
226
FlipSign(Player.YVelocity)
227
228
#platform: Use_Haptics
229
HapticEffect(55, 0, 0, 0)
230
#endplatform
231
232
#platform: Use_Origins
233
// Tell the engine that the boss fight has ended
234
game.callbackParam0 = true
235
EngineCallback(NOTIFY_BOSS_END)
236
#endplatform
237
end if
238
end if
239
end if
240
end sub
241
242
243
sub ObjectDraw
244
if Object.State < FLOWERPOD_VANISH
245
DrawSprite(0)
246
DrawSprite(Object.Frame)
247
else
248
DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)
249
DrawSpriteFX(Object.Frame, FX_INK, Object.XPos, Object.YPos)
250
end if
251
end sub
252
253
254
sub ObjectStartup
255
LoadSpriteSheet("R7/Objects2.gif")
256
257
SpriteFrame(-32, 6, 64, 42, 1, 55) // #0 - FlowerPod Stem
258
SpriteFrame(-32, -48, 64, 54, 1, 1) // #1 - FlowerPod Bulb
259
SpriteFrame(-32, -48, 64, 54, 1, 98) // #2 - FlowerPod Bulb Flash
260
SpriteFrame(-32, -10, 64, 16, 1, 153) // #3 - FlowerPod Bulb Destroyed
261
262
// Unload the Flowepod object if needed
263
ArrayPos0 = 32
264
while ArrayPos0 < 1056
265
if Object[ArrayPos0].Type == TypeName[Flower Pod]
266
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
267
if Options.GameMode != MODE_TIMEATTACK
268
// If Sonic's the main character and he's not in Time Attack, then unload
269
Object[ArrayPos0].Type = TypeName[Blank Object]
270
end if
271
end if
272
end if
273
ArrayPos0++
274
loop
275
end sub
276
277
278
// ========================
279
// Editor Subs
280
// ========================
281
282
sub RSDKDraw
283
DrawSprite(0)
284
DrawSprite(1)
285
end sub
286
287
288
sub RSDKLoad
289
LoadSpriteSheet("R7/Objects2.gif")
290
SpriteFrame(-32, 6, 64, 42, 1, 55)
291
SpriteFrame(-32, -48, 64, 54, 1, 1)
292
293
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
294
end sub
295
296