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/ARZ/BreakablePillar.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Breakable Pillar 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.height
13
private alias object.value1 : object.delay
14
15
// States
16
private alias 0 : BREAKABLEPILLAR_AWAITPLAYER
17
private alias 1 : BREAKABLEPILLAR_RISE
18
private alias 2 : BREAKABLEPILLAR_RISEN
19
private alias 3 : BREAKABLEPILLAR_NONE
20
private alias 4 : BREAKABLEPILLAR_TILEDELAY
21
private alias 5 : BREAKABLEPILLAR_FALL
22
23
// Player Aliases
24
private alias object.state : player.state
25
private alias object.xvel : player.xvel
26
private alias object.speed : player.speed
27
private alias object.gravity : player.gravity
28
private alias object.animation : player.animation
29
30
private alias object.value17 : debugMode.currentSelection
31
32
33
// ========================
34
// Function Declarations
35
// ========================
36
37
reserve function BreakablePillar_DebugDraw
38
reserve function BreakablePillar_DebugSpawn
39
40
41
// ========================
42
// Static Values
43
// ========================
44
45
private value BreakablePillar_startDebugID = 0
46
47
48
// ========================
49
// Tables
50
// ========================
51
52
private table BreakablePillar_tileVelTable
53
-0x20000, -0x20000, -0x1C000, -0x1C000, 0x1C000, -0x1C000, 0x20000, -0x20000, -0x18000, -0x18000, 0x18000, -0x18000, -0x14000, -0x14000, 0x14000, -0x14000
54
-0x10000, -0x10000, 0x10000, -0x10000, -0xC000, -0xC000, 0xC000, -0xC000, -0x8000, -0x8000, 0x8000, -0x8000
55
end table
56
57
58
// ========================
59
// Function Definitions
60
// ========================
61
62
private function BreakablePillar_DebugDraw
63
EditFrame(0, -28, -24, 56, 32, 59, 42)
64
DrawSprite(0)
65
66
temp0 = debugMode[0].currentSelection
67
temp0 -= BreakablePillar_startDebugID
68
temp0++
69
DrawSprite(temp0)
70
end function
71
72
73
private function BreakablePillar_DebugSpawn
74
temp0 = debugMode[0].currentSelection
75
temp0 -= BreakablePillar_startDebugID
76
temp0++
77
CreateTempObject(TypeName[Breakable Pillar], temp0, object.xpos, object.ypos)
78
object[tempObjectPos].height = 32
79
end function
80
81
82
// ========================
83
// Events
84
// ========================
85
86
event ObjectUpdate
87
switch object.state
88
case BREAKABLEPILLAR_AWAITPLAYER
89
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
90
BoxCollisionTest(C_TOUCH, object.entityPos, -40, -256, 40, 256, currentPlayer, -1, -1, 1, 1)
91
if checkResult == true
92
object.priority = PRIORITY_ACTIVE
93
object.state++
94
end if
95
next
96
break
97
98
case BREAKABLEPILLAR_RISE
99
object.height += 2
100
if object.height == 80
101
object.state = 2
102
end if
103
break
104
105
case BREAKABLEPILLAR_RISEN
106
break
107
108
case BREAKABLEPILLAR_NONE
109
break
110
111
case BREAKABLEPILLAR_TILEDELAY
112
object.delay--
113
if object.delay < 0
114
object.state++
115
end if
116
break
117
118
case BREAKABLEPILLAR_FALL
119
object.xpos += object.xvel
120
object.ypos += object.yvel
121
object.yvel += 0x1800
122
123
if object.outOfBounds == true
124
object.type = TypeName[Blank Object]
125
end if
126
break
127
128
end switch
129
130
if object.state < BREAKABLEPILLAR_TILEDELAY
131
temp0 = object.height
132
temp0 -= 8
133
FlipSign(temp0)
134
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
135
if object.state < BREAKABLEPILLAR_NONE
136
BoxCollisionTest(C_SOLID, object.entityPos, -16, temp0, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
137
if checkResult == COL_TOP
138
player[currentPlayer].animation = ANI_JUMPING
139
if player[currentPlayer].state == Player_State_GlideLeft
140
FlipSign(player[currentPlayer].xvel)
141
player[currentPlayer].speed = player[currentPlayer].xvel
142
end if
143
144
player[currentPlayer].state = Player_State_Roll
145
player[currentPlayer].gravity = GRAVITY_AIR
146
PlaySfx(SfxName[Ledge Break], false)
147
148
temp5 = 0
149
temp0 = object.height
150
temp0 >>= 5
151
temp1 = object.height
152
temp1 &= 31
153
if temp1 != 0
154
temp0++
155
end if
156
temp3 = object.height
157
FlipSign(temp3)
158
temp3 += 16
159
temp3 <<= 16
160
temp3 += object.ypos
161
temp2 = object.xpos
162
temp2 -= 0x180000
163
temp1 = 3
164
while temp1 < 7
165
CreateTempObject(TypeName[Breakable Pillar], temp1, temp2, temp3)
166
GetTableValue(object[tempObjectPos].xvel, temp5, BreakablePillar_tileVelTable)
167
temp5++
168
GetTableValue(object[tempObjectPos].yvel, temp5, BreakablePillar_tileVelTable)
169
temp5++
170
object[tempObjectPos].state = BREAKABLEPILLAR_TILEDELAY
171
temp2 += 0x100000
172
temp1++
173
loop
174
175
temp3 += 0x100000
176
temp4 = 4
177
while temp0 >= 0
178
temp1 = 7
179
temp2 = object.xpos
180
temp2 -= 0x80000
181
while temp1 < 9
182
CreateTempObject(TypeName[Breakable Pillar], temp1, temp2, temp3)
183
GetTableValue(object[tempObjectPos].xvel, temp5, BreakablePillar_tileVelTable)
184
temp5++
185
GetTableValue(object[tempObjectPos].yvel, temp5, BreakablePillar_tileVelTable)
186
temp5++
187
object[tempObjectPos].delay = temp4
188
object[tempObjectPos].state = BREAKABLEPILLAR_TILEDELAY
189
temp2 += 0x100000
190
temp1++
191
loop
192
temp3 += 0x100000
193
temp4 += 4
194
temp0--
195
loop
196
197
temp3 = object.ypos
198
temp3 += 0x100000
199
if object.propertyValue == 1
200
temp6 = 0
201
else
202
temp6 = 2
203
end if
204
temp6 += 9
205
206
temp1 = 0
207
temp2 = object.xpos
208
temp2 -= 0x80000
209
while temp1 < 2
210
CreateTempObject(TypeName[Breakable Pillar], temp6, temp2, temp3)
211
GetTableValue(object[tempObjectPos].xvel, temp5, BreakablePillar_tileVelTable)
212
temp5++
213
GetTableValue(object[tempObjectPos].yvel, temp5, BreakablePillar_tileVelTable)
214
temp5++
215
object[tempObjectPos].delay = temp4
216
object[tempObjectPos].state = BREAKABLEPILLAR_TILEDELAY
217
temp2 += 0x100000
218
temp6++
219
temp1++
220
loop
221
object.state = BREAKABLEPILLAR_NONE
222
end if
223
end if
224
next
225
226
temp0 = screen.xcenter
227
temp0 += 184
228
CheckCameraProximity(object.ixpos, 0, temp0, -1)
229
if checkResult == false
230
object.height = 32
231
object.delay = 0
232
object.state = BREAKABLEPILLAR_AWAITPLAYER
233
object.priority = PRIORITY_BOUNDS
234
end if
235
end if
236
end event
237
238
239
event ObjectDraw
240
if object.state != BREAKABLEPILLAR_NONE
241
temp0 = object.height
242
temp0 -= 8
243
FlipSign(temp0)
244
EditFrame(0, -28, temp0, 56, object.height, 59, 42)
245
246
DrawSprite(0)
247
DrawSprite(object.propertyValue)
248
end if
249
end event
250
251
252
event ObjectStartup
253
LoadSpriteSheet("ARZ/Objects.gif")
254
SpriteFrame(-28, -24, 56, 32, 59, 42)
255
SpriteFrame(-16, 8, 32, 24, 223, 137)
256
SpriteFrame(-16, 8, 32, 16, 71, 130)
257
SpriteFrame(-4, -8, 12, 16, 59, 42)
258
SpriteFrame(-8, -8, 16, 16, 71, 42)
259
SpriteFrame(-8, -8, 16, 16, 87, 42)
260
SpriteFrame(-8, -8, 12, 16, 103, 42)
261
SpriteFrame(-8, -8, 16, 16, 71, 58)
262
SpriteFrame(-8, -8, 16, 16, 87, 58)
263
SpriteFrame(-8, -8, 16, 24, 223, 137)
264
SpriteFrame(-8, -8, 16, 24, 239, 137)
265
SpriteFrame(-8, -8, 16, 16, 71, 130)
266
SpriteFrame(-8, -8, 16, 16, 87, 130)
267
268
temp0 = 0
269
BreakablePillar_startDebugID = DebugMode_ObjCount
270
while temp0 < 2
271
SetTableValue(TypeName[Breakable Pillar], DebugMode_ObjCount, DebugMode_TypesTable)
272
SetTableValue(BreakablePillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
273
SetTableValue(BreakablePillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
274
DebugMode_ObjCount++
275
temp0++
276
loop
277
278
foreach (TypeName[Breakable Pillar], arrayPos0, ALL_ENTITIES)
279
object[arrayPos0].height = 32
280
object[arrayPos0].propertyValue++
281
next
282
end event
283
284
285
// ========================
286
// Editor Events
287
// ========================
288
289
event RSDKEdit
290
if editor.returnVariable == true
291
switch editor.variableID
292
case EDIT_VAR_PROPVAL // property value
293
checkResult = object.propertyValue
294
checkResult &= 1
295
break
296
297
case 0 // noGrass
298
checkResult = object.propertyValue
299
checkResult &= 1
300
break
301
302
end switch
303
else
304
switch editor.variableID
305
case EDIT_VAR_PROPVAL // property value
306
object.propertyValue = editor.variableValue
307
object.propertyValue &= 1
308
break
309
310
case 0 // noGrass
311
object.propertyValue = editor.variableValue
312
object.propertyValue &= 1
313
break
314
315
end switch
316
end if
317
end event
318
319
320
event RSDKDraw
321
object.height = 80
322
object.frame = object.propertyValue
323
object.frame++
324
325
temp0 = object.height
326
temp0 -= 8
327
FlipSign(temp0)
328
EditFrame(0, -28, temp0, 56, object.height, 59, 42)
329
330
DrawSprite(0)
331
DrawSprite(object.frame)
332
end event
333
334
335
event RSDKLoad
336
LoadSpriteSheet("ARZ/Objects.gif")
337
SpriteFrame(-28, -24, 56, 32, 59, 42)
338
SpriteFrame(-16, 8, 32, 24, 223, 137)
339
SpriteFrame(-16, 8, 32, 16, 71, 130)
340
SpriteFrame(-4, -8, 12, 16, 59, 42)
341
SpriteFrame(-8, -8, 16, 16, 71, 42)
342
SpriteFrame(-8, -8, 16, 16, 87, 42)
343
SpriteFrame(-8, -8, 12, 16, 103, 42)
344
SpriteFrame(-8, -8, 16, 16, 71, 58)
345
SpriteFrame(-8, -8, 16, 16, 87, 58)
346
SpriteFrame(-8, -8, 16, 24, 223, 137)
347
SpriteFrame(-8, -8, 16, 24, 239, 137)
348
SpriteFrame(-8, -8, 16, 16, 71, 130)
349
SpriteFrame(-8, -8, 16, 16, 87, 130)
350
351
AddEditorVariable("noGrass")
352
SetActiveVariable("noGrass")
353
AddEnumVariable("false", false)
354
AddEnumVariable("true", true)
355
end event
356
357