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/SLZ/RotatePlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Rotate 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.value1 : object.drawPos.x
13
private alias object.value2 : object.drawPos.y
14
15
// Player Aliases
16
private alias object.xpos : player.xpos
17
private alias object.ypos : player.ypos
18
19
private alias object.value17 : debugMode.currentSelection
20
21
22
// ========================
23
// Function Declarations
24
// ========================
25
26
reserve function RotatePlatform_DebugDraw
27
reserve function RotatePlatform_DebugSpawn
28
29
30
// ========================
31
// Static Values
32
// ========================
33
34
private value RotatePlatform_startDebugID = 0
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function RotatePlatform_DebugDraw
42
DrawSprite(0)
43
end function
44
45
46
private function RotatePlatform_DebugSpawn
47
temp0 = debugMode[0].currentSelection
48
temp0 -= RotatePlatform_startDebugID
49
temp1 = object.direction
50
temp1 <<= 2
51
temp0 += temp1
52
CreateTempObject(TypeName[Rotate Platform], temp0, object.xpos, object.ypos)
53
end function
54
55
56
// ========================
57
// Events
58
// ========================
59
60
event ObjectUpdate
61
temp6 = object.xpos
62
temp7 = object.ypos
63
object.xpos = object.drawPos.x
64
object.ypos = object.drawPos.y
65
66
GetTableValue(temp0, 16, StageSetup_oscillationTable)
67
temp0 <<= 8
68
temp0 &= 0xFFFF0000
69
temp0 -= 0x500000
70
71
GetTableValue(temp1, 18, StageSetup_oscillationTable)
72
temp1 <<= 8
73
temp1 &= 0xFFFF0000
74
temp1 -= 0x500000
75
76
GetBit(temp2, object.propertyValue, 0)
77
if temp2 == true
78
FlipSign(temp0)
79
FlipSign(temp1)
80
end if
81
82
GetBit(temp2, object.propertyValue, 2)
83
if temp2 == true
84
FlipSign(temp0)
85
end if
86
87
GetBit(temp2, object.propertyValue, 1)
88
if temp2 == false
89
object.drawPos.x = temp0
90
object.drawPos.y = temp1
91
else
92
FlipSign(temp0)
93
object.drawPos.x = temp1
94
object.drawPos.y = temp0
95
end if
96
object.drawPos.x += temp6
97
object.drawPos.y += temp7
98
99
temp2 = object.drawPos.x
100
temp2 -= object.xpos
101
temp3 = object.drawPos.y
102
temp3 -= object.ypos
103
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
104
BoxCollisionTest(C_PLATFORM, object.entityPos, -24, -8, 24, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
105
if checkResult == true
106
player[currentPlayer].xpos += temp2
107
player[currentPlayer].ypos += temp3
108
end if
109
next
110
111
object.xpos = temp6
112
object.ypos = temp7
113
end event
114
115
116
event ObjectDraw
117
DrawSpriteXY(0, object.drawPos.x, object.drawPos.y)
118
end event
119
120
121
event ObjectStartup
122
LoadSpriteSheet("SLZ/Objects.gif")
123
SpriteFrame(-24, -8, 48, 16, 1, 196)
124
125
temp0 = 0
126
RotatePlatform_startDebugID = DebugMode_ObjCount
127
RotatePlatform_startDebugID--
128
while temp0 < 4
129
SetTableValue(TypeName[Rotate Platform], DebugMode_ObjCount, DebugMode_TypesTable)
130
SetTableValue(RotatePlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
131
SetTableValue(RotatePlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
132
DebugMode_ObjCount++
133
temp0++
134
loop
135
end event
136
137
138
// ========================
139
// Editor Events
140
// ========================
141
142
event RSDKEdit
143
if editor.returnVariable == true
144
switch editor.variableID
145
case EDIT_VAR_PROPVAL // property value
146
checkResult = object.propertyValue
147
break
148
149
case 0 // flipMoveX
150
GetBit(checkResult, object.propertyValue, 2)
151
break
152
153
case 1 // flipMoveY
154
GetBit(checkResult, object.propertyValue, 1)
155
break
156
157
case 2 // flipMoveXY
158
GetBit(checkResult, object.propertyValue, 0)
159
break
160
161
end switch
162
else
163
switch editor.variableID
164
case EDIT_VAR_PROPVAL // property value
165
object.propertyValue = editor.variableValue
166
break
167
168
case 0 // flipMoveX
169
CheckNotEqual(editor.variableValue, 0)
170
SetBit(object.propertyValue, 2, checkResult)
171
break
172
173
case 1 // flipMoveY
174
CheckNotEqual(editor.variableValue, 0)
175
SetBit(object.propertyValue, 1, checkResult)
176
break
177
178
case 2 // flipMoveXY
179
CheckNotEqual(editor.variableValue, 0)
180
SetBit(object.propertyValue, 0, checkResult)
181
break
182
183
end switch
184
end if
185
end event
186
187
188
event RSDKDraw
189
// Actual Position
190
DrawSprite(0)
191
192
if editor.showGizmos == true
193
editor.drawingOverlay = true
194
195
// Draw where the player will see the Platform
196
197
temp6 = object.xpos
198
temp7 = object.ypos
199
200
temp0 = 0
201
temp0 &= 0xFFFF0000
202
temp0 -= 0x500000
203
204
temp1 = 0
205
temp1 &= 0xFFFF0000
206
temp1 -= 0x500000
207
208
GetBit(temp2, object.propertyValue, 0)
209
if temp2 == true
210
FlipSign(temp0)
211
FlipSign(temp1)
212
end if
213
214
GetBit(temp2, object.propertyValue, 2)
215
if temp2 == true
216
FlipSign(temp0)
217
end if
218
219
GetBit(temp2, object.propertyValue, 1)
220
if temp2 == false
221
object.drawPos.x = temp0
222
object.drawPos.y = temp1
223
else
224
FlipSign(temp0)
225
object.drawPos.x = temp1
226
object.drawPos.y = temp0
227
end if
228
object.drawPos.x += temp6
229
object.drawPos.y += temp7
230
231
object.inkEffect = INK_BLEND
232
DrawSpriteFX(0, FX_INK, object.drawPos.x, object.drawPos.y)
233
234
DrawLine(object.xpos, object.ypos, object.drawPos.x, object.drawPos.y, 0xFF, 0xFF, 0x00)
235
236
editor.drawingOverlay = false
237
end if
238
end event
239
240
241
event RSDKLoad
242
LoadSpriteSheet("SLZ/Objects.gif")
243
SpriteFrame(-24, -8, 48, 16, 1, 196)
244
245
AddEditorVariable("flipMoveX")
246
SetActiveVariable("flipMoveX")
247
AddEnumVariable("false", false)
248
AddEnumVariable("true", true)
249
250
AddEditorVariable("flipMoveY")
251
SetActiveVariable("flipMoveY")
252
AddEnumVariable("false", false)
253
AddEnumVariable("true", true)
254
255
AddEditorVariable("flipMoveXY")
256
SetActiveVariable("flipMoveXY")
257
AddEnumVariable("false", false)
258
AddEnumVariable("true", true)
259
end event
260
261