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/MZ/GlassPillar.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Glass Pillar 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.value1 : object.drawPos.y
13
private alias object.value2 : object.collisionOffset.y
14
private alias object.value3 : object.shinePos.y
15
private alias object.value4 : object.shineAmplitude.y
16
private alias object.value5 : object.amplitude.y
17
18
private alias 0 : GLASSPILLAR_STATIC
19
private alias 1 : GLASSPILLAR_MOVE_UP_DOWN
20
private alias 2 : GLASSPILLAR_MOVE_DOWN_UP
21
22
// Player Aliases
23
private alias object.ypos : player.ypos
24
private alias object.gravity : player.gravity
25
private alias object.value18 : player.sortedDrawOrder
26
27
private alias object.value17 : debugMode.currentSelection
28
29
30
// ========================
31
// Function Declarations
32
// ========================
33
34
reserve function GlassPillar_DebugDraw
35
reserve function GlassPillar_DebugSpawn
36
37
// ========================
38
// Static Values
39
// ========================
40
41
private value GlassPillar_startDebugID = 0
42
43
private function GlassPillar_DebugDraw
44
temp0 = debugMode[0].currentSelection
45
temp0 -= GlassPillar_startDebugID
46
DrawSprite(temp0)
47
end function
48
49
50
private function GlassPillar_DebugSpawn
51
CreateTempObject(TypeName[Glass Pillar], 0, object.xpos, object.ypos)
52
object[tempObjectPos].frame = debugMode[0].currentSelection
53
object[tempObjectPos].frame -= GlassPillar_startDebugID
54
55
if object[tempObjectPos].frame == 0
56
if object.direction == 1
57
object[tempObjectPos].state = GLASSPILLAR_MOVE_DOWN_UP
58
object[tempObjectPos].amplitude.y = -0x1000
59
object[tempObjectPos].shineAmplitude.y = 0x800
60
object[tempObjectPos].ypos -= 0x200000
61
else
62
object[tempObjectPos].state = GLASSPILLAR_MOVE_UP_DOWN
63
object[tempObjectPos].amplitude.y = 0x1000
64
object[tempObjectPos].shineAmplitude.y = -0x800
65
object[tempObjectPos].ypos -= 0x200000
66
end if
67
else
68
object[tempObjectPos].shineAmplitude.y = 0x1000
69
end if
70
71
object[tempObjectPos].drawOrder = 5
72
end function
73
74
75
// ========================
76
// Events
77
// ========================
78
79
event ObjectUpdate
80
switch object.state
81
case GLASSPILLAR_STATIC
82
object.angle = oscillation
83
object.angle <<= 1
84
85
object.drawPos.y = object.ypos
86
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
87
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -56, 32, 56, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
88
if checkResult == COL_BOTTOM
89
if player[currentPlayer].gravity == GRAVITY_GROUND
90
CallFunction(Player_Kill)
91
player[currentPlayer].sortedDrawOrder = 6
92
end if
93
end if
94
next
95
96
object.angle = oscillation
97
object.angle <<= 1
98
Sin(object.shinePos.y, object.angle)
99
object.shinePos.y *= object.shineAmplitude.y
100
object.shinePos.y += object.ypos
101
object.shinePos.y &= 0xFFFF0000
102
break
103
104
case GLASSPILLAR_MOVE_UP_DOWN
105
case GLASSPILLAR_MOVE_DOWN_UP
106
object.angle = oscillation
107
object.angle <<= 1
108
Sin(object.collisionOffset.y, object.angle)
109
object.collisionOffset.y *= object.amplitude.y
110
object.collisionOffset.y += object.ypos
111
object.collisionOffset.y &= 0xFFFF0000
112
object.collisionOffset.y -= object.drawPos.y
113
114
temp0 = object.ypos
115
object.ypos = object.drawPos.y
116
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
117
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -72, 32, 68, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
118
switch checkResult
119
case COL_TOP
120
if checkResult == true
121
player[currentPlayer].ypos += object.collisionOffset.y
122
end if
123
break
124
125
case COL_BOTTOM
126
if player[currentPlayer].gravity == GRAVITY_GROUND
127
if object.collisionOffset.y > 0
128
CallFunction(Player_Kill)
129
player[currentPlayer].sortedDrawOrder = 6
130
end if
131
end if
132
break
133
end switch
134
next
135
136
object.ypos = temp0
137
138
Sin(object.drawPos.y, object.angle)
139
object.drawPos.y *= object.amplitude.y
140
object.drawPos.y += object.ypos
141
object.drawPos.y &= 0xFFFF0000
142
143
Sin(object.shinePos.y, object.angle)
144
object.shinePos.y *= object.shineAmplitude.y
145
object.shinePos.y += object.ypos
146
object.shinePos.y &= 0xFFFF0000
147
148
break
149
150
end switch
151
end event
152
153
154
event ObjectDraw
155
DrawSpriteXY(object.frame, object.xpos, object.drawPos.y)
156
DrawSpriteXY(2, object.xpos, object.shinePos.y)
157
end event
158
159
160
event ObjectStartup
161
LoadSpriteSheet("MZ/Objects.gif")
162
SpriteFrame(-32, -72, 64, 144, 191, 1)
163
SpriteFrame(-32, -56, 64, 112, 126, 1)
164
SpriteFrame(-16, -16, 31, 32, 159, 114)
165
166
foreach (TypeName[Glass Pillar], arrayPos0, ALL_ENTITIES)
167
object[arrayPos0].frame = object[arrayPos0].propertyValue
168
object[arrayPos0].frame >>= 4
169
object[arrayPos0].frame %= 3
170
object[arrayPos0].state = object[arrayPos0].propertyValue
171
object[arrayPos0].state &= 7
172
if object[arrayPos0].state > 5 // 5? but this object only has states counting up to 2..?
173
object[arrayPos0].state = GLASSPILLAR_STATIC
174
end if
175
176
switch object[arrayPos0].state
177
default
178
case GLASSPILLAR_STATIC
179
break
180
181
case GLASSPILLAR_MOVE_UP_DOWN
182
object[arrayPos0].amplitude.y = 0x1000
183
object[arrayPos0].shineAmplitude.y = -0x800
184
object[arrayPos0].ypos -= 0x200000
185
break
186
187
case GLASSPILLAR_MOVE_DOWN_UP
188
object[arrayPos0].amplitude.y = -0x1000
189
object[arrayPos0].shineAmplitude.y = 0x800
190
object[arrayPos0].ypos -= 0x200000
191
break
192
193
end switch
194
object[arrayPos0].drawOrder = 5
195
next
196
197
temp0 = 0
198
GlassPillar_startDebugID = DebugMode_ObjCount
199
while temp0 < 2
200
SetTableValue(TypeName[Glass Pillar], DebugMode_ObjCount, DebugMode_TypesTable)
201
SetTableValue(GlassPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
202
SetTableValue(GlassPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
203
DebugMode_ObjCount++
204
temp0++
205
loop
206
end event
207
208
209
// ========================
210
// Editor Events
211
// ========================
212
213
event RSDKEdit
214
if editor.returnVariable == true
215
switch editor.variableID
216
case EDIT_VAR_PROPVAL // property value
217
checkResult = object.propertyValue
218
break
219
220
case 0 // frameID
221
checkResult = object.propertyValue
222
checkResult &= 0x7F
223
checkResult >>= 4
224
checkResult &= 1
225
break
226
227
case 1 // moveType
228
checkResult = object.propertyValue
229
checkResult &= 7
230
if checkResult > 5
231
checkResult = GLASSPILLAR_STATIC
232
end if
233
break
234
235
end switch
236
else
237
switch editor.variableID
238
case EDIT_VAR_PROPVAL // property value
239
object.propertyValue = editor.variableValue
240
break
241
242
case 0 // frameID
243
temp1 = 0x70
244
Not(temp1)
245
object.propertyValue &= temp1
246
247
editor.variableValue &= 1
248
editor.variableValue <<= 4
249
object.propertyValue |= editor.variableValue
250
break
251
252
case 1 // moveType
253
temp1 = 7
254
Not(temp1)
255
object.propertyValue &= temp1
256
257
temp0 = editor.variableValue
258
temp0 &= 7
259
object.propertyValue |= temp0
260
break
261
262
end switch
263
end if
264
end event
265
266
267
event RSDKDraw
268
temp0 = object.propertyValue
269
temp0 >>= 4
270
temp0 %= 3
271
272
DrawSpriteXY(object.frame, object.xpos, object.ypos)
273
DrawSpriteXY(2, object.xpos, object.ypos)
274
end event
275
276
277
event RSDKLoad
278
LoadSpriteSheet("MZ/Objects.gif")
279
SpriteFrame(-32, -72, 64, 144, 191, 1)
280
SpriteFrame(-32, -56, 64, 112, 126, 1)
281
SpriteFrame(-16, -16, 31, 32, 159, 114)
282
283
AddEditorVariable("frameID")
284
SetActiveVariable("frameID")
285
AddEnumVariable("Long", 0)
286
AddEnumVariable("Medium", 1)
287
288
AddEditorVariable("moveType")
289
SetActiveVariable("moveType")
290
AddEnumVariable("Static", GLASSPILLAR_STATIC)
291
AddEnumVariable("Move Vertically", GLASSPILLAR_MOVE_UP_DOWN)
292
AddEnumVariable("Move Vertically (Reversed)", GLASSPILLAR_MOVE_DOWN_UP)
293
end event
294
295