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/HCrushGirder.txt
1487 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: H Crush Girder 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.timer
13
private alias object.value1 : object.startPos.x
14
private alias object.value2 : object.startPos.y
15
private alias object.value3 : object.nextState
16
17
private alias 0 : HCRUSHGIRDER_MOVE_RIGHT
18
private alias 1 : HCRUSHGIRDER_MOVE_DOWN
19
private alias 2 : HCRUSHGIRDER_MOVE_LEFT
20
private alias 3 : HCRUSHGIRDER_MOVE_UP
21
private alias 4 : HCRUSHGIRDER_DELAY
22
23
// Player Aliases
24
private alias object.xpos : player.xpos
25
private alias object.ypos : player.ypos
26
private alias object.gravity : player.gravity
27
private alias object.pushing : player.pushing
28
29
30
// ========================
31
// Function Declarations
32
// ========================
33
34
reserve function HCrushGirder_DebugDraw
35
reserve function HCrushGirder_DebugSpawn
36
37
38
// ========================
39
// Tables
40
// ========================
41
42
private function HCrushGirder_DebugDraw
43
DrawSprite(0)
44
end function
45
46
47
private function HCrushGirder_DebugSpawn
48
CreateTempObject(TypeName[H Crush Girder], 0, object.xpos, object.ypos)
49
object[tempObjectPos].startPos.x = object.xpos
50
object[tempObjectPos].startPos.y = object.ypos
51
end function
52
53
54
// ========================
55
// Events
56
// ========================
57
58
event ObjectUpdate
59
switch object.state
60
case HCRUSHGIRDER_MOVE_RIGHT
61
object.timer++
62
if object.timer == 96
63
object.timer = 6
64
object.nextState = HCRUSHGIRDER_MOVE_DOWN
65
object.state = HCRUSHGIRDER_DELAY
66
end if
67
68
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
69
BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
70
switch checkResult
71
case COL_TOP
72
player[currentPlayer].xpos += 0x10000
73
break
74
75
case COL_LEFT
76
player[currentPlayer].pushing = false
77
break
78
end switch
79
next
80
81
object.xpos += 0x10000
82
break
83
84
case HCRUSHGIRDER_MOVE_DOWN
85
object.timer++
86
if object.timer == 48
87
object.timer = 6
88
object.nextState = HCRUSHGIRDER_MOVE_LEFT
89
object.state = HCRUSHGIRDER_DELAY
90
end if
91
92
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
93
BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
94
switch checkResult
95
case COL_TOP
96
player[currentPlayer].ypos += 0x10000
97
break
98
99
case COL_BOTTOM
100
if player[currentPlayer].gravity == GRAVITY_GROUND
101
CallFunction(Player_Kill)
102
end if
103
break
104
end switch
105
next
106
107
object.ypos += 0x10000
108
break
109
110
// actually moves left and up a bit
111
case HCRUSHGIRDER_MOVE_LEFT
112
object.timer++
113
if object.timer == 96
114
object.timer = 6
115
object.nextState = HCRUSHGIRDER_MOVE_UP
116
object.state = HCRUSHGIRDER_DELAY
117
end if
118
119
object.ypos -= 0x4000
120
object.xpos -= 0x10000
121
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
122
BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
123
switch checkResult
124
case COL_TOP
125
player[currentPlayer].xpos -= 0x10000
126
break
127
128
case COL_BOTTOM
129
break
130
end switch
131
next
132
break
133
134
case HCRUSHGIRDER_MOVE_UP
135
object.timer++
136
if object.timer == 24
137
object.timer = 6
138
object.nextState = HCRUSHGIRDER_MOVE_RIGHT
139
object.state = HCRUSHGIRDER_DELAY
140
end if
141
142
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
143
BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
144
switch checkResult
145
case COL_TOP
146
player[currentPlayer].ypos -= 0x10000
147
break
148
149
case COL_BOTTOM
150
break
151
end switch
152
next
153
object.ypos -= 0x10000
154
break
155
156
case HCRUSHGIRDER_DELAY
157
if object.timer > 0
158
object.timer--
159
else
160
object.state = object.nextState
161
end if
162
163
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
164
BoxCollisionTest(C_SOLID, object.entityPos, -96, -24, 96, 24, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
165
if checkResult == COL_BOTTOM
166
if player[currentPlayer].gravity == GRAVITY_GROUND
167
CallFunction(Player_Kill)
168
end if
169
end if
170
next
171
break
172
173
end switch
174
end event
175
176
177
event ObjectDraw
178
DrawSprite(0)
179
end event
180
181
182
event ObjectStartup
183
LoadSpriteSheet("SBZ/Objects.gif")
184
SpriteFrame(-96, -24, 192, 48, 319, 1)
185
186
foreach (TypeName[H Crush Girder], arrayPos0, ALL_ENTITIES)
187
object[arrayPos0].startPos.x = object[arrayPos0].xpos
188
object[arrayPos0].startPos.y = object[arrayPos0].ypos
189
next
190
191
SetTableValue(TypeName[H Crush Girder], DebugMode_ObjCount, DebugMode_TypesTable)
192
SetTableValue(HCrushGirder_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
193
SetTableValue(HCrushGirder_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
194
DebugMode_ObjCount++
195
end event
196
197
198
// ========================
199
// Editor Events
200
// ========================
201
202
event RSDKDraw
203
DrawSprite(0)
204
end event
205
206
207
event RSDKLoad
208
LoadSpriteSheet("SBZ/Objects.gif")
209
SpriteFrame(-96, -24, 192, 48, 319, 1)
210
211
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
212
end event
213
214