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/Eggman.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: SBZ Eggman Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This Eggman object is used for the SBZ2 end cutscene
9
// For the game's final boss, see FZEggman instead
10
11
// ========================
12
// Aliases
13
// ========================
14
15
private alias object.value0 : object.timer
16
private alias object.value1 : object.invincibilityTimer
17
18
// Player Aliases
19
private alias object.value40 : player.hitboxLeft
20
private alias object.value38 : player.hitboxTop
21
private alias object.value41 : player.hitboxRight
22
private alias object.value39 : player.hitboxBottom
23
24
// States
25
private alias 0 : SBZEGGMAN_WAITING
26
private alias 1 : SBZEGGMAN_LAUGH
27
private alias 2 : SBZEGGMAN_JUMP
28
private alias 3 : SBZEGGMAN_INAIR
29
private alias 4 : SBZEGGMAN_LAND
30
private alias 5 : SBZEGGMAN_FINISHED
31
32
// Animations
33
private alias 0 : SBZEGGMAN_ANI_IDLE
34
private alias 1 : SBZEGGMAN_ANI_LAUGH
35
private alias 2 : SBZEGGMAN_ANI_JUMP
36
private alias 3 : SBZEGGMAN_ANI_HIT
37
38
// Player Aliases
39
private alias object.xpos : player.xpos
40
41
// Music Events
42
private alias 26 : SLOT_MUSICEVENT_BOSS
43
44
private alias 0 : MUSICEVENT_FADETOBOSS
45
private alias 1 : MUSICEVENT_FADETOSTAGE
46
private alias 2 : MUSICEVENT_TRANSITION
47
48
49
// ========================
50
// Events
51
// ========================
52
53
event ObjectUpdate
54
// Handle States
55
switch object.state
56
case SBZEGGMAN_WAITING
57
temp0 = object.xpos
58
temp0 -= 0x880000
59
if player[0].xpos >= temp0
60
object.state++
61
object.timer = 180
62
object.animation = SBZEGGMAN_ANI_LAUGH
63
end if
64
break
65
66
case SBZEGGMAN_LAUGH
67
object.timer--
68
if object.timer < 0
69
object.state++
70
object.timer = 15
71
object.animation = SBZEGGMAN_ANI_JUMP
72
end if
73
break
74
75
case SBZEGGMAN_JUMP
76
object.timer--
77
if object.timer < 0
78
object.state++
79
object.xvel = -0xFC00
80
object.yvel = -0x3C000
81
end if
82
break
83
84
case SBZEGGMAN_INAIR
85
object.xpos += object.xvel
86
object.ypos += object.yvel
87
object.yvel += 0x2400
88
if object.yvel == 0
89
object.animation = SBZEGGMAN_ANI_LAUGH
90
object.state++
91
end if
92
break
93
94
case SBZEGGMAN_LAND
95
object.animation = SBZEGGMAN_ANI_LAUGH
96
object.state++
97
break
98
99
case SBZEGGMAN_FINISHED
100
break
101
102
end switch
103
104
// Handle Animations
105
switch object.animation
106
case SBZEGGMAN_ANI_IDLE
107
object.frame = 0
108
break
109
110
case SBZEGGMAN_ANI_LAUGH
111
object.animationTimer++
112
if object.animationTimer == 14
113
object.animationTimer = 0
114
end if
115
object.frame = object.animationTimer
116
object.frame /= 7
117
object.frame++
118
break
119
120
case SBZEGGMAN_ANI_JUMP
121
if object.yvel == 0
122
object.frame = 3
123
else
124
object.frame = 4
125
end if
126
break
127
128
case SBZEGGMAN_ANI_HIT
129
if object.yvel == 0
130
object.frame = 5
131
else
132
object.frame = 6
133
end if
134
break
135
136
end switch
137
138
// Player Interactions
139
if object.invincibilityTimer != 0
140
object.invincibilityTimer--
141
end if
142
143
// Don't know how the player is even supposed to reach Eggman in the cutscene, but make Eggman have a reaction to being hit
144
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
145
#platform: USE_STANDALONE
146
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -20, 14, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
147
#endplatform
148
149
#platform: USE_ORIGINS
150
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -20, 14, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
151
#endplatform
152
153
if checkResult == true
154
if object.invincibilityTimer == 0
155
CallFunction(Player_CheckHit)
156
if checkResult == true
157
object.animation = SBZEGGMAN_ANI_HIT
158
object.invincibilityTimer = 32
159
else
160
if object.yvel == 0
161
object.animation = SBZEGGMAN_ANI_LAUGH
162
end if
163
end if
164
end if
165
end if
166
next
167
end event
168
169
170
event ObjectDraw
171
DrawSprite(object.frame)
172
end event
173
174
175
event ObjectStartup
176
LoadSpriteSheet("SBZ/Objects.gif")
177
SpriteFrame(-22, -23, 38, 51, 1, 209)
178
SpriteFrame(-22, -24, 38, 52, 42, 208)
179
SpriteFrame(-22, -23, 38, 51, 84, 209)
180
SpriteFrame(-16, -16, 46, 44, 350, 165)
181
SpriteFrame(-16, -23, 46, 55, 350, 210)
182
SpriteFrame(-22, -24, 42, 52, 225, 266)
183
SpriteFrame(-30, -24, 60, 44, 289, 165)
184
SpriteFrame(-24, -23, 54, 43, 236, 221)
185
SpriteFrame(-21, -25, 51, 52, 269, 213)
186
SpriteFrame(-22, -20, 42, 64, 225, 319)
187
end event
188
189
190
// ========================
191
// Editor Events
192
// ========================
193
194
event RSDKDraw
195
DrawSprite(0)
196
end event
197
198
199
event RSDKLoad
200
LoadSpriteSheet("SBZ/Objects.gif")
201
SpriteFrame(-22, -23, 38, 51, 1, 209)
202
203
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
204
end event
205
206