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/SYZ/HBlock.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: H 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.amplitude.x
13
private alias object.value1 : object.drawPos.x
14
private alias object.value2 : object.collisionOffset.x
15
16
// Player Aliases
17
private alias object.value17 : debugMode.currentSelection
18
19
// Player Aliases
20
private alias object.xpos : player.xpos
21
private alias object.gravity : player.gravity
22
23
// ========================
24
// Function Declarations
25
// ========================
26
27
reserve function HBlock_DebugDraw
28
reserve function HBlock_DebugSpawn
29
30
31
// ========================
32
// Static Values
33
// ========================
34
35
private value HBlock_startDebugID = 0
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function HBlock_DebugDraw
43
DrawSprite(0)
44
end function
45
46
47
private function HBlock_DebugSpawn
48
CreateTempObject(TypeName[H Block], object.direction, object.xpos, object.ypos)
49
50
temp0 = debugMode[0].currentSelection
51
temp0 -= HBlock_startDebugID
52
if temp0 == 0
53
if object.direction == FLIP_NONE
54
object[tempObjectPos].amplitude.x = 0x2000
55
else
56
object[tempObjectPos].amplitude.x = -0x2000
57
end if
58
else
59
if object.direction == FLIP_NONE
60
object[tempObjectPos].amplitude.x = 0x1000
61
else
62
object[tempObjectPos].amplitude.x = -0x1000
63
end if
64
end if
65
end function
66
67
68
// ========================
69
// Events
70
// ========================
71
72
event ObjectUpdate
73
object.angle = SYZSetup_oscillation
74
object.angle *= 0x200
75
object.angle /= 356
76
77
Sin(object.collisionOffset.x, object.angle)
78
object.collisionOffset.x *= object.amplitude.x
79
object.collisionOffset.x += object.xpos
80
object.collisionOffset.x &= 0xFFFF0000
81
object.collisionOffset.x -= object.drawPos.x
82
83
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
84
temp0 = object.xpos
85
object.xpos = object.drawPos.x
86
temp1 = player[currentPlayer].gravity
87
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
88
if checkResult == COL_TOP
89
if temp1 == GRAVITY_AIR
90
player[currentPlayer].xpos += object.collisionOffset.x
91
end if
92
end if
93
object.xpos = temp0
94
next
95
end event
96
97
98
event ObjectDraw
99
Sin(object.drawPos.x, object.angle)
100
object.drawPos.x *= object.amplitude.x
101
object.drawPos.x += object.xpos
102
object.drawPos.x &= 0xFFFF0000
103
104
DrawSpriteXY(0, object.drawPos.x, object.ypos)
105
end event
106
107
108
event ObjectStartup
109
LoadSpriteSheet("SYZ/Objects.gif")
110
SpriteFrame(-16, -16, 32, 32, 119, 34)
111
112
foreach (TypeName[H Block], arrayPos0, ALL_ENTITIES)
113
switch object[arrayPos0].propertyValue
114
case 0
115
object[arrayPos0].amplitude.x = 0x2000
116
break
117
118
case 1
119
object[arrayPos0].amplitude.x = 0x1000
120
break
121
122
case 2
123
object[arrayPos0].amplitude.x = -0x1000
124
break
125
126
case 3
127
object[arrayPos0].amplitude.x = -0x2000
128
break
129
130
end switch
131
next
132
133
temp0 = 0
134
HBlock_startDebugID = DebugMode_ObjCount
135
while temp0 < 2
136
SetTableValue(TypeName[H Block], DebugMode_ObjCount, DebugMode_TypesTable)
137
SetTableValue(HBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
138
SetTableValue(HBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
139
DebugMode_ObjCount++
140
temp0++
141
loop
142
end event
143
144
145
// ========================
146
// Editor Events
147
// ========================
148
149
event RSDKEdit
150
if editor.returnVariable == true
151
switch editor.variableID
152
case EDIT_VAR_PROPVAL // property value
153
checkResult = object.propertyValue
154
checkResult &= 3
155
break
156
157
case 0 // moveSpeed
158
checkResult = object.propertyValue
159
checkResult &= 3
160
break
161
162
end switch
163
else
164
switch editor.variableID
165
case EDIT_VAR_PROPVAL // property value
166
object.propertyValue = editor.variableValue
167
object.propertyValue &= 3
168
break
169
170
case 0 // moveSpeed
171
object.propertyValue = editor.variableValue
172
object.propertyValue &= 3
173
break
174
175
end switch
176
end if
177
end event
178
179
180
event RSDKDraw
181
DrawSprite(0)
182
183
if editor.showGizmos == true
184
editor.drawingOverlay = true
185
186
// Draw the block's starting position
187
188
switch object.propertyValue
189
case 0
190
object.amplitude.x = 0x2000
191
break
192
193
case 1
194
object.amplitude.x = 0x1000
195
break
196
197
case 2
198
object.amplitude.x = -0x1000
199
break
200
201
case 3
202
object.amplitude.x = -0x2000
203
break
204
205
end switch
206
207
object.inkEffect = INK_BLEND
208
Sin(object.drawPos.x, 0x80)
209
object.drawPos.x *= object.amplitude.x
210
object.drawPos.x += object.xpos
211
object.drawPos.x &= 0xFFFF0000
212
213
DrawSpriteFX(0, FX_INK, object.drawPos.x, object.ypos)
214
215
switch object.propertyValue
216
case 0
217
case 3
218
// Draw an arrow for the block's full path
219
FlipSign(object.amplitude.x)
220
Sin(temp0, 0x80)
221
temp0 *= object.amplitude.x
222
temp0 += object.xpos
223
temp0 &= 0xFFFF0000
224
DrawArrow(object.drawPos.x, object.ypos, temp0, object.ypos, 255, 255, 255)
225
break
226
227
end switch
228
229
editor.drawingOverlay = false
230
end if
231
end event
232
233
234
event RSDKLoad
235
LoadSpriteSheet("SYZ/Objects.gif")
236
SpriteFrame(-16, -16, 32, 32, 119, 34)
237
238
AddEditorVariable("moveSpeed")
239
SetActiveVariable("moveSpeed")
240
AddEnumVariable("Fast", 0)
241
AddEnumVariable("Slow", 1)
242
AddEnumVariable("Fast (Reverse)", 2)
243
AddEnumVariable("Slow (Reverse)", 3)
244
end event
245
246