Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/Semi.txt
1319 views
1
//-------------------Sonic CD Semi 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
#alias Object.Value1 : Object.XVelocity
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.XOriginPos
10
#alias Object.Value4 : Object.YOriginPos
11
12
#alias Object.PropertyValue : Object.Quality
13
14
// States
15
#alias 0 : SEMI_IDLE
16
#alias 1 : SEMI_START_FLY
17
#alias 2 : SEMI_BOMB_THROW
18
#alias 3 : SEMI_RESET
19
20
// Badnik Quality / Property Values
21
#alias 0 : GOOD_QUALITY
22
#alias 1 : BAD_QUALITY
23
24
// Priority
25
#alias 0 : PRIORITY_BOUNDS
26
#alias 1 : PRIORITY_ACTIVE
27
28
29
sub ObjectMain
30
if Object.OutOfBounds == true
31
Object.State = SEMI_RESET
32
Object.Timer = 0
33
34
Object.XPos = Object.XOriginPos
35
Object.YPos = Object.YOriginPos
36
end if
37
38
switch Object.State
39
case SEMI_START_FLY
40
Object.Priority = PRIORITY_ACTIVE
41
42
Object.XPos += Object.XVelocity
43
Object.YPos += Object.YVelocity
44
45
if Object.Timer < 96
46
Object.Timer++
47
else
48
Object.Timer = 0
49
Object.State++
50
end if
51
break
52
53
case SEMI_BOMB_THROW
54
Object.XPos += Object.XVelocity
55
if Object.Quality == GOOD_QUALITY
56
if Object.Timer == 0
57
Object.Timer = 60
58
CreateTempObject(TypeName[Semi Bomb], 0, Object.XPos, Object.YPos)
59
Object[TempObjectPos].YPos += 0xC0000
60
else
61
Object.Timer--
62
end if
63
end if
64
break
65
66
case SEMI_RESET
67
if Object.OutOfBounds == true
68
Object.State = SEMI_IDLE
69
Object.Priority = PRIORITY_BOUNDS
70
end if
71
break
72
end switch
73
74
// Check if this badnik should be a flower
75
CallFunction(StageSetup_CheckGoodFuture)
76
end sub
77
78
79
sub ObjectPlayerInteraction
80
switch Object.State
81
case SEMI_IDLE
82
PlayerObjectCollision(C_TOUCH, -96, -128, 96, 128)
83
if CheckResult == true
84
Object.State = SEMI_START_FLY
85
if Object.XPos > Player.XPos
86
if Object.Quality == GOOD_QUALITY
87
Object.XVelocity = 0x10000
88
Object.YVelocity = -0x8000
89
else
90
Object.XVelocity = 0xC000
91
Object.YVelocity = 0x6000
92
end if
93
else
94
if Object.Quality == GOOD_QUALITY
95
Object.XVelocity = -0x10000
96
Object.YVelocity = -0x8000
97
else
98
Object.XVelocity = -0xC000
99
Object.YVelocity = 0x6000
100
end if
101
end if
102
end if
103
break
104
105
case SEMI_START_FLY
106
case SEMI_BOMB_THROW
107
#platform: Use_Standalone
108
PlayerObjectCollision(C_TOUCH, -14, -12, 14, 12)
109
#endplatform
110
#platform: Use_Origins
111
PlayerObjectCollision(C_ENEMY, -14, -12, 14, 12)
112
#endplatform
113
if CheckResult == true
114
CallFunction(Player_BadnikBreak)
115
end if
116
break
117
end switch
118
end sub
119
120
121
sub ObjectDraw
122
switch Object.State
123
case SEMI_IDLE
124
DrawSprite(Object.Quality)
125
break
126
127
case SEMI_START_FLY
128
case SEMI_BOMB_THROW
129
TempValue0 = Object.Frame
130
TempValue0 >>= 2
131
132
if Object.Quality == GOOD_QUALITY
133
TempValue0 += 2
134
else
135
TempValue0 += 6
136
end if
137
138
if Object.Frame > 7
139
Object.Direction = FACING_LEFT
140
else
141
Object.Direction = FACING_RIGHT
142
end if
143
144
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
145
Object.Frame++
146
Object.Frame &= 15
147
break
148
end switch
149
end sub
150
151
152
sub ObjectStartup
153
LoadSpriteSheet("R6/Objects.gif")
154
155
// Good
156
SpriteFrame(-16, -16, 32, 32, 1, 224) // #0 - Semi
157
// Bad
158
SpriteFrame(-16, -16, 32, 32, 158, 166) // #1 - Semi
159
160
// Good Rotation
161
SpriteFrame(-16, -16, 32, 32, 34, 224) // #2 - Semi Good Rotating frame 0
162
SpriteFrame(-20, -16, 40, 32, 67, 224) // #3 - Semi Good Rotating frame 1
163
SpriteFrame(-16, -16, 32, 32, 34, 224) // #4 - Semi Good Rotating frame 2
164
SpriteFrame(-20, -16, 40, 32, 67, 224) // #5 - Semi Good Rotating frame 3
165
166
// Bad Rotation
167
SpriteFrame(-16, -16, 32, 32, 108, 224) // #7 - Semi Bad Rotating frame 0
168
SpriteFrame(-20, -16, 40, 32, 141, 224) // #8 - Semi Bad Rotating frame 1
169
SpriteFrame(-16, -16, 32, 32, 108, 224) // #9 - Semi Bad Rotating frame 2
170
SpriteFrame(-20, -16, 40, 32, 141, 224) // #10 - Semi Bad Rotating frame 3
171
172
ArrayPos0 = 32
173
while ArrayPos0 < 1056
174
if Object[ArrayPos0].Type == TypeName[Semi]
175
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
176
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
177
Object[ArrayPos0].DrawOrder = 5
178
end if
179
ArrayPos0++
180
loop
181
end sub
182
183
184
// ========================
185
// Editor Subs
186
// ========================
187
188
sub RSDKEdit
189
if Editor.ReturnVariable == true
190
switch Editor.VariableID
191
case EDIT_VAR_PROPVAL // Property Value
192
CheckResult = Object.PropertyValue
193
CheckResult &= 1
194
break
195
case 0 // condition
196
CheckResult = Object.PropertyValue
197
CheckResult &= 1
198
break
199
end switch
200
else
201
switch Editor.VariableID
202
case EDIT_VAR_PROPVAL // Property Value
203
Object.PropertyValue = Editor.VariableValue
204
Object.PropertyValue &= 1
205
break
206
case 0 // condition
207
Object.PropertyValue = Editor.VariableValue
208
Object.PropertyValue &= 1
209
break
210
end switch
211
end if
212
end sub
213
214
sub RSDKDraw
215
DrawSprite(Object.PropertyValue)
216
end sub
217
218
sub RSDKLoad
219
LoadSpriteSheet("R6/Objects.gif")
220
221
// Good
222
SpriteFrame(-16, -16, 32, 32, 1, 224) // #0 - Semi
223
// Bad
224
SpriteFrame(-16, -16, 32, 32, 158, 166) // #1 - Semi
225
226
AddEditorVariable("condition")
227
SetActiveVariable("condition")
228
AddEnumVariable("Good Quality", GOOD_QUALITY)
229
AddEnumVariable("Bad Quality", BAD_QUALITY)
230
end sub
231
232