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/RisingPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Rising Platform 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.stood
13
private alias object.value1 : object.collisionOffset.y
14
private alias object.value2 : object.timer
15
private alias object.value3 : object.startPos.y
16
private alias object.value4 : object.stoodAngle
17
18
private alias 0 : RISINGPLATFORM_IDLE
19
private alias 1 : RISINGPLATFORM_MOVING
20
private alias 2 : RISINGPLATFORM_RETURNTOSTART
21
private alias 3 : RISINGPLATFORM_OOB
22
23
// Player Aliases
24
private alias object.xpos : player.xpos
25
private alias object.ypos : player.ypos
26
27
// Path ID Aliases
28
private alias 0 : PATH_A
29
30
31
// ========================
32
// Function Declarations
33
// ========================
34
35
reserve function RisingPlatform_DebugDraw
36
reserve function RisingPlatform_DebugSpawn
37
38
39
// ========================
40
// Tables
41
// ========================
42
43
private function RisingPlatform_DebugDraw
44
DrawSprite(0)
45
end function
46
47
48
private function RisingPlatform_DebugSpawn
49
CreateTempObject(TypeName[Rising Platform], 0, object.xpos, object.ypos)
50
object[tempObjectPos].startPos.y = object.ypos
51
object[tempObjectPos].drawOrder = 4
52
end function
53
54
55
// ========================
56
// Events
57
// ========================
58
59
event ObjectUpdate
60
if object.stood == true
61
if object.timer == 0
62
object.timer = 30
63
end if
64
65
if object.stoodAngle < 64
66
object.stoodAngle += 4
67
end if
68
else
69
if object.stoodAngle > 0
70
object.stoodAngle -= 4
71
end if
72
end if
73
74
temp0 = object.ypos
75
temp0 &= 0xFFFF0000
76
switch object.state
77
case RISINGPLATFORM_IDLE
78
temp1 = object.stoodAngle
79
temp1 <<= 1
80
Sin(temp2, temp1)
81
temp2 <<= 9
82
object.ypos = object.startPos.y
83
object.ypos += temp2
84
85
if object.timer != 0
86
object.timer--
87
if object.timer == 0
88
object.state++
89
object.priority = PRIORITY_ACTIVE
90
end if
91
end if
92
break
93
94
case RISINGPLATFORM_MOVING
95
object.ypos += object.yvel
96
object.yvel -= 0x800
97
ObjectTileCollision(CSIDE_ROOF, 0, -12, PATH_A)
98
if checkResult == true
99
object.state++
100
end if
101
102
if object.outOfBounds == true
103
object.ypos = object.startPos.y
104
object.yvel = 0
105
object.timer = 0
106
object.state = RISINGPLATFORM_OOB
107
end if
108
break
109
110
case RISINGPLATFORM_RETURNTOSTART
111
if object.outOfBounds == true
112
object.ypos = object.startPos.y
113
object.yvel = 0
114
object.timer = 0
115
object.state++
116
end if
117
break
118
119
case RISINGPLATFORM_OOB
120
if object.outOfBounds == true
121
object.state = RISINGPLATFORM_IDLE
122
object.priority = PRIORITY_BOUNDS
123
end if
124
break
125
126
end switch
127
128
object.collisionOffset.y = object.ypos
129
object.collisionOffset.y &= 0xFFFF0000
130
object.collisionOffset.y -= temp0
131
object.stood = false
132
133
if object.state < RISINGPLATFORM_OOB
134
temp1 = object.ypos
135
object.ypos = temp0
136
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
137
BoxCollisionTest(C_SOLID, object.entityPos, -32, -12, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
138
if checkResult == COL_TOP
139
object.stood = true
140
player[currentPlayer].ypos += object.collisionOffset.y
141
end if
142
next
143
object.ypos = temp1
144
end if
145
end event
146
147
148
event ObjectDraw
149
if object.state < RISINGPLATFORM_OOB
150
DrawSprite(0)
151
end if
152
end event
153
154
155
event ObjectStartup
156
LoadSpriteSheet("LZ/Objects.gif")
157
SpriteFrame(-32, -12, 64, 24, 126, 137)
158
159
foreach (TypeName[Rising Platform], arrayPos0, ALL_ENTITIES)
160
object[arrayPos0].startPos.y = object[arrayPos0].ypos
161
object[arrayPos0].drawOrder = 4
162
next
163
164
SetTableValue(TypeName[Rising Platform], DebugMode_ObjCount, DebugMode_TypesTable)
165
SetTableValue(RisingPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
166
SetTableValue(RisingPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
167
DebugMode_ObjCount++
168
end event
169
170
171
// ========================
172
// Editor Events
173
// ========================
174
175
event RSDKDraw
176
DrawSprite(0)
177
end event
178
179
180
event RSDKLoad
181
LoadSpriteSheet("LZ/Objects.gif")
182
SpriteFrame(-32, -12, 64, 24, 126, 137)
183
184
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
185
end event
186
187