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