Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/Fan.txt
1319 views
1
//--------------------Sonic CD Fan Script---------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
6
// Button alias
7
#alias Object.PropertyValue : PushButton.Pressed
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// States / Property Values
13
// These are based on Property Value, so technically they are named the same
14
#alias 0 : VERTICAL_FAN_OFF
15
#alias 1 : VERTICAL_FAN_ON
16
#alias 2 : HORIZONTAL_FAN_OFF
17
#alias 3 : HORIZONTAL_FAN_ON
18
#alias 4 : HORIZONTAL_FAN_LEFT_OFF
19
#alias 5 : HORIZONTAL_FAN_LEFT_ON
20
21
// Time Periods
22
#alias 0 : TIME_PRESENT
23
#alias 1 : TIME_PAST
24
#alias 2 : TIME_GOOD_FUTURE
25
#alias 3 : TIME_BAD_FUTURE
26
27
28
29
sub ObjectMain
30
switch Object.State
31
case VERTICAL_FAN_OFF
32
case HORIZONTAL_FAN_OFF
33
if PushButton[-1].Pressed == true
34
Object.PropertyValue = VERTICAL_FAN_ON
35
Object.State++
36
end if
37
break
38
39
case VERTICAL_FAN_ON
40
case HORIZONTAL_FAN_ON
41
if HUD.CurrentTimePeriod < 2
42
Object.Frame++
43
if Object.Frame > 9
44
Object.Frame = 0
45
end if
46
else
47
Object.Frame = 2
48
end if
49
break
50
51
end switch
52
end sub
53
54
55
sub ObjectDraw
56
switch Object.State
57
case VERTICAL_FAN_OFF
58
DrawSprite(0)
59
break
60
61
case VERTICAL_FAN_ON
62
TempValue0 = Object.Frame
63
TempValue0 >>= 1
64
DrawSprite(TempValue0)
65
break
66
67
case HORIZONTAL_FAN_OFF
68
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
69
break
70
71
case HORIZONTAL_FAN_ON
72
TempValue0 = Object.Frame
73
TempValue0 >>= 1
74
TempValue0 += 5
75
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
76
break
77
78
end switch
79
end sub
80
81
82
sub ObjectStartup
83
switch HUD.CurrentTimePeriod
84
case TIME_PRESENT
85
case TIME_PAST
86
LoadSpriteSheet("R4/Objects.gif")
87
88
SpriteFrame(-16, -8, 32, 16, 163, 35) // #0 - Fan vertical frame 0
89
SpriteFrame(-12, -8, 24, 16, 229, 1) // #1 - Fan vertical frame 1
90
SpriteFrame(-8, -8, 16, 16, 229, 18) // #2 - Fan vertical frame 2
91
SpriteFrame(-12, -8, 24, 16, 196, 35) // #3 - Fan vertical frame 3
92
SpriteFrame(-16, -8, 32, 16, 221, 35) // #4 - Fan vertical frame 4
93
SpriteFrame(-8, -16, 16, 32, 239, 136) // #5 - Fan horizontal frame 0
94
SpriteFrame(-8, -12, 16, 24, 222, 169) // #6 - Fan horizontal frame 1
95
SpriteFrame(-8, -8, 16, 16, 239, 194) // #7 - Fan horizontal frame 2
96
SpriteFrame(-8, -12, 16, 24, 239, 169) // #8 - Fan horizontal frame 3
97
SpriteFrame(-8, -16, 16, 32, 222, 136) // #9 - Fan horizontal frame 4
98
break
99
100
case TIME_GOOD_FUTURE
101
LoadSpriteSheet("R4/Objects3.gif")
102
103
SpriteFrame(-16, -8, 32, 16, 51, 67) // #0 - Future fan vertical off
104
SpriteFrame(-16, -8, 32, 16, 51, 84) // #1 - Future fan vertical on
105
SpriteFrame(-16, -8, 32, 16, 51, 84) // #2 - Future fan vertical on
106
SpriteFrame(-16, -8, 32, 16, 51, 84) // #3 - Future fan vertical on
107
SpriteFrame(-16, -8, 32, 16, 51, 84) // #4 - Future fan vertical on
108
SpriteFrame(-8, -16, 16, 32, 50, 101) // #5 - Future fan horizontal off
109
SpriteFrame(-8, -16, 16, 32, 67, 101) // #6 - Future fan horizontal on
110
SpriteFrame(-8, -16, 16, 32, 67, 101) // #7 - Future fan horizontal on
111
SpriteFrame(-8, -16, 16, 32, 67, 101) // #8 - Future fan horizontal on
112
SpriteFrame(-8, -16, 16, 32, 67, 101) // #9 - Future fan horizontal on
113
break
114
115
case TIME_BAD_FUTURE
116
LoadSpriteSheet("R4/Objects3.gif")
117
118
SpriteFrame(-16, -8, 32, 16, 62, 228) // #0 - Future fan vertical off
119
SpriteFrame(-16, -8, 32, 16, 94, 228) // #1 - Future fan vertical on
120
SpriteFrame(-16, -8, 32, 16, 94, 228) // #2 - Future fan vertical on
121
SpriteFrame(-16, -8, 32, 16, 94, 228) // #3 - Future fan vertical on
122
SpriteFrame(-16, -8, 32, 16, 94, 228) // #4 - Future fan vertical on
123
SpriteFrame(-8, -16, 16, 32, 76, 144) // #5 - Future fan horizontal off
124
SpriteFrame(-8, -16, 16, 32, 93, 144) // #6 - Future fan horizontal on
125
SpriteFrame(-8, -16, 16, 32, 93, 144) // #7 - Future fan horizontal on
126
SpriteFrame(-8, -16, 16, 32, 93, 144) // #8 - Future fan horizontal on
127
SpriteFrame(-8, -16, 16, 32, 93, 144) // #9 - Future fan horizontal on
128
break
129
130
end switch
131
132
ArrayPos0 = 32
133
while ArrayPos0 < 1056
134
if Object[ArrayPos0].Type == TypeName[Fan]
135
Object[ArrayPos0].State = Object[ArrayPos0].PropertyValue
136
137
if Object[ArrayPos0].PropertyValue > 3
138
Object[ArrayPos0].State -= 2
139
Object[ArrayPos0].Direction = FACING_LEFT
140
end if
141
142
Object[ArrayPos0].PropertyValue &= 1
143
end if
144
ArrayPos0++
145
loop
146
end sub
147
148
149
// ========================
150
// Editor Subs
151
// ========================
152
153
sub RSDKEdit
154
if Editor.ReturnVariable == true
155
switch Editor.VariableID
156
case EDIT_VAR_PROPVAL // Property Value
157
CheckResult = Object.PropertyValue
158
break
159
case 0 // type
160
CheckResult = Object.PropertyValue
161
break
162
end switch
163
else
164
switch Editor.VariableID
165
case EDIT_VAR_PROPVAL // Property Value
166
Object.PropertyValue = Editor.VariableValue
167
break
168
case 0 // type
169
Object.PropertyValue = Editor.VariableValue
170
break
171
end switch
172
end if
173
end sub
174
175
176
sub RSDKDraw
177
if Object.PropertyValue > 3
178
Object.Direction = FACING_LEFT
179
end if
180
DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)
181
end sub
182
183
184
sub RSDKLoad
185
CallFunction(EditorHelpers_FindTimePeriod)
186
switch CheckResult
187
case TIME_PRESENT
188
case TIME_PAST
189
LoadSpriteSheet("R4/Objects.gif")
190
191
SpriteFrame(-16, -8, 32, 16, 163, 35) // #0 - Fan vertical frame 0
192
SpriteFrame(-12, -8, 24, 16, 229, 1) // #1 - Fan vertical frame 1
193
SpriteFrame(-8, -16, 16, 32, 239, 136) // #5 - Fan horizontal frame 0
194
SpriteFrame(-8, -12, 16, 24, 222, 169) // #6 - Fan horizontal frame 1
195
SpriteFrame(-8, -16, 16, 32, 239, 136) // #5 - Fan horizontal frame 0
196
SpriteFrame(-8, -12, 16, 24, 222, 169) // #6 - Fan horizontal frame 1
197
break
198
199
case TIME_GOOD_FUTURE
200
LoadSpriteSheet("R4/Objects3.gif")
201
202
SpriteFrame(-16, -8, 32, 16, 51, 67) // #0 - Future fan vertical off
203
SpriteFrame(-16, -8, 32, 16, 51, 84) // #1 - Future fan vertical on
204
SpriteFrame(-8, -16, 16, 32, 50, 101) // #5 - Future fan horizontal off
205
SpriteFrame(-8, -16, 16, 32, 67, 101) // #6 - Future fan horizontal on
206
SpriteFrame(-8, -16, 16, 32, 50, 101) // #5 - Future fan horizontal off
207
SpriteFrame(-8, -16, 16, 32, 67, 101) // #6 - Future fan horizontal on
208
break
209
210
case TIME_BAD_FUTURE
211
LoadSpriteSheet("R4/Objects3.gif")
212
213
SpriteFrame(-16, -8, 32, 16, 62, 228) // #0 - Future fan vertical off
214
SpriteFrame(-16, -8, 32, 16, 94, 228) // #1 - Future fan vertical on
215
SpriteFrame(-8, -16, 16, 32, 76, 144) // #5 - Future fan horizontal off
216
SpriteFrame(-8, -16, 16, 32, 93, 144) // #6 - Future fan horizontal on
217
SpriteFrame(-8, -16, 16, 32, 76, 144) // #5 - Future fan horizontal off
218
SpriteFrame(-8, -16, 16, 32, 93, 144) // #6 - Future fan horizontal on
219
break
220
221
end switch
222
223
AddEditorVariable("type")
224
SetActiveVariable("type")
225
AddEnumVariable("Vertical Fan (Off)", VERTICAL_FAN_OFF)
226
AddEnumVariable("Vertical Fan (On)", VERTICAL_FAN_ON)
227
AddEnumVariable("Horizontal Fan (Off)", HORIZONTAL_FAN_OFF)
228
AddEnumVariable("Horizontal Fan (On)", HORIZONTAL_FAN_ON)
229
AddEnumVariable("Horizontal Fan Facing Left (Off)", HORIZONTAL_FAN_LEFT_OFF)
230
AddEnumVariable("Horizontal Fan Facing Left (On)", HORIZONTAL_FAN_LEFT_ON)
231
232
end sub
233
234