Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/BossSpikes.txt
1319 views
1
//----------------Sonic CD Boss Spikes 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
// Boss Top Aliases
9
#alias Object.Value1 : Object.BoundsR
10
#alias Object.Value2 : Object.OldBoundsR
11
12
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
13
14
// States
15
#alias 0 : BOSSSPIKES_AWAITPLAYER
16
#alias 1 : BOSSSPIKES_AWAITARENAENTER
17
#alias 2 : BOSSSPIKES_RAISE
18
#alias 3 : BOSSSPIKES_ADVANCE
19
#alias 4 : BOSSSPIKES_STAND
20
21
// Time Periods
22
#alias 3 : TIME_BAD_FUTURE
23
24
// Priority
25
#alias 0 : PRIORITY_BOUNDS
26
#alias 1 : PRIORITY_ACTIVE
27
28
29
sub ObjectMain
30
31
switch Object.State
32
case BOSSSPIKES_AWAITPLAYER
33
if Player.XPos > Object.XPos
34
35
// Initalise the arena
36
37
// Backup the Stage's normal right bounds into the Boss Top's Values
38
Object[+3].OldBoundsR = Stage.XBoundary2
39
40
// Set left bounds
41
Stage.NewXBoundary1 = Object.iXPos
42
Stage.NewXBoundary1 += 328
43
Stage.NewXBoundary1 -= Screen.CenterX
44
45
// And right bounds
46
Stage.NewXBoundary2 = Stage.NewXBoundary1
47
Stage.NewXBoundary2 += Screen.CenterX
48
49
// Set the Boss Top's
50
Object[+3].BoundsR = Stage.NewXBoundary2
51
Object[+3].BoundsR += 160
52
Object[+3].BoundsR <<= 16
53
54
Stage.NewXBoundary2 += Screen.CenterX
55
Stage.NewYBoundary2 = Object.iYPos
56
Object.State = BOSSSPIKES_AWAITARENAENTER
57
Object.Priority = PRIORITY_ACTIVE
58
59
// Remove the Conveyer Belts controller Object
60
ResetObjectEntity(19, TypeName[Blank Object], 0, 0, 0)
61
62
// And make the default palette be used too, rather than whatever the Conveyer Belt's current palette frame was
63
SetActivePalette(0, 0, Screen.YSize)
64
end if
65
break
66
67
case BOSSSPIKES_AWAITARENAENTER
68
TempValue0 = Object.XPos
69
TempValue0 += 0x300000
70
if Player.XPos > TempValue0
71
Object.State = BOSSSPIKES_RAISE
72
end if
73
break
74
75
case BOSSSPIKES_RAISE
76
if Object.Timer < 64
77
Object.Timer += 2
78
Object.YPos -= 0x20000
79
else
80
Object.Timer = 0
81
Object.State = BOSSSPIKES_ADVANCE
82
end if
83
break
84
85
case BOSSSPIKES_ADVANCE
86
if Object.Timer < 192
87
Object.Timer += 2
88
Object.XPos += 0x20000
89
else
90
Object.Timer = 0
91
Object.State = BOSSSPIKES_STAND
92
Object.Priority = PRIORITY_BOUNDS
93
end if
94
break
95
96
end switch
97
98
end sub
99
100
101
sub ObjectPlayerInteraction
102
103
if Object.State < BOSSSPIKES_RAISE
104
105
// Just act as a box for the player
106
PlayerObjectCollision(C_BOX, -24, -32, 0, 32)
107
108
else
109
110
// See if the player is within range of behind the Spike Wall
111
PlayerObjectCollision(C_TOUCH, -64, -32, 0, 32)
112
113
if CheckResult == true
114
115
// If they are, then move them to be in front instead
116
Player.XPos = Player.CollisionRight
117
Player.XPos <<= 16
118
Player.XPos += Object.XPos
119
120
end if
121
end if
122
123
// Check collision for the Spikes side of things
124
PlayerObjectCollision(C_TOUCH, 0, -32, 24, 32)
125
126
if CheckResult == true
127
CallFunction(Player_Hit)
128
129
if Player.State == Player_State_GotHit
130
// If Sonic's been hurt, then set the Boss Platform's
131
Object[+6].Value3 = 0xC000
132
end if
133
134
end if
135
end sub
136
137
138
sub ObjectDraw
139
DrawSprite(0)
140
end sub
141
142
143
sub ObjectStartup
144
LoadSpriteSheet("R5/Objects2.gif")
145
if HUD.CurrentTimePeriod < 3 // Present Past or Future
146
SpriteFrame(-24, -32, 48, 64, 125, 191)
147
else
148
SpriteFrame(-24, -32, 48, 64, 76, 191)
149
end if
150
end sub
151
152
153
// ========================
154
// Editor Subs
155
// ========================
156
157
sub RSDKDraw
158
DrawSprite(0)
159
end sub
160
161
162
sub RSDKLoad
163
LoadSpriteSheet("R5/Objects2.gif")
164
SpriteFrame(-24, -32, 48, 64, 125, 191)
165
166
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
167
end sub
168
169