Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/ARZ/AirBubble.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Air Bubble Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.originPos.x
14
private alias object.value2 : object.targetPlayer
15
private alias object.value3 : object.bubbleUsed
16
17
// States
18
private alias 0 : AIRBUBBLE_ACTIVE
19
private alias 1 : AIRBUBBLE_USED
20
21
// Player Aliases
22
private alias object.state : player.state
23
private alias object.xvel : player.xvel
24
private alias object.yvel : player.yvel
25
private alias object.speed : player.speed
26
private alias object.animationSpeed : player.animationSpeed
27
private alias object.animation : player.animation
28
private alias object.value3 : player.drownTimer
29
private alias object.value4 : player.drownLevel
30
private alias object.value36 : player.flyCarryTimer
31
private alias object.value37 : player.shield
32
33
// Shield constants
34
private alias 2 : SHIELD_BUBBLE
35
36
event ObjectUpdate
37
currentPlayer = object.targetPlayer
38
if object.state == AIRBUBBLE_ACTIVE
39
object.timer++
40
if object.timer > 15
41
object.timer = 0
42
43
if object.frame == 8
44
object.type = TypeName[Blank Object]
45
end if
46
47
if object.frame < object.propertyValue
48
object.frame++
49
end if
50
end if
51
52
object.ypos += object.yvel
53
if currentPlayer != 0xFFFF
54
if player[currentPlayer].state == Player_State_Clinging
55
if object.propertyValue < 3
56
object.originPos.x += 0x40000
57
end if
58
end if
59
end if
60
61
if object.frame < 7
62
Sin(object.xpos, object.angle)
63
object.xpos <<= 9
64
object.xpos += object.originPos.x
65
object.angle += 4
66
object.angle &= 0x1FF
67
end if
68
69
if object.iypos < stage.waterLevel
70
if object.propertyValue == 6
71
object.frame = 7
72
object.propertyValue = 8
73
object.timer = 0
74
object.yvel = 0
75
else
76
if object.propertyValue < 6
77
object.type = TypeName[Blank Object]
78
end if
79
end if
80
end if
81
else
82
CheckEqual(player[currentPlayer].animation, ANI_HURT)
83
temp0 = checkResult
84
CheckEqual(player[currentPlayer].animation, ANI_DYING)
85
temp0 |= checkResult
86
if temp0 != 0
87
object.bubbleUsed = false
88
end if
89
90
if object.timer < 20
91
object.timer++
92
if object.bubbleUsed != false
93
player[currentPlayer].animation = ANI_BREATHING
94
end if
95
96
if object.timer > 9
97
object.frame = 8
98
end if
99
else
100
object.type = TypeName[Blank Object]
101
if object.bubbleUsed != false
102
player[currentPlayer].animation = ANI_WALKING
103
player[currentPlayer].animationSpeed = 20
104
end if
105
end if
106
end if
107
108
if object.outOfBounds == true
109
object.type = TypeName[Blank Object]
110
end if
111
112
if object.frame == 6
113
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
114
if player[currentPlayer].animation != ANI_DYING
115
if player[currentPlayer].shield != SHIELD_BUBBLE
116
BoxCollisionTest(C_TOUCH, object.entityPos, -2, -2, 2, 2, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
117
if checkResult == true
118
object.frame = 7
119
object.state = 1
120
object.timer = 0
121
object.yvel = 0
122
object.targetPlayer = currentPlayer
123
player[currentPlayer].yvel = 0
124
player[currentPlayer].xvel = 0
125
player[currentPlayer].speed = 0
126
CheckEqual(player[currentPlayer].animation, ANI_FLYING)
127
temp0 = checkResult
128
CheckEqual(player[currentPlayer].animation, ANI_FLYINGTIRED)
129
temp0 |= checkResult
130
CheckEqual(player[currentPlayer].animation, ANI_SWIM_LIFT)
131
temp0 |= checkResult
132
CheckEqual(player[currentPlayer].animation, ANI_GLIDING)
133
temp0 |= checkResult
134
CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)
135
temp0 |= checkResult
136
CheckEqual(player[currentPlayer].animation, ANI_CLIMBING)
137
temp0 |= checkResult
138
CheckEqual(player[currentPlayer].animation, ANI_LEDGEPULLUP)
139
temp0 |= checkResult
140
CheckEqual(player[currentPlayer].animation, ANI_CLINGING)
141
temp0 |= checkResult
142
CheckEqual(player[currentPlayer].animation, ANI_FANROTATE)
143
temp0 |= checkResult
144
if temp0 == false
145
player[currentPlayer].animation = ANI_BREATHING
146
object.bubbleUsed = true
147
end if
148
149
player[currentPlayer].drownTimer = 0
150
player[currentPlayer].drownLevel = 0
151
if player[currentPlayer].state == Player_State_RollJump
152
#platform: USE_STANDALONE
153
player[currentPlayer].state = Player_State_Air
154
#endplatform
155
#platform: USE_ORIGINS
156
player[currentPlayer].state = Player_State_Air_NoDropDash
157
#endplatform
158
end if
159
160
if player[currentPlayer].state == Player_State_Carried
161
#platform: USE_STANDALONE
162
player[currentPlayer].state = Player_State_Air
163
#endplatform
164
#platform: USE_ORIGINS
165
player[currentPlayer].state = Player_State_Air_NoDropDash
166
#endplatform
167
player[1].flyCarryTimer = 30
168
end if
169
PlaySfx(SfxName[Breathing], false)
170
end if
171
end if
172
end if
173
next
174
end if
175
end event
176
177
178
event ObjectDraw
179
DrawSprite(object.frame)
180
end event
181
182
183
event ObjectStartup
184
// Likely an oversignt made when copying scripts from CPZ - for some reason the CPZ sheet is loaded despite this being ARZ
185
// The ARZ version of this sheet exists too, but it remains unused because of this
186
LoadSpriteSheet("CPZ/Objects3.gif")
187
188
// Bubble frames
189
SpriteFrame(-2, -2, 4, 4, 157, 2)
190
SpriteFrame(-3, -3, 6, 6, 156, 9)
191
SpriteFrame(-4, -4, 8, 8, 155, 17)
192
SpriteFrame(-6, -6, 12, 12, 209, 36)
193
SpriteFrame(-8, -8, 16, 16, 207, 51)
194
SpriteFrame(-12, -12, 24, 24, 164, 1)
195
SpriteFrame(-16, -16, 32, 32, 189, 1)
196
SpriteFrame(-16, -16, 32, 32, 222, 1)
197
SpriteFrame(-15, -15, 30, 30, 224, 34)
198
end event
199
200
201
// ========================
202
// Editor Events
203
// ========================
204
205
event RSDKDraw
206
DrawSprite(0)
207
end event
208
209
210
event RSDKLoad
211
LoadSpriteSheet("ARZ/Objects3.gif")
212
SpriteFrame(-16, -16, 32, 32, 222, 1)
213
214
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
215
end event
216
217