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/SLZ/FallingPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Fall 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.centerPos.y
16
private alias object.value4 : object.stoodAngle
17
18
private alias 0 : FALLPLATFORM_IDLE
19
private alias 1 : FALLPLATFORM_FALLING_SOLID
20
private alias 2 : FALLPLATFORM_FALLING
21
private alias 3 : FALLPLATFORM_OFFSCREEN
22
23
// Player Aliases
24
private alias object.ypos : player.ypos
25
private alias object.yvel : player.yvel
26
private alias object.gravity : player.gravity
27
28
29
// ========================
30
// Function Declarations
31
// ========================
32
33
reserve function FallPlatform_DebugDraw
34
reserve function FallPlatform_DebugSpawn
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function FallPlatform_DebugDraw
42
DrawSprite(0)
43
end function
44
45
46
private function FallPlatform_DebugSpawn
47
CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)
48
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
49
end function
50
51
52
// ========================
53
// Events
54
// ========================
55
56
event ObjectUpdate
57
if object.stood == true
58
if object.timer == 0
59
object.priority = PRIORITY_ACTIVE
60
object.timer = 30
61
end if
62
63
if object.stoodAngle < 64
64
object.stoodAngle += 4
65
end if
66
else
67
if object.stoodAngle > 0
68
object.stoodAngle -= 4
69
end if
70
end if
71
72
temp0 = object.ypos
73
temp0 &= 0xFFFF0000
74
75
switch object.state
76
case FALLPLATFORM_IDLE
77
temp1 = object.stoodAngle
78
temp1 <<= 1
79
Sin(temp2, temp1)
80
temp2 <<= 9
81
object.ypos = object.centerPos.y
82
object.ypos += temp2
83
if object.timer != 0
84
object.timer--
85
if object.timer == 0
86
object.state++
87
object.timer = 32
88
end if
89
end if
90
break
91
92
case FALLPLATFORM_FALLING_SOLID
93
object.timer--
94
if object.timer == 0
95
object.state++
96
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
97
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
98
if checkResult == true
99
player[currentPlayer].ypos += object.yvel
100
player[currentPlayer].yvel = object.yvel
101
player[currentPlayer].yvel -= 0x3800
102
player[currentPlayer].gravity = GRAVITY_AIR
103
end if
104
next
105
end if
106
// [Fallthrough]
107
case FALLPLATFORM_FALLING
108
object.ypos += object.yvel
109
object.yvel += 0x3800
110
111
if object.outOfBounds == true
112
object.ypos = object.centerPos.y
113
object.yvel = 0
114
object.timer = 0
115
object.state++
116
end if
117
break
118
119
case FALLPLATFORM_OFFSCREEN
120
if object.outOfBounds == true
121
object.state = FALLPLATFORM_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 < FALLPLATFORM_FALLING
134
temp1 = object.ypos
135
object.ypos = temp0
136
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
137
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
138
if checkResult == true
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 < FALLPLATFORM_OFFSCREEN
150
DrawSprite(0)
151
end if
152
end event
153
154
155
event ObjectStartup
156
LoadSpriteSheet("SLZ/Objects.gif")
157
SpriteFrame(-32, -8, 64, 32, 67, 26)
158
159
foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)
160
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
161
next
162
163
SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)
164
SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
165
SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
166
DebugMode_ObjCount++
167
end event
168
169
170
// ========================
171
// Editor Events
172
// ========================
173
174
event RSDKDraw
175
DrawSprite(0)
176
end event
177
178
179
event RSDKLoad
180
LoadSpriteSheet("SLZ/Objects.gif")
181
SpriteFrame(-32, -8, 64, 32, 67, 26)
182
183
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
184
end event
185
186