Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/HorizontalDoor.txt
1319 views
1
//---------------Sonic CD Horizontal 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
#alias Object.Value1 : Object.CloseBehaviour
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// Push Button alias
13
#alias Object.PropertyValue : PushButton.Pressed
14
15
// Property Values
16
// At startup is used to set it's direction, so 0 is facing right, 1 facing left
17
#alias 0 : CLOSED_DOOR
18
#alias 1 : OPEN_DOOR
19
20
// Push Button Property Values
21
#alias 1 : PUSHBUTTON_PRESSED
22
23
// Time Periods
24
#alias 2 : TIME_GOOD_FUTURE
25
26
// Player Collision
27
#alias 0 : PLAYER_COL_NONE
28
29
// Collision Modes
30
#alias 0 : CMODE_FLOOR
31
32
// Priority
33
#alias 3 : PRIORITY_XBOUNDS
34
35
// Function declarations
36
#function HorizontalDoor_CheckClose
37
38
function HorizontalDoor_CheckClose
39
#platform: Use_Origins
40
CheckResult = false
41
if Object.CloseBehaviour == 0
42
TempValue0 = Object.YPos
43
TempValue0 -= 0x300000
44
if Player.YPos < TempValue0
45
CheckResult = true
46
end if
47
else
48
TempValue0 = Object.XPos
49
if Object.Direction == FACING_RIGHT
50
Object.XPos += 0x80000
51
else
52
Object.XPos -= 0x80000
53
end if
54
PlayerObjectCollision(C_TOUCH, -400, -100, 400, -20)
55
Object.XPos = TempValue0
56
end if
57
#endplatform
58
end function
59
60
sub ObjectMain
61
switch Object.PropertyValue
62
case CLOSED_DOOR
63
if Object.Timer > 0
64
Object.Timer -= 0x80000
65
if Object.Direction == FACING_RIGHT
66
Object.XPos += 0x80000
67
else
68
Object.XPos -= 0x80000
69
end if
70
end if
71
72
if PushButton[-1].Pressed == true
73
Object.PropertyValue = OPEN_DOOR
74
end if
75
break
76
77
case OPEN_DOOR
78
if Object.Timer < 0x800000
79
Object.Timer += 0x80000
80
if Object.Direction == FACING_RIGHT
81
Object.XPos -= 0x80000
82
else
83
Object.XPos += 0x80000
84
end if
85
end if
86
87
#platform: Use_Standalone
88
TempValue0 = Object.YPos
89
TempValue0 -= 0x300000
90
if Player.YPos < TempValue0
91
Object.PropertyValue = CLOSED_DOOR
92
end if
93
#endplatform
94
#platform: Use_Origins
95
CallFunction(HorizontalDoor_CheckClose)
96
if CheckResult != false
97
Object.PropertyValue = CLOSED_DOOR
98
end if
99
#endplatform
100
break
101
end switch
102
end sub
103
104
105
sub ObjectPlayerInteraction
106
PlayerObjectCollision(C_BOX, -64, -8, 64, 8)
107
if CheckResult > PLAYER_COL_NONE
108
Player.CollisionMode = CMODE_FLOOR
109
end if
110
end sub
111
112
113
sub ObjectDraw
114
DrawSprite(0)
115
end sub
116
117
118
sub ObjectStartup
119
if HUD.CurrentTimePeriod < 2 // Past or Present
120
LoadSpriteSheet("R4/Objects.gif")
121
SpriteFrame(-64, -8, 128, 16, 18, 69) // Horizontal Door
122
else
123
LoadSpriteSheet("R4/Objects3.gif")
124
SpriteFrame(-64, -8, 128, 16, 62, 211) // Horizontal Door
125
end if
126
127
ArrayPos0 = 32
128
while ArrayPos0 < 1056
129
if Object[ArrayPos0].Type == TypeName[Horizontal Door]
130
Object[ArrayPos0].Priority = PRIORITY_XBOUNDS
131
#platform: Use_Standalone
132
Object[ArrayPos0].Direction = Object[ArrayPos0].PropertyValue
133
#endplatform
134
#platform: Use_Origins
135
TempValue0 = Object[ArrayPos0].PropertyValue
136
TempValue0 &= 1
137
Object[ArrayPos0].Direction = TempValue0
138
TempValue0 = Object[ArrayPos0].PropertyValue
139
TempValue0 >>= 1
140
TempValue0 &= 1
141
Object[ArrayPos0].CloseBehaviour = TempValue0
142
#endplatform
143
Object[ArrayPos0].PropertyValue = CLOSED_DOOR
144
end if
145
ArrayPos0++
146
loop
147
end sub
148
149
150
// ========================
151
// Editor Subs
152
// ========================
153
154
sub RSDKDraw
155
Object.Direction = Object.PropertyValue
156
Object.Direction &= 1
157
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
158
end sub
159
160
161
sub RSDKLoad
162
CallFunction(EditorHelpers_FindTimePeriod)
163
if CheckResult < 2 // Past or Present
164
LoadSpriteSheet("R4/Objects.gif")
165
SpriteFrame(-64, -8, 128, 16, 18, 69) // Horizontal Door
166
else
167
LoadSpriteSheet("R4/Objects3.gif")
168
SpriteFrame(-64, -8, 128, 16, 62, 211) // Horizontal Door
169
end if
170
171
SetVariableAlias(ALIAS_VAR_PROPVAL, "Direction")
172
end sub
173
174