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/HPlatform2.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: H Platform 2 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 HPlatform2_DebugDraw
28
reserve function HPlatform2_DebugSpawn
29
30
31
// ========================
32
// Static Values
33
// ========================
34
35
private value HPlatform2_startDebugID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function HPlatform2_DebugDraw
43
temp0 = debugMode[0].currentSelection
44
temp0 -= HPlatform2_startDebugID
45
DrawSprite(temp0)
46
end function
47
48
49
private function HPlatform2_DebugSpawn
50
temp0 = debugMode[0].currentSelection
51
temp0 -= HPlatform2_startDebugID
52
CreateTempObject(TypeName[H Platform 2], 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].hitbox.left = -32
58
object[tempObjectPos].hitbox.right = 32
59
else
60
object[tempObjectPos].hitbox.left = -24
61
object[tempObjectPos].hitbox.right = 24
62
end if
63
end function
64
65
66
// ========================
67
// Events
68
// ========================
69
70
event ObjectUpdate
71
temp6 = object.xpos
72
GetTableValue(temp0, 4, StageSetup_oscillationTable)
73
if object.direction == FLIP_X
74
FlipSign(temp0)
75
temp0 += 0x4000
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.hitbox.left, -16, object.hitbox.right, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
95
if checkResult == true
96
SetBit(object.stoodPlayers, temp2, true)
97
end if
98
temp2++
99
next
100
end event
101
102
103
event ObjectDraw
104
DrawSprite(object.propertyValue)
105
end event
106
107
108
event ObjectStartup
109
LoadSpriteSheet("SCZ/Objects.gif")
110
SpriteFrame(-24, -16, 48, 24, 381, 178)
111
SpriteFrame(-32, -16, 64, 24, 1, 146)
112
113
foreach (TypeName[H Platform 2], arrayPos0, ALL_ENTITIES)
114
object[arrayPos0].centerPos.x = object[arrayPos0].xpos
115
if object[arrayPos0].propertyValue == 0
116
object[arrayPos0].hitbox.left = -32
117
object[arrayPos0].hitbox.right = 32
118
else
119
object[arrayPos0].hitbox.left = -24
120
object[arrayPos0].hitbox.right = 24
121
end if
122
next
123
124
temp0 = 0
125
HPlatform2_startDebugID = DebugMode_ObjCount
126
while temp0 < 2
127
SetTableValue(TypeName[H Platform 2], DebugMode_ObjCount, DebugMode_TypesTable)
128
SetTableValue(HPlatform2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
129
SetTableValue(HPlatform2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
130
DebugMode_ObjCount++
131
temp0++
132
loop
133
end event
134
135
136
// ========================
137
// Editor Events
138
// ========================
139
140
event RSDKEdit
141
if editor.returnVariable == true
142
switch editor.variableID
143
case EDIT_VAR_PROPVAL // property value
144
checkResult = object.propertyValue
145
break
146
147
case 0 // type
148
checkResult = object.propertyValue
149
break
150
151
end switch
152
else
153
switch editor.variableID
154
case EDIT_VAR_PROPVAL // property value
155
object.propertyValue = editor.variableValue
156
break
157
158
case 0 // type
159
object.propertyValue = editor.variableValue
160
break
161
162
end switch
163
end if
164
end event
165
166
167
event RSDKDraw
168
DrawSprite(object.propertyValue)
169
end event
170
171
172
event RSDKLoad
173
LoadSpriteSheet("SCZ/Objects.gif")
174
SpriteFrame(-24, -16, 48, 24, 381, 178)
175
SpriteFrame(-32, -16, 64, 24, 1, 146)
176
177
AddEditorVariable("type")
178
SetActiveVariable("type")
179
AddEnumVariable("Small Platform", 0)
180
AddEnumVariable("Wide Platform", 1)
181
end event
182
183