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/LPlatform.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: L 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
// States
18
private alias 0 : LPLATFORM_IDLE
19
private alias 1 : LPLATFORM_SINKING
20
private alias 2 : LPLATFORM_SUNKEN
21
22
// Player Aliases
23
private alias object.ypos : player.ypos
24
private alias object.gravity : player.gravity
25
26
27
// ========================
28
// Function Declarations
29
// ========================
30
31
reserve function LPlatform_DebugDraw
32
reserve function LPlatform_DebugSpawn
33
34
35
// ========================
36
// Function Definitions
37
// ========================
38
39
private function LPlatform_DebugDraw
40
DrawSprite(0)
41
end function
42
43
44
private function LPlatform_DebugSpawn
45
CreateTempObject(TypeName[L Platform], 0, object.xpos, object.ypos)
46
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
47
end function
48
49
50
// ========================
51
// Events
52
// ========================
53
54
event ObjectUpdate
55
temp0 = object.ypos
56
temp0 &= 0xFFFF0000
57
58
switch object.state
59
case LPLATFORM_IDLE
60
GetTableValue(temp6, 0, StageSetup_oscillationTable)
61
temp6 <<= 7
62
object.ypos = object.centerPos.y
63
object.ypos -= temp6
64
break
65
66
case LPLATFORM_SINKING
67
object.ypos += object.yvel
68
object.yvel += 0x800
69
70
if object.outOfBounds == true
71
object.ypos = object.centerPos.y
72
object.ypos += object.wrapOffset.y
73
object.yvel = 0
74
object.timer = 0
75
object.state++
76
end if
77
break
78
79
case LPLATFORM_SUNKEN
80
if object.outOfBounds == true
81
object.state = LPLATFORM_IDLE
82
object.priority = PRIORITY_BOUNDS
83
end if
84
break
85
86
end switch
87
88
temp7 = object.ypos
89
temp7 &= 0xFFFF0000
90
temp7 -= temp0
91
if object.state < 2
92
temp2 = 0
93
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
94
GetBit(temp0, object.stoodPlayers, temp2)
95
if temp0 == true
96
player[currentPlayer].ypos += temp7
97
end if
98
99
SetBit(object.stoodPlayers, temp2, false)
100
BoxCollisionTest(C_SOLID, object.entityPos, -32, -12, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
101
switch checkResult
102
case COL_TOP
103
SetBit(object.stoodPlayers, temp2, true)
104
if object.timer == 0
105
if object.state == LPLATFORM_IDLE
106
object.priority = PRIORITY_ACTIVE
107
object.state++
108
end if
109
end if
110
break
111
112
case COL_BOTTOM
113
if player[currentPlayer].gravity == 0
114
CallFunction(Player_Kill)
115
end if
116
break
117
end switch
118
119
temp2++
120
next
121
end if
122
end event
123
124
125
event ObjectDraw
126
if object.state < LPLATFORM_SUNKEN
127
DrawSprite(0)
128
end if
129
end event
130
131
132
event ObjectStartup
133
LoadSpriteSheet("MPZ/Objects.gif")
134
SpriteFrame(-32, -12, 64, 24, 383, 207)
135
136
foreach (TypeName[L Platform], arrayPos0, ALL_ENTITIES)
137
object[arrayPos0].ypos += 0x100000
138
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
139
next
140
141
SetTableValue(TypeName[L Platform], DebugMode_ObjCount, DebugMode_TypesTable)
142
SetTableValue(LPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
143
SetTableValue(LPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
144
DebugMode_ObjCount++
145
end event
146
147
148
// ========================
149
// Editor Events
150
// ========================
151
152
event RSDKDraw
153
DrawSprite(0)
154
end event
155
156
157
event RSDKLoad
158
LoadSpriteSheet("MPZ/Objects.gif")
159
SpriteFrame(-32, -12, 64, 24, 383, 207)
160
161
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
162
end event
163
164