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