Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/LZ/FallingBlock.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Falling Block 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.startPos.y
16
private alias object.value4 : object.stoodAngle
17
18
private alias 0 : FALLINGBLOCK_IDLE
19
private alias 1 : FALLINGBLOCK_MOVING
20
private alias 2 : FALLINGBLOCK_RETURNTOSTART
21
private alias 3 : FALLINGBLOCK_OOB
22
23
// Player Aliases
24
private alias object.ypos : player.ypos
25
26
// Path ID Aliases
27
private alias 0 : PATH_A
28
29
30
// ========================
31
// Function Declarations
32
// ========================
33
34
reserve function FallingBlock_DebugDraw
35
reserve function FallingBlock_DebugSpawn
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function FallingBlock_DebugDraw
43
DrawSprite(0)
44
end function
45
46
47
private function FallingBlock_DebugSpawn
48
CreateTempObject(TypeName[Falling Block], 0, object.xpos, object.ypos)
49
object[tempObjectPos].startPos.y = object.ypos
50
end function
51
52
53
// ========================
54
// Events
55
// ========================
56
57
event ObjectUpdate
58
if object.stood == true
59
if object.timer == 0
60
object.timer = 30
61
end if
62
63
if object.stoodAngle < 64
64
object.stoodAngle += 4
65
end if
66
else
67
if object.stoodAngle > 0
68
object.stoodAngle -= 4
69
end if
70
end if
71
72
temp0 = object.ypos
73
temp0 &= 0xFFFF0000
74
75
switch object.state
76
case FALLINGBLOCK_IDLE
77
temp1 = object.stoodAngle
78
temp1 <<= 1
79
Sin(temp2, temp1)
80
temp2 <<= 9
81
object.ypos = object.startPos.y
82
object.ypos += temp2
83
if object.timer != 0
84
object.timer--
85
if object.timer == 0
86
object.state++
87
object.priority = PRIORITY_ACTIVE
88
end if
89
end if
90
break
91
92
case FALLINGBLOCK_MOVING
93
object.ypos += object.yvel
94
object.yvel += 0x800
95
ObjectTileCollision(CSIDE_FLOOR, 0, 16, PATH_A)
96
if checkResult == true
97
object.state++
98
end if
99
100
if object.outOfBounds == true
101
object.ypos = object.startPos.y
102
object.yvel = 0
103
object.timer = 0
104
object.state = FALLINGBLOCK_OOB
105
end if
106
break
107
108
case FALLINGBLOCK_RETURNTOSTART
109
if object.outOfBounds == true
110
object.ypos = object.startPos.y
111
object.yvel = 0
112
object.timer = 0
113
object.state++
114
end if
115
break
116
117
case FALLINGBLOCK_OOB
118
if object.outOfBounds == true
119
object.state = FALLINGBLOCK_IDLE
120
object.priority = PRIORITY_BOUNDS
121
end if
122
break
123
124
end switch
125
126
object.collisionOffset.y = object.ypos
127
object.collisionOffset.y &= 0xFFFF0000
128
object.collisionOffset.y -= temp0
129
object.stood = false
130
131
if object.state < FALLINGBLOCK_OOB
132
temp1 = object.ypos
133
object.ypos = temp0
134
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
135
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
136
if checkResult == COL_TOP
137
object.stood = true
138
player[currentPlayer].ypos += object.collisionOffset.y
139
end if
140
next
141
object.ypos = temp1
142
end if
143
end event
144
145
146
event ObjectDraw
147
if object.state < FALLINGBLOCK_OOB
148
DrawSprite(0)
149
end if
150
end event
151
152
153
event ObjectStartup
154
LoadSpriteSheet("LZ/Objects.gif")
155
SpriteFrame(-16, -16, 32, 32, 84, 223)
156
157
foreach (TypeName[Falling Block], arrayPos0, ALL_ENTITIES)
158
object[arrayPos0].startPos.y = object[arrayPos0].ypos
159
next
160
161
SetTableValue(TypeName[Falling Block], DebugMode_ObjCount, DebugMode_TypesTable)
162
SetTableValue(FallingBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
163
SetTableValue(FallingBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
164
DebugMode_ObjCount++
165
end event
166
167
168
// ========================
169
// Editor Events
170
// ========================
171
172
event RSDKDraw
173
DrawSprite(0)
174
end event
175
176
177
event RSDKLoad
178
LoadSpriteSheet("LZ/Objects.gif")
179
SpriteFrame(-16, -16, 32, 32, 84, 223)
180
181
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
182
end event
183
184