Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/AirBubble.txt
1319 views
1
//-----------------Sonic CD Air Bubble 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
#alias Object.Value1 : Object.Angle
8
#alias Object.Value2 : Object.XVelocity
9
#alias Object.Value3 : Object.YVelocity
10
11
#alias Player.Value14 : Player.DropDashCharge
12
13
// States
14
#alias 0 : AIRBUBBLE_ACTIVE
15
#alias 1 : AIRBUBBLE_USED
16
17
// Stage SFX
18
#alias 6 : SFX_S_BREATHING
19
20
// Air Bubble Property Values
21
#alias 2 : BUBBLE_SMALL
22
#alias 4 : BUBBLE_MEDIUM
23
#alias 5 : BUBBLE_BREATHABLE
24
#alias 6 : BUBBLE_EXPLODE
25
26
27
sub ObjectMain
28
if Object.State == AIRBUBBLE_ACTIVE
29
Object.Timer++
30
if Object.Timer > 15
31
Object.Timer = 0
32
if Object.Frame == 6
33
Object.Type = TypeName[Blank Object]
34
end if
35
// Property value determines the max size of the bubble
36
if Object.Frame < Object.PropertyValue
37
Object.Frame++
38
end if
39
end if
40
41
Object.YPos += Object.YVelocity
42
43
// Small bubbles fly away while sonic is pushed by water streams
44
if Player.Animation == ANI_FANROTATE
45
if Object.PropertyValue < 3
46
Object.XVelocity += 0x40000
47
end if
48
end if
49
if Player.Animation == ANI_CLINGING
50
if Object.PropertyValue < 3
51
Object.XVelocity += 0x40000
52
end if
53
end if
54
55
if Object.Frame < 6
56
Sin(Object.XPos, Object.Angle)
57
Object.XPos <<= 9
58
Object.XPos += Object.XVelocity
59
60
Object.Angle += 4
61
Object.Angle &= 511
62
end if
63
64
if Object.iYPos < Stage.WaterLevel
65
if Object.PropertyValue == BUBBLE_BREATHABLE
66
Object.Frame = 6
67
Object.PropertyValue = BUBBLE_EXPLODE
68
Object.Timer = 0
69
Object.YVelocity = 0
70
else
71
// Despawn small and medium bubbles above water level
72
if Object.PropertyValue < 5
73
Object.Type = TypeName[Blank Object]
74
end if
75
end if
76
end if
77
78
else
79
if Object.Timer < 20
80
Object.Timer++
81
Player.Animation = ANI_BREATHING
82
else
83
Object.Type = TypeName[Blank Object]
84
85
Player.Animation = ANI_WALKING
86
Player.AnimationSpeed = 20
87
88
#platform: Use_Origins
89
if Player.State == Player_State_GlideRight
90
Player.Animation = ANI_GLIDING
91
end if
92
if Player.State == Player_State_GlideLeft
93
Player.Animation = ANI_GLIDING
94
end if
95
96
if Player.DropDashCharge >= 20
97
Player.PrevAnimation = ANI_WALKING
98
Player.AnimationSpeed = 200
99
end if
100
#endplatform
101
end if
102
end if
103
104
if Object.OutOfBounds == true
105
Object.Type = TypeName[Blank Object]
106
end if
107
end sub
108
109
110
sub ObjectPlayerInteraction
111
if Object.Frame == 5
112
PlayerObjectCollision(C_TOUCH, -4, -4, 4, 4)
113
if CheckResult == true
114
Object.Frame = 6
115
Object.State = AIRBUBBLE_USED
116
Object.Timer = 0
117
Object.YVelocity = 0
118
119
Player.YVelocity = 0
120
Player.XVelocity = 0
121
Player.Speed = 0
122
Player.Animation = ANI_BREATHING
123
Player.AirTimer = 0
124
PlayStageSfx(SFX_S_BREATHING, false)
125
end if
126
end if
127
end sub
128
129
130
sub ObjectDraw
131
DrawSprite(Object.Frame)
132
end sub
133
134
135
sub ObjectStartup
136
LoadSpriteSheet("R4/Objects.gif")
137
138
SpriteFrame(-4, -4, 8, 8, 212, 61) // #0 - Small Bubble
139
SpriteFrame(-4, -4, 8, 8, 212, 70) // #1 - Small Bubble 2
140
SpriteFrame(-4, -4, 8, 8, 246, 18) // #2 - Small Bubble 3
141
SpriteFrame(-8, -8, 16, 16, 116, 181) // #3 - Medium Bubble
142
SpriteFrame(-8, -8, 16, 16, 116, 198) // #4 - Medium Bubble 2
143
SpriteFrame(-16, -16, 32, 32, 148, 194) // #5 - Big Bubble
144
SpriteFrame(-16, -16, 32, 32, 181, 201) // #6 - Big Bubble 2
145
end sub
146
147
148
// ========================
149
// Editor Subs
150
// ========================
151
152
sub RSDKDraw
153
DrawSprite(0)
154
end sub
155
156
157
sub RSDKLoad
158
LoadSpriteSheet("R4/Objects.gif")
159
SpriteFrame(-16, -16, 32, 32, 148, 194) // #5 - Big Bubble
160
161
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
162
end sub
163
164