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/LZ/RotatingSpike.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Rotating Spike 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.spinAngle
13
private alias object.value1 : object.spinSpeed
14
private alias object.value2 : object.length
15
private alias object.value3 : object.amplitude
16
private alias object.value4 : object.drawPos.x
17
private alias object.value5 : object.drawPos.y
18
19
// Player Aliases
20
private alias object.value17 : debugMode.currentSelection
21
22
23
// ========================
24
// Function Declarations
25
// ========================
26
27
reserve function RotatingSpike_DebugDraw
28
reserve function RotatingSpike_DebugSpawn
29
30
31
// ========================
32
// Static Values
33
// ========================
34
35
private value RotatingSpike_startDebugID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function RotatingSpike_DebugDraw
43
temp7 = debugMode[0].currentSelection
44
temp7 -= RotatingSpike_startDebugID
45
temp6 = object.direction
46
temp6 <<= 8
47
48
DrawSprite(0)
49
temp0 = 0
50
temp1 = 16
51
while temp0 < temp7
52
Cos(temp2, temp6)
53
temp2 *= temp1
54
temp2 <<= 7
55
temp2 += object.xpos
56
57
Sin(temp3, temp6)
58
temp3 *= temp1
59
temp3 <<= 7
60
temp3 += object.ypos
61
62
DrawSpriteXY(1, temp2, temp3)
63
64
temp0++
65
temp1 += 16
66
loop
67
68
Cos(temp2, temp6)
69
temp2 *= temp1
70
temp2 <<= 7
71
temp2 += object.xpos
72
73
Sin(temp3, temp6)
74
temp3 *= temp1
75
temp3 <<= 7
76
temp3 += object.ypos
77
78
DrawSpriteXY(2, temp2, temp3)
79
end function
80
81
82
private function RotatingSpike_DebugSpawn
83
CreateTempObject(TypeName[Rotating Spike], 0, object.xpos, object.ypos)
84
85
object[tempObjectPos].spinAngle = object.direction
86
object[tempObjectPos].spinAngle <<= 16
87
88
if object.direction == FLIP_NONE
89
object[tempObjectPos].spinSpeed = 256
90
else
91
object[tempObjectPos].spinSpeed = -256
92
end if
93
94
object[tempObjectPos].length = debugMode[0].currentSelection
95
object[tempObjectPos].length -= RotatingSpike_startDebugID
96
object[tempObjectPos].length++
97
98
object[tempObjectPos].amplitude = object[tempObjectPos].length
99
object[tempObjectPos].amplitude <<= 4
100
end function
101
102
103
// ========================
104
// Events
105
// ========================
106
107
event ObjectUpdate
108
object.spinAngle += object.spinSpeed
109
object.spinAngle &= 0x1FFFF
110
temp0 = object.spinAngle
111
temp0 >>= 8
112
113
Cos(object.drawPos.x, temp0)
114
object.drawPos.x *= object.amplitude
115
object.drawPos.x <<= 7
116
object.drawPos.x += object.xpos
117
118
Sin(object.drawPos.y, temp0)
119
object.drawPos.y *= object.amplitude
120
object.drawPos.y <<= 7
121
object.drawPos.y += object.ypos
122
123
temp0 = object.xpos
124
temp1 = object.ypos
125
object.xpos = object.drawPos.x
126
object.ypos = object.drawPos.y
127
128
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
129
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
130
if checkResult == true
131
CallFunction(Player_Hit)
132
end if
133
next
134
135
object.xpos = temp0
136
object.ypos = temp1
137
end event
138
139
140
event ObjectDraw
141
DrawSprite(0)
142
143
temp0 = 0
144
temp1 = 16
145
temp4 = object.spinAngle
146
temp4 >>= 8
147
while temp0 < object.length
148
Cos(temp2, temp4)
149
temp2 *= temp1
150
temp2 <<= 7
151
temp2 += object.xpos
152
Sin(temp3, temp4)
153
temp3 *= temp1
154
temp3 <<= 7
155
temp3 += object.ypos
156
DrawSpriteXY(1, temp2, temp3)
157
temp0++
158
temp1 += 16
159
loop
160
161
temp1 -= 8
162
DrawSpriteXY(2, object.drawPos.x, object.drawPos.y)
163
end event
164
165
166
event ObjectStartup
167
LoadSpriteSheet("LZ/Objects.gif")
168
SpriteFrame(-8, -8, 16, 16, 84, 173)
169
SpriteFrame(-8, -8, 16, 16, 101, 173)
170
SpriteFrame(-16, -16, 32, 32, 84, 190)
171
172
foreach (TypeName[Rotating Spike], arrayPos0, ALL_ENTITIES)
173
object[arrayPos0].spinAngle = object[arrayPos0].direction
174
object[arrayPos0].spinAngle <<= 15
175
object[arrayPos0].direction = FLIP_NONE // this object doesn't really use dir for anything btw
176
177
object[arrayPos0].spinSpeed = object[arrayPos0].propertyValue
178
object[arrayPos0].spinSpeed &= 0xF0
179
if object[arrayPos0].spinSpeed >= 0x80
180
object[arrayPos0].spinSpeed -= 0x100
181
end if
182
object[arrayPos0].spinSpeed <<= 4
183
184
object[arrayPos0].length = object[arrayPos0].propertyValue
185
object[arrayPos0].length &= 15
186
object[arrayPos0].amplitude = object[arrayPos0].length
187
object[arrayPos0].amplitude <<= 4
188
next
189
190
temp0 = 0
191
RotatingSpike_startDebugID = DebugMode_ObjCount
192
RotatingSpike_startDebugID--
193
while temp0 < 4
194
SetTableValue(TypeName[Rotating Spike], DebugMode_ObjCount, DebugMode_TypesTable)
195
SetTableValue(RotatingSpike_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
196
SetTableValue(RotatingSpike_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
197
DebugMode_ObjCount++
198
temp0++
199
loop
200
end event
201
202
203
// ========================
204
// Editor Events
205
// ========================
206
207
event RSDKEdit
208
if editor.returnVariable == true
209
switch editor.variableID
210
case EDIT_VAR_PROPVAL // property value
211
checkResult = object.propertyValue
212
break
213
214
// TODO: these following two, aren't they the same?
215
case 0 // spinSpeed
216
checkResult = object.propertyValue
217
checkResult >>= 4
218
checkResult &= 0x0F
219
break
220
221
case 1 // length
222
checkResult = object.propertyValue
223
checkResult &= 0xF0
224
break
225
226
end switch
227
else
228
switch editor.variableID
229
case EDIT_VAR_PROPVAL // property value
230
object.propertyValue = editor.variableValue
231
break
232
233
case 0 // spinSpeed
234
editor.variableValue &= 0x0F
235
236
object.propertyValue &= 0xF0
237
object.propertyValue |= editor.variableValue
238
break
239
240
case 1 // length
241
editor.variableValue &= 0x0F
242
editor.variableValue <<= 4
243
244
object.propertyValue &= 0x0F
245
object.propertyValue |= editor.variableValue
246
break
247
248
end switch
249
end if
250
end event
251
252
253
event RSDKDraw
254
object.spinAngle = object.direction
255
object.spinAngle <<= 15
256
257
object.length = object.propertyValue
258
object.length &= 15
259
object.amplitude = object.length
260
object.amplitude <<= 4
261
262
temp0 = object.spinAngle
263
temp0 >>= 8
264
265
Cos(object.drawPos.x, temp0)
266
object.drawPos.x *= object.amplitude
267
object.drawPos.x <<= 7
268
object.drawPos.x += object.xpos
269
270
Sin(object.drawPos.y, temp0)
271
object.drawPos.y *= object.amplitude
272
object.drawPos.y <<= 7
273
object.drawPos.y += object.ypos
274
275
DrawSprite(0)
276
277
temp0 = 0
278
temp1 = 16
279
temp4 = object.spinAngle
280
temp4 >>= 8
281
while temp0 < object.length
282
Cos(temp2, temp4)
283
temp2 *= temp1
284
temp2 <<= 7
285
temp2 += object.xpos
286
287
Sin(temp3, temp4)
288
temp3 *= temp1
289
temp3 <<= 7
290
temp3 += object.ypos
291
292
DrawSpriteXY(1, temp2, temp3)
293
temp0++
294
temp1 += 16
295
loop
296
297
temp1 -= 8
298
DrawSpriteXY(2, object.drawPos.x, object.drawPos.y)
299
end event
300
301
302
event RSDKLoad
303
LoadSpriteSheet("LZ/Objects.gif")
304
SpriteFrame(-8, -8, 16, 16, 84, 173)
305
SpriteFrame(-8, -8, 16, 16, 101, 173)
306
SpriteFrame(-16, -16, 32, 32, 84, 190)
307
308
AddEditorVariable("spinSpeed")
309
SetActiveVariable("spinSpeed")
310
311
AddEditorVariable("length")
312
SetActiveVariable("length")
313
314
// TODO: looks like val0 (a pre-set angle) is a thing too? found one in m003
315
// that's just a 1 though, so maybe not..?
316
end event
317
318