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/HBlock.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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.value1 : object.drawPos.x
13
private alias object.value2 : object.collisionOffset.x
14
15
// Player Aliases
16
private alias object.state : player.state
17
private alias object.xpos : player.xpos
18
private alias object.animation : player.animation
19
20
private alias object.value1 : player.timer
21
22
23
// ========================
24
// Function Declarations
25
// ========================
26
27
reserve function HBlock_DebugDraw
28
reserve function HBlock_DebugSpawn
29
30
31
// ========================
32
// Function Definitions
33
// ========================
34
35
private function HBlock_DebugDraw
36
DrawSprite(0)
37
end function
38
39
40
private function HBlock_DebugSpawn
41
CreateTempObject(TypeName[H Block], 0, object.xpos, object.ypos)
42
object[tempObjectPos].drawPos.x = object.xpos
43
object[tempObjectPos].propertyValue = object.direction
44
if object[tempObjectPos].propertyValue == FACING_RIGHT
45
object[tempObjectPos].xpos -= 0x600000
46
else
47
object[tempObjectPos].xpos += 0x600000
48
end if
49
end function
50
51
52
// ========================
53
// Events
54
// ========================
55
56
event ObjectUpdate
57
temp6 = object.xpos
58
if object.xpos >= object.drawPos.x
59
object.xvel -= 0x400
60
else
61
object.xvel += 0x400
62
end if
63
object.xpos += object.xvel
64
65
temp0 = object.xpos
66
temp6 &= 0xFFFF0000
67
object.collisionOffset.x = object.xpos
68
object.collisionOffset.x &= 0xFFFF0000
69
object.collisionOffset.x -= temp6
70
71
object.xpos = temp6
72
73
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
74
BoxCollisionTest(C_SOLID, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
75
switch checkResult
76
case COL_TOP
77
player[currentPlayer].xpos += object.collisionOffset.x
78
break
79
80
case COL_LEFT
81
case COL_RIGHT
82
if player[currentPlayer].state == Player_State_Climb
83
player[currentPlayer].timer = 0
84
player[currentPlayer].animation = ANI_GLIDING_DROP
85
player[currentPlayer].state = Player_State_GlideDrop
86
end if
87
break
88
89
end switch
90
next
91
92
object.xpos = temp0
93
end event
94
95
96
event ObjectDraw
97
DrawSprite(0)
98
end event
99
100
101
event ObjectStartup
102
LoadSpriteSheet("CNZ/Objects.gif")
103
SpriteFrame(-32, -32, 64, 64, 82, 34)
104
foreach (TypeName[H Block], arrayPos0, ALL_ENTITIES)
105
object[arrayPos0].drawPos.x = object[arrayPos0].xpos
106
if object[arrayPos0].propertyValue == 0
107
object[arrayPos0].xpos -= 0x600000
108
else
109
object[arrayPos0].xpos += 0x600000
110
end if
111
next
112
SetTableValue(TypeName[H Block], DebugMode_ObjCount, DebugMode_TypesTable)
113
SetTableValue(HBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
114
SetTableValue(HBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
115
DebugMode_ObjCount++
116
end event
117
118
119
// ========================
120
// Editor Events
121
// ========================
122
123
event RSDKEdit
124
if editor.returnVariable == true
125
switch editor.variableID
126
case EDIT_VAR_PROPVAL // property value
127
checkResult = object.propertyValue
128
break
129
130
case 0 // startDir
131
checkResult = object.propertyValue
132
break
133
134
end switch
135
else
136
switch editor.variableID
137
case EDIT_VAR_PROPVAL // property value
138
object.propertyValue = editor.variableValue
139
break
140
141
case 0 // startDir
142
object.propertyValue = editor.variableValue
143
break
144
145
end switch
146
end if
147
end event
148
149
150
event RSDKDraw
151
DrawSprite(0)
152
end event
153
154
155
event RSDKLoad
156
LoadSpriteSheet("CNZ/Objects.gif")
157
SpriteFrame(-32, -32, 64, 64, 82, 34)
158
159
// Some HBlocks have their dir FLIP_X attr set in the scene, that's irrelevant though
160
AddEditorVariable("startDir")
161
SetActiveVariable("startDir")
162
AddEnumVariable("Right", 0)
163
AddEnumVariable("Left", 1)
164
end event
165
166