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/Fan.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Fan 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.isOn
14
15
// Player Aliases
16
private alias object.state : player.state
17
private alias object.xpos : player.xpos
18
private alias object.ypos : player.ypos
19
20
private alias object.value17 : debugMode.currentSelection
21
22
// ========================
23
// Function Declarations
24
// ========================
25
26
reserve function Fan_DebugDraw
27
reserve function Fan_DebugSpawn
28
29
30
// ========================
31
// Static Values
32
// ========================
33
34
private value Fan_startDebugID = 0
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function Fan_DebugDraw
42
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
43
end function
44
45
46
private function Fan_DebugSpawn
47
temp0 = debugMode[0].currentSelection
48
temp0 -= Fan_startDebugID
49
CreateTempObject(TypeName[Fan], temp0, object.xpos, object.ypos)
50
object[tempObjectPos].direction = object.direction
51
end function
52
53
54
// ========================
55
// Events
56
// ========================
57
58
event ObjectUpdate
59
GetBit(temp0, object.propertyValue, 1) // Bit 1 is true if the object should always be on
60
if temp0 == false
61
object.timer--
62
if object.timer <= 0
63
if object.isOn == false
64
object.timer = 120
65
else
66
object.timer = 180
67
end if
68
69
object.isOn ^= true
70
end if
71
end if
72
73
if object.isOn == false
74
// Check if the object should be activated
75
76
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
77
78
// Some special Knux exceptions, don't blow him away if he's supposed to be static for right now
79
CheckEqual(player[currentPlayer].state, Player_State_Climb)
80
temp0 = checkResult
81
CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)
82
temp0 |= checkResult
83
84
if temp0 == false
85
temp0 = player[currentPlayer].xpos
86
temp0 &= 0xFFFF0000
87
temp0 -= object.xpos
88
GetBit(temp2, object.direction, 0)
89
if temp2 == FLIP_NONE
90
FlipSign(temp0)
91
end if
92
93
temp0 += 0x500000
94
if temp0 >= 0
95
if temp0 < 0xF00000
96
temp1 = player[currentPlayer].ypos
97
temp1 &= 0xFFFF0000
98
temp1 -= object.ypos
99
100
// See if Y flip bit is set
101
GetBit(temp2, object.direction, 1)
102
if temp2 == true
103
FlipSign(temp1)
104
end if
105
temp1 += 0x600000
106
107
// See if this object should have a taller hitbox height
108
GetBit(temp2, object.propertyValue, 2)
109
if temp2 == true
110
temp3 = 0x900000
111
else
112
temp3 = 0x700000
113
end if
114
115
if temp1 >= 0
116
if temp1 < temp3
117
temp0 -= 0x500000
118
if temp0 < 0
119
temp0 ^= 0xFFFF0000
120
temp0 <<= 1
121
end if
122
temp0 += 0x600000
123
if object.direction == FLIP_NONE
124
FlipSign(temp0)
125
end if
126
temp0 ^= 0xFF0000
127
temp0 += 0x10000
128
temp0 >>= 4
129
GetBit(temp1, object.propertyValue, 0)
130
if temp1 != false
131
FlipSign(temp0)
132
end if
133
134
player[currentPlayer].xpos += temp0
135
end if
136
end if
137
end if
138
end if
139
end if
140
next
141
142
object.animationTimer++
143
if object.animationTimer >= 3
144
object.animationTimer = 0
145
end if
146
object.frame = object.animationTimer
147
148
GetBit(temp0, object.propertyValue, 0)
149
if temp0 != false
150
object.frame += 2
151
end if
152
end if
153
end event
154
155
156
event ObjectDraw
157
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
158
end event
159
160
161
event ObjectStartup
162
LoadSpriteSheet("SLZ/Objects.gif")
163
164
// Fan frames
165
SpriteFrame(-11, -16, 27, 32, 6, 223)
166
SpriteFrame(-12, -15, 28, 31, 38, 224)
167
SpriteFrame(-11, -14, 27, 30, 72, 225)
168
SpriteFrame(-12, -15, 28, 31, 38, 224)
169
SpriteFrame(-11, -16, 27, 32, 6, 223)
170
171
temp0 = 0
172
Fan_startDebugID = DebugMode_ObjCount
173
Fan_startDebugID--
174
while temp0 < 4
175
SetTableValue(TypeName[Fan], DebugMode_ObjCount, DebugMode_TypesTable)
176
SetTableValue(Fan_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
177
SetTableValue(Fan_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
178
DebugMode_ObjCount++
179
temp0++
180
loop
181
end event
182
183
184
// ========================
185
// Editor Events
186
// ========================
187
188
event RSDKEdit
189
if editor.returnVariable == true
190
switch editor.variableID
191
case EDIT_VAR_PROPVAL // property value
192
checkResult = object.propertyValue
193
checkResult &= 7
194
break
195
196
case 0 // forceDir
197
GetBit(checkResult, object.propertyValue, 0)
198
break
199
200
case 1 // alwaysOn
201
GetBit(checkResult, object.propertyValue, 1)
202
break
203
204
case 2 // force
205
GetBit(checkResult, object.propertyValue, 2)
206
break
207
208
end switch
209
else
210
switch editor.variableID
211
case EDIT_VAR_PROPVAL // property value
212
object.propertyValue = editor.variableValue
213
object.propertyValue &= 7
214
break
215
216
case 0 // forceDir
217
CheckNotEqual(editor.variableValue, 0)
218
SetBit(object.propertyValue, 0, checkResult)
219
break
220
221
case 1 // alwaysOn
222
CheckNotEqual(editor.variableValue, false)
223
SetBit(object.propertyValue, 1, checkResult)
224
break
225
226
case 2 // force
227
CheckNotEqual(editor.variableValue, 0)
228
SetBit(object.propertyValue, 2, checkResult)
229
break
230
231
end switch
232
end if
233
end event
234
235
236
event RSDKDraw
237
GetBit(object.frame, object.propertyValue, 0)
238
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
239
240
if editor.showGizmos == true
241
editor.drawingOverlay = true
242
243
// TODO: we're just drawing a dir arrow, but showing the complete hitbox would be cool
244
245
temp1 = object.xpos
246
if object.frame == 1
247
temp1 -= 0x200000
248
else
249
temp1 += 0x200000
250
end if
251
DrawArrow(object.xpos, object.ypos, temp1, object.ypos, 0x00, 0xFF, 0x00)
252
253
editor.drawingOverlay = false
254
end if
255
end event
256
257
258
event RSDKLoad
259
LoadSpriteSheet("SLZ/Objects.gif")
260
SpriteFrame(-11, -16, 27, 32, 6, 223)
261
SpriteFrame(-11, -14, 27, 30, 72, 225)
262
263
// Not the same as direction, idk why but it is what it is
264
AddEditorVariable("forceDir")
265
SetActiveVariable("forceDir")
266
AddEnumVariable("Right", 0)
267
AddEnumVariable("Left", 1)
268
269
AddEditorVariable("alwaysOn")
270
SetActiveVariable("alwaysOn")
271
AddEnumVariable("false", false)
272
AddEnumVariable("true", true)
273
274
AddEditorVariable("force") // TODO: idk what to call it but this should be hitbox height
275
SetActiveVariable("force")
276
AddEnumVariable("Weak", 0)
277
AddEnumVariable("Strong", 1)
278
end event
279
280