Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/Sasuri2.txt
1319 views
1
//------------------Sonic CD Sasuri 2 Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//-------------Used on Mission "M093 - Fast Foes"-------------//
5
6
// Aliases
7
#alias Object.Value0 : Object.MoveTimer
8
#alias Object.Value1 : Object.CannonTimer
9
#alias Object.Value2 : Object.LeftPlatformBound
10
#alias Object.Value3 : Object.RightPlatformBound
11
12
// Sasuri Bullet (SBullet) Aliases
13
#alias Object.Value1 : Object.XVelocity
14
15
// States
16
#alias 0 : SASURI2_SETBOUNDS
17
#alias 1 : SASURI2_CRAWLLEFT
18
#alias 2 : SASURI2_CRAWLRIGHT
19
#alias 3 : SASURI2_SPOTPLAYER
20
#alias 4 : SASURI2_SHOOT
21
#alias 5 : SASURI2_RETRACTCANNON
22
23
// Stage SFX
24
#alias 2 : SFX_S_SHOT
25
26
27
sub ObjectMain
28
Object.Frame++
29
Object.Frame %= 60
30
switch Object.State
31
case SASURI2_SETBOUNDS
32
// Object[+1] is whatever platform Sasuri is on top
33
Object.YPos = Object[+1].YPos
34
Object.iYPos -= 28
35
36
Object.RightPlatformBound = 32
37
Object.RightPlatformBound <<= 16
38
39
Object.LeftPlatformBound = 0
40
Object.LeftPlatformBound -= Object.RightPlatformBound
41
42
Object.RightPlatformBound += Object[+1].XPos
43
Object.LeftPlatformBound += Object[+1].XPos
44
45
Object.State = SASURI2_CRAWLLEFT
46
break
47
48
case SASURI2_CRAWLLEFT
49
// Move the Sasuri left by one pixel
50
Object.XPos -= 0x10000
51
52
// Increment its movement timer, and see if it's time to turn around now
53
Object.MoveTimer--
54
if Object.MoveTimer <= -80
55
Object.State = SASURI2_CRAWLRIGHT
56
Object.Direction=FACING_LEFT
57
end if
58
59
if Object.XPos < Object.LeftPlatformBound
60
Object.State = SASURI2_CRAWLRIGHT
61
Object.MoveTimer = 0
62
Object.Direction=FACING_LEFT
63
end if
64
break
65
66
case SASURI2_CRAWLRIGHT
67
Object.XPos += 0x10000
68
69
// As with above, do timer stuff and see if the Sasuri should turn around now
70
Object.MoveTimer++
71
if Object.MoveTimer >= 80
72
Object.State = SASURI2_CRAWLLEFT
73
Object.Direction = FACING_RIGHT
74
end if
75
76
if Object.XPos > Object.RightPlatformBound
77
Object.State = SASURI2_CRAWLLEFT
78
Object.MoveTimer = 0
79
Object.Direction=FACING_RIGHT
80
end if
81
break
82
83
case SASURI2_SPOTPLAYER
84
// This state's set in ObjectPlayerInteraction if the Player is within shooting range
85
86
if Object.CannonTimer < 30
87
Object.CannonTimer++
88
else
89
Object.State = SASURI2_SHOOT
90
Object.CannonTimer = 0
91
end if
92
break
93
94
case SASURI2_SHOOT
95
if Object.CannonTimer < 40
96
if Object.CannonTimer == 10
97
PlayStageSfx(SFX_S_SHOT, false)
98
99
// Create the Bullet that the Sasuri shot
100
CreateTempObject(TypeName[Sasuri Bullet], 0, Object.XPos, Object.YPos)
101
102
// Move the Bullet 24 pixels up, to match where the Sasuri's cannon is drawn
103
Object[TempObjectPos].YPos -= 0x180000
104
105
// Move it 24 pixels in the Sasuri's direction, as well as giving it a velocity of 3px per frame in that very same direction too
106
if Object.Direction == FACING_RIGHT
107
Object[TempObjectPos].XPos -= 0x70000
108
Object[TempObjectPos].XVelocity = -0x30000
109
else
110
Object[TempObjectPos].XPos += 0x70000
111
Object[TempObjectPos].XVelocity = 0x30000
112
end if
113
114
// Move the Sasuri up a Draw Order in order to make it drawn on top of the shot Bullet
115
Object.DrawOrder = 4
116
end if
117
118
Object.CannonTimer++
119
else
120
// Pull the cannon back in
121
Object.State = SASURI2_RETRACTCANNON
122
Object.CannonTimer = 0
123
124
// Move the Sasuri back to its original Draw Order, as at this point
125
// the Bullet's definitely beyond the Sasuri now
126
Object.DrawOrder = 3
127
end if
128
break
129
130
case SASURI2_RETRACTCANNON
131
if Object.CannonTimer < 30
132
Object.CannonTimer++
133
else
134
135
// ...what?
136
// Why make it shoot again? The State's set proper in a couple of lines after anyway...
137
Object.State = SASURI2_SHOOT
138
139
if Object.Direction == FACING_RIGHT
140
Object.State = SASURI2_CRAWLLEFT
141
else
142
Object.State = SASURI2_CRAWLRIGHT
143
end if
144
end if
145
break
146
end switch
147
148
CallFunction(StageSetup_CheckGoodFuture)
149
end sub
150
151
152
sub ObjectPlayerInteraction
153
154
PlayerObjectCollision(C_ENEMY, -22, -14, 22, 14)
155
if CheckResult == true
156
CallFunction(Player_BadnikBreak)
157
end if
158
159
switch Object.State
160
case SASURI2_CRAWLLEFT
161
case SASURI2_CRAWLRIGHT
162
// If in a movement state, then see if the Sasuri
163
if Object.CannonTimer == 0
164
PlayerObjectCollision(C_TOUCH, -64, -24, 64, 24)
165
if CheckResult == true
166
Object.State = SASURI2_SPOTPLAYER
167
168
if Player.XPos < Object.XPos
169
Object.Direction = FACING_RIGHT
170
else
171
Object.Direction = FACING_LEFT
172
end if
173
end if
174
else
175
Object.CannonTimer = 0
176
end if
177
break
178
179
end switch
180
end sub
181
182
183
sub ObjectDraw
184
if Object.Frame < 30
185
// In this order, draw the:
186
// - back paw
187
// - main body
188
// - front paw
189
190
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
191
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
192
DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)
193
else
194
// These are the same order as detailed above, just with different frames for the paws
195
196
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
197
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
198
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
199
end if
200
201
switch Object.State
202
case SASURI2_CRAWLLEFT
203
case SASURI2_CRAWLRIGHT
204
case SASURI2_SPOTPLAYER
205
case SASURI2_RETRACTCANNON
206
// Draw the pulled back cannon frame
207
DrawSpriteFX(10, FX_FLIP, Object.XPos, Object.YPos)
208
break
209
210
case SASURI2_SHOOT
211
// The Sasuri's shooting, so draw the extended cannon frame
212
DrawSpriteFX(11, FX_FLIP, Object.XPos, Object.YPos)
213
break
214
215
end switch
216
end sub
217
218
219
sub ObjectStartup
220
LoadSpriteSheet("R5/Objects.gif")
221
222
// Sasuri Frames
223
224
// Good Main Sasuri Frame
225
SpriteFrame(-24, -16, 48, 32, 174, 141)
226
227
// Bad Main Sasuri Frame
228
SpriteFrame(-24, -16, 48, 32, 174, 174)
229
230
// Good Sasuri Paw Frames
231
SpriteFrame(-32, -4, 32, 16, 100, 110)
232
SpriteFrame(-21, -3, 32, 16, 100, 110)
233
SpriteFrame(-28, -4, 32, 16, 100, 110)
234
SpriteFrame(-25, -3, 32, 16, 100, 110)
235
236
// Bad Sasuri Paw Frames
237
SpriteFrame(-32, -4, 32, 16, 100, 127)
238
SpriteFrame(-21, -3, 32, 16, 100, 127)
239
SpriteFrame(-28, -4, 32, 16, 100, 127)
240
SpriteFrame(-25, -3, 32, 16, 100, 127)
241
242
// Good Sasuri Cannon Frames
243
SpriteFrame(-9, -24, 24, 16, 100, 93)
244
SpriteFrame(-5, -29, 24, 16, 100, 93)
245
246
// Bad Sasuri Cannon Frames
247
SpriteFrame(-1, -24, 16, 16, 133, 110)
248
SpriteFrame(3, -29, 16, 16, 133, 110)
249
250
end sub
251
252
253
// ========================
254
// Editor Subs
255
// ========================
256
257
sub RSDKDraw
258
DrawSprite(2)
259
DrawSprite(0)
260
DrawSprite(3)
261
DrawSprite(6)
262
end sub
263
264
265
sub RSDKLoad
266
LoadSpriteSheet("R5/Objects.gif")
267
268
SpriteFrame(-24, -16, 48, 32, 174, 141)
269
SpriteFrame(-24, -16, 48, 32, 174, 174)
270
271
SpriteFrame(-32, -4, 32, 16, 100, 110)
272
SpriteFrame(-21, -3, 32, 16, 100, 110)
273
274
SpriteFrame(-32, -4, 32, 16, 100, 127)
275
SpriteFrame(-21, -3, 32, 16, 100, 127)
276
277
SpriteFrame(-9, -24, 24, 16, 100, 93)
278
SpriteFrame(-1, -24, 16, 16, 133, 110)
279
280
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
281
end sub
282