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/VPlatform2.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: V Platform 2 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 VPlatform2_DebugDraw
28
reserve function VPlatform2_DebugSpawn
29
30
31
// ========================
32
// Static Values
33
// ========================
34
35
private value VPlatform2_debugStartID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function VPlatform2_DebugDraw
43
temp0 = debugMode[0].currentSelection
44
temp0 -= VPlatform2_debugStartID
45
DrawSprite(temp0)
46
end function
47
48
49
private function VPlatform2_DebugSpawn
50
temp0 = debugMode[0].currentSelection
51
temp0 -= VPlatform2_debugStartID
52
CreateTempObject(TypeName[V Platform 2], 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
73
object.ypos += object.yvel
74
temp0 = object.centerPos.y
75
temp0 -= 0x600000
76
if object.ypos <= temp0
77
object.yvel += 0x800
78
else
79
object.yvel -= 0x800
80
end if
81
82
temp6 &= 0xFFFF0000
83
temp7 = object.ypos
84
temp7 &= 0xFFFF0000
85
temp7 -= temp6
86
87
temp2 = 0
88
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
89
GetBit(temp0, object.stoodPlayers, temp2)
90
if temp0 == true
91
player[currentPlayer].ypos += temp7
92
end if
93
94
SetBit(object.stoodPlayers, temp2, false)
95
BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitboxL, -16, object.hitboxR, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
96
if checkResult == true
97
SetBit(object.stoodPlayers, temp2, true)
98
end if
99
100
temp2++
101
next
102
end event
103
104
105
event ObjectDraw
106
DrawSprite(object.propertyValue)
107
end event
108
109
110
event ObjectStartup
111
LoadSpriteSheet("CPZ/Objects.gif")
112
SpriteFrame(-32, -16, 64, 27, 136, 155) // Large Platform
113
SpriteFrame(-24, -16, 48, 26, 136, 183) // Small Platform
114
115
foreach (TypeName[V Platform 2], arrayPos0, ALL_ENTITIES)
116
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
117
if object[arrayPos0].direction == FLIP_Y
118
object[arrayPos0].direction -= 0xC00000 // prolly not supposed to be "object.direction"
119
end if
120
if object[arrayPos0].propertyValue == 0
121
object[arrayPos0].hitboxL = -32
122
object[arrayPos0].hitboxR = 32
123
else
124
object[arrayPos0].hitboxL = -24
125
object[arrayPos0].hitboxR = 24
126
end if
127
next
128
129
temp0 = 0
130
VPlatform2_debugStartID = DebugMode_ObjCount
131
while temp0 < 2
132
SetTableValue(TypeName[V Platform 2], DebugMode_ObjCount, DebugMode_TypesTable)
133
SetTableValue(VPlatform2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
134
SetTableValue(VPlatform2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
135
DebugMode_ObjCount++
136
temp0++
137
loop
138
end event
139
140
141
// ========================
142
// Editor Events
143
// ========================
144
145
event RSDKEdit
146
if editor.returnVariable == true
147
switch editor.variableID
148
case EDIT_VAR_PROPVAL // property value
149
checkResult = object.propertyValue
150
break
151
152
case 0 // type
153
checkResult = object.propertyValue
154
break
155
156
end switch
157
else
158
switch editor.variableID
159
case EDIT_VAR_PROPVAL // property value
160
object.propertyValue = editor.variableValue
161
break
162
163
case 0 // type
164
object.propertyValue = editor.variableValue
165
break
166
167
end switch
168
end if
169
end event
170
171
172
event RSDKDraw
173
DrawSprite(object.propertyValue)
174
end event
175
176
177
event RSDKLoad
178
LoadSpriteSheet("CPZ/Objects.gif")
179
SpriteFrame(-32, -16, 64, 27, 136, 155)
180
SpriteFrame(-24, -16, 48, 26, 136, 183)
181
182
AddEditorVariable("type")
183
SetActiveVariable("type")
184
AddEnumVariable("Large", 0)
185
AddEnumVariable("Small", 1)
186
end event
187
188