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/SlidingFloor.txt
1483 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.collisionOffset.x
14
private alias object.value2 : object.collisionOffset.y
15
16
private alias 0 : SLIDINGFLOOR_AWAITBUTTON
17
private alias 1 : SLIDINGFLOOR_SLIDING
18
private alias 2 : SLIDINGFLOOR_FINISHEDSLIDING
19
20
// Player Aliases
21
private alias object.xpos : player.xpos
22
private alias object.ixpos : player.ixpos
23
private alias object.ypos : player.ypos
24
private alias object.iypos : player.iypos
25
private alias object.right : player.right
26
private alias object.pushing: player.pushing
27
private alias object.collisionRight: player.collisionRight
28
private alias object.collisionBottom: player.collisionBottom
29
30
// Push Button aliases
31
private alias object.value0 : pushButton.stood
32
33
34
// ========================
35
// Function Declarations
36
// ========================
37
38
reserve function SlidingFloor_DebugDraw
39
reserve function SlidingFloor_DebugSpawn
40
41
42
// ========================
43
// Tables
44
// ========================
45
46
private function SlidingFloor_DebugDraw
47
DrawSprite(0)
48
end function
49
50
51
private function SlidingFloor_DebugSpawn
52
CreateTempObject(TypeName[Sliding Floor], 0, object.xpos, object.ypos)
53
end function
54
55
56
// ========================
57
// Events
58
// ========================
59
60
event ObjectUpdate
61
switch object.state
62
case SLIDINGFLOOR_AWAITBUTTON
63
if pushButton[+1].stood == true
64
object.state++
65
object.timer = 256
66
end if
67
68
case SLIDINGFLOOR_FINISHEDSLIDING
69
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
70
BoxCollisionTest(C_SOLID, object.entityPos, -128, -64, 128, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
71
72
BoxCollisionTest(C_TOUCH, object.entityPos, -128, -64, 128, 64, currentPlayer, 2, 2, 2, 2)
73
if checkResult == true
74
if player[currentPlayer].ypos > object.ypos
75
player[currentPlayer].ixpos = player[currentPlayer].collisionRight
76
FlipSign(player[currentPlayer].xpos)
77
player[currentPlayer].xpos -= 0x800000
78
player[currentPlayer].xpos += object.xpos
79
else
80
player[currentPlayer].iypos = player[currentPlayer].collisionBottom
81
FlipSign(player[currentPlayer].ypos)
82
player[currentPlayer].ypos -= 0x400000
83
player[currentPlayer].ypos += object.ypos
84
end if
85
end if
86
87
BoxCollisionTest(C_TOUCH, object.entityPos, -130, -63, 130, 63, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
88
if checkResult == true
89
if player[currentPlayer].xpos < object.xpos
90
if player[currentPlayer].right == true
91
player[currentPlayer].pushing = 2
92
player[currentPlayer].ixpos = player[currentPlayer].collisionRight
93
FlipSign(player[currentPlayer].xpos)
94
player[currentPlayer].xpos -= 0x800000
95
player[currentPlayer].xpos += object.xpos
96
if player[currentPlayer].ypos == 0x16D0000
97
player[currentPlayer].ypos -= 0x10000
98
end if
99
if player[currentPlayer].ypos == 0x1710000
100
player[currentPlayer].ypos -= 0x10000
101
end if
102
end if
103
end if
104
end if
105
next
106
break
107
108
case SLIDINGFLOOR_SLIDING
109
temp0 = object.xpos
110
temp0 &= 0xFFFF0000
111
temp1 = object.ypos
112
temp1 &= 0xFFFF0000
113
object.xpos -= 0x10000
114
object.ypos += 0x8000
115
object.timer--
116
if object.timer < 0
117
object.state++
118
end if
119
120
object.collisionOffset.x = object.xpos
121
object.collisionOffset.x &= 0xFFFF0000
122
object.collisionOffset.x -= temp0
123
object.collisionOffset.y = object.ypos
124
object.collisionOffset.y &= 0xFFFF0000
125
object.collisionOffset.y -= temp1
126
127
temp2 = object.xpos
128
object.xpos = temp0
129
temp3 = object.ypos
130
object.ypos = temp1
131
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
132
BoxCollisionTest(C_SOLID, object.entityPos, -128, -64, 128, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
133
if checkResult == COL_TOP
134
player[currentPlayer].xpos += object.collisionOffset.x
135
player[currentPlayer].ypos += object.collisionOffset.y
136
end if
137
138
BoxCollisionTest(C_TOUCH, object.entityPos, -128, -64, 128, 64, currentPlayer, 2, 2, 2, 2)
139
if checkResult == true
140
if player[currentPlayer].ypos > object.ypos
141
player[currentPlayer].ixpos = player[currentPlayer].collisionRight
142
FlipSign(player[currentPlayer].xpos)
143
player[currentPlayer].xpos -= 0x800000
144
player[currentPlayer].xpos += object.xpos
145
else
146
player[currentPlayer].iypos = player[currentPlayer].collisionBottom
147
FlipSign(player[currentPlayer].ypos)
148
player[currentPlayer].ypos -= 0x400000
149
player[currentPlayer].ypos += object.ypos
150
end if
151
end if
152
153
BoxCollisionTest(C_TOUCH, object.entityPos, -130, -63, 130, 63, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
154
if checkResult == true
155
if player[currentPlayer].xpos < object.xpos
156
if player[currentPlayer].right == true
157
player[currentPlayer].pushing = 2
158
player[currentPlayer].ixpos = player[currentPlayer].collisionRight
159
FlipSign(player[currentPlayer].xpos)
160
player[currentPlayer].xpos -= 0x800000
161
player[currentPlayer].xpos += object.xpos
162
end if
163
end if
164
end if
165
next
166
167
object.xpos = temp2
168
object.ypos = temp3
169
break
170
171
end switch
172
end event
173
174
175
event ObjectDraw
176
DrawSprite(0)
177
end event
178
179
180
event ObjectStartup
181
LoadSpriteSheet("LZ/Objects2.gif")
182
SpriteFrame(-128, -64, 256, 125, 0, 0)
183
184
SetTableValue(TypeName[Sliding Floor], DebugMode_ObjCount, DebugMode_TypesTable)
185
SetTableValue(SlidingFloor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
186
SetTableValue(SlidingFloor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
187
DebugMode_ObjCount++
188
end event
189
190
191
// ========================
192
// Editor Events
193
// ========================
194
195
event RSDKDraw
196
DrawSprite(0)
197
end event
198
199
200
event RSDKLoad
201
LoadSpriteSheet("LZ/Objects2.gif")
202
SpriteFrame(-128, -64, 256, 125, 0, 0)
203
end event
204
205