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/GHZ/CLedgeRight.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: C Ledge Right 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.delay
14
15
private alias 0 : CLEDGER_ACTIVE
16
private alias 1 : CLEDGER_COLLAPSE
17
private alias 2 : CLEDGER_COLLAPSED
18
private alias 3 : CLEDGER_NONE
19
private alias 4 : CLEDGER_TILEDELAY
20
private alias 5 : CLEDGER_TILEFALL
21
22
// Player Aliases
23
private alias object.xpos : player.xpos
24
private alias object.ypos : player.ypos
25
private alias object.yvel : player.yvel
26
27
28
// ========================
29
// Function Declarations
30
// ========================
31
32
reserve function CLedgeRight_DebugDraw
33
reserve function CLedgeRight_DebugSpawn
34
35
36
// ========================
37
// Function Definitions
38
// ========================
39
40
private function CLedgeRight_DebugDraw
41
DrawSprite(0)
42
end function
43
44
45
private function CLedgeRight_DebugSpawn
46
CreateTempObject(TypeName[C Ledge Right], 0, object.xpos, object.ypos)
47
end function
48
49
50
// ========================
51
// Events
52
// ========================
53
54
event ObjectUpdate
55
switch object.state
56
case CLEDGER_ACTIVE
57
break
58
59
case CLEDGER_COLLAPSE
60
if object.timer < 10
61
object.timer++
62
else
63
object.frame = 1
64
temp0 = 0
65
temp3 = object.ypos
66
temp3 -= 0x380000
67
temp4 = 30
68
while temp0 < 6
69
temp1 = 0
70
temp2 = object.xpos
71
temp2 -= 0x280000
72
while temp1 < 6
73
CreateTempObject(TypeName[C Ledge Right], object.frame, temp2, temp3)
74
object[tempObjectPos].state = CLEDGER_TILEDELAY
75
object[tempObjectPos].delay = temp4
76
object.frame++
77
temp1++
78
temp2 += 0x100000
79
temp4 -= 4
80
loop
81
temp4 += 22
82
temp0++
83
temp3 += 0x100000
84
loop
85
PlaySfx(SfxName[Ledge Break L], false)
86
SetSfxAttributes(SfxName[Ledge Break L], -1, -100)
87
PlaySfx(SfxName[Ledge Break R], false)
88
SetSfxAttributes(SfxName[Ledge Break R], -1, 100)
89
object.timer = 0
90
object.state++
91
end if
92
break
93
94
case CLEDGER_COLLAPSED
95
if object.timer < 20
96
object.timer++
97
else
98
object.timer = 0
99
object.state++
100
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, object.xpos, object.ypos)
101
end if
102
break
103
104
case CLEDGER_NONE
105
break
106
107
case CLEDGER_TILEDELAY
108
if object.timer < object.delay
109
object.timer++
110
else
111
object.timer = 0
112
object.state++
113
end if
114
break
115
116
case CLEDGER_TILEFALL
117
object.ypos += object.yvel
118
object.yvel += 0x4000
119
if object.outOfBounds == true
120
object.type = TypeName[Blank Object]
121
end if
122
break
123
124
end switch
125
126
if object.state < CLEDGER_NONE
127
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
128
if player[currentPlayer].yvel >= 0
129
temp0 = player[currentPlayer].xpos
130
temp0 -= object.xpos
131
temp0 >>= 17
132
temp0 += 24
133
if temp0 < 0
134
temp0 = 0
135
end if
136
if temp0 > 47
137
temp0 = 47
138
end if
139
GetTableValue(temp1, temp0, CLedgeLeft_heightArray)
140
temp1 -= 84
141
temp0 = temp1
142
temp0 += 32
143
BoxCollisionTest(C_PLATFORM, object.entityPos, -48, temp1, 48, temp0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
144
if checkResult == true
145
player[currentPlayer].ypos += 0x40000
146
if object.state == CLEDGER_ACTIVE
147
object.state = CLEDGER_COLLAPSE
148
end if
149
end if
150
end if
151
next
152
end if
153
end event
154
155
156
event ObjectDraw
157
switch object.state
158
case CLEDGER_ACTIVE
159
case CLEDGER_COLLAPSE
160
DrawSprite(0)
161
break
162
163
case CLEDGER_TILEDELAY
164
case CLEDGER_TILEFALL
165
DrawSprite(object.propertyValue)
166
break
167
168
case CLEDGER_COLLAPSED
169
case CLEDGER_NONE
170
default
171
break
172
173
end switch
174
end event
175
176
177
event ObjectStartup
178
LoadSpriteSheet("GHZ/Objects.gif")
179
180
// 0 - Full Platform Frame
181
SpriteFrame(-48, -64, 96, 96, 1, 148)
182
183
// All the Platform "Tile" Frames are done in a loop
184
temp0 = 148
185
while temp0 < 244 // sprY + height (148 + 96 = 244)
186
temp1 = 1
187
while temp1 < 97 // sprX + width (1 + 96 = 97)
188
SpriteFrame(-8, -8, 16, 16, temp1, temp0)
189
temp1 += 16
190
loop
191
temp0 += 16
192
loop
193
194
SetTableValue(TypeName[C Ledge Right], DebugMode_ObjCount, DebugMode_TypesTable)
195
SetTableValue(CLedgeRight_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
196
SetTableValue(CLedgeRight_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
197
DebugMode_ObjCount++
198
end event
199
200
201
// ========================
202
// Editor Events
203
// ========================
204
205
event RSDKDraw
206
DrawSprite(0)
207
208
if editor.showGizmos == true
209
editor.drawingOverlay = true
210
211
temp0 = 48; temp1 = 48; temp2 = 48; temp3 = 48;
212
CallFunction(EditorHelpers_DrawHitbox)
213
214
editor.drawingOverlay = false
215
end if
216
end event
217
218
219
event RSDKLoad
220
LoadSpriteSheet("GHZ/Objects.gif")
221
SpriteFrame(-48, -64, 96, 96, 1, 148)
222
223
// Although used by the object, it shouldn't be set by the editor
224
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
225
end event
226
227