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/SBZ/FZPiston.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: FZ Piston 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.propertyValue : object.hasEggman
13
14
private alias object.value0 : object.fzEggmanSlot
15
private alias object.value3 : object.timer
16
private alias object.value4 : object.explosionTimer
17
18
// Piston States
19
private alias 0 : FZPISTON_IDLE
20
private alias 1 : FZPISTON_SETUP_CRUSHING
21
private alias 2 : FZPISTON_CRUSHING
22
private alias 3 : FZPISTON_SETUP_RETRACT
23
private alias 4 : FZPISTON_RETRACTING
24
private alias 5 : FZPISTON_SETUP_DESTROYED
25
private alias 6 : FZPISTON_DESTROYED
26
27
// Eggman aliases
28
private alias object.value0 : fzEggman.timer
29
private alias object.value2 : fzEggman.health // Health counts up instead of down this time...
30
31
// Player Aliases
32
private alias object.ypos : player.ypos
33
private alias object.gravity : player.gravity
34
35
36
// ========================
37
// Events
38
// ========================
39
40
event ObjectUpdate
41
switch object.state
42
case FZPISTON_IDLE
43
// Waiting...
44
break
45
46
case FZPISTON_SETUP_CRUSHING
47
object.timer = 31
48
object.yvel = -0x8000
49
if object.direction != FLIP_NONE
50
FlipSign(object.yvel)
51
end if
52
object.state++
53
break
54
55
case FZPISTON_CRUSHING
56
object.timer--
57
if object.timer <= 0
58
object.state++
59
end if
60
break
61
62
case FZPISTON_SETUP_RETRACT
63
object.timer = 48
64
object.yvel = -0x30000
65
if object.direction != FLIP_NONE
66
FlipSign(object.yvel)
67
end if
68
object.state++
69
break
70
71
case FZPISTON_RETRACTING
72
object.timer--
73
if object.timer <= 0
74
object.timer = 80
75
object.yvel = 0x20000
76
if object.direction != FLIP_NONE
77
FlipSign(object.yvel)
78
end if
79
object.state++
80
end if
81
break
82
83
case FZPISTON_SETUP_DESTROYED
84
case FZPISTON_DESTROYED
85
object.timer--
86
if object.timer <= 0
87
object.yvel = 0
88
object.hasEggman = false
89
object.state = FZPISTON_IDLE
90
end if
91
break
92
93
end switch
94
95
temp0 = object.ypos
96
temp0 += object.yvel
97
temp0 &= 0xFFFF0000
98
temp1 = object.ypos
99
temp1 &= 0xFFFF0000
100
temp0 -= temp1
101
102
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
103
if object.direction == 0
104
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -96, 32, 160, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
105
else
106
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -160, 32, 96, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
107
end if
108
109
switch checkResult
110
case COL_TOP
111
player[currentPlayer].ypos += temp0
112
break
113
114
case COL_BOTTOM
115
if player[currentPlayer].gravity == 0
116
if object.yvel > 0
117
CallFunction(Player_Kill)
118
end if
119
end if
120
break
121
122
end switch
123
next
124
125
object.ypos += object.yvel
126
arrayPos0 = object.fzEggmanSlot
127
if object.hasEggman == true
128
object[arrayPos0].xpos = object.xpos
129
object[arrayPos0].ypos = object.ypos
130
if object.direction == 0
131
object[arrayPos0].ypos -= 0xA0000
132
else
133
object[arrayPos0].ypos += 0xE0000
134
end if
135
end if
136
137
if object.state > FZPISTON_RETRACTING
138
if fzEggman[arrayPos0].health == 8
139
if object.state == FZPISTON_SETUP_DESTROYED
140
object.state++
141
object.timer <<= 1
142
object.timer--
143
object.yvel >>= 1
144
fzEggman[arrayPos0].timer = 160
145
arrayPos0 += 6
146
if object[arrayPos0].state == 0
147
object[arrayPos0].state++
148
end if
149
end if
150
151
object.explosionTimer++
152
temp0 = object.explosionTimer
153
temp0 &= 7
154
if temp0 == 4
155
Rand(temp0, 96)
156
temp0 -= 48
157
temp0 <<= 16
158
temp0 += object.xpos
159
Rand(temp1, 48)
160
temp1 -= 24
161
temp1 <<= 16
162
temp1 += object.ypos
163
CreateTempObject(TypeName[Explosion], 0, temp0, temp1)
164
object[tempObjectPos].drawOrder = 5
165
PlaySfx(SfxName[Explosion], false)
166
end if
167
end if
168
end if
169
end event
170
171
172
event ObjectDraw
173
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
174
end event
175
176
177
event ObjectStartup
178
LoadSpriteSheet("SBZ/Objects.gif")
179
180
// Piston frame
181
SpriteFrame(-32, -96, 64, 216, 124, 66)
182
183
foreach (TypeName[FZ Piston], arrayPos0, ALL_ENTITIES)
184
object[arrayPos0].drawOrder = 4
185
next
186
end event
187
188
189
// ========================
190
// Editor Events
191
// ========================
192
193
event RSDKDraw
194
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
195
end event
196
197
198
event RSDKLoad
199
LoadSpriteSheet("SBZ/Objects.gif")
200
SpriteFrame(-32, -96, 64, 216, 124, 66)
201
202
// Used by the boss, but not by the scene file itself
203
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
204
end event
205
206