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