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/SYZ/HPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: H 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.stood
13
private alias object.value1 : object.centerPos.x
14
private alias object.value2 : object.centerPos.y
15
private alias object.value3 : object.stoodAngle
16
17
// Player Aliases
18
private alias object.xpos : player.xpos
19
private alias object.ypos : player.ypos
20
21
22
// ========================
23
// Function Declarations
24
// ========================
25
26
reserve function HPlatform_DebugDraw
27
reserve function HPlatform_DebugSpawn
28
29
30
// ========================
31
// Tables
32
// ========================
33
34
private function HPlatform_DebugDraw
35
DrawSprite(0)
36
end function
37
38
39
private function HPlatform_DebugSpawn
40
CreateTempObject(TypeName[H Platform], object.direction, object.xpos, object.ypos)
41
object[tempObjectPos].centerPos.x = object.xpos
42
object[tempObjectPos].centerPos.y = object.ypos
43
end function
44
45
46
// ========================
47
// Events
48
// ========================
49
50
event ObjectUpdate
51
temp6 = object.xpos
52
temp7 = object.ypos
53
GetTableValue(temp0, 12, StageSetup_oscillationTable)
54
GetBit(temp1, object.propertyValue, 0)
55
if temp1 == 1
56
FlipSign(temp0)
57
temp0 += 0x4000
58
else
59
temp0 -= 0x4000
60
end if
61
temp0 <<= 8
62
63
object.xpos = object.centerPos.x
64
object.xpos -= temp0
65
66
if object.stood == true
67
if object.stoodAngle < 64
68
object.stoodAngle += 4
69
end if
70
else
71
if object.stoodAngle > 0
72
object.stoodAngle -= 4
73
end if
74
end if
75
76
temp0 = object.stoodAngle
77
temp0 <<= 1
78
Sin(temp1, temp0)
79
temp1 <<= 9
80
object.ypos = object.centerPos.y
81
object.ypos += temp1
82
83
object.stood = false
84
85
temp0 = object.xpos
86
temp1 = object.ypos
87
temp6 &= 0xFFFF0000
88
temp7 &= 0xFFFF0000
89
temp4 = object.xpos
90
temp4 &= 0xFFFF0000
91
temp4 -= temp6
92
temp5 = object.ypos
93
temp5 &= 0xFFFF0000
94
temp5 -= temp7
95
96
object.xpos = temp6
97
object.ypos = temp7
98
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
99
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
100
if checkResult == true
101
object.stood = true
102
player[currentPlayer].xpos += temp4
103
player[currentPlayer].ypos += temp5
104
end if
105
next
106
107
object.xpos = temp0
108
object.ypos = temp1
109
end event
110
111
112
event ObjectDraw
113
DrawSprite(0)
114
end event
115
116
117
event ObjectStartup
118
LoadSpriteSheet("SYZ/Objects.gif")
119
SpriteFrame(-32, -10, 64, 32, 119, 1)
120
121
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
122
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
123
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
124
next
125
126
SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)
127
SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
128
SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
129
DebugMode_ObjCount++
130
end event
131
132
133
// ========================
134
// Editor Events
135
// ========================
136
137
event RSDKEdit
138
if editor.returnVariable == true
139
switch editor.variableID
140
case EDIT_VAR_PROPVAL // property value
141
checkResult = object.propertyValue
142
break
143
144
case 0 // startDir
145
GetBit(checkResult, object.propertyValue, 0)
146
break
147
148
end switch
149
else
150
switch editor.variableID
151
case EDIT_VAR_PROPVAL // property value
152
object.propertyValue = editor.variableValue
153
break
154
155
case 0 // startDir
156
CheckNotEqual(editor.variableValue, false)
157
SetBit(object.propertyValue, 0, checkResult)
158
break
159
160
end switch
161
end if
162
end event
163
164
165
event RSDKDraw
166
DrawSprite(0)
167
168
if editor.showGizmos == true
169
editor.drawingOverlay = true
170
171
// Draw some lines to indicate where this platform is gonna go and that it's a horizontal type
172
// (Otherwise it's just the generic platform sprite, which is shared between two other objects)
173
174
// object.inkEffect = INK_BLEND
175
176
temp0 = 0x3f8000
177
temp0 += object.xpos
178
// DrawSpriteFX(0, FX_INK, temp0, object.ypos)
179
180
temp1 = -0x408000
181
temp1 += object.xpos
182
// DrawSpriteFX(0, FX_INK, temp1, object.ypos)
183
184
DrawLine(temp0, object.ypos, temp1, object.ypos, 255, 255, 255)
185
186
// object.inkEffect = INK_NONE
187
188
editor.drawingOverlay = false
189
end if
190
end event
191
192
193
event RSDKLoad
194
LoadSpriteSheet("SYZ/Objects.gif")
195
SpriteFrame(-32, -10, 64, 32, 119, 1)
196
197
AddEditorVariable("startDir")
198
SetActiveVariable("startDir")
199
AddEnumVariable("Left", 0)
200
AddEnumVariable("Right", 1)
201
202
// there is apparently another variable (uses bit 1, while startDir uses bit 0), though its not used and thus idk what it is
203
// TODO: I may have an inkling as to what it may be, investigate some more
204
end event
205
206