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/CPZ/VPlatform.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: V 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.centerPos.y
13
private alias object.value1 : object.hitboxL
14
private alias object.value2 : object.hitboxR
15
private alias object.value3 : object.stoodPlayers
16
17
// Player Aliases
18
private alias object.ypos : player.ypos
19
20
private alias object.value17 : debugMode.currentSelection
21
22
23
// ========================
24
// Function Declarations
25
// ========================
26
27
reserve function VPlatform_DebugDraw
28
reserve function VPlatform_DebugSpawn
29
30
31
// ========================
32
// Static Values
33
// ========================
34
35
private value VPlatform_debugStartID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function VPlatform_DebugDraw
43
temp0 = debugMode[0].currentSelection
44
temp0 -= VPlatform_debugStartID
45
DrawSprite(temp0)
46
end function
47
48
49
private function VPlatform_DebugSpawn
50
temp0 = debugMode[0].currentSelection
51
temp0 -= VPlatform_debugStartID
52
CreateTempObject(TypeName[V Platform], temp0, object.xpos, object.ypos)
53
54
object[tempObjectPos].centerPos.y = object.ypos
55
object[tempObjectPos].direction = object.direction
56
if object[tempObjectPos].propertyValue == 0
57
object[tempObjectPos].hitboxL = -32
58
object[tempObjectPos].hitboxR = 32
59
else
60
object[tempObjectPos].hitboxL = -24
61
object[tempObjectPos].hitboxR = 24
62
end if
63
end function
64
65
66
// ========================
67
// Events
68
// ========================
69
70
event ObjectUpdate
71
temp6 = object.ypos
72
GetTableValue(temp0, 14, StageSetup_oscillationTable)
73
if object.direction == FLIP_X
74
FlipSign(temp0)
75
temp0 += 0x8000
76
end if
77
temp0 <<= 8
78
79
object.ypos = object.centerPos.y
80
object.ypos -= temp0
81
temp6 &= 0xFFFF0000
82
temp7 = object.ypos
83
temp7 &= 0xFFFF0000
84
temp7 -= temp6
85
86
temp2 = 0
87
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
88
GetBit(temp0, object.stoodPlayers, temp2)
89
if temp0 == true
90
player[currentPlayer].ypos += temp7
91
end if
92
93
SetBit(object.stoodPlayers, temp2, false)
94
BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitboxL, -16, object.hitboxR, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
95
if checkResult == true
96
SetBit(object.stoodPlayers, temp2, true)
97
end if
98
temp2++
99
next
100
end event
101
102
103
event ObjectDraw
104
DrawSprite(object.propertyValue)
105
end event
106
107
108
event ObjectStartup
109
LoadSpriteSheet("CPZ/Objects.gif")
110
SpriteFrame(-32, -16, 64, 27, 136, 155) // Large Platform
111
SpriteFrame(-24, -16, 48, 26, 136, 183) // Small Platform
112
113
foreach (TypeName[V Platform], arrayPos0, ALL_ENTITIES)
114
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
115
if object[arrayPos0].propertyValue == 0
116
// Normal-sized platform
117
object[arrayPos0].hitboxL = -32
118
object[arrayPos0].hitboxR = 32
119
else
120
// Small-sized platform
121
object[arrayPos0].hitboxL = -24
122
object[arrayPos0].hitboxR = 24
123
end if
124
next
125
126
temp0 = 0
127
VPlatform_debugStartID = DebugMode_ObjCount
128
while temp0 < 2
129
SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)
130
SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
131
SetTableValue(VPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
132
DebugMode_ObjCount++
133
temp0++
134
loop
135
end event
136
137
138
// ========================
139
// Editor Events
140
// ========================
141
142
event RSDKEdit
143
if editor.returnVariable == true
144
switch editor.variableID
145
case EDIT_VAR_PROPVAL // property value
146
checkResult = object.propertyValue
147
break
148
149
case 0 // type
150
checkResult = object.propertyValue
151
break
152
153
end switch
154
else
155
switch editor.variableID
156
case EDIT_VAR_PROPVAL // property value
157
object.propertyValue = editor.variableValue
158
break
159
160
case 0 // type
161
object.propertyValue = editor.variableValue
162
break
163
164
end switch
165
end if
166
end event
167
168
169
event RSDKDraw
170
DrawSprite(object.propertyValue)
171
172
if editor.showGizmos == true
173
// Draw arrows to indicate that this is a V platform
174
175
editor.drawingOverlay = true
176
177
temp0 = object.ypos
178
temp0 -= 0x320000
179
DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0, 224, 0)
180
temp0 = object.ypos
181
temp0 += 0x320000
182
DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0, 224, 0)
183
184
editor.drawingOverlay = false
185
end if
186
end event
187
188
189
event RSDKLoad
190
LoadSpriteSheet("CPZ/Objects.gif")
191
SpriteFrame(-32, -16, 64, 27, 136, 155)
192
SpriteFrame(-24, -16, 48, 26, 136, 183)
193
194
AddEditorVariable("type")
195
SetActiveVariable("type")
196
AddEnumVariable("Large", 0)
197
AddEnumVariable("Small", 1)
198
end event
199
200