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