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/AirBubbler.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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
CheckCameraProximity(object.ixpos, object.iypos, screen.xcenter, screen.ycenter)
67
if checkResult == true
68
temp1 = 0
69
if object.bubbleFlags == 0
70
object.timer--
71
if object.timer < 0
72
SetBit(object.bubbleFlags, 0, true)
73
74
Rand(object.bubbleType1, 0xFFFF)
75
object.bubbleType2 = object.bubbleType1
76
object.bubbleType1 %= 6
77
object.bubbleType2 &= 12
78
object.dudsRemaining--
79
if object.dudsRemaining < 0
80
object.dudsRemaining = object.numDuds
81
SetBit(object.bubbleFlags, 1, true)
82
end if
83
84
temp1 = true
85
end if
86
else
87
object.timer--
88
if object.timer < 0
89
temp1 = true
90
end if
91
end if
92
93
if temp1 == true
94
Rand(object.timer, 32)
95
96
Rand(temp0, 17)
97
temp0 -= 8
98
temp0 <<= 16
99
temp0 += object.xpos
100
CreateTempObject(TypeName[Air Bubble], 2, temp0, object.ypos)
101
airBubble[tempObjectPos].originPos.y = object[tempObjectPos].xpos
102
Rand(object[tempObjectPos].angle, 256)
103
object[tempObjectPos].angle <<= 1
104
object[tempObjectPos].drawOrder = 4
105
object[tempObjectPos].yvel = -0x8800
106
airBubble[tempObjectPos].targetPlayer = 0xFFFF
107
temp0 = object.bubbleType2
108
temp0 += object.bubbleType1
109
GetTableValue(object[tempObjectPos].propertyValue, temp0, AirBubbler_bubbleSizes)
110
111
GetBit(temp0, object.bubbleFlags, 1)
112
if temp0 == true
113
Rand(temp0, 4)
114
115
temp1 = false
116
if temp0 == false
117
GetBit(temp0, object.bubbleFlags, 2)
118
if temp0 == false
119
temp1 = true
120
end if
121
end if
122
123
if object.bubbleType1 == 0
124
GetBit(temp0, object.bubbleFlags, 2)
125
if temp0 == false
126
temp1 = true
127
end if
128
end if
129
130
if temp1 == true
131
object[tempObjectPos].propertyValue = 6
132
SetBit(object.bubbleFlags, 2, true)
133
end if
134
end if
135
136
object.bubbleType1--
137
if object.bubbleType1 < 0
138
Rand(temp0, 128)
139
temp0 += 128
140
object.timer += temp0
141
object.bubbleFlags = 0
142
end if
143
end if
144
end if
145
end if
146
end event
147
148
149
event ObjectDraw
150
if object.iypos >= stage.waterLevel
151
temp0 = object.frame
152
temp0 >>= 4
153
DrawSprite(temp0)
154
end if
155
end event
156
157
158
event ObjectStartup
159
// Likely an oversignt made when copying scripts from CPZ - for some reason a CPZ sheet is loaded despite this being ARZ
160
// The ARZ version of this sheet exists too, but it remains unused because of this
161
LoadSpriteSheet("CPZ/Objects3.gif")
162
163
// Bubbler frames
164
SpriteFrame(-8, -8, 16, 16, 103, 1)
165
SpriteFrame(-8, -8, 16, 16, 120, 1)
166
SpriteFrame(-8, -8, 16, 16, 137, 1)
167
168
foreach (TypeName[Air Bubbler], arrayPos0, ALL_ENTITIES)
169
object[arrayPos0].drawOrder = 4
170
object[arrayPos0].dudsRemaining = object[arrayPos0].numDuds
171
next
172
173
SetTableValue(TypeName[Air Bubbler], DebugMode_ObjCount, DebugMode_TypesTable)
174
SetTableValue(AirBubbler_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
175
SetTableValue(AirBubbler_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
176
DebugMode_ObjCount++
177
end event
178
179
180
// ========================
181
// Editor Events
182
// ========================
183
184
event RSDKDraw
185
DrawSprite(0)
186
end event
187
188
189
event RSDKLoad
190
LoadSpriteSheet("ARZ/Objects3.gif")
191
SpriteFrame(-8, -8, 16, 16, 103, 1)
192
193
SetVariableAlias(ALIAS_VAR_PROPVAL, "numDuds")
194
end event
195
196