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/HPlatform.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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.collisionOffset.x
16
private alias object.value4 : object.collisionOffset.y
17
private alias object.value5 : object.stoodAngle
18
19
// Player Aliases
20
private alias object.xpos : player.xpos
21
private alias object.ypos : player.ypos
22
23
24
// ========================
25
// Function Declarations
26
// ========================
27
28
reserve function HPlatform_DebugDraw
29
reserve function HPlatform_DebugSpawn
30
31
32
// ========================
33
// Function Definitions
34
// ========================
35
36
private function HPlatform_DebugDraw
37
DrawSprite(0)
38
end function
39
40
41
private function HPlatform_DebugSpawn
42
CreateTempObject(TypeName[H Platform], 0, object.xpos, object.ypos)
43
object[tempObjectPos].centerPos.x = object.xpos
44
object[tempObjectPos].centerPos.y = object.ypos
45
object[tempObjectPos].propertyValue = object.direction
46
end function
47
48
49
// ========================
50
// Events
51
// ========================
52
53
event ObjectUpdate
54
temp6 = object.xpos
55
temp7 = object.ypos
56
57
GetTableValue(temp0, 12, StageSetup_oscillationTable)
58
if object.propertyValue == 1
59
FlipSign(temp0)
60
temp0 += 0x4000
61
else
62
temp0 -= 0x4000
63
end if
64
temp0 <<= 8
65
object.xpos = object.centerPos.x
66
object.xpos -= temp0
67
68
if object.stood == true
69
if object.stoodAngle < 64
70
object.stoodAngle += 4
71
end if
72
else
73
if object.stoodAngle > 0
74
object.stoodAngle -= 4
75
end if
76
end if
77
78
temp0 = object.stoodAngle
79
temp0 <<= 1
80
Sin(temp1, temp0)
81
temp1 <<= 9
82
object.ypos = object.centerPos.y
83
object.ypos += temp1
84
85
object.stood = false
86
temp0 = object.xpos
87
temp1 = object.ypos
88
temp6 &= 0xFFFF0000
89
temp7 &= 0xFFFF0000
90
object.collisionOffset.x = object.xpos
91
object.collisionOffset.x &= 0xFFFF0000
92
object.collisionOffset.x -= temp6
93
object.collisionOffset.y = object.ypos
94
object.collisionOffset.y &= 0xFFFF0000
95
object.collisionOffset.y -= temp7
96
97
object.xpos = temp6
98
object.ypos = temp7
99
100
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
101
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
102
if checkResult == true
103
object.stood = true
104
player[currentPlayer].xpos += object.collisionOffset.x
105
player[currentPlayer].ypos += object.collisionOffset.y
106
end if
107
next
108
109
object.xpos = temp0
110
object.ypos = temp1
111
end event
112
113
114
event ObjectDraw
115
DrawSprite(0)
116
end event
117
118
119
event ObjectStartup
120
CheckCurrentStageFolder("Zone01")
121
if checkResult == true
122
LoadSpriteSheet("EHZ/Objects.gif")
123
SpriteFrame(-32, -12, 64, 32, 127, 98)
124
else
125
LoadSpriteSheet("MBZ/Objects.gif")
126
SpriteFrame(-32, -8, 64, 32, 1, 402)
127
end if
128
129
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
130
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
131
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
132
next
133
134
SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)
135
SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
136
SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
137
DebugMode_ObjCount++
138
end event
139
140
141
// ========================
142
// Editor Events
143
// ========================
144
145
event RSDKEdit
146
if editor.returnVariable == true
147
switch editor.variableID
148
case EDIT_VAR_PROPVAL // property value
149
checkResult = object.propertyValue
150
break
151
152
case 0 // startDir
153
checkResult = object.propertyValue
154
break
155
156
end switch
157
else
158
switch editor.variableID
159
case EDIT_VAR_PROPVAL // property value
160
object.propertyValue = editor.variableValue
161
break
162
163
case 0 // startDir
164
object.propertyValue = editor.variableValue
165
break
166
167
end switch
168
end if
169
end event
170
171
172
event RSDKDraw
173
if editor.showGizmos == true
174
editor.drawingOverlay = true
175
176
// Draw ghosts of the platform's destination, notably *before* the main platform sprite is drawn
177
178
object.inkEffect = INK_BLEND
179
180
// Right end
181
temp0 = object.xpos
182
temp0 += 0x408000
183
184
// Left end
185
temp1 = object.xpos
186
temp1 -= 0x408000
187
188
DrawSpriteFX(0, FX_INK, temp0, object.ypos)
189
DrawSpriteFX(0, FX_INK, temp1, object.ypos)
190
191
object.inkEffect = INK_NONE
192
193
editor.drawingOverlay = false
194
end if
195
196
DrawSprite(0)
197
198
if editor.showGizmos == true
199
editor.drawingOverlay = true
200
201
// Now draw some arrows, pulling from the temp values calculated before
202
DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 255, 255, 255)
203
DrawArrow(object.xpos, object.ypos, temp1, object.ypos, 255, 255, 255)
204
205
editor.drawingOverlay = false
206
end if
207
end event
208
209
210
event RSDKLoad
211
CheckCurrentStageFolder("Zone01")
212
if checkResult == true
213
LoadSpriteSheet("EHZ/Objects.gif")
214
SpriteFrame(-32, -12, 64, 32, 127, 98)
215
else
216
LoadSpriteSheet("MBZ/Objects.gif")
217
SpriteFrame(-32, -8, 64, 32, 1, 402)
218
end if
219
220
AddEditorVariable("startDir")
221
SetActiveVariable("startDir")
222
AddEnumVariable("Left", 0)
223
AddEnumVariable("Right", 1)
224
end event
225
226