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/CPZ/HPlatform.txt
1479 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.centerPos.x
13
private alias object.value1 : object.hitboxL
14
private alias object.value2 : object.hitboxR
15
private alias object.value3 : object.stoodPlayers
16
17
// Player Aliases
18
private alias object.xpos : player.xpos
19
20
private alias object.value17 : debugMode.currentSelection
21
22
23
// ========================
24
// Function Declarations
25
// ========================
26
27
reserve function HPlatform_DebugDraw
28
reserve function HPlatform_DebugSpawn
29
30
31
// ========================
32
// Static Values
33
// ========================
34
35
private value HPlatform_debugStartID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function HPlatform_DebugDraw
43
temp0 = debugMode[0].currentSelection
44
temp0 -= HPlatform_debugStartID
45
DrawSprite(temp0)
46
end function
47
48
49
private function HPlatform_DebugSpawn
50
temp0 = debugMode[0].currentSelection
51
temp0 -= HPlatform_debugStartID
52
CreateTempObject(TypeName[H Platform], temp0, object.xpos, object.ypos)
53
54
object[tempObjectPos].centerPos.x = object.xpos
55
object[tempObjectPos].direction = object.direction
56
if object[tempObjectPos].propertyValue == 0
57
object[tempObjectPos].hitboxL = -32
58
object[tempObjectPos].hitboxR = 32
59
else
60
object[tempObjectPos].hitboxL = -24
61
object[tempObjectPos].hitboxR = 24
62
end if
63
end function
64
65
66
// ========================
67
// Events
68
// ========================
69
70
event ObjectUpdate
71
temp6 = object.xpos
72
GetTableValue(temp0, 6, StageSetup_oscillationTable)
73
if object.direction == FLIP_X // (FLIP_XY won't flip the platform, so don't try that)
74
FlipSign(temp0)
75
temp0 += 0x6000
76
end if
77
temp0 <<= 8
78
79
object.xpos = object.centerPos.x
80
object.xpos -= temp0
81
temp6 &= 0xFFFF0000
82
temp7 = object.xpos
83
temp7 &= 0xFFFF0000
84
temp7 -= temp6
85
86
temp2 = 0
87
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
88
GetBit(temp0, object.stoodPlayers, temp2)
89
if temp0 == true
90
player[currentPlayer].xpos += temp7
91
end if
92
93
SetBit(object.stoodPlayers, temp2, false)
94
BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitboxL, -16, object.hitboxR, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
95
if checkResult == true
96
SetBit(object.stoodPlayers, temp2, true)
97
end if
98
99
temp2++
100
next
101
end event
102
103
104
event ObjectDraw
105
DrawSprite(object.propertyValue)
106
end event
107
108
109
event ObjectStartup
110
LoadSpriteSheet("CPZ/Objects.gif")
111
SpriteFrame(-32, -16, 64, 27, 136, 155)
112
SpriteFrame(-24, -16, 48, 26, 136, 183)
113
114
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
115
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
116
if object[arrayPos0].propertyValue == 0
117
object[arrayPos0].hitboxL = -32
118
object[arrayPos0].hitboxR = 32
119
else
120
object[arrayPos0].hitboxL = -24
121
object[arrayPos0].hitboxR = 24
122
end if
123
next
124
125
temp0 = 0
126
HPlatform_debugStartID = DebugMode_ObjCount
127
while temp0 < 2
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
temp0++
133
loop
134
end event
135
136
137
// ========================
138
// Editor Events
139
// ========================
140
141
event RSDKEdit
142
if editor.returnVariable == true
143
switch editor.variableID
144
case EDIT_VAR_PROPVAL // property value
145
checkResult = object.propertyValue
146
break
147
148
case 0 // type
149
checkResult = object.propertyValue
150
break
151
152
end switch
153
else
154
switch editor.variableID
155
case EDIT_VAR_PROPVAL // property value
156
object.propertyValue = editor.variableValue
157
break
158
159
case 0 // type
160
object.propertyValue = editor.variableValue
161
break
162
163
end switch
164
end if
165
end event
166
167
168
event RSDKDraw
169
DrawSprite(object.propertyValue)
170
171
if editor.showGizmos == true
172
// Draw arrows to indicate that this is an H platform
173
174
editor.drawingOverlay = true
175
176
temp0 = object.xpos
177
temp0 -= 0x320000
178
DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 0, 224, 0)
179
temp0 = object.xpos
180
temp0 += 0x320000
181
DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 0, 224, 0)
182
183
editor.drawingOverlay = false
184
end if
185
end event
186
187
188
event RSDKLoad
189
LoadSpriteSheet("CPZ/Objects.gif")
190
SpriteFrame(-32, -16, 64, 27, 136, 155)
191
SpriteFrame(-24, -16, 48, 26, 136, 183)
192
193
AddEditorVariable("type")
194
SetActiveVariable("type")
195
AddEnumVariable("Large", 0)
196
AddEnumVariable("Small", 1)
197
end event
198
199