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/HTZ/VPlatform.txt
1479 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
// Backup the object's position and temporarily move it for collision checks
69
object.ypos = temp7
70
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
71
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
72
if checkResult == true
73
player[currentPlayer].ypos += object.collisionOffset.y
74
end if
75
next
76
object.ypos = temp1
77
end event
78
79
80
event ObjectDraw
81
DrawSprite(0)
82
end event
83
84
85
event ObjectStartup
86
LoadSpriteSheet("HTZ/Objects.gif")
87
SpriteFrame(-32, -12, 64, 32, 191, 223)
88
89
foreach (TypeName[V Platform], arrayPos0, ALL_ENTITIES)
90
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
91
next
92
93
SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)
94
SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
95
SetTableValue(VPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
96
DebugMode_ObjCount++
97
end event
98
99
100
// ========================
101
// Editor Events
102
// ========================
103
104
event RSDKEdit
105
if editor.returnVariable == true
106
switch editor.variableID
107
case EDIT_VAR_PROPVAL // property value
108
checkResult = object.propertyValue
109
break
110
111
case 0 // startDir
112
checkResult = object.propertyValue
113
checkResult &= 1
114
break
115
116
end switch
117
else
118
switch editor.variableID
119
case EDIT_VAR_PROPVAL // property value
120
object.propertyValue = editor.variableValue
121
break
122
123
case 0 // startDir
124
object.propertyValue = editor.variableValue
125
object.propertyValue &= 1
126
break
127
128
end switch
129
end if
130
end event
131
132
133
event RSDKDraw
134
DrawSprite(0)
135
end event
136
137
138
event RSDKLoad
139
LoadSpriteSheet("HTZ/Objects.gif")
140
SpriteFrame(-32, -12, 64, 32, 191, 223)
141
142
AddEditorVariable("startDir")
143
SetActiveVariable("startDir")
144
AddEnumVariable("Up", 0)
145
AddEnumVariable("Down", 1)
146
end event
147
148