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/EHZ/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.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 : FPLATFORM_FALL
19
private alias 1 : FPLATFORM_STATIC
20
21
private alias 0 : FPLATFORM_IDLE
22
private alias 1 : FPLATFORM_FALLING_SOLID
23
private alias 2 : FPLATFORM_FALLING
24
private alias 3 : FPLATFORM_OFFSCREEN
25
26
// Player Aliases
27
private alias object.ypos : player.ypos
28
private alias object.yvel : player.yvel
29
private alias object.gravity : player.gravity
30
31
32
// ========================
33
// Function Declarations
34
// ========================
35
36
reserve function FallPlatform_DebugDraw
37
reserve function FallPlatform_DebugSpawn
38
39
40
// ========================
41
// Function Definitions
42
// ========================
43
44
private function FallPlatform_DebugDraw
45
DrawSprite(0)
46
end function
47
48
49
private function FallPlatform_DebugSpawn
50
CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)
51
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
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.priority = PRIORITY_ACTIVE
63
object.timer = 30
64
end if
65
66
if object.stoodAngle < 64
67
object.stoodAngle += 4
68
end if
69
else
70
if object.stoodAngle > 0
71
object.stoodAngle -= 4
72
end if
73
end if
74
75
temp0 = object.ypos
76
temp0 &= 0xFFFF0000
77
switch object.state
78
case FPLATFORM_IDLE
79
temp1 = object.stoodAngle
80
temp1 <<= 1
81
Sin(temp2, temp1)
82
temp2 <<= 9
83
object.ypos = object.centerPos.y
84
object.ypos += temp2
85
if object.propertyValue == FPLATFORM_FALL
86
if object.timer != 0
87
object.timer--
88
if object.timer == 0
89
object.state++
90
object.timer = 32
91
end if
92
end if
93
end if
94
break
95
96
case FPLATFORM_FALLING_SOLID
97
object.timer--
98
if object.timer == 0
99
object.state++
100
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
101
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
102
if checkResult == true
103
player[currentPlayer].ypos += object.yvel
104
player[currentPlayer].yvel = object.yvel
105
player[currentPlayer].yvel -= 0x3800
106
player[currentPlayer].gravity = GRAVITY_AIR
107
end if
108
next
109
end if
110
// [FallThrough]
111
case FPLATFORM_FALLING
112
object.ypos += object.yvel
113
object.yvel += 0x3800
114
115
if object.outOfBounds == true
116
object.ypos = object.centerPos.y
117
object.yvel = 0
118
object.timer = 0
119
object.state++
120
end if
121
break
122
123
case FPLATFORM_OFFSCREEN
124
if object.outOfBounds == true
125
object.state = FPLATFORM_IDLE
126
object.priority = PRIORITY_BOUNDS
127
end if
128
break
129
130
end switch
131
132
object.collisionOffset.y = object.ypos
133
object.collisionOffset.y &= 0xFFFF0000
134
object.collisionOffset.y -= temp0
135
object.stood = false
136
137
if object.state < FPLATFORM_FALLING
138
temp1 = object.ypos
139
140
object.ypos = temp0
141
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
142
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
143
if checkResult == true
144
object.stood = true
145
player[currentPlayer].ypos += object.collisionOffset.y
146
end if
147
next
148
149
object.ypos = temp1
150
end if
151
end event
152
153
154
event ObjectDraw
155
if object.state < FPLATFORM_OFFSCREEN
156
DrawSprite(0)
157
end if
158
end event
159
160
161
event ObjectStartup
162
CheckCurrentStageFolder("Zone01")
163
if checkResult == true
164
LoadSpriteSheet("EHZ/Objects.gif")
165
SpriteFrame(-32, -12, 64, 32, 127, 98)
166
else
167
LoadSpriteSheet("MBZ/Objects.gif")
168
SpriteFrame(-32, -8, 64, 32, 1, 402)
169
end if
170
171
foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)
172
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
173
next
174
175
SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)
176
SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
177
SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
178
DebugMode_ObjCount++
179
end event
180
181
182
// ========================
183
// Editor Events
184
// ========================
185
186
event RSDKEdit
187
if editor.returnVariable == true
188
switch editor.variableID
189
case EDIT_VAR_PROPVAL // property value
190
checkResult = object.propertyValue
191
break
192
193
case 0 // type
194
checkResult = object.propertyValue
195
break
196
197
end switch
198
else
199
switch editor.variableID
200
case EDIT_VAR_PROPVAL // property value
201
object.propertyValue = editor.variableValue
202
break
203
204
case 0 // type
205
object.propertyValue = editor.variableValue
206
break
207
208
end switch
209
end if
210
end event
211
212
213
event RSDKDraw
214
DrawSprite(0)
215
216
CheckEqual(editor.showGizmos, true)
217
temp0 = checkResult
218
CheckEqual(object.propertyValue, FPLATFORM_FALL)
219
temp0 &= checkResult
220
if temp0 == true
221
// Draw a dashed line to indicate that this platform is of the falling variety
222
// (Otherwise it's just the generic platform sprite, which is shared between two other objects)
223
224
editor.drawingOverlay = true
225
226
227
temp0 = object.ypos
228
229
temp1 = object.ypos
230
temp1 += 0x60000
231
232
temp2 = object.ypos
233
temp2 += 0x3E0000
234
235
while temp0 < temp2
236
DrawLine(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)
237
238
temp0 += 0xC0000
239
temp1 += 0xC0000
240
loop
241
242
editor.drawingOverlay = false
243
end if
244
end event
245
246
247
event RSDKLoad
248
CheckCurrentStageFolder("Zone01")
249
if checkResult == true
250
LoadSpriteSheet("EHZ/Objects.gif")
251
SpriteFrame(-32, -12, 64, 32, 127, 98)
252
else
253
LoadSpriteSheet("MBZ/Objects.gif")
254
SpriteFrame(-32, -8, 64, 32, 1, 402)
255
end if
256
257
AddEditorVariable("type")
258
SetActiveVariable("type")
259
AddEnumVariable("Falling Platform", FPLATFORM_FALL)
260
AddEnumVariable("Static Platform", FPLATFORM_STATIC)
261
end event
262
263