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/EHZ/VPlatform2.txt
1480 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.collisionOffset.y
14
15
// Player Aliases
16
private alias object.ypos : player.ypos
17
18
19
// ========================
20
// Function Declarations
21
// ========================
22
23
reserve function VPlatform2_DebugDraw
24
reserve function VPlatform2_DebugSpawn
25
26
27
// ========================
28
// Function Definitions
29
// ========================
30
31
private function VPlatform2_DebugDraw
32
DrawSprite(0)
33
end function
34
35
36
private function VPlatform2_DebugSpawn
37
CreateTempObject(TypeName[V Platform 2], 0, object.xpos, object.ypos)
38
object[tempObjectPos].centerPos.y = object.ypos
39
object[tempObjectPos].propertyValue = object.direction
40
end function
41
42
43
// ========================
44
// Events
45
// ========================
46
47
event ObjectUpdate
48
temp7 = object.ypos
49
50
GetTableValue(temp0, 12, StageSetup_oscillationTable)
51
if object.propertyValue == 1
52
FlipSign(temp0)
53
temp0 += 0x4000
54
else
55
temp0 -= 0x4000
56
end if
57
temp0 <<= 7
58
59
object.ypos = object.centerPos.y
60
object.ypos -= temp0
61
temp1 = object.ypos
62
temp7 &= 0xFFFF0000
63
object.collisionOffset.y = object.ypos
64
object.collisionOffset.y &= 0xFFFF0000
65
object.collisionOffset.y -= temp7
66
object.ypos = temp7
67
68
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
69
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -46, 32, -26, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
70
if checkResult == true
71
player[currentPlayer].ypos += object.collisionOffset.y
72
end if
73
next
74
75
object.ypos = temp1
76
end event
77
78
79
event ObjectDraw
80
DrawSprite(0)
81
end event
82
83
84
event ObjectStartup
85
CheckCurrentStageFolder("Zone01")
86
if checkResult == true
87
LoadSpriteSheet("EHZ/Objects.gif")
88
SpriteFrame(-32, -52, 64, 96, 127, 1)
89
else
90
LoadSpriteSheet("MBZ/Objects.gif")
91
SpriteFrame(-32, -46, 64, 96, 1, 305)
92
end if
93
94
foreach (TypeName[V Platform 2], arrayPos0, ALL_ENTITIES)
95
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
96
next
97
98
SetTableValue(TypeName[V Platform 2], DebugMode_ObjCount, DebugMode_TypesTable)
99
SetTableValue(VPlatform2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
100
SetTableValue(VPlatform2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
101
DebugMode_ObjCount++
102
end event
103
104
105
// ========================
106
// Editor Events
107
// ========================
108
109
event RSDKEdit
110
if editor.returnVariable == true
111
switch editor.variableID
112
case EDIT_VAR_PROPVAL // property value
113
checkResult = object.propertyValue
114
break
115
116
case 0 // startDir
117
checkResult = object.propertyValue
118
break
119
120
end switch
121
else
122
switch editor.variableID
123
case EDIT_VAR_PROPVAL // property value
124
object.propertyValue = editor.variableValue
125
break
126
127
case 0 // startDir
128
object.propertyValue = editor.variableValue
129
break
130
131
end switch
132
end if
133
end event
134
135
136
event RSDKDraw
137
// Because of how tall this object is its movement path doesn't look too good
138
// I hope you'll find it fine enough though...
139
140
if editor.showGizmos == true
141
editor.drawingOverlay = true
142
143
// Draw the Platform's ghosts
144
145
object.inkEffect = INK_BLEND
146
147
temp0 = object.ypos
148
temp0 += 0x1F0000
149
DrawSpriteFX(0, FX_INK, object.xpos, temp0)
150
151
temp1 = object.ypos
152
temp1 -= 0x210000
153
DrawSpriteFX(0, FX_INK, object.xpos, temp1)
154
155
object.inkEffect = INK_NONE
156
157
editor.drawingOverlay = false
158
end if
159
160
DrawSprite(0)
161
162
if editor.showGizmos == true
163
editor.drawingOverlay = true
164
165
// Draw the Platform's range, using those values from earlier
166
167
DrawArrow(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)
168
DrawArrow(object.xpos, temp1, object.xpos, temp0, 255, 255, 255)
169
170
editor.drawingOverlay = false
171
end if
172
end event
173
174
175
event RSDKLoad
176
CheckCurrentStageFolder("Zone01")
177
if checkResult == true
178
LoadSpriteSheet("EHZ/Objects.gif")
179
SpriteFrame(-32, -52, 64, 96, 127, 1)
180
else
181
LoadSpriteSheet("MBZ/Objects.gif")
182
SpriteFrame(-32, -46, 64, 96, 1, 305)
183
end if
184
185
AddEditorVariable("startDir")
186
SetActiveVariable("startDir")
187
AddEnumVariable("Up", 0)
188
AddEnumVariable("Down", 1)
189
end event
190
191