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/ARZ/EggmanHammer.txt
1487 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Eggman Hammer 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.originPos.x
13
private alias object.value1 : object.originPos.y
14
private alias object.value2 : object.oscillationAngle
15
private alias object.value3 : object.timer
16
private alias object.value4 : object.boundsR
17
private alias object.value5 : object.boundsL
18
// value6 is unused
19
private alias object.value7 : object.boundsOffset
20
private alias object.value8 : object.hideFlames
21
private alias object.value9 : object.flameFrame
22
private alias object.value10 : object.flameAnimTimer
23
private alias object.value11 : object.arrowSlot
24
private alias object.value12 : object.arrowVelocity
25
private alias object.value13 : object.hammerOffset.x
26
private alias object.value14 : object.hammerOffset.y
27
28
// States
29
private alias 0 : EGGMANHAMMER_ENTEREGGMAN
30
private alias 1 : EGGMANHAMMER_MOVING
31
private alias 2 : EGGMANHAMMER_PREPARESLAM
32
private alias 3 : EGGMANHAMMER_SLAM
33
private alias 4 : EGGMANHAMMER_DESTROYED
34
private alias 5 : EGGMANHAMMER_DEBRIS
35
36
// EggmanTotemPole Aliases
37
private alias object.value3 : eggmanTotemPole.timer
38
private alias object.value8 : eggmanTotemPole.offset
39
private alias object.value9 : eggmanTotemPole.eyePos
40
41
// EggmanArrow Aliases
42
private alias object.value0 : eggmanArrow.targetPos.x
43
private alias object.value1 : eggmanArrow.parent
44
45
private alias 0 : EGGMANARROW_MOVING
46
47
48
// ========================
49
// Function Declarations
50
// ========================
51
52
reserve function EggmanHammer_Oscillate
53
54
55
// ========================
56
// Tables
57
// ========================
58
59
private table EggmanHammer_arrowOffsets
60
-0x280000, -0x80000, 0x180000, 0x380000
61
end table
62
63
64
// ========================
65
// Function Definitions
66
// ========================
67
68
private function EggmanHammer_Oscillate
69
object.ypos = object.originPos.y
70
Sin256(temp0, object.oscillationAngle)
71
temp0 <<= 10
72
object.ypos += temp0
73
object.oscillationAngle += 2
74
object.oscillationAngle &= 255
75
76
object[-1].xpos = object.xpos
77
object[-1].ypos = object.ypos
78
object[-1].direction = object.direction
79
end function
80
81
82
// ========================
83
// Events
84
// ========================
85
86
event ObjectUpdate
87
switch object.state
88
case EGGMANHAMMER_ENTEREGGMAN
89
object.originPos.y += 0x10000
90
91
object.timer--
92
if object.timer == 0
93
object.state++
94
end if
95
96
CallFunction(EggmanHammer_Oscillate)
97
break
98
99
case EGGMANHAMMER_MOVING
100
object.animationTimer = 0
101
if object.direction == FLIP_NONE
102
if object.xpos > object.boundsR
103
object.xpos -= object.boundsOffset
104
else
105
object.state++
106
end if
107
else
108
if object.xpos < object.boundsL
109
object.xpos += object.boundsOffset
110
else
111
object.state = EGGMANHAMMER_PREPARESLAM
112
end if
113
end if
114
115
CallFunction(EggmanHammer_Oscillate)
116
break
117
118
case EGGMANHAMMER_PREPARESLAM
119
CallFunction(EggmanHammer_Oscillate)
120
if object.oscillationAngle == 0xC0
121
object.state = EGGMANHAMMER_SLAM
122
end if
123
break
124
125
case EGGMANHAMMER_SLAM
126
object.animationTimer++
127
switch object.animationTimer
128
case 1
129
object.frame = 4
130
PlaySfx(SfxName[Crusher], false)
131
break
132
133
case 7
134
object.frame = 5
135
136
arrayPos0 = object.entityPos
137
if object.direction == FLIP_NONE
138
arrayPos0 += 4
139
else
140
arrayPos0 += 5
141
end if
142
object[arrayPos0].state = 2
143
eggmanTotemPole[arrayPos0].timer = 32
144
eggmanTotemPole[arrayPos0].offset = -0x10000
145
146
arrayPos1 = object[+1].entityPos
147
arrayPos1 += object.arrowSlot
148
object.arrowSlot++
149
object.arrowSlot %= 3
150
151
object[arrayPos1].type = TypeName[Eggman Arrow]
152
object[arrayPos1].xpos = object[arrayPos0].xpos
153
Rand(temp0, 4)
154
GetTableValue(object[arrayPos1].ypos, temp0, EggmanHammer_arrowOffsets)
155
eggmanTotemPole[arrayPos0].eyePos = object[arrayPos1].ypos
156
object[arrayPos1].ypos += object[arrayPos0].ypos
157
if object.direction == FLIP_NONE
158
eggmanArrow[arrayPos1].targetPos.x = object[+5].xpos
159
eggmanArrow[arrayPos1].targetPos.x -= 0x280000
160
object[arrayPos1].xpos += 0x100000
161
else
162
eggmanArrow[arrayPos1].targetPos.x = object[+4].xpos
163
eggmanArrow[arrayPos1].targetPos.x += 0x280000
164
object[arrayPos1].xpos -= 0x100000
165
end if
166
object[arrayPos1].direction = object.direction
167
object[arrayPos1].drawOrder = 2
168
eggmanArrow[arrayPos1].parent = object[+1].entityPos
169
eggmanArrow[arrayPos1].parent += object.arrowSlot
170
object[arrayPos1].yvel = 0
171
object[arrayPos1].frame = 0
172
object[arrayPos1].animation = 0
173
object[arrayPos1].animationTimer = 0
174
object[arrayPos1].xvel = object.arrowVelocity
175
object[arrayPos1].state = EGGMANARROW_MOVING
176
break
177
178
case 13
179
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
180
if object.direction == FLIP_NONE
181
BoxCollisionTest(C_TOUCH, object.entityPos, -88, -24, -56, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
182
else
183
BoxCollisionTest(C_TOUCH, object.entityPos, 56, -24, 88, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
184
end if
185
186
if checkResult == true
187
CallFunction(Player_Hit)
188
end if
189
next
190
break
191
192
case 22
193
object.frame = 4
194
break
195
196
case 29
197
object.frame = 3
198
break
199
200
case 32
201
object.direction ^= FLIP_X
202
object.state = EGGMANHAMMER_MOVING
203
break
204
205
end switch
206
207
CallFunction(EggmanHammer_Oscillate)
208
break
209
210
case EGGMANHAMMER_DESTROYED
211
break
212
213
case EGGMANHAMMER_DEBRIS
214
object.hammerOffset.x += object.xvel
215
object.hammerOffset.y += object.yvel
216
object.yvel += 0x3800
217
break
218
219
end switch
220
221
object.flameAnimTimer++
222
object.flameAnimTimer &= 3
223
object.flameFrame = object.flameAnimTimer
224
object.flameFrame >>= 1
225
end event
226
227
228
event ObjectDraw
229
DrawSpriteFX(2, FX_FLIP, object.xpos, object.ypos)
230
if object.hideFlames != true
231
DrawSpriteFX(object.flameFrame, FX_FLIP, object.xpos, object.ypos)
232
end if
233
234
if object.animation != 1
235
temp0 = object.xpos
236
if object.direction == FLIP_NONE
237
temp0 -= 0x280000
238
else
239
temp0 += 0x280000
240
end if
241
temp0 += object.hammerOffset.x
242
243
temp1 = object.ypos
244
temp1 += 0x40000
245
temp1 += object.hammerOffset.y
246
DrawSpriteFX(object.frame, FX_ROTATE, temp0, temp1)
247
end if
248
end event
249
250
251
event ObjectStartup
252
CheckCurrentStageFolder("Zone03")
253
if checkResult == true
254
LoadSpriteSheet("ARZ/Objects.gif")
255
SpriteFrame(-15, 24, 46, 16, 78, 183) // Flames 1 - #0
256
SpriteFrame(-16, 24, 48, 8, 207, 162) // Flames 2 - #1
257
SpriteFrame(-44, -28, 76, 52, 1, 147) // EggMobile - #2
258
SpriteFrame(-50, -49, 54, 53, 1, 202) // Hammer (Idle) - #3
259
SpriteFrame(-49, -43, 49, 55, 56, 200) // Hammer (Slamming) - #4
260
SpriteFrame(-48, -24, 48, 48, 106, 207) // Hammer (Slammed) - #5
261
else
262
LoadSpriteSheet("MBZ/Objects.gif")
263
SpriteFrame(-15, 24, 46, 16, 299, 5) // Flames 1 - #0
264
SpriteFrame(-16, 24, 48, 8, 299, 22) // Flames 2 - #1
265
SpriteFrame(-44, -28, 76, 52, 222, 5) // EggMobile - #2
266
SpriteFrame(-50, -49, 54, 53, 255, 58) // Hammer (Idle) - #3
267
SpriteFrame(-49, -43, 49, 55, 310, 56) // Hammer (Slamming) - #4
268
SpriteFrame(-48, -24, 48, 48, 348, 1) // Hammer (Slammed) - #5
269
end if
270
end event
271
272
273
// ========================
274
// Editor Events
275
// ========================
276
277
event RSDKDraw
278
DrawSprite(0)
279
end event
280
281
282
event RSDKLoad
283
CheckCurrentStageFolder("Zone03")
284
if checkResult == true
285
LoadSpriteSheet("ARZ/Objects.gif")
286
SpriteFrame(-44, -28, 76, 52, 1, 147) // EggMobile
287
else
288
LoadSpriteSheet("MBZ/Objects.gif")
289
SpriteFrame(-44, -28, 76, 52, 222, 5) // EggMobile, but duller!
290
end if
291
292
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
293
end event
294
295