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/SBZ/TrapDoor.txt
1484 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Trap 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
private alias object.value1 : object.delay
14
15
private alias object.value17 : debugMode.currentSelection
16
17
18
// ========================
19
// Function Declarations
20
// ========================
21
22
reserve function TrapDoor_DebugDraw
23
reserve function TrapDoor_DebugSpawn
24
25
26
// ========================
27
// Static Values
28
// ========================
29
30
private value TrapDoor_startDebugID = 0
31
32
33
// ========================
34
// Function Definitions
35
// ========================
36
37
private function TrapDoor_DebugDraw
38
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
39
40
object.direction ^= FLIP_X
41
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
42
43
object.direction ^= FLIP_X
44
end function
45
46
47
private function TrapDoor_DebugSpawn
48
CreateTempObject(TypeName[Trap Door], 0, object.xpos, object.ypos)
49
object[tempObjectPos].priority = PRIORITY_XBOUNDS
50
object[tempObjectPos].delay = debugMode[0].currentSelection
51
object[tempObjectPos].delay -= TrapDoor_startDebugID
52
object[tempObjectPos].delay++
53
object[tempObjectPos].delay *= 60
54
end function
55
56
57
// ========================
58
// Events
59
// ========================
60
61
event ObjectUpdate
62
object.timer--
63
if object.timer < 0
64
temp0 = 1
65
object.timer = object.delay
66
object.animation ^= 1
67
temp0 = camera[0].xpos
68
temp0 -= object.ixpos
69
Abs(temp0)
70
temp0 -= 64
71
if temp0 <= screen.xcenter
72
temp0 = camera[0].ypos
73
temp0 -= object.iypos
74
Abs(temp0)
75
temp0 -= 12
76
if temp0 <= screen.ycenter
77
PlaySfx(SfxName[Flapping Door], false)
78
end if
79
end if
80
end if
81
82
if object.animation == 0
83
if object.rotation > 0
84
object.rotation -= 16
85
end if
86
else
87
if object.rotation < 128
88
object.rotation += 16
89
end if
90
end if
91
92
if object.rotation == 0
93
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
94
BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
95
next
96
end if
97
end event
98
99
100
event ObjectDraw
101
temp0 = object.xpos
102
temp0 -= 0x400000
103
104
// Frame is always 0 lol
105
DrawSpriteFX(object.frame, FX_ROTATE, temp0, object.ypos)
106
107
object.direction ^= FLIP_X
108
object.rotation ^= 0x1FF
109
object.rotation++
110
object.rotation &= 0x1FF
111
112
temp0 += 0x800000
113
temp1 = object.ypos
114
115
if object.rotation != 0
116
temp1--
117
end if
118
119
DrawSpriteFX(object.frame, FX_ROTATE, temp0, temp1)
120
121
object.direction ^= FLIP_X
122
123
object.rotation--
124
object.rotation ^= 0x1FF
125
object.rotation &= 0x1FF
126
end event
127
128
129
event ObjectStartup
130
LoadSpriteSheet("SBZ/Objects.gif")
131
132
// Trap door frames
133
SpriteFrame(0, -12, 64, 24, 318, 115)
134
135
// Setup every trap door object
136
foreach (TypeName[Trap Door], arrayPos0, ALL_ENTITIES)
137
object[arrayPos0].priority = PRIORITY_XBOUNDS
138
139
object[arrayPos0].delay = object[arrayPos0].propertyValue
140
object[arrayPos0].delay &= 0xF
141
object[arrayPos0].delay *= 60
142
next
143
144
// Add the object to the debug mode object count
145
temp0 = 0
146
TrapDoor_startDebugID = DebugMode_ObjCount
147
while temp0 < 4
148
SetTableValue(TypeName[Trap Door], DebugMode_ObjCount, DebugMode_TypesTable)
149
SetTableValue(TrapDoor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
150
SetTableValue(TrapDoor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
151
DebugMode_ObjCount++
152
temp0++
153
loop
154
end event
155
156
157
// ========================
158
// Editor Events
159
// ========================
160
161
event RSDKEdit
162
if editor.returnVariable == true
163
switch editor.variableID
164
case EDIT_VAR_PROPVAL // property value
165
checkResult = object.propertyValue
166
break
167
168
case 0 // delay
169
checkResult = object.propertyValue
170
checkResult &= 0xF
171
break
172
173
end switch
174
else
175
switch editor.variableID
176
case EDIT_VAR_PROPVAL // property value
177
object.propertyValue = editor.variableValue
178
break
179
180
case 0 // delay
181
object.propertyValue &= 0xF0
182
object.propertyValue |= editor.variableValue
183
break
184
185
end switch
186
end if
187
end event
188
189
190
event RSDKDraw
191
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
192
object.direction ^= FLIP_X
193
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
194
object.direction ^= FLIP_X
195
end event
196
197
198
event RSDKLoad
199
LoadSpriteSheet("SBZ/Objects.gif")
200
201
// Trap door frames
202
SpriteFrame(0, -12, 64, 24, 318, 115)
203
204
AddEditorVariable("delay")
205
SetActiveVariable("delay")
206
AddEnumVariable("0 Seconds", 0)
207
AddEnumVariable("1 Second", 1)
208
AddEnumVariable("2 Seconds", 2)
209
AddEnumVariable("3 Seconds", 3)
210
AddEnumVariable("4 Seconds", 4)
211
AddEnumVariable("5 Seconds", 5)
212
AddEnumVariable("6 Seconds", 6)
213
AddEnumVariable("7 Seconds", 7)
214
AddEnumVariable("8 Seconds", 8)
215
AddEnumVariable("9 Seconds", 9)
216
AddEnumVariable("10 Seconds", 10)
217
AddEnumVariable("11 Seconds", 11)
218
AddEnumVariable("12 Seconds", 12)
219
AddEnumVariable("13 Seconds", 13)
220
AddEnumVariable("14 Seconds", 14)
221
AddEnumVariable("15 Seconds", 15)
222
end event
223
224