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/ARZ/FallingPillar.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Falling Pillar 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
// Types
19
private alias 0 : FPILLAR_FALL
20
private alias 1 : FPILLAR_STATIC
21
22
// States
23
private alias 0 : FPILLAR_IDLE
24
private alias 1 : FPILLAR_FALLING_SOLID
25
private alias 2 : FPILLAR_FALLING
26
private alias 3 : FPILLAR_OFFSCREEN
27
private alias 4 : FPILLAR_NOFALL
28
29
// Player Aliases
30
private alias object.ypos : player.ypos
31
private alias object.gravity : player.gravity
32
33
private alias object.value17 : debugMode.currentSelection
34
35
// Path ID Aliases
36
private alias 0 : PATH_A
37
38
39
// ========================
40
// Function Declarations
41
// ========================
42
43
reserve function FallingPillar_DebugDraw
44
reserve function FallingPillar_DebugSpawn
45
46
47
// ========================
48
// Static Values
49
// ========================
50
51
private value FallingPillar_startDebugID = 0
52
53
54
// ========================
55
// Function Definitions
56
// ========================
57
58
private function FallingPillar_DebugDraw
59
DrawSprite(0)
60
DrawSprite(1)
61
DrawSprite(2)
62
end function
63
64
65
private function FallingPillar_DebugSpawn
66
temp0 = debugMode[0].currentSelection
67
temp0 -= FallingPillar_startDebugID
68
CreateTempObject(TypeName[Falling Pillar], temp0, object.xpos, object.ypos)
69
object[tempObjectPos].centerPos.y = object[tempObjectPos].ypos
70
object[tempObjectPos].state = temp0
71
object[tempObjectPos].state <<= 2
72
end function
73
74
75
// ========================
76
// Events
77
// ========================
78
79
event ObjectUpdate
80
if object.stood == true
81
if object.timer == 0
82
object.timer = 30
83
end if
84
85
if object.stoodAngle < 64
86
object.stoodAngle += 4
87
end if
88
else
89
if object.stoodAngle > 0
90
object.stoodAngle -= 4
91
end if
92
end if
93
temp0 = object.ypos
94
temp0 &= 0xFFFF0000
95
96
switch object.state
97
case FPILLAR_IDLE
98
temp1 = object.stoodAngle
99
temp1 <<= 1
100
Sin(temp2, temp1)
101
temp2 <<= 9
102
object.ypos = object.centerPos.y
103
object.ypos += temp2
104
if object.timer != 0
105
object.timer--
106
if object.timer == 0
107
object.state++
108
object.priority = PRIORITY_ACTIVE
109
end if
110
end if
111
break
112
113
case FPILLAR_FALLING_SOLID
114
object.ypos += object.yvel
115
object.yvel += 0x800
116
117
ObjectTileCollision(CSIDE_FLOOR, 0, 65, PATH_A)
118
if checkResult == true
119
object.state++
120
end if
121
122
if object.outOfBounds == true
123
object.ypos = object.centerPos.y
124
object.yvel = 0
125
object.timer = 0
126
object.state = 3
127
end if
128
break
129
// [Fallthrough]
130
case FPILLAR_FALLING
131
if object.outOfBounds == true
132
object.ypos = object.centerPos.y
133
object.yvel = 0
134
object.timer = 0
135
object.state++
136
end if
137
break
138
139
case FPILLAR_OFFSCREEN
140
if object.outOfBounds == true
141
object.state = FPILLAR_IDLE
142
object.priority = PRIORITY_BOUNDS
143
end if
144
break
145
146
case FPILLAR_NOFALL
147
break
148
149
end switch
150
151
object.collisionOffset.y = object.ypos
152
object.collisionOffset.y &= 0xFFFF0000
153
object.collisionOffset.y -= temp0
154
155
object.stood = false
156
if object.state != FPILLAR_OFFSCREEN
157
temp1 = object.ypos
158
object.ypos = temp0
159
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
160
BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 65, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
161
if checkResult == COL_TOP
162
object.stood = true
163
player[currentPlayer].ypos += object.collisionOffset.y
164
end if
165
166
if checkResult == COL_BOTTOM
167
if player[currentPlayer].gravity == GRAVITY_GROUND
168
CallFunction(Player_Kill)
169
end if
170
end if
171
next
172
object.ypos = temp1
173
end if
174
end event
175
176
177
event ObjectDraw
178
DrawSprite(0)
179
DrawSprite(1)
180
DrawSprite(2)
181
end event
182
183
184
event ObjectStartup
185
LoadSpriteSheet("ARZ/Objects.gif")
186
187
// Pillar frames
188
SpriteFrame(-28, -32, 56, 56, 59, 42)
189
SpriteFrame(-16, 24, 32, 8, 140, 80)
190
SpriteFrame(-16, 32, 32, 37, 173, 38)
191
192
// Add the Falling Pillars to the debug mode object list
193
temp0 = 0
194
FallingPillar_startDebugID = DebugMode_ObjCount
195
while temp0 < 2
196
SetTableValue(TypeName[Falling Pillar], DebugMode_ObjCount, DebugMode_TypesTable)
197
SetTableValue(FallingPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
198
SetTableValue(FallingPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
199
DebugMode_ObjCount++
200
temp0++
201
loop
202
203
foreach (TypeName[Falling Pillar], arrayPos0, ALL_ENTITIES)
204
object[arrayPos0].centerPos.y = object[arrayPos0].ypos
205
if object[arrayPos0].propertyValue == FPILLAR_STATIC
206
object[arrayPos0].state = FPILLAR_NOFALL
207
end if
208
next
209
end event
210
211
212
// ========================
213
// Editor Events
214
// ========================
215
216
event RSDKEdit
217
if editor.returnVariable == true
218
switch editor.variableID
219
case EDIT_VAR_PROPVAL // property value
220
checkResult = object.propertyValue
221
break
222
223
case 0 // type
224
checkResult = object.propertyValue
225
break
226
227
end switch
228
else
229
switch editor.variableID
230
case EDIT_VAR_PROPVAL // property value
231
object.propertyValue = editor.variableValue
232
break
233
234
case 0 // type
235
object.propertyValue = editor.variableValue
236
break
237
238
end switch
239
end if
240
end event
241
242
243
event RSDKDraw
244
DrawSprite(0)
245
DrawSprite(1)
246
DrawSprite(2)
247
end event
248
249
250
event RSDKLoad
251
LoadSpriteSheet("ARZ/Objects.gif")
252
SpriteFrame(-28, -32, 56, 56, 59, 42)
253
SpriteFrame(-16, 24, 32, 8, 140, 80)
254
SpriteFrame(-16, 32, 32, 37, 173, 38)
255
256
AddEditorVariable("type")
257
SetActiveVariable("type")
258
AddEnumVariable("Falling", FPILLAR_FALL)
259
AddEnumVariable("Static", FPILLAR_STATIC)
260
end event
261
262