Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/Amy1.txt
1319 views
1
//-------------------Sonic CD Amy 1 Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
7
// Values0-1 are skipped over... possibly to keep values parallel with the Amy 2 object
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.Bounds.Left
10
#alias Object.Value4 : Object.Bounds.Right
11
12
// States
13
#alias 0 : AMY1_CAUGHT
14
#alias 1 : AMY1_FALLING
15
16
// Player Aliases
17
#alias 0 : PLAYER_SONIC_A
18
19
// Collision Sides
20
#alias 0 : CSIDE_FLOOR
21
22
// Global SFX
23
#alias 22 : SFX_G_EXPLOSION
24
25
// Game Mode Aliases
26
#alias 2 : MODE_TIMEATTACK
27
28
29
sub ObjectMain
30
31
// (AMY1_CAUGHT has no code here, all of that state's stuff is done over in PlayerObjectCollision)
32
33
if Object.State == AMY1_FALLING
34
35
// Update falling movements
36
Object.YPos += Object.YVelocity
37
38
// Gravity of 0.125 pixels per frame
39
Object.YVelocity += 0x2000
40
41
// Check if Amy's touched the floor
42
ObjectTileCollision(CSIDE_FLOOR, 0, 19, 0)
43
if CheckResult == true
44
45
// Amy's landed on the ground now, replace her with an Amy 2 object
46
ResetObjectEntity(Object.EntityNo, TypeName[Amy 2], 0, Object.XPos, Object.YPos)
47
48
Object.Frame = 4
49
Object.DrawOrder = 4
50
51
// Set Amy's bounds to make sure she doesn't go too far
52
// they're hardcoded positions btw :(
53
Object.Bounds.Left = 0x3EA40000 // Left bounds (16036 with the in-game debug position display)
54
Object.Bounds.Right = 0x40000000 // Right bounds (16384 with the in-game debug position display)
55
56
#platform: Use_Origins
57
// Some additional stuff for Origins
58
59
// Let the game know we've finished the boss!
60
// This is somewhat unused, as in ths Boss Rush, Metal Sonic already does this same thing,
61
// so Amy never gets a turn before the stage switches
62
// In normal play this hits, though at that point it doesn't really have any effect at all
63
game.callbackParam0 = true
64
EngineCallback(NOTIFY_BOSS_END)
65
66
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
67
// This code will never hit at all, check out above
68
69
StopMusic()
70
end if
71
#endplatform
72
73
end if
74
end if
75
76
end sub
77
78
79
sub ObjectPlayerInteraction
80
81
// (The opposite case of ObjectMain, there's nothing for AMY1_FALLING at all here)
82
83
if Object.State == AMY1_CAUGHT
84
85
// Due to how the engine works, there's a single frame upon landing where this code is actually
86
// being run from an Amy 2 object, so check against that
87
// This check was only introduced in an update, so it's not in the 2012 Steam version or anything
88
89
if Object.Type == TypeName[Amy 1]
90
91
// Check if Sonic's hit Amy
92
PlayerObjectCollision(C_TOUCH, -8, -16, 8, 16)
93
if CheckResult == true
94
// Free Amy if Sonic broke the rope (?)
95
96
// Bounce Sonic off
97
FlipSign(Player.YVelocity)
98
Player.YVelocity >>= 1
99
100
// And start Amy's descent
101
Object.State = AMY1_FALLING
102
Object.Frame >>= 3
103
104
// Create an Explosion for the rope (?) just broken
105
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
106
107
// And that wraps up the stage!
108
Stage.TimeEnabled = false
109
110
PlaySfx(SFX_G_EXPLOSION, false)
111
112
end if
113
114
end if
115
116
end if
117
118
end sub
119
120
121
sub ObjectDraw
122
123
if Object.State == AMY1_CAUGHT
124
TempValue0 = Object.Frame
125
TempValue0 >>= 3
126
DrawSprite(TempValue0)
127
128
// Animation is done here as well
129
Object.Frame++
130
Object.Frame &= 31
131
else
132
// Stay static while falling down
133
134
DrawSprite(Object.Frame)
135
end if
136
137
end sub
138
139
140
sub ObjectStartup
141
142
LoadSpriteSheet("R7/Objects2.gif")
143
144
// Erase all Amy 1 objects in the level if she's not supposed to appear
145
ArrayPos0 = 32
146
while ArrayPos0 < 1056
147
if Object[ArrayPos0].Type == TypeName[Amy 1]
148
149
// Only appear for Sonic
150
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
151
if Options.GameMode == MODE_TIMEATTACK
152
// Don't appear in time attack, unload
153
154
Object[ArrayPos0].Type = TypeName[Blank Object]
155
else
156
// All conditions passed - Amy can continue as normal
157
158
// Have her draw above Sonic,
159
Object[ArrayPos0].DrawOrder = 4
160
end if
161
else
162
// Amy doesn't care about Tails, unload
163
164
Object[ArrayPos0].Type = TypeName[Blank Object]
165
end if
166
167
end if
168
169
ArrayPos0++
170
loop
171
172
// Amy Frames
173
174
// 0-3 - Hanging Frames
175
SpriteFrame(-12, -20, 24, 40, 1, 170)
176
SpriteFrame(-12, -20, 24, 40, 1, 211)
177
SpriteFrame(-12, -20, 24, 40, 124, 109)
178
SpriteFrame(-12, -20, 24, 40, 1, 211)
179
180
end sub
181
182
183
// ========================
184
// Editor Subs
185
// ========================
186
187
sub RSDKDraw
188
DrawSprite(0)
189
end sub
190
191
192
sub RSDKLoad
193
LoadSpriteSheet("R7/Objects2.gif")
194
SpriteFrame(-12, -20, 24, 40, 1, 170)
195
196
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
197
end sub
198
199