Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/GHZ/VPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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
65
object.collisionOffset.y = object.ypos
66
object.collisionOffset.y &= 0xFFFF0000
67
object.collisionOffset.y -= temp7
68
69
object.ypos = temp7
70
71
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
72
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
73
if checkResult == true
74
player[currentPlayer].ypos += object.collisionOffset.y
75
end if
76
next
77
78
object.ypos = temp1
79
end event
80
81
82
event ObjectDraw
83
DrawSprite(0)
84
end event
85
86
87
event ObjectStartup
88
LoadSpriteSheet("GHZ/Objects.gif")
89
SpriteFrame(-32, -14, 64, 32, 50, 18)
90
91
foreach (TypeName[V Platform], arrayPos0, ALL_ENTITIES)
92
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
93
next
94
95
SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)
96
SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
97
SetTableValue(VPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
98
DebugMode_ObjCount++
99
end event
100
101
102
// ========================
103
// Editor Events
104
// ========================
105
106
event RSDKEdit
107
if editor.returnVariable == true
108
switch editor.variableID
109
case EDIT_VAR_PROPVAL // property value
110
checkResult = object.propertyValue
111
break
112
113
case 0 // startDir
114
checkResult = object.propertyValue
115
break
116
117
end switch
118
else
119
switch editor.variableID
120
case EDIT_VAR_PROPVAL // property value
121
object.propertyValue = editor.variableValue
122
break
123
124
case 0 // startDir
125
object.propertyValue = editor.variableValue
126
break
127
128
end switch
129
end if
130
end event
131
132
133
event RSDKDraw
134
DrawSprite(0)
135
136
if editor.showGizmos == true
137
// Draw some lines and ghosts to indicate where this platform is gonna go and that it's a vertical type
138
// (Otherwise it's just the generic platform sprite, which is shared between two other objects in GHZ)
139
140
editor.drawingOverlay = true
141
142
object.inkEffect = INK_BLEND
143
144
temp0 = 0x408000
145
temp0 += object.ypos
146
DrawSpriteFX(0, FX_INK, object.xpos, temp0)
147
148
temp1 = -0x3F8000
149
temp1 += object.ypos
150
DrawSpriteFX(0, FX_INK, object.xpos, temp1)
151
152
DrawArrow(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)
153
DrawArrow(object.xpos, temp1, object.xpos, temp0, 255, 255, 255)
154
155
object.inkEffect = INK_NONE
156
157
editor.drawingOverlay = false
158
end if
159
end event
160
161
162
event RSDKLoad
163
LoadSpriteSheet("GHZ/Objects.gif")
164
SpriteFrame(-32, -14, 64, 32, 50, 18)
165
166
AddEditorVariable("startDir")
167
SetActiveVariable("startDir")
168
AddEnumVariable("Up", 0)
169
AddEnumVariable("Down", 1)
170
end event
171
172