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/SBZ/SwingingSpike.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Swinging 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.propertyValue : object.length
13
14
private alias object.value0 : object.swingAngle
15
private alias object.value1 : object.drawPos.x
16
private alias object.value2 : object.drawPos.y
17
18
// Player Aliases
19
private alias object.value17 : debugMode.currentSelection
20
21
22
// ========================
23
// Function Declarations
24
// ========================
25
26
reserve function SwingingSpike_DebugDraw
27
reserve function SwingingSpike_DebugSpawn
28
29
30
// ========================
31
// Static Values
32
// ========================
33
34
private value SwingingSpike_startDebugID = 0
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function SwingingSpike_DebugDraw
42
temp7 = debugMode[0].currentSelection
43
temp7 -= SwingingSpike_startDebugID
44
DrawSprite(0) // in the object's normal draw routine the post is drawn last, but here it's the first thing to be drawn? sure ig..
45
46
temp0 = 0
47
temp1 = 16
48
while temp0 < temp7
49
Cos(temp2, 128)
50
temp2 *= temp1
51
temp2 <<= 7
52
temp2 += object.xpos
53
Sin(temp3, 128)
54
temp3 *= temp1
55
temp3 <<= 7
56
temp3 += object.ypos
57
DrawSpriteXY(1, temp2, temp3)
58
59
temp0++
60
temp1 += 16
61
loop
62
63
temp1 -= 8
64
Cos(temp2, 128)
65
temp2 *= temp1
66
temp2 <<= 7
67
temp2 += object.xpos
68
Sin(temp3, 128)
69
temp3 *= temp1
70
temp3 <<= 7
71
temp3 += object.ypos
72
DrawSpriteXY(2, temp2, temp3)
73
end function
74
75
76
private function SwingingSpike_DebugSpawn
77
temp0 = debugMode[0].currentSelection
78
temp0 -= SwingingSpike_startDebugID
79
CreateTempObject(TypeName[Swinging Spike], temp0, object.xpos, object.ypos)
80
object[tempObjectPos].direction = object.direction
81
end function
82
83
84
// ========================
85
// Events
86
// ========================
87
88
event ObjectUpdate
89
GetTableValue(object.swingAngle, 12, StageSetup_oscillationTable)
90
object.swingAngle >>= 8
91
if object.direction == FLIP_X
92
object.swingAngle ^= 255
93
object.swingAngle += 129
94
end if
95
object.swingAngle <<= 1
96
temp1 = object.length
97
temp1++
98
temp1 <<= 4
99
temp1 -= 8
100
101
Cos(object.drawPos.x, object.swingAngle)
102
object.drawPos.x *= temp1
103
object.drawPos.x <<= 7
104
object.drawPos.x += object.xpos
105
106
Sin(object.drawPos.y, object.swingAngle)
107
object.drawPos.y *= temp1
108
object.drawPos.y <<= 7
109
object.drawPos.y += object.ypos
110
111
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
112
temp0 = object.xpos
113
temp1 = object.ypos
114
object.xpos = object.drawPos.x
115
object.ypos = object.drawPos.y
116
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
117
if checkResult == true
118
CallFunction(Player_Hit)
119
end if
120
object.xpos = temp0
121
object.ypos = temp1
122
next
123
end event
124
125
126
event ObjectDraw
127
temp0 = 0
128
temp1 = 16
129
while temp0 < object.length
130
Cos(temp2, object.swingAngle)
131
temp2 *= temp1
132
temp2 <<= 7
133
temp2 += object.xpos
134
Sin(temp3, object.swingAngle)
135
temp3 *= temp1
136
temp3 <<= 7
137
temp3 += object.ypos
138
DrawSpriteXY(1, temp2, temp3)
139
temp0++
140
temp1 += 16
141
loop
142
143
DrawSpriteXY(2, object.drawPos.x, object.drawPos.y)
144
DrawSprite(0)
145
end event
146
147
148
event ObjectStartup
149
LoadSpriteSheet("SBZ/Objects.gif")
150
SpriteFrame(-15, -23, 30, 30, 92, 31)
151
SpriteFrame(-8, -8, 16, 16, 65, 106)
152
SpriteFrame(-24, -24, 48, 48, 397, 182)
153
154
temp0 = 0
155
SwingingSpike_startDebugID = DebugMode_ObjCount
156
SwingingSpike_startDebugID--
157
while temp0 < 8
158
SetTableValue(TypeName[Swinging Spike], DebugMode_ObjCount, DebugMode_TypesTable)
159
SetTableValue(SwingingSpike_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
160
SetTableValue(SwingingSpike_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
161
DebugMode_ObjCount++
162
temp0++
163
loop
164
end event
165
166
167
// ========================
168
// Editor Events
169
// ========================
170
171
event RSDKDraw
172
DrawSprite(0)
173
174
temp0 = 0
175
temp1 = 16
176
while temp0 < object.length
177
Cos(temp2, 128)
178
temp2 *= temp1
179
temp2 <<= 7
180
temp2 += object.xpos
181
Sin(temp3, 128)
182
temp3 *= temp1
183
temp3 <<= 7
184
temp3 += object.ypos
185
DrawSpriteXY(1, temp2, temp3)
186
temp0++
187
temp1 += 16
188
loop
189
temp1 -= 8
190
Cos(temp2, 128)
191
temp2 *= temp1
192
temp2 <<= 7
193
temp2 += object.xpos
194
Sin(temp3, 128)
195
temp3 *= temp1
196
temp3 <<= 7
197
temp3 += object.ypos
198
DrawSpriteXY(2, temp2, temp3)
199
end event
200
201
202
event RSDKLoad
203
LoadSpriteSheet("SBZ/Objects.gif")
204
SpriteFrame(-15, -23, 30, 30, 92, 31)
205
SpriteFrame(-8, -8, 16, 16, 65, 106)
206
SpriteFrame(-24, -24, 48, 48, 397, 182)
207
208
SetVariableAlias(ALIAS_VAR_PROPVAL, "length")
209
end event
210
211