Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/BossTop.txt
1319 views
1
//------------------Sonic CD Boss Top Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
8
// These Bounds Values:
9
// Before the Boss Fight starts, BoundsR is enforced here, the Boss Top Object
10
// While the Boss Fight is starting up, the stage's normal right bound is stored in OldBoundsR
11
// During the Boss Fight, new (not BoundsR) right bound is enforced in the Boss Platform Object
12
// After the Boss Right, right bounds is restored to normal based on what was stored to OldBoundsR previously
13
#alias Object.Value1 : Object.BoundsR
14
#alias Object.Value2 : Object.OldBoundsR
15
16
// States
17
#alias 0 : BOSSTOP_IDLE
18
#alias 1 : BOSSTOP_MOVEBOUNDS
19
#alias 2 : BOSSTOP_BOSSFIGHT
20
21
// Ink Effect
22
#alias 0 : INK_NONE
23
24
25
sub ObjectMain
26
27
switch Object.State
28
case BOSSTOP_MOVEBOUNDS
29
if Object.Timer < 55
30
Object.Timer++
31
32
// Move the Bounds left by 2px
33
Object.BoundsR -= 0x20000
34
else
35
Object.State = BOSSTOP_BOSSFIGHT
36
end if
37
break
38
39
end switch
40
41
end sub
42
43
44
sub ObjectPlayerInteraction
45
46
if Object.State == BOSSTOP_IDLE
47
48
// Get the Player's full X Position, including a small offset for their hitbox
49
TempValue0 = Player.CollisionRight
50
TempValue0 <<= 16
51
TempValue0 += Player.XPos
52
53
// And then get this object's right border
54
TempValue1 = Object.BoundsR
55
56
// See if the Player is past the Object's Right Bounds
57
if TempValue0 > TempValue1
58
// If they are, then move the Player back in
59
60
Player.XVelocity = 0
61
Player.Speed = 0
62
63
Player.XPos = TempValue1
64
65
// CollisionRight is in screen-space, while XPos is in world-space, so shift it right by 16
66
TempValue0 = Player.CollisionRight
67
TempValue0 <<= 16
68
69
// And now adjust the Player's Position accordingly, to account for their right hitbox
70
Player.XPos -= TempValue0
71
end if
72
73
end if
74
75
end sub
76
77
78
sub ObjectDraw
79
80
// Different draw routines based on the Object's current effect
81
if Object.InkEffect == INK_NONE
82
83
// Draw the Boss Top
84
DrawSprite(0)
85
86
TempValue0 = Object.XPos
87
88
// 24 pixels to the left, draw the left Pole
89
TempValue0 -= 0x180000
90
DrawSpriteXY(1, TempValue0, Object.YPos)
91
92
// 48 pixels to the right of that (24 pixels right absolute)
93
// draw the right Pole
94
TempValue0 += 0x300000
95
DrawSpriteXY(1, TempValue0, Object.YPos)
96
97
else
98
// This Object's Ink Effect is set to INK_ALPHA when the boss is exploding
99
// (It's set from the Boss Platform Object, which controls most of the fight)
100
101
// Draw the Boss's Top, and its flashing red overlay frame
102
DrawSprite(0)
103
DrawSpriteFX(2, FX_INK, Object.XPos, Object.YPos)
104
105
// Draw the left Pole 24 pixels to the right, and its red overlay flashing frame ontop it as well
106
TempValue0 = Object.XPos
107
TempValue0 -= 0x180000
108
DrawSpriteXY(1, TempValue0, Object.YPos)
109
DrawSpriteFX(3, FX_INK, TempValue0, Object.YPos)
110
111
// And don't forget the right pole either, 48 pixels to the right of that,
112
// which adds up to a 24 pixel + gain total, along with the flashing red overlay
113
// frame for this one too
114
TempValue0 += 0x300000
115
DrawSpriteXY(1, TempValue0, Object.YPos)
116
DrawSpriteFX(3, FX_INK, TempValue0, Object.YPos)
117
118
end if
119
120
end sub
121
122
123
sub ObjectStartup
124
LoadSpriteSheet("R5/Objects2.gif")
125
126
// Base Boss Top Frame
127
SpriteFrame(-32, -24, 64, 48, 1, 1)
128
129
// Pole Frame
130
SpriteFrame(-4, 24, 8, 88, 66, 1)
131
132
// Flashing Boss Top Frame
133
SpriteFrame(-32, -24, 64, 48, 75, 1)
134
135
// Flashing Pole Frame
136
SpriteFrame(-4, 24, 8, 88, 140, 1)
137
138
end sub
139
140
141
// ========================
142
// Editor Subs
143
// ========================
144
145
sub RSDKDraw
146
DrawSprite(0)
147
DrawSprite(1)
148
DrawSprite(2)
149
end sub
150
151
152
sub RSDKLoad
153
LoadSpriteSheet("R5/Objects2.gif")
154
SpriteFrame(-32, -24, 64, 48, 1, 1)
155
SpriteFrame( 20, 24, 8, 88, 66, 1)
156
SpriteFrame(-28, 24, 8, 88, 66, 1)
157
158
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
159
end sub
160
161