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/SecretPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Moving Block Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// the script is called "SecretPlatform" but the game refers to it as "MovingPlatform"
9
// we're using the latter name here
10
11
// ========================
12
// Aliases
13
// ========================
14
15
private alias object.value0 : object.collisionOffset.x
16
17
private alias 0 : MOVINGPLATFORM_HIDDEN
18
private alias 1 : MOVINGPLATFORM_AWAITPLAYER
19
private alias 2 : MOVINGPLATFORM_MOVING_RIGHT
20
private alias 3 : MOVINGPLATFORM_FALLING
21
private alias 4 : MOVINGPLATFORM_STOPPED
22
23
// Player Aliases
24
private alias object.xpos : player.xpos
25
private alias object.ypos : player.ypos
26
private alias object.gravity : player.gravity
27
28
// Push Button Aliases
29
private alias object.value0 : pushButton.stood
30
31
// Path ID Aliases
32
private alias 0 : PATH_A
33
34
// Achievement Aliases
35
private alias 5 : ACHIEVEMENT_SECRETOFLZ
36
37
38
// ========================
39
// Function Declarations
40
// ========================
41
42
reserve function MovingBlock_DebugDraw
43
reserve function MovingBlock_DebugSpawn
44
45
46
// ========================
47
// Function Definitions
48
// ========================
49
50
private function MovingBlock_DebugDraw
51
DrawSprite(0)
52
end function
53
54
55
private function MovingBlock_DebugSpawn
56
CreateTempObject(TypeName[Moving Block], 0, object.xpos, object.ypos)
57
object[tempObjectPos].priority = PRIORITY_XBOUNDS
58
object[tempObjectPos].state = MOVINGPLATFORM_AWAITPLAYER
59
end function
60
61
62
// ========================
63
// Events
64
// ========================
65
66
event ObjectUpdate
67
switch object.state
68
case MOVINGPLATFORM_HIDDEN
69
if pushButton[+2].stood == true
70
object.state++
71
end if
72
break
73
74
case MOVINGPLATFORM_AWAITPLAYER
75
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
76
BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
77
if checkResult == COL_TOP
78
object.state++
79
if stage.debugMode == false
80
if currentPlayer == 0
81
// Grant the "Secret of Labyrinth Zone" Achievement
82
CallNativeFunction2(SetAchievement, ACHIEVEMENT_SECRETOFLZ, 100)
83
end if
84
end if
85
end if
86
next
87
break
88
89
case MOVINGPLATFORM_MOVING_RIGHT
90
temp0 = object.xpos
91
temp0 &= 0xFFFF0000
92
object.xpos += 0x10000
93
94
ObjectTileCollision(CSIDE_LWALL, 16, 0, PATH_A)
95
if checkResult == true
96
object.state++
97
end if
98
99
object.collisionOffset.x = object.xpos
100
object.collisionOffset.x &= 0xFFFF0000
101
object.collisionOffset.x -= temp0
102
temp1 = object.xpos
103
object.xpos = temp0
104
105
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
106
BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
107
if checkResult == COL_TOP
108
player[currentPlayer].xpos += object.collisionOffset.x
109
end if
110
next
111
112
object.xpos = temp1
113
break
114
115
case MOVINGPLATFORM_FALLING
116
temp0 = object.ypos
117
temp0 &= 0xFFFF0000
118
object.ypos += object.yvel
119
object.yvel += 0x3800
120
121
ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)
122
if checkResult == true
123
object.state++
124
object.priority = PRIORITY_BOUNDS
125
end if
126
127
object.collisionOffset.x = object.ypos
128
object.collisionOffset.x &= 0xFFFF0000
129
object.collisionOffset.x -= temp0
130
temp1 = object.ypos
131
object.ypos = temp0
132
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
133
BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
134
if checkResult == COL_TOP
135
player[currentPlayer].ypos += object.collisionOffset.x
136
end if
137
138
if player[currentPlayer].gravity == GRAVITY_GROUND
139
if checkResult == COL_BOTTOM
140
CallFunction(Player_Kill)
141
end if
142
end if
143
next
144
object.ypos = temp1
145
break
146
147
case MOVINGPLATFORM_STOPPED
148
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
149
BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
150
next
151
break
152
153
end switch
154
end event
155
156
157
event ObjectDraw
158
if object.state > MOVINGPLATFORM_HIDDEN
159
DrawSprite(0)
160
end if
161
end event
162
163
164
event ObjectStartup
165
LoadSpriteSheet("LZ/Objects.gif")
166
SpriteFrame(-16, -8, 32, 16, 1, 1)
167
168
foreach (TypeName[Moving Block], arrayPos0, ALL_ENTITIES)
169
object[arrayPos0].priority = PRIORITY_XBOUNDS
170
next
171
172
SetTableValue(TypeName[Moving Block], DebugMode_ObjCount, DebugMode_TypesTable)
173
SetTableValue(MovingBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
174
SetTableValue(MovingBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
175
DebugMode_ObjCount++
176
end event
177
178
179
// ========================
180
// Editor Events
181
// ========================
182
183
event RSDKDraw
184
DrawSprite(0)
185
end event
186
187
188
event RSDKLoad
189
LoadSpriteSheet("LZ/Objects.gif")
190
SpriteFrame(-16, -8, 32, 16, 1, 1)
191
192
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
193
end event
194
195