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/VPlatform2.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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, -2, 32, 12, 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
LoadSpriteSheet("GHZ/Objects.gif")
86
SpriteFrame(-32, -8, 64, 144, 191, 1)
87
88
foreach (TypeName[V Platform 2], arrayPos0, ALL_ENTITIES)
89
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
90
next
91
92
SetTableValue(TypeName[V Platform 2], DebugMode_ObjCount, DebugMode_TypesTable)
93
SetTableValue(VPlatform2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
94
SetTableValue(VPlatform2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
95
DebugMode_ObjCount++
96
end event
97
98
99
// ========================
100
// Editor Events
101
// ========================
102
103
event RSDKEdit
104
if editor.returnVariable == true
105
switch editor.variableID
106
case EDIT_VAR_PROPVAL // property value
107
checkResult = object.propertyValue
108
break
109
110
case 0 // startDir
111
checkResult = object.propertyValue
112
break
113
114
end switch
115
else
116
switch editor.variableID
117
case EDIT_VAR_PROPVAL // property value
118
object.propertyValue = editor.variableValue
119
break
120
121
case 0 // startDir
122
object.propertyValue = editor.variableValue
123
break
124
125
end switch
126
end if
127
end event
128
129
130
event RSDKDraw
131
DrawSprite(0)
132
133
if editor.showGizmos == true
134
// Clarify that this object isn't just part of the level terrain, draw some lines
135
136
// TODO: probably best to make sure these arrows somewhat accurately represent how far it'll go in-game
137
// i have no idea how these currently look since i haven't been given any fancy re2 betas yet but the values probably look wrong
138
// the "correct" values could probably be reused from Mania's version of the object preview, although i don't have access to that either...
139
// edit: the miracle happen;
140
// github down rn but snag values from there once it's back up
141
// perhaps used cropped frame so that bottom of sprite so lower end doesn't stick out more than it should, only have grass ghost
142
143
editor.drawingOverlay = true
144
145
temp0 = 0x204000
146
temp0 += object.ypos
147
temp1 = -0x1FC000
148
temp1 += object.ypos
149
150
DrawLine(object.xpos, temp0, object.xpos, temp1, 255, 255, 255)
151
152
editor.drawingOverlay = false
153
end if
154
end event
155
156
157
event RSDKLoad
158
LoadSpriteSheet("GHZ/Objects.gif")
159
SpriteFrame(-32, -8, 64, 144, 191, 1)
160
161
AddEditorVariable("startDir")
162
SetActiveVariable("startDir")
163
AddEnumVariable("Up", 0)
164
AddEnumVariable("Down", 1)
165
end event
166
167