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/Staircase.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Staircase 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.stairPos
14
15
private alias 0 : STAIRCASE_ACTIVATE_TOP
16
private alias 1 : STAIRCASE_ACTIVATING_TOP
17
private alias 2 : STAIRCASE_LOWERING
18
private alias 3 : STAIRCASE_LOWERED
19
private alias 4 : STAIRCASE_ACTIVATE_BOTTOM
20
private alias 5 : STAIRCASE_ACTIVATING_BOTTOM
21
22
// Player Aliases
23
private alias object.ypos : player.ypos
24
private alias object.gravity : player.gravity
25
26
27
// ========================
28
// Function Declarations
29
// ========================
30
31
reserve function Staircase_DebugDraw
32
reserve function Staircase_DebugSpawn
33
34
35
// ========================
36
// Function Definitions
37
// ========================
38
39
private function Staircase_DebugDraw
40
DrawSprite(0)
41
end function
42
43
44
private function Staircase_DebugSpawn
45
CreateTempObject(TypeName[Staircase], 0, object.xpos, object.ypos)
46
GetBit(temp0, object.direction, 0)
47
if temp0 == FLIP_NONE
48
object[tempObjectPos].direction = FLIP_NONE
49
else
50
object[tempObjectPos].direction = FLIP_X
51
end if
52
end function
53
54
55
// ========================
56
// Events
57
// ========================
58
59
event ObjectUpdate
60
object.priority = PRIORITY_ACTIVE
61
switch object.state
62
case STAIRCASE_ACTIVATE_TOP
63
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
64
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
65
if checkResult == COL_TOP
66
object.timer = 32
67
object.state++
68
end if
69
next
70
break
71
72
case STAIRCASE_ACTIVATING_TOP
73
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
74
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
75
next
76
77
object.timer--
78
if object.timer < 0
79
object.timer = 128
80
object.state++
81
end if
82
break
83
84
case STAIRCASE_LOWERING
85
temp0 = object.xpos
86
temp1 = object.ypos
87
if object.direction == FLIP_NONE
88
object.xpos += 0x600000
89
temp4 = -0x200000
90
else
91
temp4 = 0x200000
92
end if
93
94
temp5 = object.stairPos
95
temp2 = 1
96
while temp2 < 5
97
object.ypos += temp5
98
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
99
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
100
if checkResult == COL_TOP
101
temp6 = object.ypos
102
temp6 &= 0xFFFF0000
103
temp7 = 0x4000
104
temp7 *= temp2
105
temp7 += object.ypos
106
temp7 &= 0xFFFF0000
107
temp7 -= temp6
108
player[currentPlayer].ypos += temp7
109
end if
110
111
if player[currentPlayer].gravity == 0
112
if checkResult == COL_BOTTOM
113
CallFunction(Player_Kill)
114
end if
115
end if
116
next
117
object.xpos += temp4
118
temp2++
119
loop
120
object.stairPos += 0x4000
121
object.xpos = temp0
122
object.ypos = temp1
123
124
object.timer--
125
if object.timer <= 0
126
object.state++
127
end if
128
break
129
130
case STAIRCASE_LOWERED
131
temp0 = object.xpos
132
temp1 = object.ypos
133
if object.direction == FLIP_NONE
134
object.xpos += 0x600000
135
temp4 = -0x200000
136
else
137
temp4 = 0x200000
138
end if
139
140
temp5 = object.stairPos
141
temp2 = 1
142
while temp2 < 5
143
object.ypos += temp5
144
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
145
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
146
if player[currentPlayer].gravity == 0
147
if checkResult == COL_BOTTOM
148
CallFunction(Player_Kill)
149
end if
150
end if
151
next
152
object.xpos += temp4
153
temp2++
154
loop
155
object.xpos = temp0
156
object.ypos = temp1
157
break
158
159
case STAIRCASE_ACTIVATE_BOTTOM
160
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
161
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
162
if checkResult == COL_BOTTOM
163
object.timer = 59
164
object.state++
165
end if
166
next
167
break
168
169
case STAIRCASE_ACTIVATING_BOTTOM
170
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
171
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 112, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
172
next
173
174
object.timer--
175
if object.timer < 0
176
object.timer = 128
177
object.state = STAIRCASE_LOWERING
178
end if
179
break
180
181
end switch
182
183
if object.outOfBounds == true
184
object.priority = PRIORITY_BOUNDS
185
object.state = STAIRCASE_ACTIVATE_TOP
186
object.stairPos = 0
187
if object.propertyValue == 2
188
object.state = STAIRCASE_ACTIVATE_BOTTOM
189
end if
190
end if
191
end event
192
193
194
event ObjectDraw
195
switch object.state
196
case STAIRCASE_ACTIVATE_TOP
197
case STAIRCASE_ACTIVATING_TOP
198
case STAIRCASE_ACTIVATE_BOTTOM
199
DrawSprite(0)
200
break
201
202
case STAIRCASE_LOWERING
203
case STAIRCASE_LOWERED
204
temp2 = object.xpos
205
temp3 = object.ypos
206
if object.direction == FLIP_NONE
207
temp2 += 0x600000
208
temp4 = -0x200000
209
else
210
temp4 = 0x200000
211
end if
212
temp5 = object.stairPos
213
temp3 += temp5
214
DrawSpriteXY(1, temp2, temp3)
215
temp2 += temp4
216
temp3 += temp5
217
DrawSpriteXY(1, temp2, temp3)
218
temp2 += temp4
219
temp3 += temp5
220
DrawSpriteXY(1, temp2, temp3)
221
temp2 += temp4
222
temp3 += temp5
223
DrawSpriteXY(1, temp2, temp3)
224
break
225
226
case STAIRCASE_ACTIVATING_BOTTOM
227
temp2 = object.xpos
228
if object.direction == FLIP_NONE
229
temp2 += 0x600000
230
temp4 = -0x200000
231
else
232
temp4 = 0x200000
233
end if
234
235
GetBit(temp5, object.timer, 2)
236
temp5 <<= 16
237
temp6 = 0
238
while temp6 < 4
239
temp3 = object.ypos
240
temp3 += temp5
241
temp5 ^= 0x10000
242
DrawSpriteXY(1, temp2, temp3)
243
temp2 += temp4
244
temp6++
245
loop
246
break
247
248
end switch
249
end event
250
251
252
event ObjectStartup
253
LoadSpriteSheet("SLZ/Objects.gif")
254
SpriteFrame(-16, -16, 128, 32, 67, 26)
255
SpriteFrame(-16, -16, 32, 32, 67, 26)
256
foreach (TypeName[Staircase], arrayPos0, ALL_ENTITIES)
257
if object[arrayPos0].propertyValue == 2
258
object[arrayPos0].state = STAIRCASE_ACTIVATE_BOTTOM
259
end if
260
next
261
SetTableValue(TypeName[Staircase], DebugMode_ObjCount, DebugMode_TypesTable)
262
SetTableValue(Staircase_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
263
SetTableValue(Staircase_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
264
DebugMode_ObjCount++
265
end event
266
267
268
// ========================
269
// Editor Events
270
// ========================
271
272
event RSDKEdit
273
if editor.returnVariable == true
274
switch editor.variableID
275
case EDIT_VAR_PROPVAL // property value
276
checkResult = object.propertyValue
277
checkResult &= 3
278
break
279
280
case 0 // type
281
checkResult = object.propertyValue
282
break
283
284
end switch
285
else
286
switch editor.variableID
287
case EDIT_VAR_PROPVAL // property value
288
object.propertyValue = editor.variableValue
289
object.propertyValue &= 3
290
break
291
292
case 0 // type
293
object.propertyValue = editor.variableValue
294
break
295
296
end switch
297
end if
298
end event
299
300
301
event RSDKDraw
302
if editor.showGizmos == true
303
editor.drawingOverlay = true
304
305
// Draw the activated Staircase
306
307
object.inkEffect = INK_BLEND
308
temp2 = object.xpos
309
temp3 = object.ypos
310
if object.direction == FLIP_NONE
311
temp2 += 0x600000
312
temp4 = -0x200000
313
else
314
temp4 = 0x200000
315
end if
316
317
temp5 = 0x200000
318
temp3 += temp5
319
DrawSpriteFX(1, FX_INK, temp2, temp3)
320
temp2 += temp4
321
temp3 += temp5
322
DrawSpriteFX(1, FX_INK, temp2, temp3)
323
temp2 += temp4
324
temp3 += temp5
325
DrawSpriteFX(1, FX_INK, temp2, temp3)
326
temp2 += temp4
327
temp3 += temp5
328
DrawSpriteFX(1, FX_INK, temp2, temp3)
329
330
editor.drawingOverlay = false
331
end if
332
333
// The Staircase's unactivated position
334
object.inkEffect = INK_NONE
335
DrawSprite(0)
336
end event
337
338
339
event RSDKLoad
340
LoadSpriteSheet("SLZ/Objects.gif")
341
SpriteFrame(-16, -16, 128, 32, 67, 26)
342
SpriteFrame(-16, -16, 32, 32, 67, 26)
343
344
AddEditorVariable("type")
345
SetActiveVariable("type")
346
AddEnumVariable("Activate From Top", 0)
347
// 1 goes unused, it was prolly for directions before it was migrated to just object.direction directly
348
AddEnumVariable("Activate From Bottom", 2)
349
end event
350
351