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