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/VanishPlatform.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Vanish Platform 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
private alias object.value3 : object.interval
16
17
// Player Aliases
18
private alias object.value17 : debugMode.currentSelection
19
20
21
// ========================
22
// Function Declarations
23
// ========================
24
25
reserve function VanishPlatform_DebugDraw
26
reserve function VanishPlatform_DebugSpawn
27
28
29
// ========================
30
// Static Values
31
// ========================
32
33
private value VanishPlatform_startDebugID = 0
34
35
36
// ========================
37
// Function Definitions
38
// ========================
39
40
private function VanishPlatform_DebugDraw
41
DrawSprite(3)
42
end function
43
44
45
private function VanishPlatform_DebugSpawn
46
CreateTempObject(TypeName[Vanish Platform], 0, object.xpos, object.ypos)
47
object[tempObjectPos].priority = PRIORITY_XBOUNDS
48
object[tempObjectPos].duration = 127
49
object[tempObjectPos].timer = 127
50
51
temp1 = debugMode[0].currentSelection
52
temp1 -= VanishPlatform_startDebugID
53
temp1 <<= 4
54
temp0 += 128
55
temp1 *= temp0
56
temp1 >>= 8
57
object[tempObjectPos].intervalOffset = temp1
58
temp0--
59
object[tempObjectPos].interval = temp0
60
end function
61
62
63
// ========================
64
// Events
65
// ========================
66
67
event ObjectUpdate
68
if object.state == 0
69
temp0 = SBZSetup_platformTimer
70
temp0 -= object.intervalOffset
71
temp0 &= object.interval
72
if temp0 == 0
73
object.state = 1
74
object.priority = PRIORITY_ACTIVE
75
end if
76
end if
77
78
if object.state != 0
79
object.timer--
80
if object.timer < 0
81
if object.animation == 0
82
object.timer = object.duration
83
else
84
object.timer = 127
85
end if
86
object.animation ^= 1
87
end if
88
89
if object.animation == 0
90
if object.frame < 3
91
object.animationTimer++
92
if object.animationTimer == 8
93
object.animationTimer = 0
94
object.frame++
95
end if
96
end if
97
else
98
if object.frame > 0
99
object.animationTimer++
100
if object.animationTimer == 8
101
object.animationTimer = 0
102
object.frame--
103
end if
104
end if
105
end if
106
107
GetBit(temp0, object.frame, 1)
108
if temp0 != 0
109
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
110
BoxCollisionTest(C_PLATFORM, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
111
next
112
end if
113
end if
114
115
temp0 = camera[0].xpos
116
temp0 -= object.ixpos
117
Abs(temp0)
118
temp0 -= 128
119
if temp0 > screen.xcenter
120
object.state = 0
121
object.timer = 127
122
object.priority = PRIORITY_XBOUNDS
123
object.animation = 0
124
object.frame = 0
125
object.animationTimer = 0
126
end if
127
end event
128
129
130
event ObjectDraw
131
DrawSprite(object.frame)
132
end event
133
134
135
event ObjectStartup
136
LoadSpriteSheet("SBZ/Objects.gif")
137
138
// Platform frames
139
SpriteFrame(0, 0, 1, 1, 449, 198)
140
SpriteFrame(-2, -8, 4, 32, 507, 231)
141
SpriteFrame(-8, -8, 16, 32, 490, 231)
142
SpriteFrame(-16, -8, 32, 32, 457, 231)
143
144
// Do setup for every vanish platform object
145
foreach (TypeName[Vanish Platform], arrayPos0, ALL_ENTITIES)
146
object[arrayPos0].priority = PRIORITY_XBOUNDS
147
temp0 = object[arrayPos0].propertyValue
148
temp0 &= 0x0F
149
temp0++
150
temp0 <<= 7
151
object[arrayPos0].duration = temp0
152
object[arrayPos0].duration--
153
object[arrayPos0].timer = 127
154
155
temp1 = object[arrayPos0].propertyValue
156
temp1 &= 0xF0
157
temp0 += 0x80
158
temp1 *= temp0
159
temp1 >>= 8
160
object[arrayPos0].intervalOffset = temp1
161
temp0--
162
object[arrayPos0].interval = temp0
163
next
164
165
// Add this object to the debug object list, several times for the different intervals
166
temp0 = 0
167
VanishPlatform_startDebugID = DebugMode_ObjCount
168
while temp0 < 16
169
SetTableValue(TypeName[Vanish Platform], DebugMode_ObjCount, DebugMode_TypesTable)
170
SetTableValue(VanishPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
171
SetTableValue(VanishPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
172
DebugMode_ObjCount++
173
temp0++
174
loop
175
end event
176
177
178
// ========================
179
// Editor Events
180
// ========================
181
182
event RSDKEdit
183
if editor.returnVariable == true
184
switch editor.variableID
185
case EDIT_VAR_PROPVAL // property value
186
checkResult = object.propertyValue
187
break
188
189
case 0 // interval
190
checkResult = object.propertyValue
191
checkResult &= 0xF
192
break
193
194
case 1 // intervalOffset
195
checkResult = object.propertyValue
196
checkResult >>= 4
197
checkResult &= 0xF
198
break
199
200
end switch
201
else
202
switch editor.variableID
203
case EDIT_VAR_PROPVAL // property value
204
object.propertyValue = editor.variableValue
205
break
206
207
case 0 // interval
208
temp0 = editor.variableValue
209
temp0 &= 0xF
210
object.propertyValue &= 0xF0
211
object.propertyValue |= temp0
212
break
213
214
case 1 // intervalOffset
215
temp0 = editor.variableValue
216
temp0 &= 0xF
217
temp0 <<= 4
218
object.propertyValue &= 0xF
219
object.propertyValue |= temp0
220
break
221
222
end switch
223
end if
224
end event
225
226
227
event RSDKDraw
228
DrawSprite(0)
229
end event
230
231
232
event RSDKLoad
233
LoadSpriteSheet("SBZ/Objects.gif")
234
235
// Platform frames
236
SpriteFrame(-16, -8, 32, 32, 457, 231)
237
238
AddEditorVariable("interval")
239
SetActiveVariable("interval")
240
AddEnumVariable("Every 128 Frames", 0)
241
AddEnumVariable("Every 256 Frames", 1)
242
AddEnumVariable("Every 384 Frames", 2)
243
AddEnumVariable("Every 512 Frames", 3)
244
AddEnumVariable("Every 640 Frames", 4)
245
AddEnumVariable("Every 768 Frames", 5)
246
AddEnumVariable("Every 896 Frames", 6)
247
AddEnumVariable("Every 1024 Frames", 7)
248
AddEnumVariable("Every 1152 Frames", 8)
249
AddEnumVariable("Every 1280 Frames", 9)
250
AddEnumVariable("Every 1408 Frames", 10)
251
AddEnumVariable("Every 1536 Frames", 11)
252
AddEnumVariable("Every 1664 Frames", 12)
253
AddEnumVariable("Every 1792 Frames", 13)
254
AddEnumVariable("Every 1920 Frames", 14)
255
AddEnumVariable("Every 2048 Frames", 15)
256
257
AddEditorVariable("intervalOffset")
258
SetActiveVariable("intervalOffset")
259
AddEnumVariable("0% through the interval", 0)
260
AddEnumVariable("6.25% through the interval", 1)
261
AddEnumVariable("12.5% through the interval", 2)
262
AddEnumVariable("18.75% through the interval", 3)
263
AddEnumVariable("25% through the interval", 4)
264
AddEnumVariable("31.25% through the interval", 5)
265
AddEnumVariable("37.5% through the interval", 6)
266
AddEnumVariable("43.75% through the interval", 7)
267
AddEnumVariable("50% through the interval", 8)
268
AddEnumVariable("56.25% through the interval", 9)
269
AddEnumVariable("62.5% through the interval", 10)
270
AddEnumVariable("68.75% through the interval", 11)
271
AddEnumVariable("75% through the interval", 12)
272
AddEnumVariable("81.25% through the interval", 13)
273
AddEnumVariable("87.5% through the interval", 14)
274
AddEnumVariable("93.75% through the interval", 15)
275
end event
276
277