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/Mission/ReviveCrabmeat.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Crabmeat 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.x
14
private alias object.value2 : object.startPos.y
15
private alias object.value3 : object.canShoot
16
17
private alias 0 : CRABMEAT_MOVING
18
private alias 1 : CRABMEAT_IDLE
19
private alias 2 : CRABMEAT_SHOOT
20
private alias 3 : CRABMEAT_SHOOTDELAY
21
private alias 4 : CRABMEAT_REVIVE
22
23
private alias 0 : CRABMEAT_ANI_MOVING
24
private alias 1 : CRABMEAT_ANI_SHOOT
25
private alias 2 : CRABMEAT_ANI_IDLE
26
27
// Player aliases
28
private alias object.value40 : player.hitboxLeft
29
private alias object.value38 : player.hitboxTop
30
private alias object.value41 : player.hitboxRight
31
private alias object.value39 : player.hitboxBottom
32
33
// Revive Enemy Aliases
34
private alias object.value47 : object.backupType
35
private alias object.value46 : object.backupState
36
private alias object.value44 : object.backupvalueA
37
private alias object.value43 : object.backupvalueB
38
private alias object.value0 : object.target
39
40
// Path ID Aliases
41
private alias 0 : PATH_A
42
43
44
// ========================
45
// Function Declarations
46
// ========================
47
48
reserve function Crabmeat_DebugDraw
49
reserve function Crabmeat_DebugSpawn
50
51
52
// ========================
53
// Function Definitions
54
// ========================
55
56
private function Crabmeat_DebugDraw
57
DrawSprite(0)
58
end function
59
60
61
private function Crabmeat_DebugSpawn
62
CreateTempObject(TypeName[Crabmeat], 0, object.xpos, object.ypos)
63
object[tempObjectPos].startPos.x = object.xpos
64
object[tempObjectPos].startPos.y = object.ypos
65
66
GetBit(temp0, object.direction, 0)
67
if temp0 == 0
68
object[tempObjectPos].direction = FACING_LEFT
69
object[tempObjectPos].xvel = 0x8000
70
else
71
object[tempObjectPos].direction = FACING_LEFT
72
object[tempObjectPos].xvel = -0x8000
73
end if
74
75
object[tempObjectPos].canShoot = false
76
end function
77
78
79
// ========================
80
// Events
81
// ========================
82
83
event ObjectUpdate
84
switch object.state
85
case CRABMEAT_MOVING
86
object.priority = PRIORITY_ACTIVE
87
88
if object.timer < 127
89
object.timer++
90
object.xpos += object.xvel
91
if object.xvel > 0
92
ObjectTileGrip(CSIDE_FLOOR, 14, 15, PATH_A)
93
else
94
ObjectTileGrip(CSIDE_FLOOR, -14, 15, PATH_A)
95
end if
96
97
if checkResult == false
98
if object.canShoot == true
99
object.state = CRABMEAT_SHOOT
100
else
101
object.state = CRABMEAT_IDLE
102
object.canShoot = true
103
end if
104
object.timer = 0
105
object.animation = CRABMEAT_ANI_SHOOT
106
end if
107
ObjectTileGrip(CSIDE_FLOOR, 0, 15, PATH_A)
108
else
109
if object.canShoot == true
110
object.state = CRABMEAT_SHOOT
111
else
112
object.state = CRABMEAT_IDLE
113
object.canShoot = true
114
end if
115
116
object.timer = 0
117
object.animation = CRABMEAT_ANI_SHOOT
118
end if
119
break
120
121
case CRABMEAT_IDLE
122
if object.timer < 59
123
object.timer++
124
else
125
object.timer = 0
126
object.state = CRABMEAT_MOVING
127
object.animation = CRABMEAT_ANI_MOVING
128
object.animationTimer = 0
129
FlipSign(object.xvel)
130
end if
131
break
132
133
case CRABMEAT_SHOOT
134
if object.timer < 59
135
object.timer++
136
else
137
CreateTempObject(TypeName[Crabmeat Shot], 0, object.xpos, object.ypos)
138
object[tempObjectPos].xpos -= 0x100000
139
object[tempObjectPos].xvel = -0x10000
140
object[tempObjectPos].yvel = -0x40000
141
142
CreateTempObject(TypeName[Crabmeat Shot], 0, object.xpos, object.ypos)
143
object[tempObjectPos].xpos += 0x100000
144
object[tempObjectPos].xvel = 0x10000
145
object[tempObjectPos].yvel = -0x40000
146
147
object.timer = 0
148
object.state++
149
object.animation = CRABMEAT_ANI_IDLE
150
end if
151
break
152
153
case CRABMEAT_SHOOTDELAY
154
if object.timer < 59
155
object.timer++
156
else
157
object.timer = 0
158
object.state = CRABMEAT_MOVING
159
object.animation = CRABMEAT_ANI_MOVING
160
object.animationTimer = 0
161
FlipSign(object.xvel)
162
end if
163
break
164
165
case CRABMEAT_REVIVE
166
object.startPos.x = object.xpos
167
object.startPos.y = object.ypos
168
169
if object.propertyValue == 1
170
object.direction = FACING_LEFT
171
object.xvel = 0x8000
172
else
173
object.direction = FACING_LEFT
174
object.xvel = -0x8000
175
end if
176
177
object.canShoot = false
178
object.state = CRABMEAT_MOVING
179
object.timer = 0
180
break
181
182
end switch
183
184
if object.outOfBounds == true
185
temp0 = object.xpos
186
temp1 = object.ypos
187
object.xpos = object.startPos.x
188
object.ypos = object.startPos.y
189
if object.outOfBounds == true
190
if object.propertyValue == 1
191
object.direction = FACING_LEFT
192
object.xvel = 0x8000
193
else
194
object.direction = FACING_LEFT
195
object.xvel = -0x8000
196
end if
197
198
object.canShoot = false
199
object.state = CRABMEAT_MOVING
200
object.timer = 0
201
object.priority = PRIORITY_BOUNDS
202
object.animation = CRABMEAT_ANI_MOVING
203
object.animationTimer = 0
204
else
205
object.xpos = temp0
206
object.ypos = temp1
207
end if
208
end if
209
210
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
211
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -14, 14, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
212
if checkResult == true
213
CreateTempObject(TypeName[ReviveEnemy], object.propertyValue, object.startPos.x, object.startPos.y)
214
object[tempObjectPos].priority = PRIORITY_ACTIVE
215
object[tempObjectPos].target = object.entityPos
216
object[tempObjectPos].backupType = object.type
217
object[tempObjectPos].backupState = CRABMEAT_REVIVE
218
CallFunction(Player_BadnikBreak)
219
end if
220
next
221
222
switch object.animation
223
case CRABMEAT_ANI_MOVING
224
object.frame = object.animationTimer
225
object.frame >>= 4
226
object.animationTimer++
227
object.animationTimer %= 48
228
break
229
230
case CRABMEAT_ANI_SHOOT
231
object.frame = 0
232
break
233
234
case CRABMEAT_ANI_IDLE
235
object.frame = 3
236
break
237
238
end switch
239
end event
240
241
242
event ObjectDraw
243
DrawSprite(object.frame)
244
end event
245
246
247
event ObjectStartup
248
CheckCurrentStageFolder("Zone01")
249
if checkResult == true
250
LoadSpriteSheet("GHZ/Objects.gif")
251
SpriteFrame(-21, -16, 42, 31, 138, 157)
252
SpriteFrame(-22, -16, 44, 31, 98, 189)
253
SpriteFrame(-22, -16, 44, 31, 98, 221)
254
SpriteFrame(-24, -15, 48, 30, 143, 189)
255
end if
256
257
CheckCurrentStageFolder("Zone03")
258
if checkResult == true
259
LoadSpriteSheet("SYZ/Objects.gif")
260
SpriteFrame(-21, -16, 42, 31, 184, 1)
261
SpriteFrame(-22, -16, 44, 31, 184, 34)
262
SpriteFrame(-22, -16, 44, 31, 184, 66)
263
SpriteFrame(-24, -15, 48, 30, 184, 173)
264
end if
265
266
CheckCurrentStageFolder("Zone07")
267
if checkResult == true
268
LoadSpriteSheet("MBZ/Objects.gif")
269
SpriteFrame(-21, -16, 42, 31, 168, 81)
270
SpriteFrame(-22, -16, 44, 31, 211, 81)
271
SpriteFrame(-22, -16, 44, 31, 211, 113)
272
SpriteFrame(-24, -15, 48, 30, 162, 114)
273
end if
274
275
foreach (TypeName[Crabmeat], arrayPos0, ALL_ENTITIES)
276
object[arrayPos0].startPos.x = object[arrayPos0].xpos
277
object[arrayPos0].startPos.y = object[arrayPos0].ypos
278
if object[arrayPos0].propertyValue == 1
279
object[arrayPos0].direction = FACING_LEFT
280
object[arrayPos0].xvel = 0x8000
281
else
282
object[arrayPos0].direction = FACING_LEFT
283
object[arrayPos0].xvel = -0x8000
284
end if
285
object[arrayPos0].canShoot = false
286
next
287
288
SetTableValue(TypeName[Crabmeat], DebugMode_ObjCount, DebugMode_TypesTable)
289
SetTableValue(Crabmeat_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
290
SetTableValue(Crabmeat_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
291
DebugMode_ObjCount++
292
end event
293
294
295
// ========================
296
// Editor Events
297
// ========================
298
299
event RSDKEdit
300
if editor.returnVariable == true
301
switch editor.variableID
302
case EDIT_VAR_PROPVAL // property value
303
checkResult = object.propertyValue
304
break
305
306
case 0 // direction
307
checkResult = object.propertyValue
308
break
309
310
end switch
311
else
312
switch editor.variableID
313
case EDIT_VAR_PROPVAL // property value
314
object.propertyValue = editor.variableValue
315
break
316
317
case 0 // direction
318
object.propertyValue = editor.variableValue
319
break
320
321
end switch
322
end if
323
end event
324
325
326
event RSDKDraw
327
DrawSprite(0)
328
end event
329
330
331
event RSDKLoad
332
CheckCurrentStageFolder("Zone01")
333
if checkResult == true
334
LoadSpriteSheet("GHZ/Objects.gif")
335
SpriteFrame(-21, -16, 42, 31, 138, 157)
336
end if
337
338
CheckCurrentStageFolder("Zone03")
339
if checkResult == true
340
LoadSpriteSheet("SYZ/Objects.gif")
341
SpriteFrame(-21, -16, 42, 31, 184, 1)
342
end if
343
344
CheckCurrentStageFolder("Zone07")
345
if checkResult == true
346
LoadSpriteSheet("MBZ/Objects.gif")
347
SpriteFrame(-21, -16, 42, 31, 168, 81)
348
end if
349
350
AddEditorVariable("direction")
351
SetActiveVariable("direction")
352
AddEnumVariable("Left", 0)
353
AddEnumVariable("Right", 1)
354
end event
355
356