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/BreakoffPillar.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Breakoff 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.offset.y
13
private alias object.value1 : object.shakePos.x
14
private alias object.value2 : object.timer
15
16
// States
17
private alias 0 : BREAKOFFPILLAR_AWAITPLAYER
18
private alias 1 : BREAKOFFPILLAR_SHAKING
19
private alias 2 : BREAKOFFPILLAR_FALLING
20
private alias 3 : BREAKOFFPILLAR_FALLEN
21
22
// Player Aliases
23
private alias object.gravity : player.gravity
24
25
// Path ID Aliases
26
private alias 0 : PATH_A
27
28
29
// ========================
30
// Function Declarations
31
// ========================
32
33
reserve function BreakoffPillar_DebugDraw
34
reserve function BreakoffPillar_DebugSpawn
35
36
37
// ========================
38
// Tables
39
// ========================
40
41
private table BreakoffPillar_shakePosTable
42
0, 0x10000, -0x10000, 0x10000, 0, -0x10000, 0, 0x10000
43
end table
44
45
46
// ========================
47
// Function Definitions
48
// ========================
49
50
private function BreakoffPillar_DebugDraw
51
DrawSprite(0)
52
DrawSprite(1)
53
DrawSprite(2)
54
end function
55
56
57
private function BreakoffPillar_DebugSpawn
58
CreateTempObject(TypeName[Breakoff Pillar], 0, object.xpos, object.ypos)
59
object[tempObjectPos].frame = 2
60
end function
61
62
63
// ========================
64
// Events
65
// ========================
66
67
event ObjectUpdate
68
switch object.state
69
case BREAKOFFPILLAR_AWAITPLAYER
70
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
71
BoxCollisionTest(C_TOUCH, object.entityPos, -128, -256, 128, 256, currentPlayer, -1, -1, 1, 1)
72
if checkResult == true
73
object.priority = PRIORITY_ACTIVE
74
object.timer = 8
75
object.state = BREAKOFFPILLAR_SHAKING
76
end if
77
next
78
break
79
80
case BREAKOFFPILLAR_SHAKING
81
object.timer--
82
if object.timer >= 0
83
GetTableValue(object.shakePos.x, object.timer, BreakoffPillar_shakePosTable)
84
else
85
object.state = BREAKOFFPILLAR_FALLING
86
end if
87
break
88
89
case BREAKOFFPILLAR_FALLING
90
object.offset.y += object.yvel
91
object.yvel += 0x3800
92
93
temp0 = object.ypos
94
object.ypos += object.offset.y
95
temp1 = object.ypos
96
ObjectTileCollision(CSIDE_FLOOR, 0, 65, PATH_A)
97
if checkResult == true
98
object.state = BREAKOFFPILLAR_FALLEN
99
object.frame++
100
end if
101
temp1 -= object.ypos
102
object.ypos = temp0
103
104
object.offset.y -= temp1
105
break
106
107
case BREAKOFFPILLAR_FALLEN
108
break
109
110
end switch
111
112
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
113
BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
114
115
temp0 = object.ypos
116
object.ypos += object.offset.y
117
BoxCollisionTest(C_SOLID, object.entityPos, -16, 32, 16, 65, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
118
if checkResult == COL_BOTTOM
119
if player[currentPlayer].gravity == GRAVITY_GROUND
120
CallFunction(Player_Kill)
121
end if
122
end if
123
object.ypos = temp0
124
next
125
126
temp0 = screen.xcenter
127
temp0 += 184
128
CheckCameraProximity(object.ixpos, 0, temp0, -1)
129
if checkResult == false
130
object.offset.y = 0
131
object.shakePos.x = 0
132
object.yvel = 0
133
object.timer = 0
134
object.frame = 2
135
object.state = BREAKOFFPILLAR_AWAITPLAYER
136
object.priority = PRIORITY_BOUNDS
137
end if
138
end event
139
140
141
event ObjectDraw
142
DrawSprite(0)
143
DrawSprite(1)
144
temp0 = object.xpos
145
temp0 += object.shakePos.x
146
temp1 = object.ypos
147
temp1 += object.offset.y
148
DrawSpriteXY(object.frame, temp0, temp1)
149
end event
150
151
152
event ObjectStartup
153
LoadSpriteSheet("ARZ/Objects.gif")
154
SpriteFrame(-28, -32, 56, 56, 59, 42)
155
SpriteFrame(-16, 24, 32, 8, 140, 80)
156
SpriteFrame(-16, 32, 32, 37, 173, 38)
157
SpriteFrame(-16, 32, 32, 41, 140, 38)
158
159
SetTableValue(TypeName[Breakoff Pillar], DebugMode_ObjCount, DebugMode_TypesTable)
160
SetTableValue(BreakoffPillar_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
161
SetTableValue(BreakoffPillar_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
162
DebugMode_ObjCount++
163
164
foreach (TypeName[Breakoff Pillar], arrayPos0, ALL_ENTITIES)
165
object[arrayPos0].frame = 2
166
next
167
end event
168
169
170
// ========================
171
// Editor Events
172
// ========================
173
174
event RSDKDraw
175
DrawSprite(0)
176
DrawSprite(1)
177
DrawSprite(2)
178
end event
179
180
181
event RSDKLoad
182
LoadSpriteSheet("ARZ/Objects.gif")
183
SpriteFrame(-28, -32, 56, 56, 59, 42)
184
SpriteFrame(-16, 24, 32, 8, 140, 80)
185
SpriteFrame(-16, 32, 32, 37, 173, 38)
186
187
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
188
end event
189
190