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/Octus.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Octus 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.value0 : object.timer
13
private alias object.value1 : object.startPos.y
14
15
// States
16
private alias 0 : OCTUS_SETUP
17
private alias 1 : OCTUS_JUMPDELAY
18
private alias 2 : OCTUS_JUMP
19
private alias 3 : OCTUS_SHOOT
20
private alias 4 : OCTUS_FALL
21
22
// Player Aliases
23
private alias object.value40 : player.hitboxLeft
24
private alias object.value38 : player.hitboxTop
25
private alias object.value41 : player.hitboxRight
26
private alias object.value39 : player.hitboxBottom
27
28
// Path ID Aliases
29
private alias 0 : PATH_A
30
31
32
// ========================
33
// Function Declarations
34
// ========================
35
36
reserve function Octus_DebugDraw
37
reserve function Octus_DebugSpawn
38
reserve function Octus_TryPlayShotSfx
39
40
41
// ========================
42
// Function Definitions
43
// ========================
44
45
private function Octus_DebugDraw
46
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
47
end function
48
49
50
private function Octus_DebugSpawn
51
CreateTempObject(TypeName[Octus], 0, object.xpos, object.ypos)
52
object[tempObjectPos].direction = object.direction
53
end function
54
55
56
private function Octus_TryPlayShotSfx
57
temp0 = screen.xcenter
58
temp0 += 32
59
CheckCameraProximity(object.ixpos, object.iypos, temp0, 140)
60
if checkResult == true
61
// Fun fact, this sound effect isn't named correctly for Mission Mode Sky Chase in Origins LOL
62
// because of that it just plays the jump sfx (id 0)
63
PlaySfx(SfxName[Octus Shot], false)
64
end if
65
end function
66
67
68
// ========================
69
// Events
70
// ========================
71
72
event ObjectUpdate
73
switch object.state
74
case OCTUS_SETUP
75
if object.priority != PRIORITY_XBOUNDS_DESTROY
76
object.priority = PRIORITY_ACTIVE
77
end if
78
79
ObjectTileGrip(CSIDE_FLOOR, 0, 13, PATH_A)
80
81
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
82
BoxCollisionTest(C_TOUCH, object.entityPos, -128, -512, 128, 512, currentPlayer, 0, 0, 0, 0)
83
if checkResult == true
84
object.state = OCTUS_JUMPDELAY
85
end if
86
next
87
88
object.frame = object.animationTimer
89
object.frame >>= 4
90
object.animationTimer++
91
object.animationTimer &= 31
92
break
93
94
case OCTUS_JUMPDELAY
95
object.frame = 2
96
97
object.timer++
98
if object.timer == 32
99
object.timer = 0
100
object.yvel = -0x20000
101
object.animationTimer = 0
102
object.state = OCTUS_JUMP
103
end if
104
break
105
106
case OCTUS_JUMP
107
if object.timer < 8
108
object.timer++
109
object.frame = 1
110
else
111
object.frame = object.animationTimer
112
object.frame >>= 2
113
object.frame += 3
114
object.animationTimer++
115
object.animationTimer %= 12
116
end if
117
118
object.yvel += 0x1000
119
if object.yvel >= 0
120
object.timer = 0
121
object.drawOrder = 4
122
object.state = OCTUS_SHOOT
123
end if
124
125
object.ypos += object.yvel
126
break
127
128
case OCTUS_SHOOT
129
if object.timer == 0
130
CreateTempObject(TypeName[Octus Shot], 0, object.xpos, object.ypos)
131
if object.direction == FLIP_NONE
132
object[tempObjectPos].xpos -= 0xE0000
133
object[tempObjectPos].xvel = -0x20000
134
else
135
object[tempObjectPos].xpos += 0xE0000
136
object[tempObjectPos].xvel = 0x20000
137
end if
138
139
CallFunction(Octus_TryPlayShotSfx)
140
end if
141
142
if object.timer == 15
143
object.drawOrder = 3
144
end if
145
146
object.frame = object.animationTimer
147
object.frame >>= 2
148
object.frame += 3
149
object.animationTimer++
150
object.animationTimer %= 12
151
object.timer++
152
if object.timer == 60
153
object.timer = 0
154
object.state = OCTUS_FALL
155
end if
156
break
157
158
case OCTUS_FALL
159
object.frame = object.animationTimer
160
object.frame >>= 2
161
object.frame += 3
162
object.animationTimer++
163
object.animationTimer %= 12
164
object.yvel += 0x1000
165
object.ypos += object.yvel
166
ObjectTileCollision(CSIDE_FLOOR, 0, 13, PATH_A)
167
if checkResult == true
168
object.yvel = 0
169
object.animationTimer = 0
170
object.state = OCTUS_SETUP
171
end if
172
break
173
174
end switch
175
176
if object.outOfBounds == true
177
#platform: USE_ORIGINS
178
if game.playMode == BOOT_PLAYMODE_MISSION
179
object.yvel = 0
180
end if
181
#endplatform
182
temp0 = object.ypos
183
object.ypos = object.startPos.y
184
if object.outOfBounds == true
185
if object.priority != PRIORITY_XBOUNDS_DESTROY
186
object.priority = PRIORITY_BOUNDS
187
object.timer = 0
188
object.animationTimer = 0
189
object.state = OCTUS_SETUP
190
end if
191
else
192
object.ypos = temp0
193
end if
194
end if
195
196
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
197
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
198
if checkResult == true
199
CallFunction(Player_BadnikBreak)
200
end if
201
next
202
end event
203
204
205
event ObjectDraw
206
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
207
end event
208
209
210
event ObjectStartup
211
CheckCurrentStageFolder("Zone07")
212
if checkResult == true
213
LoadSpriteSheet("OOZ/Objects.gif")
214
SpriteFrame(-21, -12, 42, 25, 1, 49)
215
SpriteFrame(-16, -19, 32, 32, 149, 52)
216
SpriteFrame(-21, -12, 42, 25, 1, 75)
217
SpriteFrame(-21, -12, 42, 25, 1, 49)
218
SpriteFrame(-20, -12, 40, 25, 44, 49)
219
SpriteFrame(-21, -12, 42, 25, 85, 49)
220
else
221
// This does mean the entire MBZ sheet is loaded in Origins's WFZ mission
222
223
LoadSpriteSheet("MBZ/Objects.gif")
224
SpriteFrame(-21, -12, 42, 25, 667, 256)
225
SpriteFrame(-16, -19, 32, 32, 634, 256)
226
SpriteFrame(-21, -12, 42, 25, 794, 256)
227
SpriteFrame(-21, -12, 42, 25, 667, 256)
228
SpriteFrame(-20, -12, 40, 25, 710, 256)
229
SpriteFrame(-21, -12, 42, 25, 751, 256)
230
end if
231
232
foreach (TypeName[Octus], arrayPos0, ALL_ENTITIES)
233
object[arrayPos0].direction = object[arrayPos0].propertyValue
234
object[arrayPos0].direction &= FLIP_X
235
object[arrayPos0].startPos.y = object[arrayPos0].ypos
236
next
237
238
SetTableValue(TypeName[Octus], DebugMode_ObjCount, DebugMode_TypesTable)
239
SetTableValue(Octus_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
240
SetTableValue(Octus_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
241
DebugMode_ObjCount++
242
end event
243
244
245
// ========================
246
// Editor Events
247
// ========================
248
249
event RSDKEdit
250
if editor.returnVariable == true
251
switch editor.variableID
252
case EDIT_VAR_PROPVAL // property value
253
checkResult = object.propertyValue
254
break
255
256
case 0 // direction
257
checkResult = object.propertyValue
258
break
259
260
end switch
261
else
262
switch editor.variableID
263
case EDIT_VAR_PROPVAL // property value
264
object.propertyValue = editor.variableValue
265
break
266
267
case 0 // direction
268
object.propertyValue = editor.variableValue
269
break
270
271
end switch
272
end if
273
end event
274
275
276
event RSDKDraw
277
GetBit(object.direction, object.propertyValue, 0)
278
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
279
280
if editor.showGizmos == true
281
editor.drawingOverlay = true
282
283
temp0 = object.ypos
284
temp0 -= 0x200000
285
286
// we might have to flip so no ink effects for us, sorry..
287
DrawSpriteFX(0, FX_FLIP, object.xpos, temp0)
288
289
DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0x00, 0xFF, 0x00)
290
291
editor.drawingOverlay = false
292
end if
293
end event
294
295
296
event RSDKLoad
297
CheckCurrentStageFolder("Zone07")
298
if checkResult == true
299
LoadSpriteSheet("OOZ/Objects.gif")
300
SpriteFrame(-21, -12, 42, 25, 1, 49)
301
else
302
LoadSpriteSheet("MBZ/Objects.gif")
303
SpriteFrame(-21, -12, 42, 25, 667, 256)
304
end if
305
306
AddEditorVariable("direction")
307
SetActiveVariable("direction")
308
AddEnumVariable("Left", 0)
309
AddEnumVariable("Right", 1)
310
end event
311
312