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/WFZ/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.hitbox.left
14
private alias object.value2 : object.hitbox.right
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_startDebugID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function VPlatform2_DebugDraw
43
temp0 = debugMode[0].currentSelection
44
temp0 -= VPlatform2_startDebugID
45
DrawSprite(temp0)
46
end function
47
48
49
private function VPlatform2_DebugSpawn
50
temp0 = debugMode[0].currentSelection
51
temp0 -= VPlatform2_startDebugID
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].hitbox.left = -32
58
object[tempObjectPos].hitbox.right = 32
59
else
60
object[tempObjectPos].hitbox.left = -24
61
object[tempObjectPos].hitbox.right = 24
62
end if
63
end function
64
65
66
// ========================
67
// Events
68
// ========================
69
70
event ObjectUpdate
71
temp6 = object.ypos
72
object.ypos += object.yvel
73
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
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.hitbox.left, -16, object.hitbox.right, 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("SCZ/Objects.gif")
110
SpriteFrame(-24, -16, 48, 24, 381, 178)
111
SpriteFrame(-32, -16, 64, 24, 1, 146)
112
113
foreach (TypeName[V Platform 2], arrayPos0, ALL_ENTITIES)
114
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
115
if object[arrayPos0].direction == FLIP_Y
116
object[arrayPos0].direction -= 0xC00000 // prolly not supposed to be "object.direction"
117
end if
118
119
if object[arrayPos0].propertyValue == 0
120
object[arrayPos0].hitbox.left = -32
121
object[arrayPos0].hitbox.right = 32
122
else
123
object[arrayPos0].hitbox.left = -24
124
object[arrayPos0].hitbox.right = 24
125
end if
126
next
127
128
temp0 = 0
129
VPlatform2_startDebugID = DebugMode_ObjCount
130
while temp0 < 2
131
SetTableValue(TypeName[V Platform 2], DebugMode_ObjCount, DebugMode_TypesTable)
132
SetTableValue(VPlatform2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
133
SetTableValue(VPlatform2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
134
DebugMode_ObjCount++
135
temp0++
136
loop
137
end event
138
139
140
// ========================
141
// Editor Events
142
// ========================
143
144
event RSDKEdit
145
if editor.returnVariable == true
146
switch editor.variableID
147
case EDIT_VAR_PROPVAL // property value
148
checkResult = object.propertyValue
149
break
150
151
case 0 // type
152
checkResult = object.propertyValue
153
break
154
155
end switch
156
else
157
switch editor.variableID
158
case EDIT_VAR_PROPVAL // property value
159
object.propertyValue = editor.variableValue
160
break
161
162
case 0 // type
163
object.propertyValue = editor.variableValue
164
break
165
166
end switch
167
end if
168
end event
169
170
171
event RSDKDraw
172
DrawSprite(object.propertyValue)
173
end event
174
175
176
event RSDKLoad
177
LoadSpriteSheet("SCZ/Objects.gif")
178
SpriteFrame(-24, -16, 48, 24, 381, 178)
179
SpriteFrame(-32, -16, 64, 24, 1, 146)
180
181
AddEditorVariable("type")
182
SetActiveVariable("type")
183
AddEnumVariable("Small Platform", 0)
184
AddEnumVariable("Wide Platform", 1)
185
end event
186
187