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