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/Mission/Buzzer2.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Buzzer2 Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This Object is used in Mission "Stinger Swarm!" - M030 - Mission_Zone01
9
10
// ========================
11
// Aliases
12
// ========================
13
14
// This object has values set from the Editor, but these values are used for different purposes in-game
15
16
// These pair of values, as they are set from the editor initially
17
private alias object.value0 : object.initialCooldown
18
private alias object.value1 : object.initialXVel
19
20
// And then these are the same pair of values, but labelled as to what they do in-game
21
private alias object.value0 : object.timer
22
private alias object.value1 : object.startPos.x
23
24
private alias object.value2 : object.hasShot
25
private alias object.value3 : object.shootTimer
26
private alias object.value4 : object.cooldownTime
27
private alias object.value5 : object.setXVel
28
29
// States
30
private alias 0 : BUZZER2_FLYING
31
private alias 1 : BUZZER2_STOPPED
32
private alias 2 : BUZZER2_SHOOTING
33
private alias 3 : BUZZER2_INVISIBLE
34
35
// Animations
36
private alias 0 : BUZZER2_ANI_FLYING
37
private alias 1 : BUZZER2_ANI_STOPPED
38
private alias 2 : BUZZER2_ANI_SHOOTING
39
private alias 3 : BUZZER2_ANI_INVISBLE
40
41
// Player Aliases
42
private alias object.value40 : player.hitboxLeft
43
private alias object.value38 : player.hitboxTop
44
private alias object.value41 : player.hitboxRight
45
private alias object.value39 : player.hitboxBottom
46
47
48
// ========================
49
// Function Declarations
50
// ========================
51
52
reserve function Buzzer2_DebugDraw
53
reserve function Buzzer2_DebugSpawn
54
55
56
// ========================
57
// Function Definitions
58
// ========================
59
60
private function Buzzer2_DebugDraw
61
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
62
end function
63
64
65
private function Buzzer2_DebugSpawn
66
CreateTempObject(TypeName[Buzzer2], 0, object.xpos, object.ypos)
67
GetBit(temp0, object.direction, 0)
68
if temp0 == FACING_RIGHT
69
object[tempObjectPos].direction = FLIP_NONE
70
object[tempObjectPos].xvel = -0x10000
71
else
72
object[tempObjectPos].direction = FLIP_X
73
object[tempObjectPos].xvel = 0x10000
74
end if
75
end function
76
77
78
// ========================
79
// Events
80
// ========================
81
82
event ObjectUpdate
83
switch object.state
84
case BUZZER2_FLYING
85
object.priority = PRIORITY_ACTIVE
86
if object.timer < object.cooldownTime
87
object.timer++
88
object.xpos += object.xvel
89
else
90
object.timer = 0
91
object.state = BUZZER2_STOPPED
92
object.animation = BUZZER2_ANI_STOPPED
93
object.direction ^= FLIP_X
94
FlipSign(object.xvel)
95
end if
96
break
97
98
case BUZZER2_STOPPED
99
if object.shootTimer < 30
100
object.shootTimer++
101
else
102
object.shootTimer = 0
103
object.state = BUZZER2_FLYING
104
object.animation = BUZZER2_ANI_FLYING
105
object.hasShot = false
106
end if
107
break
108
109
case BUZZER2_SHOOTING
110
if object.shootTimer < 50
111
object.shootTimer++
112
if object.shootTimer == 30
113
CreateTempObject(TypeName[Buzzer Shot], 0, object.xpos, object.ypos)
114
object[tempObjectPos].direction = object.direction
115
if object.direction == FLIP_NONE
116
object[tempObjectPos].xpos += 0xD0000
117
object[tempObjectPos].xvel = -0x18000
118
else
119
object[tempObjectPos].xpos -= 0xD0000
120
object[tempObjectPos].xvel = 0x18000
121
end if
122
object[tempObjectPos].ypos += 0x180000
123
object[tempObjectPos].yvel = 0x18000
124
end if
125
else
126
object.shootTimer = 0
127
object.state = BUZZER2_FLYING
128
object.animation = BUZZER2_ANI_FLYING
129
object.hasShot = true
130
end if
131
break
132
133
case BUZZER2_INVISIBLE
134
object.animation = BUZZER2_ANI_INVISBLE
135
break
136
137
end switch
138
139
if object.outOfBounds == true
140
temp0 = object.xpos
141
object.xpos = object.startPos.x
142
if object.shootTimer == 1
143
object.state = BUZZER2_INVISIBLE
144
end if
145
146
if object.outOfBounds == true
147
object.xpos = object.startPos.x
148
object.xvel = object.setXVel
149
GetBit(temp0, object.propertyValue, 0)
150
if temp0 == false
151
object.direction = FLIP_NONE
152
FlipSign(object.xvel)
153
else
154
object.direction = FLIP_X
155
end if
156
157
object.timer = 0
158
object.animation = BUZZER2_ANI_FLYING
159
object.priority = PRIORITY_BOUNDS
160
object.state = BUZZER2_FLYING
161
else
162
object.xpos = temp0
163
end if
164
end if
165
166
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
167
if object.state == BUZZER2_FLYING
168
if object.hasShot == false
169
if object.direction == FLIP_NONE
170
BoxCollisionTest(C_TOUCH, object.entityPos, -28, -256, -30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
171
else
172
BoxCollisionTest(C_TOUCH, object.entityPos, 28, -256, 30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
173
end if
174
175
if checkResult == true
176
object.state = BUZZER2_SHOOTING
177
object.animation = BUZZER2_ANI_SHOOTING
178
end if
179
end if
180
end if
181
182
if object.state < BUZZER2_INVISIBLE
183
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
184
if checkResult == true
185
CallFunction(Player_BadnikBreak)
186
end if
187
end if
188
next
189
190
object.frame = object.animationTimer
191
object.frame /= 3
192
object.frame += 3
193
object.animationTimer++
194
if object.animationTimer >= 6
195
object.animationTimer = 0
196
end if
197
end event
198
199
200
event ObjectDraw
201
switch object.animation
202
case BUZZER2_ANI_FLYING
203
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
204
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
205
break
206
207
case BUZZER2_ANI_STOPPED
208
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
209
break
210
211
case BUZZER2_ANI_SHOOTING
212
DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)
213
break
214
215
case BUZZER2_ANI_INVISBLE
216
break
217
218
end switch
219
end event
220
221
222
event ObjectStartup
223
CheckCurrentStageFolder("Zone01")
224
if checkResult == true
225
LoadSpriteSheet("EHZ/Objects.gif")
226
SpriteFrame(-24, -8, 48, 16, 1, 1)
227
SpriteFrame(-24, -8, 42, 31, 1, 18)
228
SpriteFrame(1, 6, 17, 17, 50, 1)
229
SpriteFrame(5, -8, 6, 5, 19, 50)
230
SpriteFrame(5, -8, 7, 5, 19, 56)
231
else
232
LoadSpriteSheet("MBZ/Objects.gif")
233
SpriteFrame(-24, -8, 48, 16, 1, 256)
234
SpriteFrame(-24, -8, 42, 31, 1, 273)
235
SpriteFrame(1, 6, 17, 17, 268, 501)
236
SpriteFrame(5, -8, 6, 5, 137, 331)
237
SpriteFrame(5, -8, 7, 5, 137, 337)
238
end if
239
240
// They updated the use of TypeName here to be Buzzer2, but then...
241
foreach (TypeName[Buzzer2], arrayPos0, ALL_ENTITIES)
242
if object[arrayPos0].initialCooldown <= 0
243
object[arrayPos0].initialCooldown = 256
244
end if
245
246
object[arrayPos0].cooldownTime = object[arrayPos0].initialCooldown
247
object[arrayPos0].timer = 0 // same object value as initialCooldown
248
249
if object[arrayPos0].initialXVel <= 0
250
object[arrayPos0].initialXVel = 100
251
end if
252
object[arrayPos0].initialXVel *= 0x10000
253
object[arrayPos0].initialXVel /= 100
254
object[arrayPos0].setXVel = object[arrayPos0].initialXVel
255
256
object[arrayPos0].startPos.x = object[arrayPos0].xpos
257
object[arrayPos0].xvel = object[arrayPos0].setXVel
258
259
GetBit(temp0, object[arrayPos0].propertyValue, 0)
260
if temp0 == false
261
object[arrayPos0].direction = FLIP_NONE
262
FlipSign(object[arrayPos0].xvel)
263
else
264
object[arrayPos0].direction = FLIP_X
265
end if
266
next
267
268
// ... this TypeName is still referencing a normal Buzzer, but with the Buzzer2 functions? sure ig
269
// It doesn't matter much since both Buzzers and Buzzer2's have the same SpriteFrames, but it's worth noting ig
270
SetTableValue(TypeName[Buzzer], DebugMode_ObjCount, DebugMode_TypesTable)
271
SetTableValue(Buzzer2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
272
SetTableValue(Buzzer2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
273
DebugMode_ObjCount++
274
end event
275
276
277
// ========================
278
// Editor Events
279
// ========================
280
281
event RSDKEdit
282
if editor.returnVariable == true
283
switch editor.variableID
284
case EDIT_VAR_PROPVAL // property value
285
checkResult = object.propertyValue
286
break
287
288
case 0 // direction
289
checkResult = object.propertyValue
290
break
291
292
end switch
293
else
294
switch editor.variableID
295
case EDIT_VAR_PROPVAL // property value
296
object.propertyValue = editor.variableValue
297
break
298
299
case 0 // direction
300
object.propertyValue = editor.variableValue
301
break
302
303
end switch
304
end if
305
end event
306
307
308
event RSDKDraw
309
GetBit(object.direction, object.propertyValue, 0)
310
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
311
DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)
312
end event
313
314
315
event RSDKLoad
316
CheckCurrentStageFolder("Zone01")
317
if checkResult == true
318
LoadSpriteSheet("EHZ/Objects.gif")
319
SpriteFrame(-24, -8, 48, 16, 1, 1)
320
SpriteFrame(5, -8, 6, 5, 19, 50)
321
else
322
LoadSpriteSheet("MBZ/Objects.gif")
323
SpriteFrame(-24, -8, 48, 16, 1, 256)
324
SpriteFrame(5, -8, 6, 5, 137, 331)
325
end if
326
327
AddEditorVariable("direction")
328
SetActiveVariable("direction")
329
AddEnumVariable("Left", 0)
330
AddEnumVariable("Right", 1)
331
332
SetVariableAlias(ALIAS_VAR_VAL0, "cooldownTime")
333
SetVariableAlias(ALIAS_VAR_VAL1, "setXVel")
334
end event
335
336