Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/MPZ/FPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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.timer
13
private alias object.value1 : object.centerPos.y
14
private alias object.value2 : object.stoodPlayers
15
private alias object.value31 : object.wrapOffset.y
16
17
// Types
18
private alias 0 : FPLATFORM_FALL
19
private alias 1 : FPLATFORM_STATIC
20
21
// States
22
private alias 0 : FPLATFORM_IDLE
23
private alias 1 : FPLATFORM_FALLING_SOLID
24
private alias 2 : FPLATFORM_FALLING
25
private alias 3 : FPLATFORM_OFFSCREEN
26
27
// Player Aliases
28
private alias object.ypos : player.ypos
29
private alias object.yvel : player.yvel
30
private alias object.gravity : player.gravity
31
32
33
// ========================
34
// Function Declarations
35
// ========================
36
37
reserve function FallPlatform_DebugDraw
38
reserve function FallPlatform_DebugSpawn
39
40
41
// ========================
42
// Function Definitions
43
// ========================
44
45
private function FallPlatform_DebugDraw
46
DrawSprite(0)
47
end function
48
49
50
private function FallPlatform_DebugSpawn
51
CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)
52
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
53
end function
54
55
56
// ========================
57
// Events
58
// ========================
59
60
event ObjectUpdate
61
temp0 = object.ypos
62
temp0 &= 0xFFFF0000
63
64
switch object.state
65
case FPLATFORM_IDLE
66
if object.propertyValue == 0
67
if object.timer != 0
68
object.timer--
69
if object.timer == 0
70
object.state++
71
object.timer = 32
72
end if
73
end if
74
end if
75
break
76
77
case FPLATFORM_FALLING_SOLID
78
object.timer--
79
if object.timer == 0
80
object.state++
81
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
82
BoxCollisionTest(C_SOLID, object.entityPos, -32, -12, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
83
if checkResult == COL_TOP
84
player[currentPlayer].ypos += object.yvel
85
player[currentPlayer].yvel = object.yvel
86
player[currentPlayer].yvel -= 0x3800
87
player[currentPlayer].gravity = GRAVITY_AIR
88
end if
89
next
90
end if
91
// [Fallthrough]
92
case FPLATFORM_FALLING
93
object.ypos += object.yvel
94
object.yvel += 0x3800
95
96
if object.outOfBounds == true
97
object.ypos = object.centerPos.y
98
object.ypos += object.wrapOffset.y
99
object.yvel = 0
100
object.timer = 0
101
object.state++
102
end if
103
break
104
105
case FPLATFORM_OFFSCREEN
106
if object.outOfBounds == true
107
object.state = FPLATFORM_IDLE
108
object.priority = PRIORITY_BOUNDS
109
end if
110
break
111
112
end switch
113
114
temp7 = object.ypos
115
temp7 &= 0xFFFF0000
116
temp7 -= temp0
117
if object.state < FPLATFORM_FALLING
118
temp2 = 0
119
120
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
121
GetBit(temp0, object.stoodPlayers, temp2)
122
if temp0 == true
123
player[currentPlayer].ypos += temp7
124
end if
125
126
SetBit(object.stoodPlayers, temp2, false)
127
BoxCollisionTest(C_SOLID, object.entityPos, -32, -12, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
128
switch checkResult
129
case COL_TOP
130
SetBit(object.stoodPlayers, temp2, true)
131
if object.timer == 0
132
if object.state == FPLATFORM_IDLE
133
object.priority = PRIORITY_ACTIVE
134
object.timer = 30
135
end if
136
end if
137
break
138
139
case COL_BOTTOM
140
if player[currentPlayer].gravity == GRAVITY_GROUND
141
CallFunction(Player_Kill)
142
end if
143
break
144
end switch
145
146
temp2++
147
next
148
end if
149
end event
150
151
152
event ObjectDraw
153
if object.state < FPLATFORM_OFFSCREEN
154
DrawSprite(0)
155
end if
156
end event
157
158
159
event ObjectStartup
160
LoadSpriteSheet("MPZ/Objects.gif")
161
SpriteFrame(-32, -12, 64, 24, 383, 207)
162
163
foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)
164
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
165
next
166
167
SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)
168
SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
169
SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
170
DebugMode_ObjCount++
171
end event
172
173
174
// ========================
175
// Editor Events
176
// ========================
177
178
event RSDKEdit
179
if editor.returnVariable == true
180
switch editor.variableID
181
case EDIT_VAR_PROPVAL // property value
182
checkResult = object.propertyValue
183
break
184
185
case 0 // type
186
checkResult = object.propertyValue
187
break
188
189
end switch
190
else
191
switch editor.variableID
192
case EDIT_VAR_PROPVAL // property value
193
object.propertyValue = editor.variableValue
194
break
195
196
case 0 // type
197
object.propertyValue = editor.variableValue
198
break
199
200
end switch
201
end if
202
end event
203
204
205
event RSDKDraw
206
DrawSprite(0)
207
end event
208
209
210
event RSDKLoad
211
LoadSpriteSheet("MPZ/Objects.gif")
212
SpriteFrame(-32, -12, 64, 24, 383, 207)
213
214
AddEditorVariable("type")
215
SetActiveVariable("type")
216
AddEnumVariable("Falling Platform", FPLATFORM_FALL)
217
AddEnumVariable("Static Platform", FPLATFORM_STATIC)
218
end event
219
220