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/CogPlatform.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Cog 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.startPos.x
13
14
// Player Aliases
15
private alias object.state : player.state
16
private alias object.xpos : player.xpos
17
private alias object.animation : player.animation
18
19
private alias object.value1 : player.timer
20
private alias object.value17 : debugMode.currentSelection
21
22
// Path ID Aliases
23
private alias 0 : PATH_A
24
25
26
// ========================
27
// Function Declarations
28
// ========================
29
30
reserve function CogPlatform_DebugDraw
31
reserve function CogPlatform_DebugSpawn
32
33
34
// ========================
35
// Static Values
36
// ========================
37
38
private value CogPlatform_startDebugID = 0
39
40
41
// ========================
42
// Function Definitions
43
// ========================
44
45
private function CogPlatform_DebugDraw
46
DrawSprite(0)
47
end function
48
49
50
private function CogPlatform_DebugSpawn
51
temp0 = debugMode[0].currentSelection
52
temp0 -= CogPlatform_startDebugID
53
CreateTempObject(TypeName[Cog Platform], temp0, object.xpos, object.ypos)
54
object[tempObjectPos].direction = object.direction
55
end function
56
57
58
// ========================
59
// Events
60
// ========================
61
62
event ObjectUpdate
63
temp0 = object.xpos
64
temp0 &= 0xFFFF0000
65
66
object.xpos += object.xvel
67
if object.direction == FLIP_NONE
68
ObjectTileCollision(CSIDE_LWALL, 64, 0, PATH_A)
69
else
70
ObjectTileCollision(CSIDE_RWALL, -64, 0, PATH_A)
71
end if
72
73
if checkResult == true
74
if object.propertyValue == 0
75
object.xvel = 0
76
MPZSetup_cogTimer = 0
77
MPZSetup_cogFrame = 0
78
else
79
object.direction ^= FLIP_X
80
FlipSign(object.xvel)
81
FlipSign(MPZSetup_cogFrame)
82
end if
83
end if
84
85
temp4 = object.xpos
86
temp2 = object.xpos
87
temp2 &= 0xFFFF0000
88
temp2 -= temp0
89
90
object.xpos = temp0
91
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
92
BoxCollisionTest(C_SOLID, object.entityPos, -64, -12, 64, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
93
switch checkResult
94
case COL_TOP
95
if object.xvel == 0
96
object.priority = PRIORITY_ACTIVE
97
if object.direction == FLIP_NONE
98
object.xvel = 0x20000
99
MPZSetup_cogTimer = -1
100
else
101
object.xvel = -0x20000
102
MPZSetup_cogTimer = 1
103
end if
104
end if
105
player[currentPlayer].xpos += temp2
106
break
107
108
case COL_LEFT
109
case COL_RIGHT
110
if player[currentPlayer].state == Player_State_Climb
111
player[currentPlayer].timer = 0
112
player[currentPlayer].animation = ANI_GLIDING_DROP
113
player[currentPlayer].state = Player_State_GlideDrop
114
end if
115
break
116
117
end switch
118
next
119
120
object.xpos = temp4
121
122
if object.outOfBounds == true
123
if object.startPos.x == 0 // It will only be 0 if the Platform was spawned via Debug Mode
124
object.type = TypeName[Blank Object]
125
else
126
object.xpos = object.startPos.x
127
if object.outOfBounds == false
128
object.xpos = temp4
129
else
130
object.priority = PRIORITY_BOUNDS
131
object.xvel = 0
132
MPZSetup_cogTimer = 0
133
MPZSetup_cogFrame = 0
134
end if
135
end if
136
end if
137
end event
138
139
140
event ObjectDraw
141
DrawSprite(0)
142
end event
143
144
145
event ObjectStartup
146
LoadSpriteSheet("MPZ/Objects.gif")
147
SpriteFrame(-64, -12, 128, 24, 350, 182)
148
149
// Nothing too notable but normally setup foreaches are before the Debug Mode table additions, but here they're switched around in order
150
151
temp0 = 0
152
CogPlatform_startDebugID = DebugMode_ObjCount
153
while temp0 < 2
154
SetTableValue(TypeName[Cog Platform], DebugMode_ObjCount, DebugMode_TypesTable)
155
SetTableValue(CogPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
156
SetTableValue(CogPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
157
DebugMode_ObjCount++
158
temp0++
159
loop
160
161
foreach (TypeName[Cog Platform], arrayPos0, ALL_ENTITIES)
162
object[arrayPos0].startPos.x = object[arrayPos0].xpos
163
next
164
end event
165
166
167
// ========================
168
// Editor Events
169
// ========================
170
171
event RSDKEdit
172
if editor.returnVariable == true
173
switch editor.variableID
174
case EDIT_VAR_PROPVAL // property value
175
checkResult = object.propertyValue
176
break
177
178
case 0 // type
179
checkResult = object.propertyValue
180
break
181
182
end switch
183
else
184
switch editor.variableID
185
case EDIT_VAR_PROPVAL // property value
186
object.propertyValue = editor.variableValue
187
break
188
189
case 0 // type
190
object.propertyValue = editor.variableValue
191
break
192
193
end switch
194
end if
195
end event
196
197
198
event RSDKDraw
199
DrawSprite(0)
200
end event
201
202
203
event RSDKLoad
204
LoadSpriteSheet("MPZ/Objects.gif")
205
SpriteFrame(-64, -12, 128, 24, 350, 182)
206
207
AddEditorVariable("type")
208
SetActiveVariable("type")
209
AddEnumVariable("Stop On Contact", 0)
210
AddEnumVariable("Swap Direction On Contact", 1)
211
end event
212
213