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/SBZ/CollapsingFloor.txt
1481 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: C Floor 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.delay
14
private alias object.value2 : object.collapseTable
15
16
private alias 0 : CFLOOR_TOPSOLID_L
17
private alias 1 : CFLOOR_TOPSOLID_B
18
private alias 2 : CFLOOR_ALLSOLID_L
19
private alias 3 : CFLOOR_ALLSOLID_B
20
21
private alias 0 : CFLOOR_ACTIVE
22
private alias 1 : CFLOOR_COLLAPSE
23
private alias 2 : CFLOOR_COLLAPSED
24
private alias 3 : CFLOOR_NONE
25
private alias 4 : CFLOOR_TILEDELAY
26
private alias 5 : CFLOOR_TILEFALL
27
28
// Player Aliases
29
private alias object.yvel : player.yvel
30
31
32
// ========================
33
// Function Declarations
34
// ========================
35
36
reserve function CFloor_DebugDraw
37
reserve function CFloor_DebugSpawn
38
39
40
// ========================
41
// Tables
42
// ========================
43
44
private table CFloor_collapseTableL
45
30, 22, 14, 6
46
26, 18, 10, 2
47
end table
48
49
private table CFloor_collapseTableB
50
22, 30, 26, 18
51
6, 14, 10, 2
52
end table
53
54
55
// ========================
56
// Function Definitions
57
// ========================
58
59
private function CFloor_DebugDraw
60
DrawSprite(0)
61
end function
62
63
64
private function CFloor_DebugSpawn
65
CreateTempObject(TypeName[C Floor], 0, object.xpos, object.ypos)
66
object[tempObjectPos].collapseTable = CFloor_collapseTableL
67
GetBit(temp0, object.direction, 0)
68
if temp0 == FACING_RIGHT
69
object[tempObjectPos].direction = FLIP_NONE
70
else
71
object[tempObjectPos].direction = FLIP_X
72
end if
73
end function
74
75
76
// ========================
77
// Events
78
// ========================
79
80
event ObjectUpdate
81
switch object.state
82
case CFLOOR_ACTIVE
83
break
84
85
case CFLOOR_COLLAPSE
86
if object.timer < 10
87
object.timer++
88
else
89
temp5 = 0
90
temp0 = 0
91
temp3 = object.ypos
92
temp4 = 10
93
while temp0 < 2
94
temp1 = 0
95
temp2 = object.xpos
96
if object.direction == FLIP_X
97
temp2 -= 0x180000
98
else
99
temp2 += 0x180000
100
end if
101
102
while temp1 < 4
103
CreateTempObject(TypeName[C Floor], 1, temp2, temp3)
104
object[tempObjectPos].state = CFLOOR_TILEDELAY
105
GetTableValue(object[tempObjectPos].delay, temp5, object.collapseTable)
106
temp5++
107
temp1++
108
if object.direction == FLIP_X
109
temp2 += 0x100000
110
else
111
temp2 -= 0x100000
112
end if
113
temp4 += 4
114
loop
115
temp4 -= 26
116
object.frame += 2
117
temp0++
118
temp3 += 0x100000
119
loop
120
PlaySfx(SfxName[Ledge Break L], false)
121
SetSfxAttributes(SfxName[Ledge Break L], -1, -100)
122
PlaySfx(SfxName[Ledge Break R], false)
123
SetSfxAttributes(SfxName[Ledge Break R], -1, 100)
124
object.timer = 0
125
object.state++
126
end if
127
break
128
129
case CFLOOR_COLLAPSED
130
if object.timer < 20
131
object.timer++
132
else
133
object.timer = 0
134
object.state++
135
end if
136
break
137
138
default
139
case CFLOOR_NONE
140
break
141
142
case CFLOOR_TILEDELAY
143
if object.timer < object.delay
144
object.timer++
145
else
146
object.timer = 0
147
object.state++
148
end if
149
break
150
151
case CFLOOR_TILEFALL
152
object.ypos += object.yvel
153
object.yvel += 0x4000
154
if object.outOfBounds == true
155
object.type = TypeName[Blank Object]
156
end if
157
break
158
159
end switch
160
161
if object.state < CFLOOR_TILEDELAY
162
if object.outOfBounds == true
163
object.state = 0
164
object.timer = 0
165
object.priority = PRIORITY_BOUNDS
166
end if
167
end if
168
169
if object.state < CFLOOR_NONE
170
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
171
if object.propertyValue < CFLOOR_ALLSOLID_L
172
if player[currentPlayer].yvel >= 0
173
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
174
else
175
checkResult = COL_NONE
176
end if
177
else
178
BoxCollisionTest(C_SOLID, object.entityPos, -32, -8, 32, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
179
end if
180
181
if checkResult == COL_TOP
182
if object.state == CFLOOR_ACTIVE
183
object.state = CFLOOR_COLLAPSE
184
object.priority = PRIORITY_ACTIVE
185
end if
186
end if
187
next
188
end if
189
end event
190
191
192
event ObjectDraw
193
switch object.state
194
case CFLOOR_ACTIVE
195
case CFLOOR_COLLAPSE
196
DrawSprite(0)
197
break
198
199
case CFLOOR_TILEDELAY
200
case CFLOOR_TILEFALL
201
DrawSprite(object.propertyValue)
202
break
203
204
end switch
205
end event
206
207
208
event ObjectStartup
209
LoadSpriteSheet("SBZ/Objects.gif")
210
SpriteFrame(-32, -8, 64, 32, 0, 105)
211
SpriteFrame(-8, -8, 16, 16, 0, 105)
212
foreach (TypeName[C Floor], arrayPos0, ALL_ENTITIES)
213
GetBit(temp5, object[arrayPos0].propertyValue, 0) // temp5? when no other temps are used nearby? can if you wanna ig
214
if temp5 == false
215
object[arrayPos0].collapseTable = CFloor_collapseTableL
216
else
217
object[arrayPos0].collapseTable = CFloor_collapseTableB
218
end if
219
next
220
SetTableValue(TypeName[C Floor], DebugMode_ObjCount, DebugMode_TypesTable)
221
SetTableValue(CFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
222
SetTableValue(CFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
223
DebugMode_ObjCount++
224
end event
225
226
227
// ========================
228
// Editor Events
229
// ========================
230
231
event RSDKEdit
232
if editor.returnVariable == true
233
switch editor.variableID
234
case EDIT_VAR_PROPVAL // property value
235
checkResult = object.propertyValue
236
break
237
238
case 0 // type
239
checkResult = object.propertyValue
240
checkResult &= 1
241
break
242
case 1 // solidity
243
checkResult = object.propertyValue
244
checkResult >>= 1
245
checkResult &= 1
246
break
247
248
end switch
249
else
250
switch editor.variableID
251
case EDIT_VAR_PROPVAL // property value
252
object.propertyValue = editor.variableValue
253
break
254
255
case 0 // type
256
temp0 = 1
257
Not(temp0)
258
object.propertyValue &= temp0
259
260
editor.variableValue &= 1
261
262
object.propertyValue |= editor.variableValue
263
break
264
case 1 // solidity
265
temp0 = 1
266
temp0 <<= 1
267
Not(temp0)
268
object.propertyValue &= temp0
269
270
editor.variableValue &= 1
271
editor.variableValue <<= 1
272
273
object.propertyValue |= editor.variableValue
274
break
275
276
end switch
277
end if
278
end event
279
280
281
event RSDKDraw
282
DrawSprite(0)
283
end event
284
285
286
event RSDKLoad
287
LoadSpriteSheet("SBZ/Objects.gif")
288
SpriteFrame(-32, -8, 64, 32, 0, 105)
289
290
AddEditorVariable("type")
291
SetActiveVariable("type")
292
AddEnumVariable("Left", CFLOOR_TOPSOLID_L)
293
AddEnumVariable("Bottom", CFLOOR_TOPSOLID_B)
294
295
AddEditorVariable("solidity")
296
SetActiveVariable("solidity")
297
AddEnumVariable("Top Solid", 0)
298
AddEnumVariable("All Solid", 1)
299
end event
300
301