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