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/DoorFlapping.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Flapping 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.interval
14
private alias object.value2 : object.frameTimer
15
private alias object.value3 : object.displayedFrame
16
17
// States
18
private alias 0 : FLAPPINGDOOR_CLOSED
19
private alias 1 : FLAPPINGDOOR_OPENING
20
private alias 2 : FLAPPINGDOOR_OPENED
21
22
// Player Aliases
23
private alias object.xpos : player.xpos
24
25
26
// ========================
27
// Function Declarations
28
// ========================
29
30
reserve function FlappingDoor_DebugDraw
31
reserve function FlappingDoor_DebugSpawn
32
33
34
// ========================
35
// Function Definitions
36
// ========================
37
38
private function FlappingDoor_DebugDraw
39
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
40
end function
41
42
43
private function FlappingDoor_DebugSpawn
44
CreateTempObject(TypeName[Flapping Door], 0, object.xpos, object.ypos)
45
object[tempObjectPos].direction = object.direction
46
object[tempObjectPos].interval = 56
47
object[tempObjectPos].timer = 56
48
end function
49
50
51
// ========================
52
// Events
53
// ========================
54
55
event ObjectUpdate
56
switch object.frame
57
case FLAPPINGDOOR_CLOSED
58
if player[0].xpos < object.xpos
59
CurrentTunnel_activateDelay = 4
60
end if
61
// [Fallthrough]
62
case FLAPPINGDOOR_OPENING
63
object.timer--
64
if object.timer == -1
65
temp0 = camera[0].xpos
66
temp0 -= object.ixpos
67
temp0 -= 8
68
Abs(temp0)
69
if temp0 <= screen.xcenter
70
temp0 = camera[0].ypos
71
temp0 -= object.iypos
72
temp0 -= 32
73
Abs(temp0)
74
if temp0 <= screen.ycenter
75
PlaySfx(SfxName[Flapping Door], false)
76
end if
77
end if
78
end if
79
80
if object.timer == -5
81
object.frameTimer = 0
82
object.frame = 2
83
end if
84
break
85
86
case FLAPPINGDOOR_OPENED
87
object.frameTimer++
88
if object.frameTimer == 4
89
object.displayedFrame ^= 1
90
object.frame = object.displayedFrame
91
object.timer = object.interval
92
end if
93
break
94
95
end switch
96
97
if object.frame == FLAPPINGDOOR_CLOSED
98
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
99
BoxCollisionTest(C_SOLID, object.entityPos, -8, -32, 8, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
100
next
101
end if
102
end event
103
104
105
event ObjectDraw
106
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
107
end event
108
109
110
event ObjectStartup
111
LoadSpriteSheet("LZ/Objects.gif")
112
SpriteFrame(-8, -32, 16, 64, 1, 191)
113
SpriteFrame(0, -40, 32, 80, 51, 175)
114
SpriteFrame(-5, -38, 32, 76, 18, 179)
115
116
foreach (TypeName[Flapping Door], arrayPos0, ALL_ENTITIES)
117
object[arrayPos0].interval = object[arrayPos0].propertyValue
118
object[arrayPos0].interval *= 60
119
object[arrayPos0].interval -= 4
120
object[arrayPos0].timer = object[arrayPos0].interval
121
next
122
123
SetTableValue(TypeName[Flapping Door], DebugMode_ObjCount, DebugMode_TypesTable)
124
SetTableValue(FlappingDoor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
125
SetTableValue(FlappingDoor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
126
DebugMode_ObjCount++
127
end event
128
129
130
// ========================
131
// Editor Events
132
// ========================
133
134
event RSDKEdit
135
if editor.returnVariable == true
136
switch editor.variableID
137
case EDIT_VAR_PROPVAL // property value
138
checkResult = object.propertyValue
139
break
140
141
case 0 // interval
142
checkResult = object.propertyValue
143
break
144
145
end switch
146
else
147
switch editor.variableID
148
case EDIT_VAR_PROPVAL // property value
149
object.propertyValue = editor.variableValue
150
break
151
152
case 0 // interval
153
object.propertyValue = editor.variableValue
154
break
155
156
end switch
157
end if
158
end event
159
160
161
event RSDKDraw
162
DrawSprite(0)
163
end event
164
165
166
event RSDKLoad
167
LoadSpriteSheet("LZ/Objects.gif")
168
SpriteFrame(-8, -32, 16, 64, 1, 191)
169
170
AddEditorVariable("interval")
171
SetActiveVariable("interval")
172
end event
173
174