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/SpinPlatform.txt
1481 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Spin 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.interval
15
16
// Player Aliases
17
private alias object.value17 : debugMode.currentSelection
18
19
20
// ========================
21
// Function Declarations
22
// ========================
23
24
reserve function SpinPlatform_DebugDraw
25
reserve function SpinPlatform_DebugSpawn
26
27
28
// ========================
29
// Static Values
30
// ========================
31
32
private value SpinPlatform_startDebugID = 0
33
34
35
// ========================
36
// Tables
37
// ========================
38
39
private table SpinPlatform_frameTable
40
0, 1, 2, 3, 4, 3, 2, 1
41
end table
42
43
private table SpinPlatform_directionTable
44
0, 0, 0, 0
45
0, 2, 2, 2
46
2, 3, 3, 3
47
3, 1, 1, 1
48
end table
49
50
51
// ========================
52
// Function Definitions
53
// ========================
54
55
private function SpinPlatform_DebugDraw
56
DrawSprite(0)
57
end function
58
59
60
private function SpinPlatform_DebugSpawn
61
CreateTempObject(TypeName[Spin Platform], 0, object.xpos, object.ypos)
62
object[tempObjectPos].interval = debugMode[0].currentSelection
63
object[tempObjectPos].interval -= SpinPlatform_startDebugID
64
object[tempObjectPos].interval <<= 4
65
object[tempObjectPos].interval += 16
66
object[tempObjectPos].interval <<= 2
67
object[tempObjectPos].interval--
68
object[tempObjectPos].drawOrder = 4
69
end function
70
71
72
// ========================
73
// Events
74
// ========================
75
76
event ObjectUpdate
77
temp0 = SBZSetup_platformTimer
78
temp0 &= object.interval
79
if temp0 == 0
80
object.state = 1
81
object.priority = PRIORITY_ACTIVE
82
end if
83
84
temp0 = false
85
if object.state != 0
86
object.timer--
87
if object.timer < 0
88
temp0 = true
89
object.timer = object.duration
90
object.state = 0
91
end if
92
end if
93
94
if object.rotation != 0
95
object.rotation++
96
object.rotation &= 31
97
else
98
if temp0 != false
99
object.rotation++
100
end if
101
end if
102
103
temp0 = object.rotation
104
temp0 >>= 1
105
GetTableValue(object.direction, temp0, SpinPlatform_directionTable)
106
temp0 &= 7
107
GetTableValue(object.frame, temp0, SpinPlatform_frameTable)
108
109
if object.rotation == 0
110
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
111
BoxCollisionTest(C_SOLID, object.entityPos, -16, -7, 16, 7, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
112
next
113
end if
114
end event
115
116
117
event ObjectDraw
118
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
119
end event
120
121
122
event ObjectStartup
123
LoadSpriteSheet("SBZ/Objects.gif")
124
SpriteFrame(-16, -7, 32, 14, 413, 166)
125
SpriteFrame(-16, -12, 32, 25, 446, 169)
126
SpriteFrame(-15, -15, 30, 30, 480, 166)
127
SpriteFrame(-13, -16, 25, 32, 449, 198)
128
SpriteFrame(-7, -16, 14, 32, 480, 198)
129
130
foreach (TypeName[Spin Platform], arrayPos0, ALL_ENTITIES)
131
object[arrayPos0].priority = PRIORITY_XBOUNDS
132
object[arrayPos0].drawOrder = 4
133
134
object[arrayPos0].duration = object[arrayPos0].propertyValue
135
object[arrayPos0].duration &= 0x0F
136
object[arrayPos0].duration *= 6
137
object[arrayPos0].timer = object[arrayPos0].duration
138
139
object[arrayPos0].interval = object[arrayPos0].propertyValue
140
object[arrayPos0].interval &= 0x70
141
object[arrayPos0].interval += 16
142
object[arrayPos0].interval <<= 2
143
object[arrayPos0].interval--
144
next
145
146
temp0 = 0
147
SpinPlatform_startDebugID = DebugMode_ObjCount
148
while temp0 < 8
149
SetTableValue(TypeName[Spin Platform], DebugMode_ObjCount, DebugMode_TypesTable)
150
SetTableValue(SpinPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
151
SetTableValue(SpinPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
152
DebugMode_ObjCount++
153
temp0++
154
loop
155
end event
156
157
158
// ========================
159
// Editor Events
160
// ========================
161
162
event RSDKEdit
163
if editor.returnVariable == true
164
switch editor.variableID
165
case EDIT_VAR_PROPVAL // property value
166
checkResult = object.propertyValue
167
break
168
169
case 0 // duration
170
checkResult = object.propertyValue
171
checkResult &= 0x0F
172
break
173
174
case 1 // interval
175
checkResult = object.propertyValue
176
checkResult &= 0x70
177
checkResult >>= 4
178
break
179
180
end switch
181
else
182
switch editor.variableID
183
case EDIT_VAR_PROPVAL // property value
184
object.propertyValue = editor.variableValue
185
break
186
187
case 0 // duration
188
editor.variableValue &= 0x0F
189
190
object.propertyValue &= 0xF0
191
object.propertyValue |= editor.variableValue
192
break
193
194
case 1 // interval
195
editor.variableValue &= 7
196
editor.variableValue <<= 4
197
198
object.propertyValue &= 0x0F
199
object.propertyValue |= temp0
200
break
201
202
end switch
203
end if
204
end event
205
206
207
event RSDKDraw
208
DrawSprite(0)
209
end event
210
211
212
event RSDKLoad
213
LoadSpriteSheet("SBZ/Objects.gif")
214
SpriteFrame(-16, -7, 32, 14, 413, 166)
215
SpriteFrame(-16, -12, 32, 25, 446, 169)
216
SpriteFrame(-15, -15, 30, 30, 480, 166)
217
SpriteFrame(-13, -16, 25, 32, 449, 198)
218
SpriteFrame(-7, -16, 14, 32, 480, 198)
219
220
AddEditorVariable("duration")
221
SetActiveVariable("duration")
222
AddEnumVariable("Every Frame", 0)
223
AddEnumVariable("Every 6 Frames", 1)
224
AddEnumVariable("Every 12 Frames", 2)
225
AddEnumVariable("Every 18 Frames", 3)
226
AddEnumVariable("Every 24 Frames", 4)
227
AddEnumVariable("Every 30 Frames", 5)
228
AddEnumVariable("Every 36 Frames", 6)
229
AddEnumVariable("Every 42 Frames", 7)
230
AddEnumVariable("Every 48 Frames", 8)
231
AddEnumVariable("Every 54 Frames", 9)
232
AddEnumVariable("Every 60 Frames", 10)
233
AddEnumVariable("Every 66 Frames", 11)
234
AddEnumVariable("Every 72 Frames", 12)
235
AddEnumVariable("Every 78 Frames", 13)
236
AddEnumVariable("Every 84 Frames", 14)
237
AddEnumVariable("Every 90 Frames", 15)
238
239
AddEditorVariable("interval")
240
SetActiveVariable("interval")
241
AddEnumVariable("Every 64 Frames", 0)
242
AddEnumVariable("Every 128 Frames", 1)
243
AddEnumVariable("Every 192 Frames", 2)
244
AddEnumVariable("Every 256 Frames", 3)
245
AddEnumVariable("Every 320 Frames", 4)
246
AddEnumVariable("Every 384 Frames", 5)
247
AddEnumVariable("Every 448 Frames", 6)
248
AddEnumVariable("Every 512 Frames", 7)
249
end event
250
251