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/SlidingFloor.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Sliding Floor 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.startPos.x
14
15
private alias 0 : SLIDINGFLOOR_WAITFORPLAYER
16
private alias 1 : SLIDINGFLOOR_SLIDEAWAY
17
private alias 2 : SLIDINGFLOOR_FINISHEDSLIDING
18
private alias 3 : SLIDINGFLOOR_RETURNTOSTART
19
20
// Player Aliases
21
private alias object.xpos : player.xpos
22
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function SlidingFloor_DebugDraw
29
reserve function SlidingFloor_DebugSpawn
30
31
32
// ========================
33
// Function Definitions
34
// ========================
35
36
private function SlidingFloor_DebugDraw
37
DrawSprite(0)
38
end function
39
40
41
private function SlidingFloor_DebugSpawn
42
CreateTempObject(TypeName[Sliding Floor], 0, object.xpos, object.ypos)
43
if object.direction == FLIP_NONE
44
object[tempObjectPos].xvel = 0x80000
45
else
46
object[tempObjectPos].xvel = -0x80000
47
end if
48
object[tempObjectPos].startPos.x = object.xpos
49
end function
50
51
52
// ========================
53
// Events
54
// ========================
55
56
event ObjectUpdate
57
switch object.state
58
case SLIDINGFLOOR_WAITFORPLAYER
59
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
60
BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
61
if checkResult == true
62
object.priority = PRIORITY_ACTIVE
63
object.state++
64
end if
65
next
66
break
67
68
case SLIDINGFLOOR_SLIDEAWAY
69
object.timer++
70
if object.timer == 16
71
object.timer = 0
72
object.state++
73
end if
74
75
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
76
BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
77
if checkResult == true
78
player[currentPlayer].xpos += object.xvel
79
end if
80
next
81
object.xpos += object.xvel
82
break
83
84
case SLIDINGFLOOR_FINISHEDSLIDING
85
object.timer++
86
if object.timer == 360
87
object.timer = 0
88
object.state++
89
end if
90
91
if object.timer < 3
92
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
93
BoxCollisionTest(C_PLATFORM, object.entityPos, -72, -12, 72, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
94
next
95
else
96
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
97
BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
98
next
99
end if
100
break
101
102
case SLIDINGFLOOR_RETURNTOSTART
103
object.timer++
104
if object.timer == 16
105
object.timer = 0
106
object.state = SLIDINGFLOOR_WAITFORPLAYER
107
end if
108
109
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
110
BoxCollisionTest(C_PLATFORM, object.entityPos, -64, -12, 64, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
111
if checkResult == true
112
player[currentPlayer].xpos -= object.xvel
113
end if
114
next
115
object.xpos -= object.xvel
116
break
117
118
end switch
119
120
if object.outOfBounds == true
121
temp0 = object.xpos
122
object.xpos = object.startPos.x
123
124
if object.outOfBounds == true
125
object.timer = 0
126
object.priority = PRIORITY_BOUNDS
127
object.state = SLIDINGFLOOR_WAITFORPLAYER
128
else
129
object.xpos = temp0
130
end if
131
end if
132
end event
133
134
135
event ObjectDraw
136
DrawSprite(0)
137
end event
138
139
140
event ObjectStartup
141
LoadSpriteSheet("SBZ/Objects.gif")
142
SpriteFrame(-64, -12, 128, 24, 383, 115)
143
144
foreach (TypeName[Sliding Floor], arrayPos0, ALL_ENTITIES)
145
object[arrayPos0].propertyValue &= 1
146
if object[arrayPos0].propertyValue == 0
147
object[arrayPos0].xvel = 0x80000
148
else
149
object[arrayPos0].xvel = -0x80000
150
end if
151
object[arrayPos0].startPos.x = object[arrayPos0].xpos
152
next
153
154
SetTableValue(TypeName[Sliding Floor], DebugMode_ObjCount, DebugMode_TypesTable)
155
SetTableValue(SlidingFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
156
SetTableValue(SlidingFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
157
DebugMode_ObjCount++
158
end event
159
160
161
// ========================
162
// Editor Events
163
// ========================
164
165
event RSDKEdit
166
if editor.returnVariable == true
167
switch editor.variableID
168
case EDIT_VAR_PROPVAL // property value
169
checkResult = object.propertyValue
170
checkResult &= 1
171
break
172
173
case 0 // direction
174
checkResult = object.propertyValue
175
break
176
177
end switch
178
else
179
switch editor.variableID
180
case EDIT_VAR_PROPVAL // property value
181
object.propertyValue = editor.variableValue
182
object.propertyValue &= 1
183
break
184
185
case 0 // direction
186
object.propertyValue = editor.variableValue
187
break
188
189
end switch
190
end if
191
end event
192
193
194
event RSDKDraw
195
DrawSprite(0)
196
end event
197
198
199
event RSDKLoad
200
LoadSpriteSheet("SBZ/Objects.gif")
201
SpriteFrame(-64, -12, 128, 24, 383, 115)
202
203
AddEditorVariable("direction")
204
SetActiveVariable("direction")
205
AddEnumVariable("Right", 0)
206
AddEnumVariable("Left", 1)
207
end event
208
209