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/Global/PSwitch_H.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Plane Sw H 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.extendLeft
13
private alias object.value1 : object.extendRight
14
private alias object.value2 : object.planeR // bottom (rising up), named the same as PSwitch_V for consistency
15
private alias object.value3 : object.planeL // top (falling down), named the same as PSwitch_V for consistency
16
private alias object.value4 : object.drawOrderR // bottom (rising up), named the same as PSwitch_V for consistency
17
private alias object.value5 : object.drawOrderL // top (falling down), named the same as PSwitch_V for consistency
18
private alias object.value6 : object.onGround
19
20
// Player Aliases
21
private alias object.state : player.state
22
private alias object.yvel : player.yvel
23
private alias object.gravity : player.gravity
24
private alias object.collisionPlane : player.collisionPlane
25
private alias object.value18 : player.sortedDrawOrder
26
27
28
// ========================
29
// Events
30
// ========================
31
32
event ObjectUpdate
33
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
34
CheckEqual(object.onGround, false)
35
temp0 = checkResult
36
CheckEqual(player[currentPlayer].gravity, GRAVITY_GROUND)
37
temp0 |= checkResult
38
CheckEqual(player[currentPlayer].state, Player_State_Climb)
39
temp0 |= checkResult
40
41
if temp0 == true
42
BoxCollisionTest(C_TOUCH, object.entityPos, object.extendLeft, -12, object.extendRight, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
43
if checkResult == true
44
if player[currentPlayer].yvel > 0
45
player[currentPlayer].collisionPlane = object.planeL
46
player[currentPlayer].sortedDrawOrder = object.drawOrderL
47
else
48
player[currentPlayer].collisionPlane = object.planeR
49
player[currentPlayer].sortedDrawOrder = object.drawOrderR
50
end if
51
end if
52
end if
53
next
54
end event
55
56
57
event ObjectStartup
58
foreach (TypeName[Plane Sw H], arrayPos0, ALL_ENTITIES)
59
temp0 = object[arrayPos0].propertyValue
60
temp0 &= 3
61
temp0 += 2
62
object[arrayPos0].extendLeft = 1
63
object[arrayPos0].extendLeft <<= temp0
64
object[arrayPos0].extendLeft <<= 3
65
object[arrayPos0].extendLeft += 8
66
object[arrayPos0].extendRight = object[arrayPos0].extendLeft
67
FlipSign(object[arrayPos0].extendLeft)
68
69
GetBit(object[arrayPos0].planeR, object[arrayPos0].propertyValue, 2)
70
GetBit(object[arrayPos0].planeL, object[arrayPos0].propertyValue, 3)
71
72
GetBit(object[arrayPos0].drawOrderR, object[arrayPos0].propertyValue, 4)
73
object[arrayPos0].drawOrderR <<= 1
74
object[arrayPos0].drawOrderR += 4
75
GetBit(object[arrayPos0].drawOrderL, object[arrayPos0].propertyValue, 5)
76
object[arrayPos0].drawOrderL <<= 1
77
object[arrayPos0].drawOrderL += 4
78
79
GetBit(object[arrayPos0].onGround, object[arrayPos0].propertyValue, 7)
80
next
81
end event
82
83
84
// ========================
85
// Editor Events & Aliases
86
// ========================
87
88
private alias 0 : VAR_ID_SIZE
89
private alias 1 : VAR_ID_PLANEL
90
private alias 2 : VAR_ID_PLANER
91
private alias 3 : VAR_ID_DRAWL
92
private alias 4 : VAR_ID_DRAWR
93
private alias 5 : VAR_ID_ONGROUND
94
95
96
event RSDKEdit
97
if editor.returnVariable == true
98
switch editor.variableID
99
case EDIT_VAR_PROPVAL // property value
100
checkResult = object.propertyValue
101
break
102
103
case VAR_ID_SIZE // size
104
checkResult = object.propertyValue
105
checkResult &= 3
106
break
107
108
case VAR_ID_PLANEL // collisionPlaneL
109
GetBit(checkResult, object.propertyValue, 2)
110
break
111
112
case VAR_ID_PLANER // collisionPlaneR
113
GetBit(checkResult, object.propertyValue, 3)
114
break
115
116
case VAR_ID_DRAWL // drawOrderL
117
GetBit(checkResult, object.propertyValue, 4)
118
break
119
120
case VAR_ID_DRAWR // drawOrderR
121
GetBit(checkResult, object.propertyValue, 5)
122
break
123
124
case VAR_ID_ONGROUND // onGround
125
GetBit(checkResult, object.propertyValue, 7)
126
break
127
128
end switch
129
else
130
switch editor.variableID
131
case EDIT_VAR_PROPVAL // property value
132
object.propertyValue = editor.variableValue
133
break
134
135
case VAR_ID_SIZE // size
136
temp1 = 3
137
Not(temp1)
138
object.propertyValue &= temp1
139
140
temp0 = editor.variableValue
141
temp0 &= 3
142
object.propertyValue |= temp0
143
break
144
145
case VAR_ID_PLANEL // collisionPlaneL
146
CheckNotEqual(editor.variableValue, false)
147
SetBit(object.propertyValue, 2, checkResult)
148
break
149
150
case VAR_ID_PLANER // collisionPlaneR
151
CheckNotEqual(editor.variableValue, false)
152
SetBit(object.propertyValue, 3, checkResult)
153
break
154
155
case VAR_ID_DRAWL // drawOrderL
156
CheckNotEqual(editor.variableValue, false)
157
SetBit(object.propertyValue, 4, checkResult)
158
break
159
160
case VAR_ID_DRAWR // drawOrderR
161
CheckNotEqual(editor.variableValue, false)
162
SetBit(object.propertyValue, 5, checkResult)
163
break
164
165
case VAR_ID_ONGROUND // onGround
166
CheckNotEqual(editor.variableValue, false)
167
SetBit(object.propertyValue, 7, checkResult)
168
break
169
170
end switch
171
end if
172
end event
173
174
175
event RSDKDraw
176
// Grabbed this from S2's debug view since S1 doesn't have one, works the same though
177
178
temp1 = object.propertyValue
179
temp1 &= 3
180
temp1 += 2
181
temp0 = 1
182
temp0 <<= temp1
183
temp1 = temp0
184
temp0 <<= 19
185
FlipSign(temp0)
186
temp0 += object.xpos
187
temp0 += 0x80000
188
189
GetBit(temp2, object.propertyValue, 7)
190
temp3 = object.propertyValue
191
temp3 >>= 2
192
temp3 &= 15
193
194
temp4 = 0
195
while temp4 < temp1
196
if temp2 == true
197
DrawSpriteXY(16, temp0, object.ypos)
198
end if
199
DrawSpriteXY(temp3, temp0, object.ypos)
200
temp0 += 0x100000
201
temp4++
202
loop
203
204
if temp1 == 0
205
DrawSprite(temp3)
206
end if
207
end event
208
209
210
event RSDKLoad
211
LoadSpriteSheet("Global/Display.gif")
212
213
temp0 = 0
214
temp1 = 46
215
while temp0 < 8
216
SpriteFrame(-8, -8, 16, 16, temp1, 158)
217
temp0++
218
temp1 += 17
219
loop
220
221
temp0 = 0
222
temp1 = 46
223
while temp0 < 8
224
SpriteFrame(-8, -8, 16, 16, temp1, 175)
225
temp0++
226
temp1 += 17
227
loop
228
229
SpriteFrame(-8, -8, 16, 16, 182, 141) // #16 - back
230
231
AddEditorVariable("size")
232
SetActiveVariable("size")
233
AddEnumVariable("4 Nodes", 0)
234
AddEnumVariable("8 Nodes", 1)
235
AddEnumVariable("16 Nodes", 2)
236
AddEnumVariable("32 Nodes", 3)
237
238
AddEditorVariable("collisionPlaneL")
239
SetActiveVariable("collisionPlaneL")
240
AddEnumVariable("Plane A", 0)
241
AddEnumVariable("Plane B", 1)
242
243
AddEditorVariable("collisionPlaneR")
244
SetActiveVariable("collisionPlaneR")
245
AddEnumVariable("Plane A", 0)
246
AddEnumVariable("Plane B", 1)
247
248
AddEditorVariable("drawOrderL")
249
SetActiveVariable("drawOrderL")
250
AddEnumVariable("Low Layer", 0)
251
AddEnumVariable("High Layer", 1)
252
253
AddEditorVariable("drawOrderR")
254
SetActiveVariable("drawOrderR")
255
AddEnumVariable("Low Layer", 0)
256
AddEnumVariable("High Layer", 1)
257
258
AddEditorVariable("onGround")
259
SetActiveVariable("onGround")
260
AddEnumVariable("false", false)
261
AddEnumVariable("true", true)
262
end event
263
264