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/MBZ/TubePath.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Tube Path 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.targetPlayer
13
private alias object.value2 : object.nextNode
14
15
private alias 0 : TUBEPATH_ENTRY
16
private alias 1 : TUBEPATH_EXIT
17
private alias 2 : TUBEPATH_CONTROL
18
19
// Player Aliases
20
private alias object.state : player.state
21
private alias object.xpos : player.xpos
22
private alias object.ypos : player.ypos
23
private alias object.xvel : player.xvel
24
private alias object.yvel : player.yvel
25
private alias object.speed : player.speed
26
private alias object.gravity : player.gravity
27
private alias object.animation : player.animation
28
private alias object.tileCollisions : player.tileCollisions
29
30
31
// ========================
32
// Events
33
// ========================
34
35
event ObjectUpdate
36
switch object.propertyValue
37
case TUBEPATH_ENTRY
38
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
39
if player[currentPlayer].state != Player_State_Static
40
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
41
if checkResult == true
42
player[currentPlayer].xpos = object.xpos
43
player[currentPlayer].state = Player_State_Static
44
player[currentPlayer].tileCollisions = 0
45
if player[currentPlayer].animation != ANI_JUMPING
46
PlaySfx(SfxName[Rolling], false)
47
player[currentPlayer].animation = ANI_JUMPING
48
end if
49
CreateTempObject(TypeName[Tube Path], TUBEPATH_CONTROL, object.xpos, object.ypos)
50
object[tempObjectPos].targetPlayer = currentPlayer
51
object[tempObjectPos].nextNode = object.entityPos
52
object[tempObjectPos].nextNode++
53
end if
54
end if
55
next
56
break
57
58
case TUBEPATH_EXIT
59
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
60
if player[currentPlayer].state == Player_State_Static
61
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, 0, 0, 0, 0)
62
if checkResult == true
63
#platform: USE_STANDALONE
64
player[currentPlayer].state = Player_State_Air
65
#endplatform
66
#platform: USE_ORIGINS
67
player[currentPlayer].state = Player_State_Air_NoDropDash
68
#endplatform
69
player[currentPlayer].gravity = GRAVITY_AIR
70
player[currentPlayer].xpos = object.xpos
71
player[currentPlayer].ypos = object.ypos
72
player[currentPlayer].yvel = -0xA0000
73
player[currentPlayer].speed = 0
74
player[currentPlayer].xvel = 0
75
player[currentPlayer].tileCollisions = true
76
PlaySfx(SfxName[Release], false)
77
end if
78
end if
79
next
80
break
81
82
case TUBEPATH_CONTROL
83
currentPlayer = object.targetPlayer
84
if player[currentPlayer].state == Player_State_Static
85
arrayPos0 = object.nextNode
86
87
temp0 = player[currentPlayer].xpos
88
temp0 -= object[arrayPos0].xpos
89
temp0 >>= 16
90
91
temp1 = player[currentPlayer].ypos
92
temp1 -= object[arrayPos0].ypos
93
temp1 >>= 16
94
ATan2(temp2, temp0, temp1)
95
96
Cos256(player[currentPlayer].xvel, temp2)
97
Sin256(player[currentPlayer].yvel, temp2)
98
player[currentPlayer].xvel *= -0xC00
99
player[currentPlayer].yvel *= -0xC00
100
temp2 = player[currentPlayer].xvel
101
Abs(temp2)
102
temp3 = player[currentPlayer].yvel
103
Abs(temp3)
104
105
if temp2 > temp3
106
player[currentPlayer].yvel = 0
107
else
108
player[currentPlayer].xvel = 0
109
end if
110
111
if object[arrayPos0].type == TypeName[Blank Object]
112
temp2 = temp0
113
temp2 *= temp0
114
temp0 = temp1
115
temp0 *= temp1
116
temp0 += temp2
117
if temp0 < 256
118
player[currentPlayer].xpos = object[arrayPos0].xpos
119
player[currentPlayer].ypos = object[arrayPos0].ypos
120
player[currentPlayer].xvel = 0
121
player[currentPlayer].yvel = 0
122
object.nextNode++
123
end if
124
end if
125
else
126
object.type = TypeName[Blank Object]
127
end if
128
break
129
130
end switch
131
end event
132
133
134
// ========================
135
// Editor Events
136
// ========================
137
138
event RSDKEdit
139
if editor.returnVariable == true
140
switch editor.variableID
141
case EDIT_VAR_PROPVAL // property value
142
checkResult = object.propertyValue
143
checkResult &= 1
144
break
145
146
case 0 // isExit
147
checkResult = object.propertyValue
148
checkResult &= 1
149
break
150
151
end switch
152
else
153
switch editor.variableID
154
case EDIT_VAR_PROPVAL // property value
155
object.propertyValue = editor.variableValue
156
object.propertyValue &= 1
157
break
158
159
case 0 // isExit
160
object.propertyValue = editor.variableValue
161
object.propertyValue &= 1
162
break
163
164
end switch
165
end if
166
end event
167
168
169
event RSDKDraw
170
DrawSprite(0)
171
172
if editor.showGizmos == true
173
editor.drawingOverlay = true
174
175
// Draw all the nodes that make up the path
176
177
arrayPos0 = object.entityPos
178
arrayPos1 = object[+1].entityPos
179
180
while object[arrayPos1].type == 0
181
DrawArrow(object[arrayPos0].xpos, object[arrayPos0].ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)
182
arrayPos0++
183
arrayPos1++
184
loop
185
186
// Final one;
187
// no checks for type to match in-game behvaiour, but it should be a Tube Path obj with a prop val of 1
188
DrawArrow(object[arrayPos0].xpos, object[arrayPos0].ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)
189
190
editor.drawingOverlay = false
191
end if
192
end event
193
194
195
event RSDKLoad
196
LoadSpriteSheet("Global/Display.gif")
197
SpriteFrame(-8, -8, 16, 16, 168, 18)
198
199
AddEditorVariable("isExit")
200
SetActiveVariable("isExit")
201
AddEnumVariable("false", false)
202
AddEnumVariable("true", true)
203
end event
204
205