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/BreakWall.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Breakable Wall Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
9
// Player Aliases
10
private alias object.state : player.state
11
private alias object.xpos : player.xpos
12
private alias object.speed : player.speed
13
private alias object.direction : player.direction
14
private alias object.animation : player.animation
15
private alias object.value40 : player.hitboxLeft
16
private alias object.value38 : player.hitboxTop
17
private alias object.value41 : player.hitboxRight
18
private alias object.value39 : player.hitboxBottom
19
private alias object.value16 : player.isSidekick
20
21
// Super States
22
private alias 1 : SUPERSTATE_SUPER
23
24
25
// ========================
26
// Function Declarations
27
// ========================
28
29
reserve function BreakableWall_DebugDraw
30
reserve function BreakableWall_DebugSpawn
31
32
33
// ========================
34
// Function Definitions
35
// ========================
36
37
private function BreakableWall_DebugDraw
38
DrawSprite(0)
39
end function
40
41
42
private function BreakableWall_DebugSpawn
43
CreateTempObject(TypeName[Breakable Wall], false, object.xpos, object.ypos)
44
object[tempObjectPos].propertyValue = false
45
object[tempObjectPos].drawOrder = 4
46
end function
47
48
49
// ========================
50
// Events
51
// ========================
52
53
event ObjectUpdate
54
if object.propertyValue == true
55
object.xpos += object.xvel
56
object.ypos += object.yvel
57
object.yvel += 0x7000
58
if object.outOfBounds == true
59
object.type = TypeName[Blank Object]
60
end if
61
else
62
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
63
checkResult = false
64
65
if player[currentPlayer].state == Player_State_Roll
66
if player[currentPlayer].speed >= 0x48000
67
checkResult = true
68
end if
69
if player[currentPlayer].speed <= -0x48000
70
checkResult = true
71
end if
72
end if
73
74
if stage.playerListPos == PLAYER_KNUCKLES_A
75
checkResult = true
76
end if
77
78
if Player_superState == SUPERSTATE_SUPER
79
checkResult = true
80
end if
81
#platform: USE_STANDALONE
82
if checkResult == true
83
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
84
#endplatform
85
86
#platform: USE_ORIGINS
87
if stage.playerListPos == PLAYER_AMY
88
if player[currentPlayer].isSidekick == false
89
if player[currentPlayer].animation == ANI_HAMMER_JUMP
90
checkResult = 2
91
end if
92
if player[currentPlayer].animation == ANI_HAMMER_DASH
93
checkResult = 2
94
end if
95
end if
96
end if
97
if checkResult != 0
98
switch checkResult
99
case 1
100
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
101
break
102
case 2
103
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
104
break
105
end switch
106
#endplatform
107
if checkResult == true
108
object.type = TypeName[Blank Object]
109
PlaySfx(SfxName[Block Break], false)
110
temp2 = object.xpos
111
temp2 -= 0x80000
112
temp3 = object.xpos
113
temp3 += 0x80000
114
temp4 = object.ypos
115
temp4 -= 0x180000
116
if player[currentPlayer].xpos < object.xpos
117
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
118
object[tempObjectPos].xvel = -0x60000
119
object[tempObjectPos].yvel = -0x60000
120
object[tempObjectPos].drawOrder = 4
121
122
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
123
object[tempObjectPos].xvel = -0x40000
124
object[tempObjectPos].yvel = -0x50000
125
object[tempObjectPos].drawOrder = 4
126
temp4 += 0x100000
127
128
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
129
object[tempObjectPos].xvel = -0x80000
130
object[tempObjectPos].yvel = -0x20000
131
object[tempObjectPos].drawOrder = 4
132
133
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
134
object[tempObjectPos].xvel = -0x60000
135
object[tempObjectPos].yvel = -0x10000
136
object[tempObjectPos].drawOrder = 4
137
temp4 += 0x100000
138
139
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
140
object[tempObjectPos].xvel = -0x80000
141
object[tempObjectPos].yvel = 0x20000
142
object[tempObjectPos].drawOrder = 4
143
144
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
145
object[tempObjectPos].xvel = -0x60000
146
object[tempObjectPos].yvel = 0x10000
147
object[tempObjectPos].drawOrder = 4
148
temp4 += 0x100000
149
150
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
151
object[tempObjectPos].xvel = -0x60000
152
object[tempObjectPos].yvel = 0x60000
153
object[tempObjectPos].drawOrder = 4
154
155
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
156
object[tempObjectPos].xvel = -0x40000
157
object[tempObjectPos].yvel = 0x50000
158
object[tempObjectPos].drawOrder = 4
159
else
160
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
161
object[tempObjectPos].xvel = 0x40000
162
object[tempObjectPos].yvel = -0x50000
163
object[tempObjectPos].drawOrder = 4
164
165
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
166
object[tempObjectPos].xvel = 0x60000
167
object[tempObjectPos].yvel = -0x60000
168
object[tempObjectPos].drawOrder = 4
169
temp4 += 0x100000
170
171
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
172
object[tempObjectPos].xvel = 0x60000
173
object[tempObjectPos].yvel = -0x10000
174
object[tempObjectPos].drawOrder = 4
175
176
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
177
object[tempObjectPos].xvel = 0x80000
178
object[tempObjectPos].yvel = -0x20000
179
object[tempObjectPos].drawOrder = 4
180
temp4 += 0x100000
181
182
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
183
object[tempObjectPos].xvel = 0x60000
184
object[tempObjectPos].yvel = 0x10000
185
object[tempObjectPos].drawOrder = 4
186
187
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
188
object[tempObjectPos].xvel = 0x80000
189
object[tempObjectPos].yvel = 0x20000
190
object[tempObjectPos].drawOrder = 4
191
temp4 += 0x100000
192
193
CreateTempObject(TypeName[Breakable Wall], true, temp2, temp4)
194
object[tempObjectPos].xvel = 0x40000
195
object[tempObjectPos].yvel = 0x50000
196
object[tempObjectPos].drawOrder = 4
197
198
CreateTempObject(TypeName[Breakable Wall], true, temp3, temp4)
199
object[tempObjectPos].xvel = 0x60000
200
object[tempObjectPos].yvel = 0x60000
201
object[tempObjectPos].drawOrder = 4
202
end if
203
204
if player[currentPlayer].animation == ANI_GLIDING
205
player[currentPlayer].animation = ANI_GLIDING_DROP
206
player[currentPlayer].state = Player_State_GlideDrop
207
if player[currentPlayer].direction == 1
208
FlipSign(player[currentPlayer].speed)
209
end if
210
end if
211
end if
212
else
213
BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
214
end if
215
next
216
end if
217
end event
218
219
220
event ObjectDraw
221
DrawSprite(object.propertyValue)
222
end event
223
224
225
event ObjectStartup
226
LoadSpriteSheet("SLZ/Objects.gif")
227
228
arrayPos0 = 32
229
while arrayPos0 < 0x420
230
if object[arrayPos0].type == TypeName[Breakable Wall]
231
// LOL its forced to 0 to make sure you dont spawn tiles accidently
232
object[arrayPos0].propertyValue = false
233
object[arrayPos0].drawOrder = 4
234
end if
235
arrayPos0++
236
loop
237
238
SpriteFrame(-16, -32, 32, 64, 34, 26)
239
SpriteFrame(-8, -8, 16, 16, 34, 26)
240
241
SetTableValue(TypeName[Breakable Wall], DebugMode_ObjCount, DebugMode_TypesTable)
242
SetTableValue(BreakableWall_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
243
SetTableValue(BreakableWall_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
244
DebugMode_ObjCount++
245
end event
246
247
248
// ========================
249
// Editor Events
250
// ========================
251
252
event RSDKDraw
253
DrawSprite(0)
254
end event
255
256
257
event RSDKLoad
258
LoadSpriteSheet("SLZ/Objects.gif")
259
SpriteFrame(-16, -32, 32, 64, 34, 26)
260
261
// I think it actually uses the same values as the GHZ one, but its always "middle", so idc
262
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
263
end event
264
265