Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/HPZ/BreakWall.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Breakable Wall 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.isDebris
13
14
// Player Aliases
15
private alias object.propertyValue : player.character
16
private alias object.state : player.state
17
private alias object.xpos : player.xpos
18
private alias object.speed : player.speed
19
private alias object.direction : player.direction
20
private alias object.animation : player.animation
21
private alias object.value16 : player.isSidekick
22
private alias object.value40 : player.hitboxLeft
23
private alias object.value38 : player.hitboxTop
24
private alias object.value41 : player.hitboxRight
25
private alias object.value39 : player.hitboxBottom
26
27
private alias 1 : SUPERSTATE_SUPER
28
29
30
// ========================
31
// Function Declarations
32
// ========================
33
34
reserve function BreakableWall_DebugDraw
35
reserve function BreakableWall_DebugSpawn
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function BreakableWall_DebugDraw
43
DrawSprite(0)
44
end function
45
46
47
private function BreakableWall_DebugSpawn
48
CreateTempObject(TypeName[Breakable Wall], 0, object.xpos, object.ypos)
49
object[tempObjectPos].isDebris = false
50
object[tempObjectPos].drawOrder = 4
51
end function
52
53
54
// ========================
55
// Events
56
// ========================
57
58
event ObjectUpdate
59
if object.isDebris == true
60
object.xpos += object.xvel
61
object.ypos += object.yvel
62
object.yvel += 0x7000
63
64
if object.outOfBounds == true
65
object.type = TypeName[Blank Object]
66
end if
67
else
68
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
69
checkResult = false
70
if player[currentPlayer].state == Player_State_Roll
71
if player[currentPlayer].speed >= 0x48000
72
checkResult = true
73
end if
74
75
if player[currentPlayer].speed < -0x48000
76
checkResult = true
77
end if
78
end if
79
80
#platform: USE_STANDALONE
81
if stage.playerListPos == PLAYER_KNUCKLES_A
82
#endplatform
83
#platform: USE_ORIGINS
84
// Origins Plus fixed a bug where sidekick Tails could break walls when playing as Knuckles & Tails
85
if player[currentPlayer].character == PLAYER_KNUCKLES
86
#endplatform
87
checkResult = true
88
end if
89
90
if Player_superState == SUPERSTATE_SUPER
91
checkResult = true
92
end if
93
94
#platform: USE_STANDALONE
95
if checkResult == true
96
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
97
#endplatform
98
#platform: USE_ORIGINS
99
if stage.playerListPos == PLAYER_AMY
100
if player[currentPlayer].isSidekick == false
101
if player[currentPlayer].animation == ANI_HAMMER_JUMP
102
checkResult = 2
103
end if
104
if player[currentPlayer].animation == ANI_HAMMER_DASH
105
checkResult = 2
106
end if
107
end if
108
end if
109
110
if checkResult != false
111
switch checkResult
112
case 1
113
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
114
break
115
116
case 2
117
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
118
break
119
end switch
120
#endplatform
121
if checkResult == true
122
object.type = TypeName[Blank Object]
123
PlaySfx(SfxName[Ledge Break], false)
124
125
temp2 = object.xpos
126
temp2 -= 0x80000
127
128
temp3 = object.xpos
129
temp3 += 0x80000
130
temp4 = object.ypos
131
temp4 -= 0x180000
132
133
if player[currentPlayer].xpos < object.xpos
134
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
135
object[tempObjectPos].xvel = -0x60000
136
object[tempObjectPos].yvel = -0x60000
137
object[tempObjectPos].drawOrder = 4
138
139
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
140
object[tempObjectPos].xvel = -0x40000
141
object[tempObjectPos].yvel = -0x50000
142
object[tempObjectPos].drawOrder = 4
143
temp4 += 0x100000
144
145
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
146
object[tempObjectPos].xvel = -0x80000
147
object[tempObjectPos].yvel = -0x20000
148
object[tempObjectPos].drawOrder = 4
149
150
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
151
object[tempObjectPos].xvel = -0x60000
152
object[tempObjectPos].yvel = -0x10000
153
object[tempObjectPos].drawOrder = 4
154
temp4 += 0x100000
155
156
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
157
object[tempObjectPos].xvel = -0x80000
158
object[tempObjectPos].yvel = 0x20000
159
object[tempObjectPos].drawOrder = 4
160
161
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
162
object[tempObjectPos].xvel = -0x60000
163
object[tempObjectPos].yvel = 0x10000
164
object[tempObjectPos].drawOrder = 4
165
temp4 += 0x100000
166
167
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
168
object[tempObjectPos].xvel = -0x60000
169
object[tempObjectPos].yvel = 0x60000
170
object[tempObjectPos].drawOrder = 4
171
172
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
173
object[tempObjectPos].xvel = -0x40000
174
object[tempObjectPos].yvel = 0x50000
175
object[tempObjectPos].drawOrder = 4
176
else
177
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
178
object[tempObjectPos].xvel = 0x40000
179
object[tempObjectPos].yvel = -0x50000
180
object[tempObjectPos].drawOrder = 4
181
182
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
183
object[tempObjectPos].xvel = 0x60000
184
object[tempObjectPos].yvel = -0x60000
185
object[tempObjectPos].drawOrder = 4
186
temp4 += 0x100000
187
188
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
189
object[tempObjectPos].xvel = 0x60000
190
object[tempObjectPos].yvel = -0x10000
191
object[tempObjectPos].drawOrder = 4
192
193
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
194
object[tempObjectPos].xvel = 0x80000
195
object[tempObjectPos].yvel = -0x20000
196
object[tempObjectPos].drawOrder = 4
197
temp4 += 0x100000
198
199
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
200
object[tempObjectPos].xvel = 0x60000
201
object[tempObjectPos].yvel = 0x10000
202
object[tempObjectPos].drawOrder = 4
203
204
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
205
object[tempObjectPos].xvel = 0x80000
206
object[tempObjectPos].yvel = 0x20000
207
object[tempObjectPos].drawOrder = 4
208
temp4 += 0x100000
209
210
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
211
object[tempObjectPos].xvel = 0x40000
212
object[tempObjectPos].yvel = 0x50000
213
object[tempObjectPos].drawOrder = 4
214
215
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
216
object[tempObjectPos].xvel = 0x60000
217
object[tempObjectPos].yvel = 0x60000
218
object[tempObjectPos].drawOrder = 4
219
end if
220
221
if player[currentPlayer].animation == ANI_GLIDING
222
player[currentPlayer].animation = ANI_GLIDING_DROP
223
player[currentPlayer].state = Player_State_GlideDrop
224
if player[currentPlayer].direction == FACING_LEFT
225
FlipSign(player[currentPlayer].speed)
226
end if
227
end if
228
end if
229
else
230
BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
231
end if
232
next
233
end if
234
end event
235
236
237
event ObjectDraw
238
DrawSprite(object.propertyValue)
239
end event
240
241
242
event ObjectStartup
243
LoadSpriteSheet("HPZ/Objects.gif")
244
245
arrayPos0 = 0x20
246
while arrayPos0 < 0x420
247
if object[arrayPos0].type == TypeName[Breakable Wall]
248
object[arrayPos0].isDebris = false // Make sure we don't accidentally spawn debris by mistake
249
object[arrayPos0].drawOrder = 4
250
end if
251
252
arrayPos0++
253
loop
254
255
SpriteFrame(-16, -32, 32, 64, 443, 34)
256
SpriteFrame(-8, -8, 16, 16, 443, 34)
257
258
SetTableValue(TypeName[Breakable Wall], DebugMode_ObjCount, DebugMode_TypesTable)
259
SetTableValue(BreakableWall_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
260
SetTableValue(BreakableWall_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
261
DebugMode_ObjCount++
262
end event
263
264
265
// ========================
266
// Editor Events
267
// ========================
268
269
event RSDKDraw
270
DrawSprite(0)
271
end event
272
273
274
event RSDKLoad
275
LoadSpriteSheet("HPZ/Objects.gif")
276
SpriteFrame(-16, -32, 32, 64, 443, 34)
277
278
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
279
end event
280
281