Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/Boss_LegJoint2.txt
1319 views
1
//--------------Sonic CD Boss Leg Joint 2 Script--------------//
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.BodyEntity
8
#alias Object.Value1 : Object.LegsEntity
9
#alias Object.Value1 : Object.LegREntity // Alt. for Right leg joint
10
#alias Object.Value2 : Object.XOffSet
11
#alias Object.Value4 : Object.LegSide
12
#alias Object.Value5 : Object.YOffSet
13
#alias Object.Value6 : Object.XVelocity
14
#alias Object.Value7 : Object.YVelocity
15
16
// Boss Body aliases
17
#alias Object.Value0 : Body.FaceEntity
18
#alias Object.State : Body.State
19
#alias Object.XPos : Body.XPos
20
#alias Object.YPos : Body.YPos
21
#alias Object.Value1 : Body.LegJointREntity
22
#alias Object.Value2 : Body.LegJointLEntity
23
24
// Boss Face aliases
25
#alias Object.XPos : Face.XPos
26
#alias Object.YPos : Face.YPos
27
28
// Boss Foot aliases
29
#alias Object.XPos : Foot.XPos
30
#alias Object.YPos : Foot.YPos
31
#alias Object.State : Foot.State
32
#alias Object.Value2 : Foot.XOffSet
33
#alias Object.Value4 : Foot.LegSide
34
35
// Boss Legs aliases
36
#alias Object.Value1 : Legs.FootEntity
37
#alias Object.State : Legs.State
38
39
// Boss Foot (Right) aliases
40
#alias Object.XPos : FootR.XPos
41
#alias Object.YPos : FootR.YPos
42
#alias Object.State : FootR.State
43
#alias Object.Value2 : FootR.XOffSet
44
#alias Object.Value4 : FootR.LegSide
45
46
// Boss Legs (Right) aliases
47
#alias Object.Value1 : LegR.FootREntity
48
#alias Object.State : LegR.State
49
50
// Boss Leg Joint (Right) Aliases
51
#alias Object.Priority : LegJointR.Priority
52
#alias Object.Value0 : LegJointR.BodyEntity
53
#alias Object.Value1 : LegJointR.LegREntity
54
#alias Object.Value2 : LegJointR.XOffSet
55
#alias Object.Value4 : LegJointR.LegSide
56
#alias Object.XPos : LegJointR.XPos
57
#alias Object.YPos : LegJointR.YPos
58
59
// Boss Leg Joint (Left) Aliases
60
#alias Object.Priority : LegJointL.Priority
61
#alias Object.DrawOrder : LegJointL.DrawOrder
62
#alias Object.Value0 : LegJointL.BodyEntity
63
#alias Object.Value1 : LegJointL.LegLEntity
64
65
// States
66
#alias 0 : BOSSLEGJOINT2_SETUP
67
#alias 1 : BOSSLEGJOINT2_STEP_START
68
#alias 2 : BOSSLEGJOINT2_STEP
69
#alias 3 : BOSSLEGJOINT2_STEP_END
70
#alias 4 : BOSSLEGJOINT2_WAIT_LEG
71
#alias 5 : BOSSLEGJOINT2_LANDING
72
#alias 6 : BOSSLEGJOINT2_DESCEND
73
#alias 7 : BOSSLEGJOINT2_STAND
74
#alias 8 : BOSSLEGJOINT2_MIMIC_RIGHT
75
#alias 9 : BOSSLEGJOINT2_STEP_START_BW
76
#alias 10 : BOSSLEGJOINT2_STEP_BW
77
#alias 11 : BOSSLEGJOINT2_WAIT_LEG_BW
78
#alias 12 : BOSSLEGJOINT2_DESTROYED
79
80
// Boss Foot States
81
#alias 1 : BOSSFOOT2_STEP
82
#alias 2 : BOSSFOOT2_HANDLE_STEP
83
#alias 3 : BOSSFOOT2_STEP_OPPOSITE
84
#alias 4 : BOSSFOOT2_HANDLE_STEP_OPPOSITE
85
86
// Priority
87
#alias 0 : PRIORITY_BOUNDS
88
89
// Function declarations
90
#function BossLegJoint2_JointRotation
91
#function BossLegJoint2_HandleMovement
92
#function BossLegJoint2_HandleLanding
93
94
95
function BossLegJoint2_JointRotation
96
ArrayPos0 = Object.BodyEntity
97
Object.XPos = Body[ArrayPos0].XPos
98
Object.XPos += 0xC0000
99
Object.XPos += TempValue7
100
if Object.DrawOrder == 2
101
Object.XPos -= 0xA0000
102
end if
103
Object.YPos = Body[ArrayPos0].YPos
104
Object.YPos += 0x140000
105
Object.YPos += TempValue6
106
end function
107
108
109
function BossLegJoint2_HandleMovement
110
Sin256(TempValue6, Object.XOffSet)
111
TempValue6 <<= 12
112
Cos256(TempValue7, Object.XOffSet)
113
TempValue7 <<= 12
114
GetBit(TempValue0, Object.LegSide, 4)
115
if TempValue0 == false
116
SetBit(Object.LegSide, 1, 0)
117
CallFunction(BossLegJoint2_JointRotation)
118
else
119
GetBit(TempValue0, Object.LegSide, 5)
120
if TempValue0 == false
121
CallFunction(BossLegJoint2_JointRotation)
122
else
123
GetBit(TempValue0, Object.LegSide, 1)
124
if TempValue0 == false
125
SetBit(Object.LegSide, 1, 1)
126
Object.XVelocity = TempValue6
127
Object.YVelocity = TempValue7
128
else
129
ArrayPos0 = Object.BodyEntity
130
ArrayPos1 = Body[ArrayPos0].FaceEntity
131
132
TempValue0 = TempValue7
133
TempValue0 -= Object.YVelocity
134
Object.YVelocity = TempValue7
135
136
Body[ArrayPos0].XPos -= TempValue0
137
Face[ArrayPos1].XPos -= TempValue0
138
139
TempValue0 = TempValue6
140
TempValue0 -= Object.XVelocity
141
Object.XVelocity = TempValue6
142
143
Body[ArrayPos0].YPos -= TempValue0
144
Face[ArrayPos1].YPos -= TempValue0
145
end if
146
end if
147
end if
148
end function
149
150
151
function BossLegJoint2_HandleLanding
152
ArrayPos0 = Object.LegsEntity
153
ArrayPos1 = Legs[ArrayPos0].FootEntity
154
if Foot[ArrayPos1].State == BOSSFOOT2_HANDLE_STEP
155
if Object.XOffSet >= 88
156
GetBit(TempValue0, Foot[ArrayPos1].LegSide, 0)
157
158
if TempValue0 == true
159
SetBit(Foot[ArrayPos1].LegSide, 0, 0)
160
SetBit(Object.LegSide, 0, 1)
161
end if
162
163
CallFunction(BossLegJoint2_HandleMovement)
164
end if
165
166
else
167
Foot[ArrayPos1].State = BOSSFOOT2_STEP
168
if Object.XOffSet < 88
169
Object.XOffSet += Object.YOffSet
170
if Object.XOffSet > 88
171
Object.XOffSet = 88
172
end if
173
end if
174
CallFunction(BossLegJoint2_HandleMovement)
175
176
end if
177
end function
178
179
180
sub ObjectMain
181
switch Object.State
182
case BOSSLEGJOINT2_SETUP
183
Object.XOffSet = 88
184
TempValue0 = 2
185
TempValue0 *= Object.PropertyValue
186
TempValue0 /= 10
187
Object.YOffSet = TempValue0
188
Object.State = BOSSLEGJOINT2_DESCEND
189
break
190
191
case BOSSLEGJOINT2_STEP_START
192
ArrayPos0 = Object.LegsEntity
193
ArrayPos1 = Legs[ArrayPos0].FootEntity
194
if Foot[ArrayPos1].State != BOSSFOOT2_STEP_OPPOSITE
195
if Foot[ArrayPos1].State != BOSSFOOT2_HANDLE_STEP_OPPOSITE
196
SetBit(Foot[ArrayPos1].LegSide, 0, 0)
197
Foot[ArrayPos1].State = BOSSFOOT2_STEP_OPPOSITE
198
end if
199
end if
200
201
TempValue0 = false
202
if Object.XOffSet > 0
203
Object.XOffSet -= Object.YOffSet
204
if Object.XOffSet > 0
205
CallFunction(BossLegJoint2_HandleMovement)
206
TempValue0 = true
207
end if
208
end if
209
210
if TempValue0 == false
211
Object.XOffSet = 0
212
if Foot[ArrayPos1].State != BOSSFOOT2_HANDLE_STEP_OPPOSITE
213
GetBit(TempValue0, Foot[ArrayPos1].LegSide, 0)
214
if TempValue0 == false
215
CallFunction(BossLegJoint2_HandleMovement)
216
else
217
SetBit(Foot[ArrayPos1].LegSide, 0, 0)
218
Object.State = BOSSLEGJOINT2_STEP
219
CallFunction(BossLegJoint2_HandleMovement)
220
end if
221
else
222
Object.State = BOSSLEGJOINT2_STEP
223
CallFunction(BossLegJoint2_HandleMovement)
224
end if
225
end if
226
break
227
228
case BOSSLEGJOINT2_STEP
229
ArrayPos0 = Object.LegsEntity
230
ArrayPos1 = Legs[ArrayPos0].FootEntity
231
Object.XOffSet += Object.YOffSet
232
if Object.XOffSet >= 88
233
Object.XOffSet = 88
234
Object.State = BOSSLEGJOINT2_STEP_END
235
Foot[ArrayPos1].State = BOSSFOOT2_STEP
236
end if
237
CallFunction(BossLegJoint2_HandleMovement)
238
break
239
240
case BOSSLEGJOINT2_STEP_END
241
ArrayPos0 = Object.LegsEntity
242
ArrayPos1 = Legs[ArrayPos0].FootEntity
243
GetBit(TempValue0, Foot[ArrayPos1].LegSide, 4)
244
if TempValue0 == 1
245
SetBit(Object.LegSide, 0, 1)
246
end if
247
CallFunction(BossLegJoint2_HandleMovement)
248
break
249
250
case BOSSLEGJOINT2_WAIT_LEG // wait for the other leg to move
251
GetBit(TempValue0, Object.LegSide, 0)
252
if TempValue0 == 0
253
Object.XOffSet -= Object.YOffSet
254
if Object.XOffSet < 24
255
Object.XOffSet = 24
256
SetBit(Object.LegSide, 0, 1)
257
end if
258
end if
259
CallFunction(BossLegJoint2_HandleMovement)
260
break
261
262
case BOSSLEGJOINT2_LANDING // Only the right uses this, the left mimics
263
ArrayPos0 = Object.LegREntity
264
ArrayPos1 = LegR[ArrayPos0].FootREntity
265
if FootR[ArrayPos1].State == BOSSFOOT2_HANDLE_STEP_OPPOSITE
266
if Object.XOffSet == 0
267
GetBit(TempValue0, FootR[ArrayPos1].LegSide, 0)
268
if TempValue0 == true
269
SetBit(FootR[ArrayPos1].LegSide, 0, 0)
270
SetBit(Object.LegSide, 0, 1)
271
end if
272
273
CallFunction(BossLegJoint2_HandleMovement)
274
else
275
if Object.XOffSet != 0
276
Object.XOffSet -= Object.YOffSet
277
if Object.XOffSet < 0
278
Object.XOffSet = 0
279
end if
280
end if
281
282
CallFunction(BossLegJoint2_HandleMovement)
283
end if
284
else
285
FootR[ArrayPos1].State = BOSSFOOT2_STEP_OPPOSITE
286
287
if Object.XOffSet != 0
288
Object.XOffSet -= Object.YOffSet
289
if Object.XOffSet < 0
290
Object.XOffSet = 0
291
end if
292
end if
293
CallFunction(BossLegJoint2_HandleMovement)
294
end if
295
break
296
297
case BOSSLEGJOINT2_DESCEND // Only the right uses this, the left mimics
298
CallFunction(BossLegJoint2_HandleLanding)
299
break
300
301
case BOSSLEGJOINT2_STAND
302
if Object.XOffSet < 24
303
Object.XOffSet += Object.YOffSet
304
305
ArrayPos0 = Object.LegsEntity
306
ArrayPos1 = Legs[ArrayPos0].FootEntity
307
SetBit(Foot[ArrayPos1].LegSide, 7, 1)
308
309
ArrayPos0 = Object.BodyEntity
310
ArrayPos1 = Body[ArrayPos0].LegJointLEntity
311
312
ArrayPos0 = LegJointL[ArrayPos1].LegLEntity
313
ArrayPos1 = Body[ArrayPos0].LegJointREntity
314
SetBit(LegJointR[ArrayPos1].LegSide, 7, 1)
315
316
CallFunction(BossLegJoint2_HandleLanding)
317
if Object.XOffSet > 24
318
Object.XOffSet = 24
319
end if
320
else
321
if Object.XOffSet > 24
322
ArrayPos0 = Object.LegsEntity
323
ArrayPos1 = Legs[ArrayPos0].FootEntity
324
if Foot[ArrayPos1].State == BOSSFOOT2_HANDLE_STEP_OPPOSITE
325
326
if Object.XOffSet == 0
327
328
GetBit(TempValue0, Foot[ArrayPos1].LegSide, 0)
329
if TempValue0 == true
330
SetBit(Foot[ArrayPos1].LegSide, 0, 0)
331
SetBit(Object.LegSide, 0, 1)
332
end if
333
334
CallFunction(BossLegJoint2_HandleMovement)
335
else
336
if Object.XOffSet != 0
337
Object.XOffSet -= Object.YOffSet
338
if Object.XOffSet < 0
339
Object.XOffSet = 0
340
end if
341
end if
342
343
CallFunction(BossLegJoint2_HandleMovement)
344
end if
345
346
else
347
Foot[ArrayPos1].State = BOSSFOOT2_STEP_OPPOSITE
348
if Object.XOffSet != 0
349
Object.XOffSet -= Object.YOffSet
350
if Object.XOffSet < 0
351
Object.XOffSet = 0
352
end if
353
end if
354
355
CallFunction(BossLegJoint2_HandleMovement)
356
end if
357
358
Object.XOffSet -= Object.YOffSet
359
if Object.XOffSet < 24
360
Object.XOffSet = 24
361
end if
362
363
else
364
ArrayPos0 = Object.LegsEntity
365
ArrayPos1 = Legs[ArrayPos0].FootEntity
366
GetBit(TempValue0, Foot[ArrayPos1].LegSide, 0)
367
if TempValue0 == true
368
SetBit(Object.LegSide, 0, 1)
369
end if
370
371
CallFunction(BossLegJoint2_HandleMovement)
372
end if
373
374
end if
375
break
376
377
case BOSSLEGJOINT2_MIMIC_RIGHT // only the left leg uses this
378
ArrayPos0 = Object.BodyEntity
379
ArrayPos1 = Body[ArrayPos0].LegJointREntity
380
Object.XPos = LegJointR[ArrayPos1].XPos
381
Object.XPos -= 0xA0000
382
Object.YPos = LegJointR[ArrayPos1].YPos
383
Object.XOffSet = LegJointR[ArrayPos1].XOffSet
384
break
385
386
case BOSSLEGJOINT2_STEP_START_BW
387
ArrayPos0 = Object.LegsEntity
388
ArrayPos1 = Legs[ArrayPos0].FootEntity
389
TempValue1 = false
390
if Foot[ArrayPos1].State != BOSSFOOT2_STEP_OPPOSITE
391
392
if Foot[ArrayPos1].State != BOSSFOOT2_HANDLE_STEP_OPPOSITE
393
SetBit(Foot[ArrayPos1].LegSide, 0, 0)
394
Foot[ArrayPos1].State = BOSSFOOT2_STEP_OPPOSITE
395
else
396
if Object.XOffSet != 32
397
398
Object.XOffSet -= Object.YOffSet
399
if Object.XOffSet > 0
400
TempValue1 = true
401
end if
402
403
end if
404
405
if TempValue1 == false
406
Object.XOffSet = 32
407
SetBit(Foot[ArrayPos1].LegSide, 0, 0)
408
Object.State = BOSSLEGJOINT2_STEP_BW
409
end if
410
411
end if
412
413
end if
414
415
CallFunction(BossLegJoint2_HandleMovement)
416
break
417
418
case BOSSLEGJOINT2_STEP_BW
419
ArrayPos0 = Object.LegsEntity
420
ArrayPos1 = Legs[ArrayPos0].FootEntity
421
422
Object.XOffSet += Object.YOffSet
423
if Object.XOffSet >= 48
424
Object.XOffSet = 48
425
Object.State = BOSSLEGJOINT2_STEP_END
426
Foot[ArrayPos1].State = BOSSFOOT2_STEP
427
end if
428
429
CallFunction(BossLegJoint2_HandleMovement)
430
break
431
432
case BOSSLEGJOINT2_WAIT_LEG_BW
433
GetBit(TempValue0, Object.LegSide, 0)
434
if TempValue0 == false
435
436
ArrayPos0 = Object.LegsEntity
437
ArrayPos1 = Legs[ArrayPos0].FootEntity
438
if Foot[ArrayPos1].State != BOSSFOOT2_STEP
439
440
if Foot[ArrayPos1].State != BOSSFOOT2_HANDLE_STEP
441
Foot[ArrayPos1].State = BOSSFOOT2_STEP
442
else
443
Object.XOffSet += Object.YOffSet
444
if Object.XOffSet >= 80
445
SetBit(Object.LegSide, 0, 1)
446
end if
447
448
end if
449
450
end if
451
452
end if
453
CallFunction(BossLegJoint2_HandleMovement)
454
break
455
456
case BOSSLEGJOINT2_DESTROYED
457
GetBit(TempValue0, Object.LegSide, 4)
458
if TempValue0 == false
459
Object.XOffSet -= 0x600
460
else
461
Object.XOffSet += 0x600
462
end if
463
Object.XPos += Object.XOffSet
464
465
Object.YOffSet += 0x1860
466
Object.YPos += Object.YOffSet
467
468
if Object.OutOfBounds == true
469
Object.Type = TypeName[Blank Object]
470
Object.Priority = PRIORITY_BOUNDS
471
end if
472
break
473
474
end switch
475
end sub
476
477
478
sub ObjectDraw
479
DrawSprite(0)
480
end sub
481
482
483
sub ObjectStartup
484
LoadSpriteSheet("R1/Objects3.gif")
485
486
SpriteFrame(-8, -8, 16, 16, 74, 42) // #0 - Leg Joint
487
end sub
488
489
490
// ========================
491
// Editor Subs
492
// ========================
493
494
sub RSDKDraw
495
DrawSprite(0)
496
end sub
497
498
499
sub RSDKLoad
500
LoadSpriteSheet("R1/Objects3.gif")
501
SpriteFrame(-8, -8, 16, 16, 74, 42) // #0 - Leg Joint
502
503
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
504
end sub
505
506