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/CNZ/VBlock.txt
1482 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
if object[tempObjectPos].propertyValue == 0
42
object[tempObjectPos].ypos -= 0x600000
43
else
44
object[tempObjectPos].ypos += 0x600000
45
end if
46
end function
47
48
49
// ========================
50
// Events
51
// ========================
52
53
event ObjectUpdate
54
temp6 = object.ypos
55
if object.ypos >= object.drawPos.y
56
object.yvel -= 0x400
57
else
58
object.yvel += 0x400
59
end if
60
object.ypos += object.yvel
61
62
temp0 = object.ypos
63
temp6 &= 0xFFFF0000
64
object.collisionOffset.y = object.ypos
65
object.collisionOffset.y &= 0xFFFF0000
66
object.collisionOffset.y -= temp6
67
68
object.ypos = temp6
69
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
70
BoxCollisionTest(C_SOLID2, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
71
switch checkResult
72
case COL_TOP
73
player[currentPlayer].ypos += object.collisionOffset.y
74
break
75
76
case COL_BOTTOM
77
if player[currentPlayer].gravity == GRAVITY_GROUND
78
if object.yvel > 0
79
CallFunction(Player_Kill)
80
end if
81
end if
82
break
83
84
end switch
85
next
86
87
object.ypos = temp0
88
end event
89
90
91
event ObjectDraw
92
DrawSprite(0)
93
end event
94
95
96
event ObjectStartup
97
LoadSpriteSheet("CNZ/Objects.gif")
98
SpriteFrame(-32, -32, 64, 64, 82, 34)
99
100
foreach (TypeName[V Block], arrayPos0, ALL_ENTITIES)
101
object[arrayPos0].drawPos.y = object[arrayPos0].ypos
102
if object[arrayPos0].propertyValue == 0
103
object[arrayPos0].ypos -= 0x600000
104
else
105
object[arrayPos0].ypos += 0x600000
106
end if
107
next
108
109
SetTableValue(TypeName[V Block], DebugMode_ObjCount, DebugMode_TypesTable)
110
SetTableValue(VBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
111
SetTableValue(VBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
112
DebugMode_ObjCount++
113
end event
114
115
116
// ========================
117
// Editor Events
118
// ========================
119
120
event RSDKEdit
121
if editor.returnVariable == true
122
switch editor.variableID
123
case EDIT_VAR_PROPVAL // property value
124
checkResult = object.propertyValue
125
break
126
127
case 0 // startDir
128
checkResult = object.propertyValue
129
break
130
131
end switch
132
else
133
switch editor.variableID
134
case EDIT_VAR_PROPVAL // property value
135
object.propertyValue = editor.variableValue
136
break
137
138
case 0 // startDir
139
object.propertyValue = editor.variableValue
140
break
141
142
end switch
143
end if
144
end event
145
146
147
event RSDKDraw
148
DrawSprite(0)
149
end event
150
151
152
event RSDKLoad
153
LoadSpriteSheet("CNZ/Objects.gif")
154
SpriteFrame(-32, -32, 64, 64, 82, 34)
155
156
// Some VBlocks have their dir FLIP_Y attr set in the scene, that's irrelevant though
157
AddEditorVariable("startDir")
158
SetActiveVariable("startDir")
159
AddEnumVariable("Down", 0)
160
AddEnumVariable("Up", 1)
161
end event
162
163