Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/LZ/Door.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Door Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
14
private alias 0 : DOOR_CLOSED
15
private alias 1 : DOOR_OPENING
16
private alias 2 : DOOR_OPENED
17
private alias 3 : DOOR_AWAITCLOSE
18
private alias 4 : DOOR_CLOSING
19
20
// PushButton Aliases
21
private alias object.value0 : pushButton.stood
22
23
// Player Aliases
24
private alias object.xpos : player.xpos
25
26
27
// ========================
28
// Function Declarations
29
// ========================
30
31
reserve function Door_DebugDraw
32
reserve function Door_DebugSpawn
33
34
35
// ========================
36
// Function Definitions
37
// ========================
38
39
private function Door_DebugDraw
40
DrawSprite(0)
41
end function
42
43
44
private function Door_DebugSpawn
45
CreateTempObject(TypeName[Door], 0, object.xpos, object.ypos)
46
object[tempObjectPos].priority = PRIORITY_ACTIVE
47
object[tempObjectPos].timer = 32
48
end function
49
50
51
// ========================
52
// Events
53
// ========================
54
55
event ObjectUpdate
56
switch object.state
57
case DOOR_CLOSED
58
if object.propertyValue == 2
59
if player[0].xpos < object.xpos
60
CurrentTunnel_activateDelay = 4
61
end if
62
end if
63
64
if pushButton[+1].stood == true
65
object.state++
66
end if
67
break
68
69
case DOOR_OPENING
70
object.ypos -= 0x20000
71
72
object.timer--
73
if object.timer < 0
74
object.state++
75
if object.propertyValue == 1
76
object.state++
77
end if
78
end if
79
break
80
81
case DOOR_OPENED
82
break
83
84
case DOOR_AWAITCLOSE
85
if player[0].xpos > 0x11200000 // hardcoded xpos in the scene :(
86
object.state++
87
end if
88
break
89
90
case DOOR_CLOSING
91
object.ypos += 0x20000
92
93
object.timer++
94
if object.timer >= 32
95
object.state = DOOR_CLOSED
96
end if
97
break
98
99
end switch
100
101
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
102
BoxCollisionTest(C_SOLID, object.entityPos, -8, -32, 8, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
103
next
104
end event
105
106
107
event ObjectDraw
108
DrawSprite(0)
109
end event
110
111
112
event ObjectStartup
113
LoadSpriteSheet("LZ/Objects.gif")
114
115
// Door frame
116
SpriteFrame(-8, -32, 16, 64, 206, 142)
117
118
foreach (TypeName[Door], arrayPos0, ALL_ENTITIES)
119
object[arrayPos0].priority = PRIORITY_ACTIVE
120
object[arrayPos0].timer = 32
121
next
122
123
// Add this object to the debug item list
124
SetTableValue(TypeName[Door], DebugMode_ObjCount, DebugMode_TypesTable)
125
SetTableValue(Door_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
126
SetTableValue(Door_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
127
DebugMode_ObjCount++
128
end event
129
130
131
// ========================
132
// Editor Events
133
// ========================
134
135
event RSDKEdit
136
if editor.returnVariable == true
137
switch editor.variableID
138
case EDIT_VAR_PROPVAL // property value
139
checkResult = object.propertyValue
140
break
141
142
case 0 // type
143
checkResult = object.propertyValue
144
break
145
146
end switch
147
else
148
switch editor.variableID
149
case EDIT_VAR_PROPVAL // property value
150
object.propertyValue = editor.variableValue
151
break
152
153
case 0 // type
154
object.propertyValue = editor.variableValue
155
break
156
157
end switch
158
end if
159
end event
160
161
162
event RSDKDraw
163
DrawSprite(0)
164
165
if editor.showGizmos == true
166
editor.drawingOverlay = true
167
168
// Draw a line connecting the door to its trigger button
169
DrawLine(object.xpos, object.ypos, object[+1].xpos, object[+1].ypos, 0xFF, 0xFF, 0x00)
170
171
editor.drawingOverlay = false
172
end if
173
end event
174
175
176
event RSDKLoad
177
LoadSpriteSheet("LZ/Objects.gif")
178
SpriteFrame(-8, -32, 16, 64, 206, 142)
179
180
AddEditorVariable("type")
181
SetActiveVariable("type")
182
AddEnumVariable("Stay Opened", 0)
183
AddEnumVariable("Open Then Close", 1) // hardcoded to only close after player passes ixpos 4384 in the scene btw
184
AddEnumVariable("Current", 2)
185
end event
186
187