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/EHZ/EggmanCar.txt
1488 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Eggman Car 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.drawPos.y
14
private alias object.value2 : object.boundsL
15
private alias object.value3 : object.boundsR
16
private alias object.value4 : object.carPos.y
17
18
// States
19
private alias 0 : EHZEGGMANCAR_SELFDRIVING
20
private alias 1 : EHZEGGMANCAR_EGGMANENTER
21
private alias 2 : EHZEGGMANCAR_DRIVING
22
private alias 3 : EHZEGGMANCAR_EXPLODE
23
private alias 4 : EHZEGGMANCAR_DESTROYED
24
25
// Eggman Aliases
26
private alias object.value8 : eggman.health
27
28
// Car Drill States
29
private alias 0 : EHZEGGMANDRILL_ATTATCHED
30
private alias 2 : EHZEGGMANDRILL_FIRED
31
32
// Car Wheel States
33
private alias 2 : EHZEGGMANWHEEL_BOUNCE
34
35
// Path ID Aliases
36
private alias 0 : PATH_A
37
38
39
// ========================
40
// Events
41
// ========================
42
43
event ObjectUpdate
44
if object.state < EHZEGGMANCAR_EXPLODE
45
object.drawPos.y = object.carPos.y
46
object.drawPos.y >>= 1
47
object.drawPos.y -= 0xC0000
48
object.carPos.y = 0
49
end if
50
51
switch object.state
52
case EHZEGGMANCAR_SELFDRIVING
53
object.xpos -= 0x10000
54
55
object.timer++
56
if object.timer == 321
57
object.timer = 0
58
object.state++
59
end if
60
61
temp0 = oscillation
62
temp0 &= 15
63
if temp0 == 0
64
temp0 = object.xpos
65
if object.direction == FLIP_NONE
66
temp0 += 0x2E0000
67
else
68
temp0 -= 0x2E0000
69
end if
70
71
temp1 = object.drawPos.y
72
temp1 -= 0x40000
73
CreateTempObject(TypeName[Exhaust Puff], 0, temp0, temp1)
74
object[tempObjectPos].yvel = -0x10000
75
end if
76
break
77
78
case EHZEGGMANCAR_EGGMANENTER
79
break
80
81
case EHZEGGMANCAR_DRIVING
82
object.xpos += object.xvel
83
84
if object.xpos <= object.boundsL
85
FlipSign(object.xvel)
86
object.direction ^= FLIP_X
87
object[-2].direction ^= FLIP_X
88
object[-1].direction ^= FLIP_X
89
object[+1].direction ^= FLIP_X
90
object[+2].direction ^= FLIP_X
91
object[+3].direction ^= FLIP_X
92
object[+4].direction ^= FLIP_X
93
94
// if we can fire drill, do fire drill
95
if eggman[-1].health == 1
96
if object[+1].state == EHZEGGMANDRILL_ATTATCHED
97
object[+1].state += EHZEGGMANDRILL_FIRED
98
object[+1].xpos = object.xpos
99
if object.direction == FLIP_NONE
100
object[+1].xpos -= 0x360000
101
object[+1].xvel = -0x30000
102
else
103
object[+1].xpos += 0x360000
104
object[+1].xvel = 0x30000
105
end if
106
end if
107
end if
108
end if
109
110
if object.xpos >= object.boundsR
111
FlipSign(object.xvel)
112
object.direction ^= FLIP_X
113
object[-2].direction ^= FLIP_X
114
object[-1].direction ^= FLIP_X
115
object[+1].direction ^= FLIP_X
116
object[+2].direction ^= FLIP_X
117
object[+3].direction ^= FLIP_X
118
object[+4].direction ^= FLIP_X
119
120
// if we can fire drill, do fire drill
121
if eggman[-1].health == 1
122
if object[+1].state == EHZEGGMANDRILL_ATTATCHED
123
object[+1].state += EHZEGGMANDRILL_FIRED
124
object[+1].xpos = object.xpos
125
if object.direction == FLIP_NONE
126
object[+1].xpos -= 0x360000
127
object[+1].xvel = -0x30000
128
else
129
object[+1].xpos += 0x360000
130
object[+1].xvel = 0x30000
131
end if
132
end if
133
end if
134
end if
135
136
// Handle eggman pos
137
object[-1].xpos = object.xpos
138
object[-1].ypos = object.drawPos.y
139
object[-1].ypos -= 0x80000
140
141
temp0 = oscillation
142
temp0 &= 15
143
if temp0 == 0
144
temp0 = object.xpos
145
if object.direction == FLIP_NONE
146
temp0 += 0x2E0000
147
else
148
temp0 -= 0x2E0000
149
end if
150
151
temp1 = object.drawPos.y
152
temp1 -= 0x40000
153
CreateTempObject(TypeName[Exhaust Puff], 0, temp0, temp1)
154
object[tempObjectPos].yvel = -0x10000
155
end if
156
break
157
158
case EHZEGGMANCAR_EXPLODE
159
object.ypos += object.yvel
160
object.yvel += 0x3800
161
162
object.drawPos.y = object.ypos
163
ObjectTileCollision(CSIDE_FLOOR, 0, 17, PATH_A)
164
if checkResult == true
165
if object.direction == FLIP_NONE
166
temp0 = -0x20000
167
else
168
temp0 = 0x20000
169
end if
170
171
// Back Wheel
172
object[-2].state += EHZEGGMANWHEEL_BOUNCE
173
object[-2].xvel = temp0
174
object[-2].yvel = 0x30000
175
FlipSign(object[-2].xvel)
176
177
// Front Wheel 1
178
object[+2].state += EHZEGGMANWHEEL_BOUNCE
179
object[+2].xvel = temp0
180
object[+2].yvel = 0x30000
181
182
// Front Wheel 2
183
object[+3].state += EHZEGGMANWHEEL_BOUNCE
184
object[+3].xvel = temp0
185
object[+3].yvel = 0x30000
186
187
object.state++
188
end if
189
190
// Eggman
191
object[-1].xpos = object.xpos
192
object[-1].ypos = object.drawPos.y
193
object[-1].ypos -= 0x80000
194
break
195
196
case EHZEGGMANCAR_DESTROYED
197
break
198
199
end switch
200
end event
201
202
203
event ObjectDraw
204
DrawSpriteFX(0, FX_FLIP, object.xpos, object.drawPos.y)
205
end event
206
207
208
event ObjectStartup
209
CheckCurrentStageFolder("Zone01")
210
if checkResult == true
211
LoadSpriteSheet("EHZ/Objects.gif")
212
213
// Car Body Frame
214
SpriteFrame(-48, -16, 93, 32, 0, 109)
215
else
216
LoadSpriteSheet("MBZ/Objects.gif")
217
218
// Car Body Frame
219
SpriteFrame(-48, -16, 93, 32, 123, 1)
220
end if
221
end event
222
223
224
// ========================
225
// Editor Events
226
// ========================
227
228
event RSDKDraw
229
DrawSprite(0)
230
end event
231
232
233
event RSDKLoad
234
CheckCurrentStageFolder("Zone01")
235
if checkResult == true
236
LoadSpriteSheet("EHZ/Objects.gif")
237
SpriteFrame(-48, -16, 93, 32, 0, 109)
238
else
239
LoadSpriteSheet("MBZ/Objects.gif")
240
SpriteFrame(-48, -16, 93, 32, 123, 1)
241
end if
242
243
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
244
end event
245
246