Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/UFOPowerUp.txt
1319 views
1
//---------------Sonic CD UFO Power Up Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.ExplosionDir
7
#alias Object.Value1 : Object.ExplosionXVel
8
#alias Object.Value2 : Object.ExplosionYVel
9
#alias Object.Value3 : Object.Timer
10
#alias Object.Value4 : Object.YVelocity
11
#alias Object.Value5 : Object.ScreenDepth // Not used in this script, but set by the parent UFO Object upon spawning
12
#alias Object.Value6 : Object.ExplosionTimer
13
#alias Object.Value7 : Object.StartResults
14
15
// Player aliases
16
#alias Object.State : SSSonic.State
17
18
#alias 9 : SSSONIC_CAMERAPAN
19
20
// Stage Finish Aliases
21
#alias 8 : STAGEFINISH_LOADTIMEATTACK
22
#alias 9 : STAGEFINISH_LOADCREDITS
23
24
// SFX aliases
25
#alias 22 : SFX_G_EXPLOSION
26
27
// Game Mode Aliases
28
#alias 2 : MODE_TIMEATTACK
29
30
31
sub ObjectDraw
32
// If the Object isn't falling at a rate of 4px downwards per frame yet, then update movements
33
if Object.YVelocity < 0x40000
34
35
// Draw the Power Up icon
36
DrawSpriteScreenXY(Object.PropertyValue, Object.iXPos, Object.iYPos)
37
38
// Apply an eighth pixel's worth of gravity per frame
39
Object.YVelocity += 0x2000
40
41
// And then update the Power Up's position itself
42
Object.YPos += Object.YVelocity
43
end if
44
45
// Create explosions as needed
46
Object.ExplosionTimer++
47
if Object.ExplosionTimer == 6
48
Object.ExplosionTimer = 0
49
PlaySfx(SFX_G_EXPLOSION, false)
50
51
// Randomise the explosion offset a tad bit
52
Rand(TempValue0, 48)
53
TempValue0 -= 24
54
TempValue0 += Screen.XOffset
55
TempValue0 <<= 16
56
TempValue0 += Object.ExplosionXVel
57
58
Rand(TempValue1, 48)
59
TempValue1 -= 24
60
TempValue1 += Screen.YOffset
61
TempValue1 <<= 16
62
TempValue1 += Object.ExplosionYVel
63
64
CreateTempObject(TypeName[Smoke Puff], 0, TempValue0, TempValue1)
65
66
Object[TempObjectPos].DrawOrder = 4
67
end if
68
69
// This value is randomised by the parent UFO object already, this Object doesn't set it itself
70
if Object.ExplosionDir > 50
71
// Moving to the bottom right corner of the screen
72
73
Object.ExplosionXVel += 0x20000
74
else
75
// Moving to the bottom left corner of the screen
76
77
Object.ExplosionXVel -= 0x20000
78
end if
79
80
// Make the explosions gravitate to the bottom corner of the screen, at a rate of 0.75 pixels per frame
81
Object.ExplosionYVel += 0xC000
82
83
Object.Timer++
84
if Object.Timer == 160
85
if Object.StartResults == true
86
// If this object was the spawned by the last UFO, then end the stage
87
// -> StartResults is set by the parent UFO when spawning this Power Up
88
89
if Options.GameMode < MODE_TIMEATTACK
90
if Stage.ActNo < 8
91
// If in a normal Special Stage, then hand the rest of the ending sequence to Sonic
92
93
SSSonic[2].State = SSSONIC_CAMERAPAN
94
else
95
// If in the hidden Robotnik Special Stage, then go ahead and load the credits
96
97
Object[30].Type = TypeName[Stage Finish]
98
Object[30].State = STAGEFINISH_LOADCREDITS
99
Object[30].DrawOrder = 7
100
end if
101
else
102
// If in time attack, then go ahead and fade out to the TA Menu scene
103
104
Object[30].Type = TypeName[Stage Finish]
105
Object[30].State = STAGEFINISH_LOADTIMEATTACK
106
Object[30].DrawOrder = 0
107
end if
108
end if
109
110
Object.Type = TypeName[Blank Object]
111
end if
112
113
end sub
114
115
116
sub ObjectStartup
117
118
LoadSpriteSheet("Special/Objects.gif")
119
120
// 0 - Ring Icon
121
SpriteFrame(-8, -8, 16, 16, 1, 67)
122
123
// 1 - Speed Shoes Icon
124
SpriteFrame(-8, -8, 16, 16, 18, 67)
125
126
// 2 - Clock Icon
127
SpriteFrame(-8, -8, 16, 16, 35, 67)
128
129
end sub
130
131
132
// ========================
133
// Editor Subs
134
// ========================
135
136
sub RSDKDraw
137
DrawSprite(0)
138
end sub
139
140
141
sub RSDKLoad
142
LoadSpriteSheet("Special/Objects.gif")
143
SpriteFrame(-8, -8, 16, 16, 1, 67)
144
145
// Although used by the object, it shouldn't be set by the editor
146
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
147
end sub
148
149