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/HTZ/TubeSwitch.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Tube Switch 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.value0 : object.active // Gets set a few times, but seems to never be used otherwise?
13
14
private alias 0 : TUBESWITCH_L_ENTRY
15
private alias 1 : TUBESWITCH_R_ENTRY
16
17
// Player Aliases
18
private alias object.state : player.state
19
private alias object.xvel : player.xvel
20
private alias object.yvel : player.yvel
21
private alias object.speed : player.speed
22
private alias object.direction : player.direction
23
private alias object.gravity : player.gravity
24
private alias object.animation : player.animation
25
26
private alias object.value34 : player.collisionDisabled
27
28
29
// ========================
30
// Events
31
// ========================
32
33
event ObjectUpdate
34
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
35
if player[currentPlayer].collisionDisabled == true
36
// Player should collide with stuff while in a tube
37
player[currentPlayer].collisionDisabled = false
38
end if
39
40
CheckEqual(player[currentPlayer].state, Player_State_Death)
41
temp0 = checkResult
42
CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)
43
temp0 |= checkResult
44
CheckEqual(player[currentPlayer].state, Player_State_Climb)
45
temp0 |= checkResult
46
if temp0 == false
47
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
48
if checkResult == true
49
if player[currentPlayer].yvel < 0
50
player[currentPlayer].yvel = 0
51
end if
52
53
switch object.propertyValue
54
case TUBESWITCH_L_ENTRY
55
if player[currentPlayer].xvel > 0
56
if player[currentPlayer].animation != ANI_JUMPING
57
if player[currentPlayer].state != Player_State_TubeRoll
58
PlaySfx(SfxName[Rolling], false)
59
end if
60
end if
61
62
if player[currentPlayer].state == Player_State_GlideLeft
63
FlipSign(player[currentPlayer].speed)
64
end if
65
66
player[currentPlayer].direction = FACING_RIGHT
67
player[currentPlayer].state = Player_State_TubeRoll
68
player[currentPlayer].animation = ANI_JUMPING
69
else
70
if player[currentPlayer].gravity == GRAVITY_GROUND
71
if player[currentPlayer].xvel > -0x20000
72
player[currentPlayer].speed = -0x20000
73
end if
74
end if
75
76
player[currentPlayer].state = Player_State_Roll
77
player[currentPlayer].animation = ANI_JUMPING
78
end if
79
break
80
81
case TUBESWITCH_R_ENTRY
82
if player[currentPlayer].xvel < 0
83
if player[currentPlayer].animation != ANI_JUMPING
84
if player[currentPlayer].state != Player_State_TubeRoll
85
PlaySfx(SfxName[Rolling], false)
86
end if
87
end if
88
89
if player[currentPlayer].state == Player_State_GlideLeft
90
FlipSign(player[currentPlayer].speed)
91
end if
92
93
player[currentPlayer].direction = FACING_LEFT
94
player[currentPlayer].state = Player_State_TubeRoll
95
player[currentPlayer].animation = ANI_JUMPING
96
else
97
if player[currentPlayer].gravity == GRAVITY_GROUND
98
if player[currentPlayer].xvel < 0x20000
99
player[currentPlayer].speed = 0x20000
100
end if
101
end if
102
103
player[currentPlayer].state = Player_State_Roll
104
player[currentPlayer].animation = ANI_JUMPING
105
end if
106
break
107
108
end switch
109
110
object.active = true
111
else
112
object.active = false
113
end if
114
end if
115
next
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 // type
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 // type
142
object.propertyValue = editor.variableValue
143
break
144
145
end switch
146
end if
147
end event
148
149
150
event RSDKDraw
151
temp0 = object.xpos
152
temp0 -= 0x80000
153
temp1 = object.ypos
154
temp1 -= 0x80000
155
156
DrawSpriteXY(0, temp0, temp1)
157
158
temp0 += 0x100000
159
DrawSpriteXY(0, temp0, temp1)
160
161
temp1 += 0x100000
162
DrawSpriteXY(0, temp0, temp1)
163
164
temp0 -= 0x100000
165
DrawSpriteXY(0, temp0, temp1)
166
end event
167
168
169
event RSDKLoad
170
LoadSpriteSheet("Global/Display.gif")
171
SpriteFrame(-8, -8, 16, 16, 168, 18) // "T" (ubeSwitch) - #0
172
173
AddEditorVariable("type")
174
SetActiveVariable("type")
175
AddEnumVariable("Enter From Left, Exit From Right", 0)
176
AddEnumVariable("Enter From Right, Exit From Left", 1)
177
end event
178
179