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/DEZ/Eggman.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Eggman Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// Using DEZEggman as a prefix here because there's like 12 "Eggman" objects in the game so its less confusing this way
9
// (and this object is called "DEZ Eggman" in MBZ)
10
11
// ========================
12
// Aliases
13
// ========================
14
15
private alias object.value0 : object.sweat.x
16
private alias object.value1 : object.sweat.y
17
private alias object.value2 : object.sweat.yvel
18
private alias object.value3 : object.sweat.visible
19
private alias object.value4 : object.sweat.timer
20
21
private alias 0 : DEZEGGMAN_AWAITPLAYER
22
private alias 1 : DEZEGGMAN_GRIMACING
23
private alias 2 : DEZEGGMAN_RUNNING
24
private alias 3 : DEZEGGMAN_DERJUMP
25
26
// Reserved object slots
27
private alias 0 : SLOT_PLAYER1
28
29
// One Way Door aliases
30
private alias object.state : oneWayDoor.isOpen
31
32
33
// ========================
34
// Events
35
// ========================
36
37
event ObjectUpdate
38
switch object.state
39
case DEZEGGMAN_AWAITPLAYER
40
oneWayDoor[-1].isOpen = false
41
42
// Check to see if Sonic (or whoever P1 is) is approaching
43
BoxCollisionTest(C_TOUCH, object.entityPos, -92, -92, 0, 92, 0, 1, 1, 1, 1)
44
if checkResult == true
45
object.frame = 1
46
object.state = DEZEGGMAN_GRIMACING
47
end if
48
break
49
50
case DEZEGGMAN_GRIMACING
51
oneWayDoor[-1].isOpen = false
52
object.animationTimer++
53
if object.animationTimer >= 24
54
object.state = DEZEGGMAN_RUNNING
55
end if
56
break
57
58
case DEZEGGMAN_RUNNING
59
if object[SLOT_PLAYER1].xpos < object[+1].xpos
60
oneWayDoor[+1].isOpen = true
61
end if
62
63
// Constant speed of at least 2 pixels a frame
64
object.xpos += 0x20000
65
66
// Make sure to always stay a few steps ahead of that pesky hedgehog
67
temp0 = object.xpos
68
temp0 -= 0x500000
69
if object[SLOT_PLAYER1].xpos > temp0
70
object.xpos = object[SLOT_PLAYER1].xpos
71
object.xpos += 0x500000
72
end if
73
74
// Animate the skidaddling
75
object.animationTimer++
76
if object.animationTimer >= 6
77
object.animationTimer = 0
78
object.frame++
79
if object.frame > 4
80
object.frame = 2
81
end if
82
end if
83
84
object.sweat.timer++
85
switch object.sweat.timer
86
case 1
87
object.sweat.x = object.xpos
88
object.sweat.x -= 0x70000
89
object.sweat.y = object.ypos
90
object.sweat.y -= 0x180000
91
object.sweat.yvel = 0
92
object.sweat.visible = true
93
break
94
95
case 2
96
case 3
97
case 4
98
case 5
99
case 6
100
case 7
101
case 8
102
object.sweat.x -= 0x10000
103
object.sweat.yvel += 0x1C00
104
object.sweat.y += object.sweat.yvel
105
break
106
107
case 9
108
object.sweat.visible = false
109
break
110
111
case 32
112
object.sweat.timer = 0
113
break
114
115
end switch
116
117
// Check if arrived at the Death Egg Robot yet
118
// (Object [+9] is DER)
119
temp0 = object[+9].xpos
120
temp0 -= object.xpos
121
if temp0 <= 0x2C0000
122
// Hop in to the Death Egg Robot
123
object.xpos = object[+9].xpos
124
object.xpos -= 0x2C0000
125
object.yvel = -0x20000
126
object.frame = 2
127
object.sweat.visible = false
128
object.state = DEZEGGMAN_DERJUMP
129
end if
130
break
131
132
case DEZEGGMAN_DERJUMP
133
object.xpos += 0xA000
134
object.ypos += object.yvel
135
object.yvel += 0x1000
136
if object.ypos >= object[+9].ypos
137
// Robotnik's no longer visible at all, so start up the Death Egg Robot and make this object dissappear
138
PlaySfx(SfxName[Machine Move], false)
139
object[+9].state = 2
140
object.type = TypeName[Blank Object]
141
end if
142
break
143
144
end switch
145
end event
146
147
148
event ObjectDraw
149
if object.sweat.visible == true
150
DrawSpriteXY(5, object.sweat.x, object.sweat.y)
151
end if
152
153
DrawSprite(object.frame)
154
end event
155
156
157
event ObjectStartup
158
CheckCurrentStageFolder("Zone12")
159
if checkResult == true
160
LoadSpriteSheet("DEZ/Objects.gif")
161
162
// 0 - Idle Frame
163
SpriteFrame(-16, -25, 32, 51, 1, 58)
164
165
// 1 - Panic Frame
166
SpriteFrame(-16, -26, 32, 52, 34, 58)
167
168
// 2-4 - Running Frames
169
SpriteFrame(-30, -27, 58, 43, 67, 58)
170
SpriteFrame(-30, -27, 46, 55, 126, 58)
171
SpriteFrame(-30, -27, 51, 52, 173, 58)
172
173
// 5 - Sweat Frame
174
SpriteFrame(-5, -2, 12, 5, 256, 52)
175
176
// 6-7 - Laughing Frames
177
// (I don't think these are ever actually used?)
178
SpriteFrame(-16, -26, 32, 52, 225, 58)
179
SpriteFrame(-16, -25, 32, 51, 258, 58)
180
else
181
LoadSpriteSheet("MBZ/Objects.gif")
182
183
// 0 - Idle Frame
184
SpriteFrame(-16, -25, 32, 51, 513, 58)
185
186
// 1 - Panic Frame
187
SpriteFrame(-16, -26, 32, 52, 546, 58)
188
189
// 2-4 - Running Frames
190
SpriteFrame(-30, -27, 58, 43, 579, 58)
191
SpriteFrame(-30, -27, 46, 55, 638, 58)
192
SpriteFrame(-30, -27, 51, 52, 685, 58)
193
194
// 5 - Sweat Frame
195
SpriteFrame(-5, -2, 12, 5, 768, 52)
196
197
// 6-7 - Laughing Frames
198
// (I don't think these are ever actually used?)
199
SpriteFrame(-16, -26, 32, 52, 737, 58)
200
SpriteFrame(-16, -25, 32, 51, 770, 58)
201
end if
202
end event
203
204
205
// ========================
206
// Editor Events
207
// ========================
208
209
event RSDKDraw
210
DrawSprite(0)
211
end event
212
213
214
event RSDKLoad
215
CheckCurrentStageFolder("Zone12")
216
if checkResult == true
217
LoadSpriteSheet("DEZ/Objects.gif")
218
SpriteFrame(-16, -25, 32, 51, 1, 58)
219
else
220
LoadSpriteSheet("MBZ/Objects.gif")
221
SpriteFrame(-16, -25, 32, 51, 513, 58)
222
end if
223
224
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
225
end event
226
227