Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/Boss_Leg2.txt
1319 views
1
//----------------Sonic CD Boss Leg Script 2------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//---------Used on Mission "M099 - Eggman: Speed Up"----------//
5
6
// Aliases
7
#alias Object.Value0 : Object.LegJointEntity
8
#alias Object.Value1 : Object.FootEntity
9
#alias Object.Value2 : Object.XOffSet
10
#alias Object.Value4 : Object.LegSide
11
#alias Object.Value5 : Object.YOffSet
12
#alias Object.Value6 : Object.XVelocity
13
#alias Object.Value7 : Object.YVelocity
14
15
// Foot Aliases
16
#alias Object.Value4 : Foot.LegSide
17
18
// Leg Joint Aliases
19
#alias Object.XPos : LegJoint.XPos
20
#alias Object.YPos : LegJoint.YPos
21
#alias Object.Value0 : LegJoint.BodyEntity
22
23
#alias Object.Value1 : LegJointR.LegREntity
24
25
// Leg Aliases
26
#alias Object.XPos : LegR.XPos
27
#alias Object.YPos : LegR.YPos
28
29
// Body Aliases
30
#alias Object.Value0 : Body.FaceEntity
31
#alias Object.Value1 : Body.LegJointREntity
32
#alias Object.XPos : Body.XPos
33
#alias Object.YPos : Body.YPos
34
35
// Face Aliases
36
#alias Object.XPos : Face.XPos
37
#alias Object.YPos : Face.YPos
38
#alias Object.Animation : Face.Animation
39
#alias Object.Direction : Face.FaceTimer
40
41
// Player Aliases
42
#alias Player.Value4 : Player.InvincibleTimer
43
44
// States
45
#alias 0 : BOSSLEG2_SETUP
46
#alias 1 : BOSSLEG2_LANDING
47
#alias 2 : BOSSLEG2_L_MIMIC_R
48
#alias 3 : BOSSLEG2_MOVE
49
#alias 4 : BOSSLEG2_MOVE_OPPOSITE
50
#alias 5 : BOSSLEG2_MOVE_C // Charged version
51
#alias 6 : BOSSLEG2_MOVE_OPPOSITE_C // Charged version
52
#alias 7 : BOSSLEG2_DESTROYED
53
54
// Eggman Animations
55
#alias 1 : EGGANI_LAUGH
56
57
// Priority
58
#alias 0 : PRIORITY_BOUNDS
59
60
// Function declarations
61
#function BossLeg2_SaveLegPosition
62
#function BossLeg2_HandleMovement
63
64
function BossLeg2_SaveLegPosition
65
GetBit(TempValue0, Object.LegSide, 5)
66
if TempValue0 == true
67
ArrayPos0 = Object.LegJointEntity
68
LegJoint[ArrayPos0].XPos += TempValue1
69
LegJoint[ArrayPos0].YPos += TempValue2
70
71
ArrayPos1 = LegJoint[ArrayPos0].BodyEntity
72
Body[ArrayPos1].XPos += TempValue1
73
Body[ArrayPos1].YPos += TempValue2
74
75
ArrayPos0 = Body[ArrayPos1].FaceEntity
76
Face[ArrayPos0].XPos += TempValue1
77
Face[ArrayPos0].YPos += TempValue2
78
end if
79
end function
80
81
82
function BossLeg2_HandleMovement
83
ArrayPos0 = Object.LegJointEntity
84
Object.XPos = LegJoint[ArrayPos0].XPos
85
Object.XPos += 0x40000
86
Object.XPos += Object.XVelocity
87
88
Object.YPos = LegJoint[ArrayPos0].YPos
89
Object.YPos += 0x100000
90
Object.YPos += Object.YVelocity
91
end function
92
93
94
sub ObjectMain
95
switch Object.State
96
case BOSSLEG2_SETUP
97
TempValue0 = 0x4000
98
TempValue0 *= Object.PropertyValue // Set the XOffset value based on it's property value
99
TempValue0 /= 10
100
101
Object.XOffSet = TempValue0
102
Object.XOffSet <<= 1
103
Object.YOffSet = TempValue0
104
105
Object.State = BOSSLEG2_LANDING
106
break
107
108
case BOSSLEG2_LANDING
109
ArrayPos0 = Object.LegJointEntity
110
111
Object.XPos = LegJoint[ArrayPos0].XPos
112
Object.XPos += 0x40000
113
114
Object.YPos = LegJoint[ArrayPos0].YPos
115
Object.YPos += 0x100000
116
break
117
118
case BOSSLEG2_L_MIMIC_R
119
// No matter the leg, it will end up picking the right leg here
120
ArrayPos0 = Object.LegJointEntity
121
ArrayPos1 = LegJoint[ArrayPos0].BodyEntity
122
ArrayPos0 = Body[ArrayPos1].LegJointREntity
123
ArrayPos1 = LegJointR[ArrayPos0].LegREntity
124
125
Object.XPos = LegR[ArrayPos1].XPos
126
Object.XPos -= 0xA0000
127
Object.YPos = LegR[ArrayPos1].YPos
128
break
129
130
case BOSSLEG2_MOVE
131
// Whatever leg this is, it will move
132
ArrayPos0 = Object.FootEntity
133
if Object.XVelocity < 0x80000
134
TempValue1 = Object.XOffSet
135
Object.XVelocity += TempValue1
136
137
GetBit(TempValue0, Object.LegSide, 4)
138
if TempValue0 == true
139
FlipSign(TempValue1)
140
TempValue2 = false
141
CallFunction(BossLeg2_SaveLegPosition)
142
else
143
CallFunction(BossLeg2_HandleMovement)
144
end if
145
146
else
147
CallFunction(BossLeg2_HandleMovement)
148
end if
149
break
150
151
case BOSSLEG2_MOVE_OPPOSITE
152
// Whatever leg this is, it will wait for the opposite to move
153
ArrayPos0 = Object.FootEntity
154
if Object.XVelocity > -0x80000
155
TempValue1 = Object.XOffSet
156
Object.XVelocity -= TempValue1
157
158
GetBit(TempValue0, Object.LegSide, 4)
159
if TempValue0 == true
160
TempValue2 = false
161
CallFunction(BossLeg2_SaveLegPosition)
162
else
163
CallFunction(BossLeg2_HandleMovement)
164
end if
165
166
else
167
CallFunction(BossLeg2_HandleMovement)
168
end if
169
break
170
171
case BOSSLEG2_MOVE_C
172
// whatever leg this is, it will move
173
if Object.XVelocity > -0x80000
174
TempValue1 = Object.XOffSet
175
Object.XVelocity -= TempValue1
176
else
177
TempValue1 = 0
178
end if
179
180
if Object.YVelocity > -0x40000
181
TempValue2 = Object.YOffSet
182
Object.YVelocity -= TempValue2
183
else
184
TempValue2 = 0
185
end if
186
187
GetBit(TempValue0, Object.LegSide, 4)
188
if TempValue0 == true
189
CallFunction(BossLeg2_SaveLegPosition)
190
else
191
CallFunction(BossLeg2_HandleMovement)
192
end if
193
break
194
195
case BOSSLEG2_MOVE_OPPOSITE_C
196
// whatever leg this is, it will wait for it's opposite to move
197
if Object.XVelocity > -0x80000
198
TempValue1 = Object.XOffSet
199
Object.XVelocity -= TempValue1
200
else
201
TempValue1 = 0
202
end if
203
204
if Object.YVelocity < 0x40000
205
TempValue2 = Object.YOffSet
206
Object.YVelocity += TempValue2
207
else
208
TempValue2 = 0
209
end if
210
211
GetBit(TempValue0, Object.LegSide, 4)
212
if TempValue0 == true
213
FlipSign(TempValue2)
214
CallFunction(BossLeg2_SaveLegPosition)
215
else
216
CallFunction(BossLeg2_HandleMovement)
217
end if
218
break
219
220
case BOSSLEG2_DESTROYED
221
GetBit(TempValue0, Object.LegSide, 4)
222
if TempValue0 == false
223
Object.XOffSet -= 0x600
224
else
225
Object.XOffSet += 0x600
226
end if
227
Object.YOffSet += 0x1A60
228
229
Object.XPos += Object.XOffSet
230
Object.YPos += Object.YOffSet
231
232
if Object.OutOfBounds == true
233
Object.Type = TypeName[Blank Object]
234
Object.Priority = PRIORITY_BOUNDS
235
end if
236
break
237
end switch
238
end sub
239
240
241
sub ObjectPlayerInteraction
242
if Object.State < BOSSLEG2_DESTROYED
243
if Player.InvincibleTimer == 0
244
PlayerObjectCollision(C_TOUCH, -12, -20, 12, -20)
245
if CheckResult == true
246
247
Player.State = Player_State_GotHit
248
249
ArrayPos0 = Object.LegJointEntity
250
ArrayPos1 = LegJoint[ArrayPos0].BodyEntity
251
ArrayPos0 = Body[ArrayPos1].FaceEntity
252
253
Face[ArrayPos0].Animation = EGGANI_LAUGH
254
Face[ArrayPos0].FaceTimer = 180
255
256
if Player.XPos > Object.XPos
257
Player.Speed = 0x20000
258
else
259
Player.Speed = -0x20000
260
end if
261
end if
262
end if
263
end if
264
end sub
265
266
267
sub ObjectDraw
268
DrawSprite(0)
269
end sub
270
271
272
sub ObjectStartup
273
LoadSpriteSheet("R1/Objects3.gif")
274
275
SpriteFrame(-12, -20, 24, 40, 74, 1) // #0 - EGG-HVC-001 Leg
276
end sub
277
278
279
// ========================
280
// Editor Subs
281
// ========================
282
283
sub RSDKDraw
284
DrawSprite(0)
285
end sub
286
287
288
sub RSDKLoad
289
LoadSpriteSheet("R1/Objects3.gif")
290
SpriteFrame(-12, -20, 24, 40, 74, 1) // #0 - EGG-HVC-001 Leg
291
292
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
293
end sub
294