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/HTZ/FPlatform.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Fall 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.collisionOffset.y
14
private alias object.value2 : object.timer
15
private alias object.value3 : object.centerPos.y
16
private alias object.value4 : object.stoodAngle
17
18
private alias 0 : FPLATFORM_IDLE
19
private alias 1 : FPLATFORM_FALLING_SOLID
20
private alias 2 : FPLATFORM_FALLING
21
private alias 3 : FPLATFORM_OFFSCREEN
22
23
// Player Aliases
24
private alias object.ypos : player.ypos
25
private alias object.yvel : player.yvel
26
private alias object.gravity : player.gravity
27
28
29
// ========================
30
// Function Declarations
31
// ========================
32
33
reserve function FallPlatform_DebugDraw
34
reserve function FallPlatform_DebugSpawn
35
36
37
private function FallPlatform_DebugDraw
38
DrawSprite(0)
39
end function
40
41
42
private function FallPlatform_DebugSpawn
43
CreateTempObject(TypeName[Fall Platform], 0, object.xpos, object.ypos)
44
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
45
end function
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
if object.stood == true
54
if object.timer == 0
55
object.priority = PRIORITY_ACTIVE
56
object.timer = 30
57
end if
58
if object.stoodAngle < 64
59
object.stoodAngle += 4
60
end if
61
else
62
if object.stoodAngle > 0
63
object.stoodAngle -= 4
64
end if
65
end if
66
67
temp0 = object.ypos
68
temp0 &= 0xFFFF0000
69
switch object.state
70
case FPLATFORM_IDLE
71
temp1 = object.stoodAngle
72
temp1 <<= 1
73
Sin(temp2, temp1)
74
temp2 <<= 9
75
object.ypos = object.centerPos.y
76
object.ypos += temp2
77
if object.propertyValue == 0 // Falling variant?
78
if object.timer != 0
79
object.timer--
80
if object.timer == 0
81
object.state++
82
object.timer = 32
83
end if
84
end if
85
end if
86
break
87
88
case FPLATFORM_FALLING_SOLID
89
object.timer--
90
if object.timer == 0
91
object.state++
92
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
93
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
94
if checkResult == true
95
player[currentPlayer].ypos += object.yvel
96
player[currentPlayer].yvel = object.yvel
97
player[currentPlayer].yvel -= 0x3800
98
player[currentPlayer].gravity = GRAVITY_AIR
99
end if
100
next
101
end if
102
// [Fallthrough]
103
case FPLATFORM_FALLING
104
object.ypos += object.yvel
105
object.yvel += 0x3800
106
if object.outOfBounds == true
107
object.ypos = object.centerPos.y
108
object.yvel = 0
109
object.timer = 0
110
object.state++
111
end if
112
break
113
114
case FPLATFORM_OFFSCREEN
115
if object.outOfBounds == true
116
object.state = 0
117
object.priority = PRIORITY_BOUNDS
118
end if
119
break
120
121
end switch
122
123
object.collisionOffset.y = object.ypos
124
object.collisionOffset.y &= 0xFFFF0000
125
object.collisionOffset.y -= temp0
126
object.stood = false
127
128
if object.state < 2
129
temp1 = object.ypos
130
object.ypos = temp0
131
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
132
BoxCollisionTest(C_PLATFORM, object.entityPos, -32, -8, 32, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
133
134
if checkResult == true
135
object.stood = true
136
player[currentPlayer].ypos += object.collisionOffset.y
137
end if
138
next
139
object.ypos = temp1
140
end if
141
end event
142
143
144
event ObjectDraw
145
if object.state < 3
146
DrawSprite(0)
147
end if
148
end event
149
150
151
event ObjectStartup
152
LoadSpriteSheet("HTZ/Objects.gif")
153
SpriteFrame(-32, -12, 64, 32, 191, 223)
154
155
foreach (TypeName[Fall Platform], arrayPos0, ALL_ENTITIES)
156
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
157
next
158
159
SetTableValue(TypeName[Fall Platform], DebugMode_ObjCount, DebugMode_TypesTable)
160
SetTableValue(FallPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
161
SetTableValue(FallPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
162
DebugMode_ObjCount++
163
end event
164
165
166
// ========================
167
// Editor Events
168
// ========================
169
170
event RSDKEdit
171
if editor.returnVariable == true
172
switch editor.variableID
173
case EDIT_VAR_PROPVAL // property value
174
checkResult = object.propertyValue
175
break
176
177
case 0 // type
178
checkResult = object.propertyValue
179
break
180
181
end switch
182
else
183
switch editor.variableID
184
case EDIT_VAR_PROPVAL // property value
185
object.propertyValue = editor.variableValue
186
break
187
188
case 0 // type
189
object.propertyValue = editor.variableValue
190
break
191
192
end switch
193
end if
194
end event
195
196
197
event RSDKDraw
198
DrawSprite(0)
199
end event
200
201
202
event RSDKLoad
203
LoadSpriteSheet("HTZ/Objects.gif")
204
SpriteFrame(-32, -12, 64, 32, 191, 223)
205
206
AddEditorVariable("type")
207
SetActiveVariable("type")
208
AddEnumVariable("Falling Platform", 0)
209
AddEnumVariable("Static Platform", 1)
210
end event
211
212