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/ARZ/FPlatform.txt
1479 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.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
// Types
19
private alias 0 : FPLATFORM_FALL
20
private alias 1 : FPLATFORM_STATIC
21
22
// States
23
private alias 0 : FPLATFORM_IDLE
24
private alias 1 : FPLATFORM_FALLING_SOLID
25
private alias 2 : FPLATFORM_FALLING
26
private alias 3 : FPLATFORM_OFFSCREEN
27
28
// Player Aliases
29
private alias object.ypos : player.ypos
30
private alias object.yvel : player.yvel
31
private alias object.gravity : player.gravity
32
33
private alias object.value17 : debugMode.currentSelection
34
35
36
// ========================
37
// Function Declarations
38
// ========================
39
40
reserve function FallPlatform_DebugDraw
41
reserve function FallPlatform_DebugSpawn
42
43
44
// ========================
45
// Static Values
46
// ========================
47
48
private value FallPlatform_startDebugID = 0
49
50
51
// ========================
52
// Function Definitions
53
// ========================
54
55
private function FallPlatform_DebugDraw
56
DrawSprite(0)
57
end function
58
59
60
private function FallPlatform_DebugSpawn
61
temp0 = debugMode[0].currentSelection
62
temp0 -= FallPlatform_startDebugID
63
CreateTempObject(TypeName[Fall Platform], temp0, object.xpos, object.ypos)
64
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
65
end function
66
67
68
// ========================
69
// Events
70
// ========================
71
72
event ObjectUpdate
73
if object.stood == true
74
if object.timer == 0
75
object.priority = PRIORITY_ACTIVE
76
object.timer = 30
77
end if
78
79
if object.stoodAngle < 64
80
object.stoodAngle += 4
81
end if
82
else
83
if object.stoodAngle > 0
84
object.stoodAngle -= 4
85
end if
86
end if
87
88
temp0 = object.ypos
89
temp0 &= 0xFFFF0000
90
switch object.state
91
case FPLATFORM_IDLE
92
temp1 = object.stoodAngle
93
temp1 <<= 1
94
Sin(temp2, temp1)
95
temp2 <<= 9
96
object.ypos = object.centerPos.y
97
object.ypos += temp2
98
if object.propertyValue == FPLATFORM_FALL
99
if object.timer != 0
100
object.timer--
101
if object.timer == 0
102
object.state++
103
object.timer = 32
104
end if
105
end if
106
end if
107
break
108
109
case FPLATFORM_FALLING_SOLID
110
object.timer--
111
if object.timer == 0
112
object.state++
113
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
114
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 13, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
115
if checkResult == true
116
player[currentPlayer].ypos += object.yvel
117
player[currentPlayer].yvel = object.yvel
118
player[currentPlayer].yvel -= 0x3800
119
player[currentPlayer].gravity = GRAVITY_AIR
120
end if
121
next
122
end if
123
// Fall-through
124
125
case FPLATFORM_FALLING
126
object.ypos += object.yvel
127
object.yvel += 0x3800
128
if object.outOfBounds == true
129
object.ypos = object.centerPos.y
130
object.yvel = 0
131
object.timer = 0
132
object.state++
133
end if
134
break
135
136
case FPLATFORM_OFFSCREEN
137
if object.outOfBounds == true
138
object.state = 0
139
object.priority = PRIORITY_BOUNDS
140
end if
141
break
142
end switch
143
144
object.collisionOffset.y = object.ypos
145
object.collisionOffset.y &= 0xFFFF0000
146
object.collisionOffset.y -= temp0
147
object.stood = false
148
149
if object.state < FPLATFORM_FALLING
150
temp1 = object.ypos
151
152
object.ypos = temp0
153
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
154
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
155
if checkResult == true
156
object.stood = true
157
player[currentPlayer].ypos += object.collisionOffset.y
158
end if
159
next
160
161
object.ypos = temp1
162
end if
163
end event
164
165
166
event ObjectDraw
167
if object.state < FPLATFORM_OFFSCREEN
168
DrawSprite(0)
169
end if
170
end event
171
172
173
event ObjectStartup
174
LoadSpriteSheet("ARZ/Objects.gif")
175
SpriteFrame(-32, -13, 64, 45, 126, 145)
176
177
foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)
178
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
179
next
180
181
temp0 = 0
182
FallPlatform_startDebugID = DebugMode_ObjCount
183
while temp0 < 2
184
SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)
185
SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
186
SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
187
DebugMode_ObjCount++
188
temp0++
189
loop
190
end event
191
192
193
// ========================
194
// Editor Events
195
// ========================
196
197
event RSDKEdit
198
if editor.returnVariable == true
199
switch editor.variableID
200
case EDIT_VAR_PROPVAL // property value
201
checkResult = object.propertyValue
202
break
203
204
case 0 // type
205
checkResult = object.propertyValue
206
break
207
end switch
208
else
209
switch editor.variableID
210
case EDIT_VAR_PROPVAL // property value
211
object.propertyValue = editor.variableValue
212
break
213
214
case 0 // type
215
object.propertyValue = editor.variableValue
216
break
217
end switch
218
end if
219
end event
220
221
222
event RSDKDraw
223
DrawSprite(0)
224
end event
225
226
227
event RSDKLoad
228
LoadSpriteSheet("ARZ/Objects.gif")
229
SpriteFrame(-32, -13, 64, 45, 126, 145)
230
231
AddEditorVariable("type")
232
SetActiveVariable("type")
233
AddEnumVariable("Falling Platform", FPLATFORM_FALL)
234
AddEnumVariable("Static Platform", FPLATFORM_STATIC)
235
end event
236
237