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/CPZ/TippingFloor.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Tipping 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.duration
14
private alias object.value2 : object.intervalOffset
15
16
// Player Aliases
17
private alias object.value17 : debugMode.currentSelection
18
19
private alias 0 : TIPPINGFLOOR_IDLE
20
private alias 1 : TIPPINGFLOOR_TIPPING
21
private alias 2 : TIPPINGFLOOR_STATIC
22
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function TippingFloor_DebugDraw
29
reserve function TippingFloor_DebugSpawn
30
31
32
// ========================
33
// Static Values
34
// ========================
35
36
private value TippingFloor_startDebugID = 0
37
38
39
// ========================
40
// Function Definitions
41
// ========================
42
43
private function TippingFloor_DebugDraw
44
DrawSprite(0)
45
end function
46
47
48
private function TippingFloor_DebugSpawn
49
CreateTempObject(TypeName[Tipping Floor], 0, object.xpos, object.ypos)
50
object[tempObjectPos].duration = 127
51
object[tempObjectPos].timer = 127
52
object[tempObjectPos].intervalOffset = debugMode[0].currentSelection
53
object[tempObjectPos].intervalOffset -= TippingFloor_startDebugID
54
object[tempObjectPos].intervalOffset <<= 4
55
object[tempObjectPos].intervalOffset += 16
56
object[tempObjectPos].intervalOffset--
57
end function
58
59
60
// ========================
61
// Events
62
// ========================
63
64
event ObjectUpdate
65
if object.state == TIPPINGFLOOR_IDLE
66
temp0 = oscillation
67
temp0 += object.intervalOffset
68
temp0 &= 0xFF
69
if temp0 == 0
70
object.state = TIPPINGFLOOR_TIPPING
71
object.priority = PRIORITY_ACTIVE
72
end if
73
end if
74
75
if object.state == TIPPINGFLOOR_TIPPING
76
object.timer--
77
if object.timer < 0
78
if object.animation == 0
79
object.timer = object.duration
80
else
81
object.timer = 127
82
end if
83
84
object.animation ^= 1
85
end if
86
87
if object.animation == 0
88
if object.frame < 4
89
object.animationTimer++
90
if object.animationTimer == 8
91
object.animationTimer = 0
92
object.frame++
93
end if
94
end if
95
else
96
if object.frame > 0
97
object.animationTimer++
98
if object.animationTimer == 8
99
object.animationTimer = 0
100
object.frame--
101
end if
102
end if
103
end if
104
end if
105
106
if object.frame == 0
107
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
108
BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -16, 16, -8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
109
next
110
end if
111
112
if options.vsMode == false
113
temp0 = camera[0].xpos
114
temp0 -= object.ixpos
115
Abs(temp0)
116
temp0 -= 128
117
if temp0 > screen.xcenter
118
object.state = TIPPINGFLOOR_IDLE
119
object.timer = object.duration
120
object.priority = PRIORITY_XBOUNDS
121
object.animation = 0
122
object.frame = 0
123
object.animationTimer = 0
124
end if
125
end if
126
end event
127
128
129
event ObjectDraw
130
DrawSprite(object.frame)
131
end event
132
133
134
event ObjectStartup
135
CheckCurrentStageFolder("Zone02")
136
if checkResult == true
137
LoadSpriteSheet("CPZ/Objects.gif")
138
SpriteFrame(-16, -16, 32, 32, 1, 222)
139
SpriteFrame(-16, -21, 32, 37, 34, 218)
140
SpriteFrame(-16, -12, 32, 32, 67, 223)
141
SpriteFrame(-16, -8, 32, 37, 99, 218)
142
SpriteFrame(-16, -8, 32, 32, 132, 223)
143
else
144
LoadSpriteSheet("MBZ/Objects.gif")
145
SpriteFrame(-16, -16, 32, 32, 34, 692)
146
SpriteFrame(-16, -21, 32, 37, 34, 725)
147
SpriteFrame(-16, -12, 32, 32, 34, 763)
148
SpriteFrame(-16, -8, 32, 37, 34, 796)
149
SpriteFrame(-16, -8, 32, 32, 34, 834)
150
end if
151
152
foreach (TypeName[Tipping Floor], arrayPos0, ALL_ENTITIES)
153
object[arrayPos0].priority = PRIORITY_XBOUNDS
154
CheckGreater(object[arrayPos0].propertyValue, 0x7F)
155
temp0 = checkResult
156
CheckEqual(options.vsMode, true)
157
temp0 &= checkResult
158
if temp0 == true
159
object[arrayPos0].state = TIPPINGFLOOR_STATIC
160
else
161
object[arrayPos0].intervalOffset = object[arrayPos0].propertyValue
162
object[arrayPos0].intervalOffset &= 0x0F
163
object[arrayPos0].intervalOffset++
164
object[arrayPos0].intervalOffset <<= 4
165
object[arrayPos0].duration = object[arrayPos0].propertyValue
166
object[arrayPos0].duration &= 0x70
167
object[arrayPos0].duration += 16
168
object[arrayPos0].duration--
169
object[arrayPos0].timer = object[arrayPos0].duration
170
end if
171
next
172
173
temp0 = 0
174
TippingFloor_startDebugID = DebugMode_ObjCount
175
while temp0 < 16
176
SetTableValue(TypeName[Tipping Floor], DebugMode_ObjCount, DebugMode_TypesTable)
177
SetTableValue(TippingFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
178
SetTableValue(TippingFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
179
DebugMode_ObjCount++
180
temp0++
181
loop
182
end event
183
184
185
// ========================
186
// Editor Events
187
// ========================
188
189
event RSDKEdit
190
if editor.returnVariable == true
191
switch editor.variableID
192
case EDIT_VAR_PROPVAL // property value
193
checkResult = object.propertyValue
194
break
195
196
case 0 // duration
197
checkResult = object.propertyValue
198
checkResult >>= 4
199
checkResult &= 3
200
break
201
202
case 1 // intervalOffset
203
checkResult = object.propertyValue
204
checkResult &= 0x0F
205
break
206
207
case 2 // vsDisable
208
GetBit(checkResult, object.propertyValue, 7)
209
break
210
211
end switch
212
else
213
switch editor.variableID
214
case EDIT_VAR_PROPVAL // property value
215
object.propertyValue = editor.variableValue
216
break
217
218
case 0 // duration
219
temp0 = 0x70
220
Not(temp0)
221
object.propertyValue &= temp0
222
editor.variableValue &= 3
223
editor.variableValue <<= 4
224
object.propertyValue |= editor.variableValue
225
break
226
227
case 1 // intervalOffset
228
object.propertyValue &= 0xF0
229
editor.variableValue &= 0x0F
230
object.propertyValue |= editor.variableValue
231
break
232
233
case 2 // vsDisable
234
CheckNotEqual(editor.variableValue, false)
235
SetBit(object.propertyValue, 7, checkResult)
236
break
237
238
end switch
239
end if
240
end event
241
242
243
event RSDKDraw
244
DrawSprite(0)
245
end event
246
247
248
event RSDKLoad
249
CheckCurrentStageFolder("Zone02")
250
if checkResult == true
251
LoadSpriteSheet("CPZ/Objects.gif")
252
SpriteFrame(-16, -16, 32, 32, 1, 222)
253
SpriteFrame(-16, -21, 32, 37, 34, 218)
254
SpriteFrame(-16, -12, 32, 32, 67, 223)
255
SpriteFrame(-16, -8, 32, 37, 99, 218)
256
SpriteFrame(-16, -8, 32, 32, 132, 223)
257
else
258
LoadSpriteSheet("MBZ/Objects.gif")
259
SpriteFrame(-16, -16, 32, 32, 34, 692)
260
SpriteFrame(-16, -21, 32, 37, 34, 725)
261
SpriteFrame(-16, -12, 32, 32, 34, 763)
262
SpriteFrame(-16, -8, 32, 37, 34, 796)
263
SpriteFrame(-16, -8, 32, 32, 34, 834)
264
end if
265
266
AddEditorVariable("duration")
267
SetActiveVariable("duration")
268
AddEnumVariable("15 Frames", 0)
269
AddEnumVariable("31 Frames", 1)
270
AddEnumVariable("47 Frames", 2)
271
AddEnumVariable("63 Frames", 3)
272
273
AddEditorVariable("intervalOffset")
274
SetActiveVariable("intervalOffset")
275
AddEnumVariable("0% through the interval", 0)
276
AddEnumVariable("6.25% through the interval", 1)
277
AddEnumVariable("12.5% through the interval", 2)
278
AddEnumVariable("18.75% through the interval", 3)
279
AddEnumVariable("25% through the interval", 4)
280
AddEnumVariable("31.25% through the interval", 5)
281
AddEnumVariable("37.5% through the interval", 6)
282
AddEnumVariable("43.75% through the interval", 7)
283
AddEnumVariable("50% through the interval", 8)
284
AddEnumVariable("56.25% through the interval", 9)
285
AddEnumVariable("62.5% through the interval", 10)
286
AddEnumVariable("68.75% through the interval", 11)
287
AddEnumVariable("75% through the interval", 12)
288
AddEnumVariable("81.25% through the interval", 13)
289
AddEnumVariable("87.5% through the interval", 14)
290
AddEnumVariable("93.75% through the interval", 15)
291
292
AddEditorVariable("vsDisable")
293
SetActiveVariable("vsDisable")
294
AddEnumVariable("false", false)
295
AddEnumVariable("true", true)
296
end event
297
298