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/Enemies/Bubbler.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Bubbler Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// States
13
private alias 0 : BUBBLER_FALLING
14
private alias 1 : BUBBLER_EXPLODE
15
16
// Path ID Aliases
17
private alias 0 : PATH_A
18
19
20
// ========================
21
// Function Declarations
22
// ========================
23
24
reserve function Bubbler_DebugDraw
25
reserve function Bubbler_DebugSpawn
26
27
28
// ========================
29
// Function Definitions
30
// ========================
31
32
private function Bubbler_DebugDraw
33
DrawSprite(0)
34
end function
35
36
37
private function Bubbler_DebugSpawn
38
CreateTempObject(TypeName[Bubbler], 0, object.xpos, object.ypos)
39
end function
40
41
42
// ========================
43
// Events
44
// ========================
45
46
event ObjectUpdate
47
object.priority = PRIORITY_ACTIVE
48
49
switch object.state
50
case BUBBLER_FALLING
51
object.animationTimer++
52
object.animationTimer &= 15
53
object.frame = object.animationTimer
54
object.frame >>= 2
55
56
object.ypos += 0x10000
57
58
ObjectTileCollision(CSIDE_FLOOR, 0, 0, PATH_A)
59
if checkResult == true
60
object.state = BUBBLER_EXPLODE
61
object.animationTimer = 0
62
object.frame = 4
63
end if
64
65
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
66
BoxCollisionTest(C_TOUCH, object.entityPos, -2, -2, 2, 2, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
67
if checkResult == true
68
CallFunction(Player_ProjectileHit)
69
end if
70
next
71
break
72
73
case BUBBLER_EXPLODE
74
object.animationTimer++
75
if object.animationTimer >= 4
76
object.animationTimer = 0
77
object.frame++
78
if object.frame >= 11
79
object.type = TypeName[Blank Object]
80
end if
81
end if
82
83
if object.frame < 10
84
temp0 = object.frame
85
temp0 -= 4
86
temp0 >>= 1
87
temp0 <<= 2
88
temp0 += 4
89
temp1 = temp0
90
FlipSign(temp0)
91
92
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
93
BoxCollisionTest(C_TOUCH, object.entityPos, temp0, -8, temp1, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
94
if checkResult == true
95
CallFunction(Player_Hit)
96
end if
97
next
98
end if
99
break
100
101
end switch
102
end event
103
104
105
event ObjectDraw
106
DrawSprite(object.frame)
107
end event
108
109
110
event ObjectStartup
111
CheckCurrentStageFolder("Zone02")
112
if checkResult == true
113
LoadSpriteSheet("CPZ/Objects.gif")
114
SpriteFrame(-2, -2, 5, 5, 190, 141)
115
SpriteFrame(-2, -2, 5, 5, 196, 141)
116
SpriteFrame(-3, -4, 7, 7, 190, 147)
117
SpriteFrame(-3, -4, 7, 7, 198, 147)
118
SpriteFrame(-4, -6, 8, 6, 157, 2)
119
SpriteFrame(-4, -7, 8, 7, 148, 1)
120
SpriteFrame(-8, -8, 16, 8, 149, 9)
121
SpriteFrame(-8, -14, 16, 14, 149, 18)
122
SpriteFrame(-12, -15, 24, 15, 141, 33)
123
SpriteFrame(-12, -16, 23, 16, 142, 49)
124
SpriteFrame(-7, -13, 14, 14, 151, 66)
125
else
126
LoadSpriteSheet("MBZ/Objects.gif")
127
128
// Huh?
129
// Just one Sprite Frame?
130
// And it's not even a Bubbler sprite, it's just the middle of the EHZ EggMobile...
131
// But then, if you look at where this sprite would be on the CPZ sheet, it's a Ball sprite! What?
132
SpriteFrame(-12, -12, 24, 24, 166, 1)
133
134
// The strange thing is, Bubbler's sprites don't even exist on the MBZ sheet anyway, so I wonder how this came about...
135
end if
136
137
SetTableValue(TypeName[Bubbler], DebugMode_ObjCount, DebugMode_TypesTable)
138
SetTableValue(Bubbler_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
139
SetTableValue(Bubbler_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
140
DebugMode_ObjCount++
141
end event
142
143
144
// ========================
145
// Editor Events
146
// ========================
147
148
event RSDKDraw
149
DrawSprite(0)
150
end event
151
152
153
event RSDKLoad
154
CheckCurrentStageFolder("Zone02")
155
if checkResult == true
156
LoadSpriteSheet("CPZ/Objects.gif")
157
SpriteFrame(-2, -2, 5, 5, 190, 141)
158
else
159
LoadSpriteSheet("MBZ/Objects.gif")
160
SpriteFrame(-12, -12, 24, 24, 166, 1) // May as well stick with this frame anyway...
161
end if
162
163
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
164
end event
165
166