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