Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/HPZ/VBlock.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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
// ========================
21
// Function Declarations
22
// ========================
23
24
reserve function VBlock_DebugDraw
25
reserve function VBlock_DebugSpawn
26
27
28
// ========================
29
// Function Definitions
30
// ========================
31
32
private function VBlock_DebugDraw
33
DrawSprite(0)
34
end function
35
36
37
private function VBlock_DebugSpawn
38
CreateTempObject(TypeName[V Block], 0, object.xpos, object.ypos)
39
object[tempObjectPos].drawPos.y = object.ypos
40
object[tempObjectPos].propertyValue = object.direction
41
end function
42
43
44
// ========================
45
// Events
46
// ========================
47
48
event ObjectUpdate
49
temp7 = object.ypos
50
51
GetTableValue(temp0, 12, StageSetup_oscillationTable)
52
if object.propertyValue == 1
53
FlipSign(temp0)
54
temp0 += 0x4000
55
else
56
temp0 -= 0x4000
57
end if
58
temp0 <<= 8
59
60
object.ypos = object.drawPos.y
61
object.ypos -= temp0
62
temp1 = object.ypos
63
64
temp7 &= 0xFFFF0000
65
object.collisionOffset.y = object.ypos
66
object.collisionOffset.y &= 0xFFFF0000
67
object.collisionOffset.y -= temp7
68
69
object.ypos = temp7
70
71
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
72
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
73
switch checkResult
74
case COL_TOP
75
player[currentPlayer].ypos += object.collisionOffset.y
76
break
77
78
case COL_BOTTOM
79
if player[currentPlayer].gravity == GRAVITY_GROUND
80
if object.collisionOffset.y > 0
81
CallFunction(Player_Kill)
82
end if
83
end if
84
break
85
86
end switch
87
next
88
89
object.ypos = temp1
90
end event
91
92
93
event ObjectDraw
94
DrawSprite(0)
95
end event
96
97
98
event ObjectStartup
99
LoadSpriteSheet("HPZ/Objects.gif")
100
SpriteFrame(-32, -32, 64, 64, 353, 1)
101
102
foreach (TypeName[V Block], arrayPos0, ALL_ENTITIES)
103
object[arrayPos0].drawPos.y = object[arrayPos0].ypos
104
next
105
106
SetTableValue(TypeName[V Block], DebugMode_ObjCount, DebugMode_TypesTable)
107
SetTableValue(VBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
108
SetTableValue(VBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
109
DebugMode_ObjCount++
110
end event
111
112
113
// ========================
114
// Editor Events
115
// ========================
116
117
event RSDKEdit
118
if editor.returnVariable == true
119
switch editor.variableID
120
case EDIT_VAR_PROPVAL // property value
121
checkResult = object.propertyValue
122
checkResult &= 1
123
break
124
125
case 0 // startDir
126
checkResult = object.propertyValue
127
checkResult &= 1
128
break
129
130
end switch
131
else
132
switch editor.variableID
133
case EDIT_VAR_PROPVAL // property value
134
object.propertyValue = editor.variableValue
135
object.propertyValue &= 1
136
break
137
138
case 0 // startDir
139
object.propertyValue = editor.variableValue
140
object.propertyValue &= 1
141
break
142
143
end switch
144
end if
145
end event
146
147
148
event RSDKDraw
149
DrawSprite(0)
150
end event
151
152
153
event RSDKLoad
154
LoadSpriteSheet("HPZ/Objects.gif")
155
SpriteFrame(-32, -32, 64, 64, 353, 1)
156
157
AddEditorVariable("startDir")
158
SetActiveVariable("startDir")
159
AddEnumVariable("Up", 0)
160
AddEnumVariable("Down", 1)
161
end event
162
163