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/AirBubbler.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Air Bubbler 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.propertyValue : object.numDuds
13
14
private alias object.value0 : object.timer
15
private alias object.value1 : object.bubbleType2
16
private alias object.value2 : object.bubbleType1
17
private alias object.value3 : object.bubbleFlags
18
private alias object.value4 : object.dudsRemaining
19
20
// AirBubble object aliases
21
private alias object.value1 : airBubble.originPos.y
22
private alias object.value2 : airBubble.targetPlayer
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function AirBubbler_DebugDraw
29
reserve function AirBubbler_DebugSpawn
30
31
32
// ========================
33
// Tables
34
// ========================
35
36
private table AirBubbler_bubbleSizes
37
2, 4, 2, 2, 2, 2, 4, 2, 4, 2, 2, 4, 2, 4, 2, 2, 4, 2
38
end table
39
40
41
// ========================
42
// Function Definitions
43
// ========================
44
45
private function AirBubbler_DebugDraw
46
DrawSprite(0)
47
end function
48
49
50
private function AirBubbler_DebugSpawn
51
CreateTempObject(TypeName[Air Bubbler], 0, object.xpos, object.ypos)
52
object[tempObjectPos].drawOrder = 4
53
object[tempObjectPos].dudsRemaining = 0
54
end function
55
56
57
// ========================
58
// Events
59
// ========================
60
61
event ObjectUpdate
62
object.frame++
63
object.frame %= 48
64
65
if object.iypos > stage.waterLevel
66
temp0 = object.ixpos
67
temp0 -= camera[0].xpos
68
Abs(temp0)
69
70
if temp0 < screen.xcenter
71
temp0 = object.iypos
72
temp0 -= camera[0].ypos
73
Abs(temp0)
74
75
if temp0 < screen.ycenter
76
temp1 = false
77
78
if object.bubbleFlags == 0
79
object.timer--
80
81
if object.timer < 0
82
SetBit(object.bubbleFlags, 0, true)
83
Rand(object.bubbleType1, 0xFFFF)
84
object.bubbleType2 = object.bubbleType1
85
object.bubbleType1 %= 6
86
object.bubbleType2 &= 12
87
object.dudsRemaining--
88
89
if object.dudsRemaining < 0
90
object.dudsRemaining = object.numDuds
91
SetBit(object.bubbleFlags, 1, true)
92
end if
93
94
temp1 = true
95
end if
96
else
97
object.timer--
98
99
if object.timer < 0
100
temp1 = true
101
end if
102
end if
103
104
if temp1 == true
105
// Randomize the time the next bubble is created
106
Rand(object.timer, 32)
107
108
// Get bubble offset
109
Rand(temp0, 17)
110
temp0 -= 8
111
temp0 <<= 16
112
temp0 += object.xpos
113
114
// Create the air bubble
115
CreateTempObject(TypeName[Air Bubble], 2, temp0, object.ypos)
116
117
// Set its values and such
118
airBubble[tempObjectPos].originPos.y = object[tempObjectPos].xpos
119
Rand(object[tempObjectPos].angle, 256)
120
object[tempObjectPos].angle <<= 1
121
object[tempObjectPos].drawOrder = 4
122
object[tempObjectPos].yvel = -0x8800
123
airBubble[tempObjectPos].targetPlayer = 0xFFFF
124
125
temp0 = object.bubbleType2
126
temp0 += object.bubbleType1
127
GetTableValue(object[tempObjectPos].propertyValue, temp0, AirBubbler_bubbleSizes)
128
GetBit(temp0, object.bubbleFlags, 1)
129
130
if temp0 == true
131
Rand(temp0, 4)
132
temp1 = false
133
134
if temp0 == 0
135
GetBit(temp0, object.bubbleFlags, 2)
136
if temp0 == false
137
temp1 = true
138
end if
139
end if
140
141
if object.bubbleType1 == 0
142
GetBit(temp0, object.bubbleFlags, 2)
143
if temp0 == false
144
temp1 = true
145
end if
146
end if
147
148
if temp1 == true
149
object[tempObjectPos].propertyValue = 6
150
SetBit(object.bubbleFlags, 2, true)
151
end if
152
end if
153
154
object.bubbleType1--
155
if object.bubbleType1 < 0
156
Rand(temp0, 128)
157
temp0 += 128
158
object.timer += temp0
159
object.bubbleFlags = 0
160
end if
161
end if
162
end if
163
end if
164
end if
165
end event
166
167
168
event ObjectDraw
169
if object.iypos >= stage.waterLevel
170
temp0 = object.frame
171
temp0 >>= 4
172
DrawSprite(temp0)
173
end if
174
end event
175
176
177
event ObjectStartup
178
LoadSpriteSheet("LZ/Objects.gif")
179
180
// Bubbler frames
181
SpriteFrame(-8, -8, 16, 16, 61, 51)
182
SpriteFrame(-8, -8, 16, 16, 78, 51)
183
SpriteFrame(-8, -8, 16, 16, 95, 51)
184
185
foreach (TypeName[Air Bubbler], arrayPos0, ALL_ENTITIES)
186
object[arrayPos0].drawOrder = 4
187
object[arrayPos0].dudsRemaining = object[arrayPos0].numDuds
188
next
189
190
SetTableValue(TypeName[Air Bubbler], DebugMode_ObjCount, DebugMode_TypesTable)
191
SetTableValue(AirBubbler_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
192
SetTableValue(AirBubbler_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
193
DebugMode_ObjCount++
194
end event
195
196
197
// ========================
198
// Editor Events
199
// ========================
200
201
event RSDKDraw
202
DrawSprite(0)
203
end event
204
205
206
event RSDKLoad
207
LoadSpriteSheet("LZ/Objects.gif")
208
SpriteFrame(-8, -8, 16, 16, 61, 51)
209
210
SetVariableAlias(ALIAS_VAR_PROPVAL, "numDuds")
211
end event
212
213