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