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/VPlatform.txt
1480 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.collisionOffset.y
14
15
// Player Aliases
16
private alias object.ypos : player.ypos
17
18
19
// ========================
20
// Function Declarations
21
// ========================
22
23
reserve function VPlatform_DebugDraw
24
reserve function VPlatform_DebugSpawn
25
26
27
// ========================
28
// Function Definitions
29
// ========================
30
31
private function VPlatform_DebugDraw
32
DrawSprite(0)
33
end function
34
35
36
private function VPlatform_DebugSpawn
37
CreateTempObject(TypeName[V Platform], 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 <<= 8
58
59
object.ypos = object.centerPos.y
60
object.ypos -= temp0
61
62
temp1 = object.ypos
63
temp7 &= 0xFFFF0000
64
object.collisionOffset.y = object.ypos
65
object.collisionOffset.y &= 0xFFFF0000
66
object.collisionOffset.y -= temp7
67
68
object.ypos = temp7
69
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
70
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
71
if checkResult == true
72
player[currentPlayer].ypos += object.collisionOffset.y
73
end if
74
next
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, -12, 64, 32, 127, 98)
89
else
90
LoadSpriteSheet("MBZ/Objects.gif")
91
SpriteFrame(-32, -8, 64, 32, 1, 402)
92
end if
93
94
foreach (TypeName[V Platform], arrayPos0, ALL_ENTITIES)
95
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
96
next
97
98
SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)
99
SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
100
SetTableValue(VPlatform_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
DrawSprite(0)
138
139
if editor.showGizmos == true
140
// Draw some lines and ghosts to indicate where this platform is gonna go and that it's a vertical type
141
// (Otherwise it's just the generic platform sprite, which is shared between two other objects in EHZ)
142
143
editor.drawingOverlay = true
144
145
object.inkEffect = INK_BLEND
146
147
temp0 = 0x408000
148
temp0 += object.ypos
149
DrawSpriteFX(0, FX_INK, object.xpos, temp0)
150
151
temp1 = -0x3F8000
152
temp1 += object.ypos
153
DrawSpriteFX(0, FX_INK, object.xpos, temp1)
154
155
object.inkEffect = INK_NONE
156
DrawArrow(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)
157
DrawArrow(object.xpos, temp1, object.xpos, temp0, 255, 255, 255)
158
159
editor.drawingOverlay = false
160
end if
161
end event
162
163
164
event RSDKLoad
165
CheckCurrentStageFolder("Zone01")
166
if checkResult == true
167
LoadSpriteSheet("EHZ/Objects.gif")
168
SpriteFrame(-32, -12, 64, 32, 127, 98)
169
else
170
LoadSpriteSheet("MBZ/Objects.gif")
171
SpriteFrame(-32, -8, 64, 32, 1, 402)
172
end if
173
174
AddEditorVariable("startDir")
175
SetActiveVariable("startDir")
176
AddEnumVariable("Up", 0)
177
AddEnumVariable("Down", 1)
178
end event
179
180