Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/OneWayDoor.txt
1319 views
1
//---------------Sonic CD One Way Door Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.YOffset
7
8
// States
9
#alias 0 : ONEWAYDOOR_CLOSE
10
#alias 1 : ONEWAYDOOR_OPEN
11
12
// Property Values
13
#alias 1 : OPEN_FROM_LEFT
14
#alias 2 : OPEN_FROM_RIGHT
15
#alias 3 : OPEN_FROM_LEFT_NO_LIGHTS
16
17
// Collision
18
#alias 1 : PLAYER_COL_FLOOR
19
#alias 2 : PLAYER_COL_LWALL
20
#alias 3 : PLAYER_COL_RWALL
21
#alias 4 : PLAYER_COL_ROOF
22
23
24
sub ObjectMain
25
if Object.State == ONEWAYDOOR_CLOSE
26
if Object.YOffset > 0
27
Object.YOffset -= 0x20000
28
end if
29
else
30
if Object.YOffset < 0x200000
31
Object.YOffset += 0x20000
32
end if
33
end if
34
end sub
35
36
37
sub ObjectPlayerInteraction
38
TempValue0 = Object.YPos
39
TempValue1 = Player.YPos
40
Object.YPos -= Object.YOffset
41
PlayerObjectCollision(C_BOX, -8, -48, 8, -16)
42
if CheckResult > PLAYER_COL_FLOOR
43
Player.YPos = TempValue1
44
end if
45
46
Object.YPos = TempValue0
47
Object.YPos += Object.YOffset
48
PlayerObjectCollision(C_BOX, -8, -16, 8, 16)
49
if CheckResult > PLAYER_COL_FLOOR
50
Player.YPos = TempValue1
51
end if
52
53
Object.YPos = TempValue0
54
if Object.PropertyValue == OPEN_FROM_RIGHT
55
PlayerObjectCollision(C_TOUCH, -96, -48, 8, 16)
56
else
57
PlayerObjectCollision(C_TOUCH, -8, -48, 96, 16)
58
end if
59
60
Object.State = CheckResult
61
end sub
62
63
64
sub ObjectDraw
65
Object.Frame = Object.AnimationTimer
66
Object.Frame /= 3
67
switch Object.PropertyValue
68
case OPEN_FROM_LEFT
69
TempValue0 = Object.YOffset
70
FlipSign(TempValue0)
71
TempValue0 += Object.YPos
72
DrawSpriteXY(0, Object.XPos, TempValue0)
73
Object.Frame += 6
74
DrawSpriteXY(Object.Frame, Object.XPos, TempValue0)
75
TempValue0 = Object.YOffset
76
TempValue0 += Object.YPos
77
DrawSpriteXY(1, Object.XPos, TempValue0)
78
Object.Frame += 2
79
DrawSpriteXY(Object.Frame, Object.XPos, TempValue0)
80
break
81
82
case OPEN_FROM_RIGHT
83
TempValue0 = Object.YOffset
84
FlipSign(TempValue0)
85
TempValue0 += Object.YPos
86
DrawSpriteXY(0, Object.XPos, TempValue0)
87
Object.Frame += 2
88
DrawSpriteXY(Object.Frame, Object.XPos, TempValue0)
89
TempValue0 = Object.YOffset
90
TempValue0 += Object.YPos
91
DrawSpriteXY(1, Object.XPos, TempValue0)
92
Object.Frame += 2
93
DrawSpriteXY(Object.Frame, Object.XPos, TempValue0)
94
break
95
96
case OPEN_FROM_LEFT_NO_LIGHTS
97
TempValue0 = Object.YOffset
98
FlipSign(TempValue0)
99
TempValue0 += Object.YPos
100
DrawSpriteXY(0, Object.XPos, TempValue0)
101
TempValue0 = Object.YOffset
102
TempValue0 += Object.YPos
103
DrawSpriteXY(1, Object.XPos, TempValue0)
104
break
105
end switch
106
107
Object.AnimationTimer++
108
Object.AnimationTimer %= 6
109
end sub
110
111
112
sub ObjectStartup
113
LoadSpriteSheet("R8/Objects.gif")
114
115
SpriteFrame(-8, -48, 16, 32, 58, 131) // #0 - Left One Way Door
116
SpriteFrame(-8, -16, 16, 32, 58, 131) // #1 - Right One Way Door
117
118
SpriteFrame(-16, -36, 8, 8, 50, 173) // #2 - Left Door Lights (left side) frame 0
119
SpriteFrame(-16, -36, 8, 8, 59, 173) // #3 - Left Door Lights (left side) frame 1
120
SpriteFrame(-16, -4, 8, 8, 50, 173) // #4 - Right Door Lights (left side) frame 0
121
SpriteFrame(-16, -4, 8, 8, 59, 173) // #5 - Right Door Lights (left side) frame 1
122
123
SpriteFrame(8, -36, 8, 8, 50, 164) // #6 - Left Door Lights (right side) frame 0
124
SpriteFrame(8, -36, 8, 8, 59, 164) // #7 - Left Door Lights (right side) frame 1
125
SpriteFrame(8, -4, 8, 8, 50, 164) // #8 - Right Door Lights (right side) frame 0
126
SpriteFrame(8, -4, 8, 8, 59, 164) // #9 - Right Door Lights (right side) frame 1
127
end sub
128
129
130
// ========================
131
// Editor Subs
132
// ========================
133
134
sub RSDKEdit
135
if Editor.ReturnVariable == true
136
switch Editor.VariableID
137
case EDIT_VAR_PROPVAL // Property Value
138
CheckResult = Object.PropertyValue
139
CheckResult &= 3
140
break
141
case 0 // type
142
CheckResult = Object.PropertyValue
143
CheckResult &= 3
144
break
145
end switch
146
else
147
switch Editor.VariableID
148
case EDIT_VAR_PROPVAL // Property Value
149
Object.PropertyValue = Editor.VariableValue
150
Object.PropertyValue &= 3
151
break
152
case 0 // type
153
Object.PropertyValue = Editor.VariableValue
154
Object.PropertyValue &= 3
155
break
156
end switch
157
end if
158
end sub
159
160
sub RSDKDraw
161
DrawSprite(0)
162
DrawSprite(1)
163
164
switch Object.PropertyValue
165
case 1
166
DrawSprite(6)
167
DrawSprite(8)
168
break
169
case 2
170
DrawSprite(2)
171
DrawSprite(4)
172
break
173
end switch
174
end sub
175
176
177
sub RSDKLoad
178
LoadSpriteSheet("R8/Objects.gif")
179
180
SpriteFrame(-8, -48, 16, 32, 58, 131) // #0 - Left One Way Door
181
SpriteFrame(-8, -16, 16, 32, 58, 131) // #1 - Right One Way Door
182
183
SpriteFrame(-16, -36, 8, 8, 50, 173) // #2 - Left Door Lights (left side) frame 0
184
SpriteFrame(-16, -36, 8, 8, 59, 173) // #3 - Left Door Lights (left side) frame 1
185
SpriteFrame(-16, -4, 8, 8, 50, 173) // #4 - Right Door Lights (left side) frame 0
186
SpriteFrame(-16, -4, 8, 8, 59, 173) // #5 - Right Door Lights (left side) frame 1
187
188
SpriteFrame(8, -36, 8, 8, 50, 164) // #6 - Left Door Lights (right side) frame 0
189
SpriteFrame(8, -36, 8, 8, 59, 164) // #7 - Left Door Lights (right side) frame 1
190
SpriteFrame(8, -4, 8, 8, 50, 164) // #8 - Right Door Lights (right side) frame 0
191
SpriteFrame(8, -4, 8, 8, 59, 164) // #9 - Right Door Lights (right side) frame 1
192
193
AddEditorVariable("type")
194
SetActiveVariable("type")
195
AddEnumVariable("Null", 0) // why do i need this?
196
AddEnumVariable("Open from the left", OPEN_FROM_LEFT)
197
AddEnumVariable("Open from the right", OPEN_FROM_RIGHT)
198
AddEnumVariable("Open from the left (no lights)", OPEN_FROM_LEFT_NO_LIGHTS)
199
end sub
200
201