Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/Eggman.txt
1319 views
1
//-------------------Sonic CD Eggman Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
8
// States
9
#alias 0 : EGGMAN_IDLE
10
#alias 1 : EGGMAN_CONTROL
11
#alias 2 : EGGMAN_DAMAGED
12
#alias 3 : EGGMAN_PANICK_JUMP
13
#alias 4 : EGGMAN_PANICK_IDLE
14
#alias 5 : EGGMAN_PANICK_CONTROL
15
#alias 6 : EGGMAN_FLEE
16
17
18
sub ObjectDraw
19
20
// This Object is managed entirely by other Objects, the only thing this Object does is draw (and flee at the end)
21
22
switch Object.State
23
case EGGMAN_IDLE
24
// Draw his Idle Frame
25
DrawSprite(0)
26
27
// Nope, no animation needed here!
28
break
29
30
case EGGMAN_CONTROL
31
// Similarly to above, just draw his Controlling Frame here
32
DrawSprite(1)
33
34
// No animation needed here, either!
35
break
36
37
case EGGMAN_DAMAGED
38
39
// Get the Sprite to use
40
TempValue0 = Object.Frame
41
TempValue0 >>= 3
42
TempValue0 += 2
43
44
DrawSprite(TempValue0)
45
46
// Animate Robotnik
47
Object.Frame++
48
Object.Frame &= 15
49
50
// Draw his floating Sweat Frame if needed
51
if Object.Timer < 4
52
TempValue0 += 8
53
DrawSprite(TempValue0)
54
end if
55
56
Object.Timer++
57
Object.Timer &= 7
58
break
59
60
case EGGMAN_PANICK_JUMP
61
62
// Get the Frame Robotnik should use
63
TempValue0 = Object.Frame
64
TempValue0 &= 15
65
TempValue0 >>= 3
66
67
// Sprite Frame ID Offset of 4
68
TempValue0 += 4
69
70
DrawSprite(TempValue0)
71
72
// Animate the Object
73
Object.Frame++
74
75
// And then draw the Sweat Frame, but onlly if needed
76
if Object.Timer < 4
77
TempValue0 += 6
78
DrawSprite(TempValue0)
79
end if
80
81
// Animate Robotnik, along with his Sweat
82
Object.Timer++
83
Object.Timer &= 7
84
85
if Object.Frame == 48
86
// Stop jumping for a moment and go back to looking normal
87
88
Object.Timer = 0
89
Object.Frame = 0
90
Object.State = EGGMAN_PANICK_IDLE
91
end if
92
break
93
94
case EGGMAN_PANICK_IDLE
95
// Draw the normal Idle Frame
96
DrawSprite(0)
97
98
if Object.Timer < 20
99
Object.Timer++
100
else
101
// Go back to jumping around
102
103
Object.Timer = 0
104
Object.State = EGGMAN_PANICK_JUMP
105
end if
106
break
107
108
case EGGMAN_PANICK_CONTROL
109
// Due to an oversight, this state isn't seen very much
110
// (Once this state goes to EGGMAN_PANICK_JUMP, it goes back to EGGMAN_PANICK_IDLE afterwards instead of here)
111
// (And that is, this state is only entered in the first place if Robotnik's doing his Control pose when he enters his damage dance)
112
113
// Draw his normal Control Frame
114
DrawSprite(1)
115
116
// Update animation
117
if Object.Timer < 20
118
Object.Timer++
119
else
120
Object.Timer = 0
121
Object.Frame = 0
122
Object.State = EGGMAN_PANICK_JUMP
123
end if
124
break
125
126
case EGGMAN_FLEE
127
128
// Draw the main Robotnik Running Sprite
129
TempValue0 = Object.Frame
130
TempValue0 /= 6
131
TempValue0 += 6
132
DrawSprite(TempValue0)
133
134
// Robotnik should be continuously animating here, his legs gotta keep moving!
135
Object.Frame++
136
Object.Frame %= 24
137
138
// Get the Sweat Frame Sprite ID to use
139
TempValue0 = Object.Timer
140
TempValue0 /= 6
141
TempValue0 += 12
142
143
// And then see if the Frame should even be drawn at all
144
TempValue1 = Object.Timer
145
TempValue1 %= 6
146
if TempValue1 < 3
147
// Flip the sprite around, so that it appears behind Robotnik
148
Object.Direction = FACING_LEFT
149
150
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
151
152
// And then restore normal Object Direction
153
// -> This doesn't matter anyway though, as no other parts of this Object use Object.Direction in any way
154
Object.Direction = FACING_RIGHT
155
end if
156
157
Object.Timer++
158
Object.Timer %= 12
159
160
// Object movement in the ObjectDraw sub... I can't say I'm in support of this...
161
// Regardless, move at a rate of 1px per frame
162
Object.XPos += 0x10000
163
164
// Unload when no longer needed
165
if Object.OutOfBounds == true
166
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
167
end if
168
break
169
170
end switch
171
172
end sub
173
174
175
sub ObjectStartup
176
LoadSpriteSheet("R5/Objects2.gif")
177
178
// Idle Frame
179
SpriteFrame(-24, -24, 40, 56, 174, 181)
180
181
// Controlling Frame
182
SpriteFrame(-24, -24, 40, 56, 215, 181)
183
184
// Shock Frames
185
// (Used when the machine is initially falling to start the fight)
186
SpriteFrame(-24, -24, 48, 48, 158, 18)
187
SpriteFrame(-24, -24, 48, 48, 207, 18)
188
189
// Panick Frames
190
// (Used whenever Robotnik's fumbling around on hot ground)
191
SpriteFrame(-24, -24, 48, 56, 158, 67)
192
SpriteFrame(-24, -24, 48, 56, 207, 67)
193
194
// Run Frames
195
SpriteFrame(-32, -25, 64, 48, 66, 138)
196
SpriteFrame(-32, -23, 48, 56, 150, 124)
197
SpriteFrame(-32, -21, 56, 56, 199, 124) // huh? what happened to his mustache here..?
198
SpriteFrame(-32, -23, 48, 56, 150, 124)
199
200
// Damage - Sweat Frames
201
SpriteFrame(-24, -40, 48, 16, 158, 1)
202
SpriteFrame(-24, -40, 48, 16, 207, 1)
203
204
// Panick - Sweat frames
205
SpriteFrame(-20, -40, 0, 0, 158, 1)
206
SpriteFrame(-20, -40, 48, 16, 158, 1)
207
SpriteFrame(-20, -40, 48, 16, 207, 1)
208
209
end sub
210
211
212
// ========================
213
// Editor Subs
214
// ========================
215
216
sub RSDKDraw
217
DrawSprite(0)
218
end sub
219
220
221
sub RSDKLoad
222
LoadSpriteSheet("R5/Objects2.gif")
223
SpriteFrame(-24, -24, 40, 56, 215, 181)
224
225
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
226
end sub
227
228