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/Enemies/BallHog.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Ball Hog 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.value1 : object.timer
13
14
// Ball Hog Bomb Aliases
15
private alias object.value0 : object.time
16
17
// Player Aliases
18
private alias object.value40 : player.hitboxLeft
19
private alias object.value38 : player.hitboxTop
20
private alias object.value41 : player.hitboxRight
21
private alias object.value39 : player.hitboxBottom
22
23
// Path ID Aliases
24
private alias 0 : PATH_A
25
26
27
// ========================
28
// Function Declarations
29
// ========================
30
31
reserve function BallHog_DebugDraw
32
reserve function BallHog_DebugSpawn
33
34
35
// ========================
36
// Tables
37
// ========================
38
39
private table BallHog_frameTable
40
0, 2, 3, 2, 0, 2, 3, 2, 0, 2, 3, 2, 0, 1, 0
41
end table
42
43
private table BallHog_frameDelayTable
44
20, 20, 10, 10, 20, 20, 10, 10, 20, 20, 10, 10, 20, 10
45
end table
46
47
48
// ========================
49
// Function Definitions
50
// ========================
51
52
private function BallHog_DebugDraw
53
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
54
end function
55
56
57
private function BallHog_DebugSpawn
58
CreateTempObject(TypeName[Ball Hog], 0, object.xpos, object.ypos)
59
object[tempObjectPos].direction = object.direction
60
object[tempObjectPos].propertyValue = 1
61
end function
62
63
64
// ========================
65
// Events
66
// ========================
67
68
event ObjectUpdate
69
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
70
BoxCollisionTest(C_TOUCH, object.entityPos, -12, -18, 12, 18, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
71
if checkResult == true
72
CallFunction(Player_BadnikBreak)
73
end if
74
next
75
76
// Sidestep a little
77
if object.frame == 3
78
object.ypos += object.yvel
79
object.yvel += 0x95C0
80
ObjectTileCollision(CSIDE_FLOOR, 0, 20, PATH_A)
81
if checkResult == false
82
object.animationTimer = 2
83
end if
84
end if
85
86
// Update animation & ball lobbing
87
object.animationTimer--
88
if object.animationTimer <= 0
89
GetTableValue(object.animationTimer, object.timer, BallHog_frameDelayTable)
90
GetTableValue(object.frame, object.timer, BallHog_frameTable)
91
92
object.timer++
93
if object.timer >= 14
94
object.timer = 0
95
end if
96
97
if object.frame == 3
98
object.yvel = -0x29999
99
object.ypos += object.yvel
100
object.yvel += 0x95C0
101
end if
102
103
if object.frame == 1
104
// Drop a bomb ball
105
106
CreateTempObject(TypeName[Ball Hog Bomb], 0, object.xpos, object.ypos)
107
if object.direction == FLIP_NONE
108
object[tempObjectPos].xpos -= 0x40000
109
object[tempObjectPos].xvel = -0x10000
110
else
111
object[tempObjectPos].xpos += 0x40000
112
object[tempObjectPos].xvel = 0x10000
113
end if
114
115
object[tempObjectPos].ypos += 0xC0000
116
object[tempObjectPos].time = object.propertyValue
117
object[tempObjectPos].time *= 60
118
end if
119
end if
120
end event
121
122
123
event ObjectDraw
124
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
125
end event
126
127
128
event ObjectStartup
129
CheckCurrentStageFolder("Zone06")
130
if checkResult == true
131
LoadSpriteSheet("SBZ/Objects.gif")
132
SpriteFrame(-11, -17, 22, 37, 1, 170)
133
SpriteFrame(-11, -17, 22, 37, 24, 170)
134
SpriteFrame(-12, -12, 24, 32, 47, 175)
135
SpriteFrame(-11, -20, 22, 40, 72, 167)
136
end if
137
138
CheckCurrentStageFolder("Zone07")
139
if checkResult == true
140
LoadSpriteSheet("MBZ/Objects.gif")
141
SpriteFrame(-11, -17, 22, 37, 76, 292)
142
SpriteFrame(-11, -17, 22, 37, 99, 292)
143
SpriteFrame(-12, -12, 24, 32, 122, 297)
144
SpriteFrame(-11, -20, 22, 40, 147, 289)
145
end if
146
147
foreach (TypeName[Ball Hog], arrayPos0, ALL_ENTITIES)
148
temp0 = object[arrayPos0].propertyValue
149
temp0 &= 0x80
150
if temp0 != 0
151
object[arrayPos0].direction = FLIP_X
152
object[arrayPos0].propertyValue &= 0x7F
153
end if
154
next
155
156
SetTableValue(TypeName[Ball Hog], DebugMode_ObjCount, DebugMode_TypesTable)
157
SetTableValue(BallHog_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
158
SetTableValue(BallHog_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
159
DebugMode_ObjCount++
160
end event
161
162
163
// ========================
164
// Editor Events
165
// ========================
166
167
event RSDKEdit
168
if editor.returnVariable == true
169
switch editor.variableID
170
case EDIT_VAR_PROPVAL // property value
171
checkResult = object.propertyValue
172
break
173
174
case 0 // bombTime
175
checkResult = object.propertyValue
176
checkResult &= 0x7F
177
break
178
179
case 1 // direction
180
GetBit(checkResult, object.propertyValue, 7)
181
break
182
183
end switch
184
else
185
switch editor.variableID
186
case EDIT_VAR_PROPVAL // property value
187
object.propertyValue = editor.variableValue
188
break
189
190
case 0 // bombTime
191
object.propertyValue &= 0x80
192
editor.variableValue &= 0x7F
193
194
object.propertyValue |= editor.variableValue
195
break
196
197
case 1 // direction
198
CheckNotEqual(editor.variableValue, false)
199
SetBit(object.propertyValue, 7, checkResult)
200
break
201
202
end switch
203
end if
204
end event
205
206
207
event RSDKDraw
208
GetBit(object.direction, object.propertyValue, 7)
209
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
210
end event
211
212
213
event RSDKLoad
214
CheckCurrentStageFolder("Zone07")
215
if checkResult == true
216
LoadSpriteSheet("MBZ/Objects.gif")
217
SpriteFrame(-11, -17, 22, 37, 76, 292)
218
SpriteFrame(-11, -17, 22, 37, 99, 292)
219
SpriteFrame(-12, -12, 24, 32, 122, 297)
220
SpriteFrame(-11, -20, 22, 40, 147, 289)
221
else
222
LoadSpriteSheet("SBZ/Objects.gif")
223
SpriteFrame(-11, -17, 22, 37, 1, 170)
224
SpriteFrame(-11, -17, 22, 37, 24, 170)
225
SpriteFrame(-12, -12, 24, 32, 47, 175)
226
SpriteFrame(-11, -20, 22, 40, 72, 167)
227
end if
228
229
AddEditorVariable("bombTime")
230
231
AddEditorVariable("direction")
232
SetActiveVariable("direction")
233
AddEnumVariable("Left", 0)
234
AddEnumVariable("Right", 1)
235
end event
236
237