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/WFZ/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.centerPos.x
13
private alias object.value1 : object.hitbox.left
14
private alias object.value2 : object.hitbox.right
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
// Static Values
32
// ========================
33
34
private value HPlatform_startDebugID = 0
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function HPlatform_DebugDraw
42
temp0 = debugMode[0].currentSelection
43
temp0 -= HPlatform_startDebugID
44
DrawSprite(temp0)
45
end function
46
47
48
private function HPlatform_DebugSpawn
49
temp0 = debugMode[0].currentSelection
50
temp0 -= HPlatform_startDebugID
51
CreateTempObject(TypeName[H Platform], temp0, object.xpos, object.ypos)
52
53
object[tempObjectPos].centerPos.x = object.xpos
54
object[tempObjectPos].direction = object.direction
55
if object[tempObjectPos].propertyValue == 0
56
object[tempObjectPos].hitbox.left = -32
57
object[tempObjectPos].hitbox.right = 32
58
else
59
object[tempObjectPos].hitbox.left = -24
60
object[tempObjectPos].hitbox.right = 24
61
end if
62
end function
63
64
65
// ========================
66
// Events
67
// ========================
68
69
event ObjectUpdate
70
temp6 = object.xpos
71
GetTableValue(temp0, 6, StageSetup_oscillationTable)
72
if object.direction == FLIP_X
73
FlipSign(temp0)
74
temp0 += 0x6000
75
end if
76
temp0 <<= 8
77
78
object.xpos = object.centerPos.x
79
object.xpos -= temp0
80
temp6 &= 0xFFFF0000
81
temp7 = object.xpos
82
temp7 &= 0xFFFF0000
83
temp7 -= temp6
84
85
temp2 = 0
86
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
87
GetBit(temp0, object.stoodPlayers, temp2)
88
if temp0 == true
89
player[currentPlayer].xpos += temp7
90
end if
91
92
SetBit(object.stoodPlayers, temp2, false)
93
BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitbox.left, -16, object.hitbox.right, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
94
if checkResult == true
95
SetBit(object.stoodPlayers, temp2, true)
96
end if
97
temp2++
98
next
99
end event
100
101
102
event ObjectDraw
103
DrawSprite(object.propertyValue)
104
end event
105
106
107
event ObjectStartup
108
LoadSpriteSheet("SCZ/Objects.gif")
109
SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0
110
SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1
111
112
foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)
113
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
114
if object[arrayPos0].propertyValue == 0
115
object[arrayPos0].hitbox.left = -32
116
object[arrayPos0].hitbox.right = 32
117
else
118
object[arrayPos0].hitbox.left = -24
119
object[arrayPos0].hitbox.right = 24
120
end if
121
next
122
123
temp0 = 0
124
HPlatform_startDebugID = DebugMode_ObjCount
125
while temp0 < 2
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
temp0++
131
loop
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 // type
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 // type
158
object.propertyValue = editor.variableValue
159
break
160
161
end switch
162
end if
163
end event
164
165
166
event RSDKDraw
167
DrawSprite(object.propertyValue)
168
end event
169
170
171
event RSDKLoad
172
LoadSpriteSheet("SCZ/Objects.gif")
173
SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0
174
SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1
175
176
AddEditorVariable("type")
177
SetActiveVariable("type")
178
AddEnumVariable("Small Platform", 0)
179
AddEnumVariable("Wide Platform", 1)
180
end event
181
182