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/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.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
LoadSpriteSheet("GHZ/Objects.gif")
121
SpriteFrame(-32, -14, 64, 32, 50, 18)
122
123
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
124
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
125
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
126
next
127
128
SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)
129
SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
130
SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
131
DebugMode_ObjCount++
132
end event
133
134
135
// ========================
136
// Editor Events
137
// ========================
138
139
event RSDKEdit
140
if editor.returnVariable == true
141
switch editor.variableID
142
case EDIT_VAR_PROPVAL // property value
143
checkResult = object.propertyValue
144
break
145
146
case 0 // startDir
147
checkResult = object.propertyValue
148
break
149
150
end switch
151
else
152
switch editor.variableID
153
case EDIT_VAR_PROPVAL // property value
154
object.propertyValue = editor.variableValue
155
break
156
157
case 0 // startDir
158
object.propertyValue = editor.variableValue
159
break
160
161
end switch
162
end if
163
end event
164
165
166
event RSDKDraw
167
if editor.showGizmos == true
168
editor.drawingOverlay = true
169
170
// Draw ghosts of the platform's destination, notably *before* the main platform sprite is drawn
171
172
object.inkEffect = INK_BLEND
173
174
// Right end
175
temp0 = object.xpos
176
temp0 += 0x408000
177
178
// Left end
179
temp1 = object.xpos
180
temp1 -= 0x408000
181
182
DrawSpriteFX(0, FX_INK, temp0, object.ypos)
183
DrawSpriteFX(0, FX_INK, temp1, object.ypos)
184
185
editor.drawingOverlay = false
186
end if
187
188
DrawSprite(0)
189
190
if editor.showGizmos == true
191
editor.drawingOverlay = true
192
193
// Now draw some arrows, pulling from the temp values calculated before
194
195
DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 255, 255, 255)
196
DrawArrow(object.xpos, object.ypos, temp1, object.ypos, 255, 255, 255)
197
198
editor.drawingOverlay = false
199
end if
200
end event
201
202
203
event RSDKLoad
204
LoadSpriteSheet("GHZ/Objects.gif")
205
SpriteFrame(-32, -14, 64, 32, 50, 18)
206
207
AddEditorVariable("startDir")
208
SetActiveVariable("startDir")
209
AddEnumVariable("Left", 0)
210
AddEnumVariable("Right", 1)
211
end event
212
213