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/Enemies/Roller.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Roller 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.timer
13
private alias object.value1 : object.onGround
14
private alias object.value2 : object.hasTarget
15
private alias object.value3 : object.startPos.x
16
private alias object.value4 : object.startPos.y
17
18
private alias 0 : ROLLER_FINDTARGET
19
private alias 1 : ROLLER_ROLLING
20
private alias 2 : ROLLER_FALLING
21
private alias 3 : ROLLER_STANDING
22
23
private alias 0 : ROLLER_ANI_HIDDEN
24
private alias 1 : ROLLER_ANI_ROLLING
25
private alias 2 : ROLLER_ANI_ENDROLL
26
private alias 3 : ROLLER_ANI_STANDING
27
private alias 4 : ROLLER_ANI_BEGINROLL
28
29
// Player Aliases
30
private alias object.xpos : player.xpos
31
private alias object.ypos : player.ypos
32
private alias object.value40 : player.hitboxLeft
33
private alias object.value38 : player.hitboxTop
34
private alias object.value41 : player.hitboxRight
35
private alias object.value39 : player.hitboxBottom
36
37
// Tile Info ID Aliases
38
private alias 6 : TILEINFO_ANGLEA
39
40
// Path ID Aliases
41
private alias 0 : PATH_A
42
43
44
// ========================
45
// Events
46
// ========================
47
48
event ObjectUpdate
49
switch object.state
50
case ROLLER_FINDTARGET
51
object.priority = PRIORITY_ACTIVE
52
53
temp0 = true
54
temp1 = false
55
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
56
BoxCollisionTest(C_TOUCH, object.entityPos, -212, -120, 212, 120, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
57
if checkResult == true
58
temp0 = false
59
end if
60
61
temp2 = player[currentPlayer].xpos
62
temp2 -= object.xpos
63
if temp2 >= 0x1000000
64
if temp2 < 0x2400000
65
temp2 = player[currentPlayer].ypos
66
temp2 -= object.ypos
67
if temp2 >= -0xF00000
68
if temp2 < 0xF00000
69
temp1 = true
70
end if
71
end if
72
end if
73
end if
74
next
75
76
temp0 &= temp1
77
if temp0 != false
78
object.animation = ROLLER_ANI_ROLLING
79
object.xvel = 0x70000
80
object.state = ROLLER_ROLLING
81
end if
82
break
83
84
case ROLLER_ROLLING
85
object.xpos += object.xvel
86
temp0 = false
87
ObjectTileGrip(CSIDE_FLOOR, 0, 15, PATH_A)
88
ObjectTileGrip(CSIDE_FLOOR, 0, 14, PATH_A)
89
90
if object.onGround == false
91
if checkResult == false
92
temp0 = true
93
else
94
temp2 = object.xpos
95
temp3 = object.ypos
96
if object.xvel < 0
97
ObjectTileCollision(CSIDE_RWALL, -32, 0, PATH_A)
98
if checkResult == true
99
temp2 >>= 16
100
temp3 >>= 16
101
temp2 -= 32
102
temp3 += 0
103
Get16x16TileInfo(temp5, temp2, temp3, TILEINFO_ANGLEA)
104
temp5 &= 255
105
if temp5 == 0
106
temp0 = true
107
else
108
temp2 += 32
109
object.xpos = temp2
110
object.xpos <<= 16
111
object.ypos = temp3
112
object.ypos <<= 16
113
end if
114
end if
115
else
116
ObjectTileCollision(CSIDE_LWALL, 32, 0, PATH_A)
117
if checkResult == true
118
temp2 >>= 16
119
temp3 >>= 16
120
temp2 += 32
121
temp3 += 0
122
Get16x16TileInfo(temp5, temp2, temp3, TILEINFO_ANGLEA)
123
temp5 &= 255
124
if temp5 == 0
125
temp0 = true
126
else
127
temp2 -= 32
128
object.xpos = temp2
129
object.xpos <<= 16
130
object.ypos = temp3
131
object.ypos <<= 16
132
end if
133
end if
134
end if
135
end if
136
end if
137
138
if temp0 == true
139
object.yvel = -0x60000
140
object.onGround = true
141
object.state = ROLLER_FALLING
142
else
143
if object.hasTarget == false
144
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
145
temp0 = player[currentPlayer].xpos
146
temp0 -= object.xpos
147
if temp0 < 0x300000
148
if temp0 >= 0
149
temp0 = player[currentPlayer].ypos
150
temp0 -= object.ypos
151
if temp0 >= -0x600000
152
if temp0 < 0x600000
153
temp1 = true
154
end if
155
end if
156
end if
157
end if
158
next
159
160
if temp1 == true
161
object.hasTarget = true
162
object.animationTimer = 0
163
object.animation = ROLLER_ANI_ENDROLL
164
object.frame = 2
165
object.timer = 120
166
object.state = ROLLER_STANDING
167
end if
168
end if
169
end if
170
break
171
172
case ROLLER_FALLING
173
object.xpos += object.xvel
174
object.ypos += object.yvel
175
object.yvel += 0x3800
176
if object.yvel > 0
177
ObjectTileCollision(CSIDE_FLOOR, 0, 14, PATH_A)
178
if checkResult == true
179
object.state = ROLLER_ROLLING
180
end if
181
end if
182
break
183
184
case ROLLER_STANDING
185
object.timer--
186
if object.timer == 0
187
object.animation = ROLLER_ANI_BEGINROLL
188
object.animationTimer = 0
189
end if
190
break
191
192
end switch
193
194
if object.outOfBounds == true
195
temp0 = object.xpos
196
temp1 = object.ypos
197
object.xpos = object.startPos.x
198
object.ypos = object.startPos.y
199
if object.outOfBounds == true
200
object.animation = ROLLER_ANI_HIDDEN
201
object.onGround = false
202
object.hasTarget = false
203
object.priority = PRIORITY_BOUNDS
204
object.state = ROLLER_FINDTARGET
205
else
206
object.xpos = temp0
207
object.ypos = temp1
208
end if
209
end if
210
211
if object.animation != ROLLER_ANI_HIDDEN
212
if object.frame < 2
213
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
214
BoxCollisionTest(C_TOUCH, object.entityPos, -15, -15, 15, 15, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
215
if checkResult == true
216
CallFunction(Player_BadnikBreak)
217
end if
218
next
219
else
220
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
221
BoxCollisionTest(C_TOUCH, object.entityPos, -15, -15, 15, 15, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
222
if checkResult == true
223
CallFunction(Player_Hit)
224
end if
225
next
226
end if
227
end if
228
229
switch object.animation
230
case ROLLER_ANI_HIDDEN
231
break
232
233
case ROLLER_ANI_ROLLING
234
object.frame = object.animationTimer
235
object.frame >>= 2
236
object.frame += 2
237
object.animationTimer++
238
if object.animationTimer >= 12
239
object.animationTimer = 0
240
end if
241
break
242
243
case ROLLER_ANI_ENDROLL
244
object.animationTimer++
245
if object.animationTimer >= 16
246
object.frame--
247
if object.frame == 0
248
object.animation = ROLLER_ANI_STANDING
249
end if
250
object.animationTimer = 0
251
end if
252
break
253
254
case ROLLER_ANI_STANDING
255
break
256
257
case ROLLER_ANI_BEGINROLL
258
object.animationTimer++
259
if object.animationTimer >= 16
260
object.frame++
261
if object.frame == 3
262
object.animation = ROLLER_ANI_ROLLING
263
object.state = ROLLER_ROLLING
264
end if
265
object.animationTimer = 0
266
end if
267
break
268
269
end switch
270
end event
271
272
273
event ObjectDraw
274
if object.animation != ROLLER_ANI_HIDDEN
275
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
276
end if
277
end event
278
279
280
event ObjectStartup
281
CheckCurrentStageFolder("Zone03")
282
if checkResult == true
283
LoadSpriteSheet("SYZ/Objects.gif")
284
SpriteFrame(-16, -33, 29, 47, 1, 179)
285
SpriteFrame(-16, -25, 29, 39, 31, 187)
286
SpriteFrame(-14, -14, 28, 28, 1, 227)
287
SpriteFrame(-14, -14, 28, 28, 31, 227)
288
SpriteFrame(-14, -14, 28, 28, 60, 227)
289
end if
290
291
CheckCurrentStageFolder("Zone07")
292
if checkResult == true
293
LoadSpriteSheet("MBZ/Objects.gif")
294
SpriteFrame(-16, -33, 29, 47, 105, 30)
295
SpriteFrame(-16, -25, 29, 39, 75, 59)
296
SpriteFrame(-14, -14, 28, 28, 74, 1)
297
SpriteFrame(-14, -14, 28, 28, 104, 1)
298
SpriteFrame(-14, -14, 28, 28, 76, 30)
299
end if
300
301
foreach (TypeName[Roller], arrayPos0, ALL_ENTITIES)
302
object[arrayPos0].startPos.x = object[arrayPos0].xpos
303
object[arrayPos0].startPos.y = object[arrayPos0].ypos
304
next
305
306
// This badnik isn't featured in Debug Mode...
307
end event
308
309
310
// ========================
311
// Editor Events
312
// ========================
313
314
event RSDKDraw
315
DrawSprite(0)
316
end event
317
318
319
event RSDKLoad
320
CheckCurrentStageFolder("Zone07")
321
if checkResult == true
322
LoadSpriteSheet("MBZ/Objects.gif")
323
SpriteFrame(-16, -33, 29, 47, 105, 30)
324
SpriteFrame(-16, -25, 29, 39, 75, 59)
325
SpriteFrame(-14, -14, 28, 28, 74, 1)
326
SpriteFrame(-14, -14, 28, 28, 104, 1)
327
SpriteFrame(-14, -14, 28, 28, 76, 30)
328
else
329
LoadSpriteSheet("SYZ/Objects.gif")
330
SpriteFrame(-16, -33, 29, 47, 1, 179)
331
SpriteFrame(-16, -25, 29, 39, 31, 187)
332
SpriteFrame(-14, -14, 28, 28, 1, 227)
333
SpriteFrame(-14, -14, 28, 28, 31, 227)
334
SpriteFrame(-14, -14, 28, 28, 60, 227)
335
end if
336
337
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
338
end event
339
340