Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/Boss_Arm.txt
1319 views
1
//----------------Sonic CD Boss Arm Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// ========================
6
// Aliases
7
// ========================
8
9
#alias Object.Value0 : Object.ArmJointEntity // Set by [Boss Face]
10
#alias Object.Value2 : Object.XOffSet
11
#alias Object.Value3 : Object.Timer
12
#alias Object.Value4 : Object.Charging
13
#alias Object.Value5 : Object.YOffSet
14
#alias Object.Value6 : Object.XVelocity
15
#alias Object.Value7 : Object.YVelocity
16
17
// States
18
#alias 0 : BOSSARM_SETUP
19
#alias 1 : BOSSARM_IDLE
20
#alias 2 : BOSSARM_DESTROYED
21
#alias 3 : BOSSARM_MOVE_TO_FRONT
22
#alias 4 : BOSSARM_MOVE_TO_BACK
23
#alias 5 : BOSSARM_START_CHARGE
24
25
// Arm Joint Aliases
26
#alias Object.XPos : ArmJoint.XPos
27
#alias Object.YPos : ArmJoint.YPos
28
29
// Priority Aliases
30
#alias 0 : PRIORITY_BOUNDS
31
32
// Global SFX Aliases
33
#alias 22 : SFX_G_EXPLOSION
34
35
36
// ========================
37
// Fuction Declarations
38
// ========================
39
40
#function BossArm_HandleArmMovement
41
42
43
// ========================
44
// Fucntion Definitions
45
// ========================
46
47
function BossArm_HandleArmMovement
48
ArrayPos0 = Object.ArmJointEntity
49
50
Object.XPos = ArmJoint[ArrayPos0].XPos
51
Object.XPos -= 0x240000
52
Object.XPos += Object.XVelocity
53
54
Object.YPos = ArmJoint[ArrayPos0].YPos
55
56
TempValue1 = true
57
GetBit(TempValue0, Object.Charging, 7) // Check if the HVC is charging agaisnt Sonic
58
if TempValue0 == false // If not, adjust the arms height to defend from the player
59
if Player.YPos < Object.YPos
60
if Object.YVelocity > -0x80000
61
Object.YVelocity -= 0x10000
62
end if
63
64
TempValue1 = false
65
end if
66
end if
67
68
if TempValue1 == true // If it's charging, then the arm's height is set in stone
69
if Object.YVelocity < 0x80000
70
Object.YVelocity += 0x10000
71
end if
72
end if
73
Object.YPos += Object.YVelocity
74
end function
75
76
77
// ========================
78
// Events
79
// ========================
80
81
sub ObjectMain
82
switch Object.State
83
case BOSSARM_SETUP
84
Object.State = BOSSARM_IDLE
85
// [Fallthrough]
86
case BOSSARM_IDLE
87
CallFunction(BossArm_HandleArmMovement)
88
break
89
90
case BOSSARM_DESTROYED
91
Object.XOffSet -= 0x620
92
Object.XPos += Object.XOffSet
93
94
Object.YOffSet += 0x1220
95
Object.YPos += Object.YOffSet
96
97
Object.Timer++
98
if Object.Timer == 7
99
Object.Timer = 0
100
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
101
PlaySfx(SFX_G_EXPLOSION, false)
102
end if
103
104
if Object.OutOfBounds == true
105
Object.Type = TypeName[Blank Object]
106
Object.Priority = PRIORITY_BOUNDS
107
end if
108
break
109
110
case BOSSARM_MOVE_TO_FRONT
111
if Object.XVelocity > 0
112
Object.XVelocity -= 0x8000
113
end if
114
CallFunction(BossArm_HandleArmMovement)
115
break
116
117
case BOSSARM_MOVE_TO_BACK
118
if Object.XVelocity < 0x100000
119
Object.XVelocity += 0x8000
120
end if
121
CallFunction(BossArm_HandleArmMovement)
122
break
123
124
case BOSSARM_START_CHARGE
125
if Object.XVelocity < 0x80000
126
Object.XVelocity += 0x8000
127
else
128
// Set the arm to its retracted frame
129
// -> However, because of an oversight when drawing, this change can't be seen anyway so this has no effect
130
Object.Frame = 1
131
end if
132
133
ArrayPos0 = Object.ArmJointEntity
134
135
Object.XPos = ArmJoint[ArrayPos0].XPos
136
Object.XPos -= 0x240000
137
Object.XPos += Object.XVelocity
138
139
if Object.YVelocity <0x80000
140
Object.YVelocity += 0x10000
141
end if
142
Object.YPos = ArmJoint[ArrayPos0].YPos
143
Object.YPos += Object.YVelocity
144
break
145
146
end switch
147
end sub
148
149
150
sub ObjectDraw
151
DrawSprite(3)
152
153
// See above - this should actually be Object.Frame
154
// However, since it isn't, the arm just shows as extended all the time
155
DrawSprite(0)
156
end sub
157
158
159
sub ObjectStartup
160
LoadSpriteSheet("R1/Objects3.gif")
161
162
SpriteFrame(-15, -8, 32, 16, 141, 34) // #0 - Arm Extend
163
SpriteFrame(-6, -8, 24, 16, 174, 34) // #1 - Arm Retract Frame 0 (Unused, though meant to be used)
164
SpriteFrame(2, -8, 16, 16, 124, 51) // #2 - Arm Retract Frame 1 (Unused)
165
SpriteFrame(9, -8, 24, 16, 141, 51) // #3 - Arm Elbow
166
end sub
167
168
169
// ========================
170
// Editor Subs
171
// ========================
172
173
sub RSDKDraw
174
DrawSprite(1)
175
DrawSprite(0)
176
end sub
177
178
179
sub RSDKLoad
180
LoadSpriteSheet("R1/Objects3.gif")
181
SpriteFrame(-15, -8, 32, 16, 141, 34) // Arm Extend
182
SpriteFrame(9, -8, 24, 16, 141, 51) // Elbow
183
184
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
185
end sub
186
187