Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/FlipDoor.txt
1319 views
1
//-----------------Sonic CD Flip Door 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
8
// States
9
#alias 0 : FLIPDOOR_CLOSED
10
#alias 1 : FLIPDOOR_HALF_OPEN
11
#alias 2 : FLIPDOOR_OPEN
12
#alias 3 : FLIPDOOR_HALF_CLOSED
13
14
// Stages SFX
15
#alias 9 : SFX_S_DOOR
16
17
18
sub ObjectMain
19
20
if Object.Frame == 0
21
if Player.ObjectInteraction == true
22
PlayerObjectCollision(C_BOX, -4, -32, 4, 32)
23
end if
24
end if
25
26
if Object.Direction == FACING_RIGHT
27
28
switch Object.State
29
case FLIPDOOR_CLOSED
30
Object.Frame = 0
31
PlayerObjectCollision(C_TOUCH, -48, -32, 0, 32)
32
if CheckResult == true
33
Object.State = FLIPDOOR_HALF_OPEN
34
PlayStageSfx(SFX_S_DOOR, false)
35
end if
36
break
37
38
case FLIPDOOR_HALF_OPEN
39
if Object.Timer < 4
40
Object.Timer++
41
Object.Frame = 1
42
else
43
Object.Timer = 0
44
Object.State = FLIPDOOR_OPEN
45
end if
46
break
47
48
case FLIPDOOR_OPEN
49
Object.Frame = 2
50
PlayerObjectCollision(C_TOUCH, -48, -32, 64, 64)
51
if CheckResult == false
52
Object.State = FLIPDOOR_HALF_CLOSED
53
end if
54
break
55
56
case FLIPDOOR_HALF_CLOSED
57
if Object.Timer < 4
58
Object.Timer++
59
Object.Frame = 1
60
else
61
Object.Timer = 0
62
Object.State = FLIPDOOR_CLOSED
63
end if
64
break
65
end switch
66
else
67
68
switch Object.State
69
case FLIPDOOR_CLOSED
70
Object.Frame = 0
71
PlayerObjectCollision(C_TOUCH, 0, -32, 48, 32)
72
if CheckResult == true
73
Object.State = FLIPDOOR_HALF_OPEN
74
PlayStageSfx(SFX_S_DOOR, false)
75
end if
76
break
77
78
case FLIPDOOR_HALF_OPEN
79
if Object.Timer < 4
80
Object.Timer++
81
Object.Frame = 1
82
else
83
Object.Timer = 0
84
Object.State = FLIPDOOR_OPEN
85
end if
86
break
87
88
case FLIPDOOR_OPEN
89
Object.Frame = 2
90
PlayerObjectCollision(C_TOUCH, -64, -32, 48, 64)
91
if CheckResult == false
92
Object.State = FLIPDOOR_HALF_CLOSED
93
end if
94
break
95
96
case FLIPDOOR_HALF_CLOSED
97
if Object.Timer < 4
98
Object.Timer++
99
Object.Frame = 1
100
else
101
Object.Timer = 0
102
Object.State = FLIPDOOR_CLOSED
103
end if
104
break
105
end switch
106
end if
107
end sub
108
109
110
sub ObjectDraw
111
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
112
end sub
113
114
115
sub ObjectStartup
116
LoadSpriteSheet("R6/Objects.gif")
117
118
// Sprite frames
119
SpriteFrame(-4, -32, 8, 64, 230, 1) // #0 - FlipDoor Closed
120
SpriteFrame(-4, -32, 48, 48, 83, 34) // #1 - FlipDoor Half-Open
121
SpriteFrame(-4, -32, 64, 8, 132, 34) // #2 - FlipDoor Open
122
123
124
ArrayPos0 = 32
125
while ArrayPos0 < 1056
126
if Object[ArrayPos0].Type == TypeName[Flip Door]
127
Object[ArrayPos0].DrawOrder = 4
128
Object[ArrayPos0].Direction = Object[ArrayPos0].PropertyValue
129
end if
130
ArrayPos0++
131
loop
132
end sub
133
134
135
// ========================
136
// Editor Subs
137
// ========================
138
139
sub RSDKEdit
140
if Editor.ReturnVariable == true
141
switch Editor.VariableID
142
case EDIT_VAR_PROPVAL // Property Value
143
CheckResult = Object.PropertyValue
144
break
145
case 0 // direction
146
CheckResult = Object.PropertyValue
147
CheckResult &= 1
148
break
149
end switch
150
else
151
switch Editor.VariableID
152
case EDIT_VAR_PROPVAL // Property Value
153
Object.PropertyValue = Editor.VariableValue
154
break
155
case 0 // direction
156
Object.PropertyValue = Editor.VariableValue
157
Object.PropertyValue &= 1
158
break
159
end switch
160
end if
161
end sub
162
163
164
sub RSDKDraw
165
Object.Direction = Object.PropertyValue
166
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
167
end sub
168
169
170
sub RSDKLoad
171
LoadSpriteSheet("R6/Objects.gif")
172
173
// Sprite frames
174
SpriteFrame(-4, -32, 8, 64, 230, 1) // #0 - FlipDoor Closed
175
176
AddEditorVariable("direction")
177
SetActiveVariable("direction")
178
AddEnumVariable("right", 0)
179
AddEnumVariable("left", 1)
180
end sub
181
182