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/VBlock.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: V 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.value1 : object.drawPos.y
13
private alias object.value2 : object.collisionOffset.y
14
15
// Player Aliases
16
private alias object.ypos : player.ypos
17
private alias object.gravity : player.gravity
18
19
// ========================
20
// Function Declarations
21
// ========================
22
23
reserve function VBlock_DebugDraw
24
reserve function VBlock_DebugSpawn
25
26
27
// ========================
28
// Static Values
29
// ========================
30
31
private value VBlock_unusedValue = 0 // Prolly VBlock_startDebugID if I had to guess
32
33
34
// ========================
35
// Function Definitions
36
// ========================
37
38
private function VBlock_DebugDraw
39
DrawSprite(0)
40
end function
41
42
43
private function VBlock_DebugSpawn
44
CreateTempObject(TypeName[V Block], object.direction, object.xpos, object.ypos)
45
if object[tempObjectPos].propertyValue == 1
46
object[tempObjectPos].ypos -= 0x200000
47
else
48
object[tempObjectPos].ypos -= 0x1F0000
49
end if
50
end function
51
52
53
// ========================
54
// Events
55
// ========================
56
57
event ObjectUpdate
58
object.angle = SYZSetup_oscillation
59
object.angle *= 0x200
60
object.angle /= 356
61
if object.propertyValue == 1
62
object.angle += 0x100
63
end if
64
object.angle &= 0x1FF
65
66
Sin(object.collisionOffset.y, object.angle)
67
object.collisionOffset.y <<= 12
68
object.collisionOffset.y += object.ypos
69
object.collisionOffset.y &= 0xFFFF0000
70
object.collisionOffset.y -= object.drawPos.y
71
72
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
73
temp0 = object.ypos
74
object.ypos = object.drawPos.y
75
76
BoxCollisionTest(C_SOLID, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
77
switch checkResult
78
case COL_TOP
79
player[currentPlayer].ypos += object.collisionOffset.y
80
break
81
82
case COL_BOTTOM
83
if player[currentPlayer].gravity == GRAVITY_GROUND
84
if object.angle > 384
85
CallFunction(Player_Kill)
86
end if
87
88
if object.angle < 128
89
CallFunction(Player_Kill)
90
end if
91
end if
92
break
93
94
end switch
95
96
object.ypos = temp0
97
next
98
end event
99
100
101
event ObjectDraw
102
Sin(object.drawPos.y, object.angle)
103
object.drawPos.y <<= 12
104
object.drawPos.y += object.ypos
105
object.drawPos.y &= 0xFFFF0000
106
DrawSpriteXY(0, object.xpos, object.drawPos.y)
107
end event
108
109
110
event ObjectStartup
111
LoadSpriteSheet("SYZ/Objects.gif")
112
SpriteFrame(-32, -32, 64, 64, 119, 34)
113
114
foreach (TypeName[V Block], arrayPos0, ALL_ENTITIES)
115
if object[arrayPos0].propertyValue == 1
116
object[arrayPos0].ypos -= 0x200000
117
else
118
object[arrayPos0].ypos -= 0x1F0000
119
end if
120
next
121
122
SetTableValue(TypeName[V Block], DebugMode_ObjCount, DebugMode_TypesTable)
123
SetTableValue(VBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
124
SetTableValue(VBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
125
DebugMode_ObjCount++
126
end event
127
128
129
// ========================
130
// Editor Events
131
// ========================
132
133
event RSDKEdit
134
if editor.returnVariable == true
135
switch editor.variableID
136
case EDIT_VAR_PROPVAL // property value
137
checkResult = object.propertyValue
138
checkResult &= 1
139
break
140
141
case 0 // startDir
142
checkResult = object.propertyValue
143
checkResult &= 1
144
break
145
146
end switch
147
else
148
switch editor.variableID
149
case EDIT_VAR_PROPVAL // property value
150
object.propertyValue = editor.variableValue
151
object.propertyValue &= 1
152
break
153
154
case 0 // startDir
155
object.propertyValue = editor.variableValue
156
object.propertyValue &= 1
157
break
158
159
end switch
160
end if
161
end event
162
163
164
event RSDKDraw
165
DrawSprite(0)
166
167
if editor.showGizmos == true
168
editor.drawingOverlay = true
169
170
// Draw this object's range of movement
171
temp0 = -0x200000
172
temp0 += object.ypos
173
DrawLine(object.xpos, object.ypos, object.xpos, temp0, 255, 255, 255)
174
175
editor.drawingOverlay = false
176
end if
177
end event
178
179
180
event RSDKLoad
181
LoadSpriteSheet("SYZ/Objects.gif")
182
SpriteFrame(-32, -32, 64, 64, 119, 34)
183
184
AddEditorVariable("startDir")
185
SetActiveVariable("startDir")
186
AddEnumVariable("Up", 0)
187
AddEnumVariable("Down", 1)
188
end event
189
190