Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/Ladybug.txt
1319 views
1
//------------------Sonic CD Ladybug Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Oscillation
7
#alias Object.Value1 : Object.XVelocity
8
#alias Object.Value2 : Object.BombTimer
9
10
#alias Object.PropertyValue : Object.Quality
11
12
// States
13
#alias 0 : LADYBUG_GUARD
14
#alias 1 : LADYBUG_FLEE
15
#alias 2 : LADYBUG_FLY
16
17
// Badnik Quality / Property Values
18
#alias 0 : GOOD_QUALITY
19
#alias 1 : BAD_QUALITY
20
21
// Collision Sides
22
#alias 0 : CSIDE_FLOOR
23
24
25
sub ObjectMain
26
switch Object.State
27
case LADYBUG_GUARD
28
if Object.XPos > Player.XPos
29
Object.Direction = FACING_RIGHT
30
else
31
Object.Direction = FACING_LEFT
32
end if
33
34
TempValue0 = Object.Oscillation
35
TempValue0 <<= 4
36
37
Sin(TempValue1, TempValue0)
38
TempValue1 >>= 8
39
TempValue1 += 24
40
ObjectTileGrip(CSIDE_FLOOR, 0, TempValue1, 0)
41
42
PlayerObjectCollision(C_TOUCH, -64, -256, 64, 256)
43
if CheckResult == true // If the player gets close enough, start fleeing
44
Object.State = LADYBUG_FLEE
45
46
Object.DrawOrder = 4
47
48
if Object.XPos > Player.XPos
49
Object.XVelocity = 0x10000
50
Object.Direction = FACING_LEFT
51
else
52
Object.XVelocity = -0x10000
53
Object.Direction = FACING_RIGHT
54
end if
55
56
end if
57
break
58
59
case LADYBUG_FLEE
60
TempValue0 = Object.Oscillation
61
TempValue0 &= 3
62
if TempValue0 < 3
63
Object.XPos += Object.XVelocity
64
end if
65
66
if Object.Oscillation < 16
67
ObjectTileGrip(CSIDE_FLOOR, 0, 24, 0)
68
else
69
ObjectTileGrip(CSIDE_FLOOR, 0, 23, 0)
70
end if
71
if CheckResult == false
72
Object.State = LADYBUG_FLY // Once the ladybug runs out of floor, start flying up
73
end if
74
75
if Object.Quality == GOOD_QUALITY // if the ladybug is a good quality one, set bombs while escaping
76
if Object.BombTimer < 128
77
Object.BombTimer++
78
else
79
Object.BombTimer = 0
80
CreateTempObject(TypeName[Ladybug Bomb], 0, Object.XPos, Object.YPos)
81
Object[TempObjectPos].YPos += 0x140000
82
end if
83
end if
84
break
85
86
case LADYBUG_FLY
87
Object.YPos -= 0x8000
88
break
89
90
end switch
91
92
Object.Oscillation++
93
Object.Oscillation &= 31
94
95
Object.Frame++
96
Object.Frame %= 12
97
98
CallFunction(StageSetup_CheckGoodFuture) // Check if it should be a flower
99
end sub
100
101
102
sub ObjectPlayerInteraction
103
#platform: Use_Standalone
104
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 20)
105
#endplatform
106
#platform: Use_Origins
107
PlayerObjectCollision(C_ENEMY, -16, -16, 16, 20)
108
#endplatform
109
if CheckResult == true
110
CallFunction(Player_BadnikBreak)
111
end if
112
end sub
113
114
115
sub ObjectDraw
116
TempValue0 = Object.Frame
117
TempValue0 >>= 2
118
if Object.Quality == BAD_QUALITY
119
TempValue0 += 3
120
end if
121
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
122
end sub
123
124
125
sub ObjectStartup
126
LoadSpriteSheet("R3/Objects.gif")
127
128
// New Ladybug
129
SpriteFrame(-16, -16, 32, 32, 67, 134) // #0 - LadyBug Frame 0
130
SpriteFrame(-16, -16, 32, 32, 100, 134) // #1 - LadyBug Frame 1
131
SpriteFrame(-16, -16, 32, 32, 133, 134) // #2 - LadyBug Frame 2
132
// Old Ladybug
133
SpriteFrame(-16, -16, 32, 32, 67, 101) // #3 - LadyBug Frame 0
134
SpriteFrame(-16, -16, 32, 32, 100, 101) // #4 - LadyBug Frame 1
135
SpriteFrame(-16, -16, 32, 32, 133, 101) // #5 - LadyBug Frame 2
136
end sub
137
138
139
// ========================
140
// Editor Subs
141
// ========================
142
143
sub RSDKEdit
144
if Editor.ReturnVariable == true
145
switch Editor.VariableID
146
case EDIT_VAR_PROPVAL // Property Value
147
CheckResult = Object.PropertyValue
148
CheckResult &= 1
149
break
150
case 0 // condition
151
CheckResult = Object.PropertyValue
152
CheckResult &= 1
153
break
154
end switch
155
else
156
switch Editor.VariableID
157
case EDIT_VAR_PROPVAL // Property Value
158
Object.PropertyValue = Editor.VariableValue
159
Object.PropertyValue &= 1
160
break
161
case 0 // condition
162
Object.PropertyValue = Editor.VariableValue
163
Object.PropertyValue &= 1
164
break
165
end switch
166
end if
167
end sub
168
169
170
sub RSDKDraw
171
switch Object.Quality
172
case GOOD_QUALITY
173
DrawSprite(0)
174
break
175
case BAD_QUALITY
176
DrawSprite(1)
177
break
178
end switch
179
end sub
180
181
182
sub RSDKLoad
183
LoadSpriteSheet("R3/Objects.gif")
184
185
// New Ladybug
186
SpriteFrame(-16, -16, 32, 32, 67, 134) // #0 - LadyBug
187
// Old Ladybug
188
SpriteFrame(-16, -16, 32, 32, 67, 101) // #1 - LadyBug
189
190
AddEditorVariable("condition")
191
SetActiveVariable("condition")
192
AddEnumVariable("Good Quality", GOOD_QUALITY)
193
AddEnumVariable("Bad Quality", BAD_QUALITY)
194
end sub
195
196