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/TubeSwitch.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Tube Switch Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This object seems to be unused, but it's just a basic roll object that doesn't really do all that much
9
10
// ========================
11
// Aliases
12
// ========================
13
14
private alias object.value0 : object.inTube // I dont really know what the point of this variable is but alright I guess
15
16
private alias 0 : TUBESWITCH_R_ENTRY
17
private alias 1 : TUBESWITCH_L_ENTRY
18
19
// Player Aliases
20
private alias object.state : player.state
21
private alias object.speed : player.speed
22
private alias object.xvel : player.xvel
23
private alias object.yvel : player.yvel
24
private alias object.gravity : player.gravity
25
private alias object.direction : player.direction
26
private alias object.animation : player.animation
27
private alias object.value34 : player.collisionDisabled
28
29
30
// ========================
31
// Events
32
// ========================
33
34
event ObjectUpdate
35
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
36
if player[currentPlayer].collisionDisabled == true
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_R_ENTRY // Enter from the right, exit from the left
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_L_ENTRY // Enter from the left, exit from the right
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
end switch
108
109
object.inTube = true
110
else
111
object.inTube = false
112
end if
113
end if
114
next
115
end event
116
117
118
// ========================
119
// Editor Events
120
// ========================
121
122
event RSDKEdit
123
if editor.returnVariable == true
124
switch editor.variableID
125
case EDIT_VAR_PROPVAL // property value
126
checkResult = object.propertyValue
127
break
128
129
case 0 // type
130
checkResult = object.propertyValue
131
break
132
133
end switch
134
else
135
switch editor.variableID
136
case EDIT_VAR_PROPVAL // property value
137
object.propertyValue = editor.variableValue
138
break
139
140
case 0 // type
141
object.propertyValue = editor.variableValue
142
break
143
144
end switch
145
end if
146
end event
147
148
149
event RSDKDraw
150
temp0 = object.xpos
151
temp0 -= 0x80000
152
temp1 = object.ypos
153
temp1 -= 0x80000
154
155
DrawSpriteXY(0, temp0, temp1)
156
157
temp0 += 0x100000
158
DrawSpriteXY(0, temp0, temp1)
159
160
temp1 += 0x100000
161
DrawSpriteXY(0, temp0, temp1)
162
163
temp0 -= 0x100000
164
DrawSpriteXY(0, temp0, temp1)
165
end event
166
167
168
event RSDKLoad
169
LoadSpriteSheet("Global/Display.gif")
170
SpriteFrame(-8, -8, 16, 16, 168, 18) // "T" (ubeSwitch) - #0
171
172
AddEditorVariable("type")
173
SetActiveVariable("type")
174
AddEnumVariable("Enter From Left, Exit From Right", 0)
175
AddEnumVariable("Enter From Right, Exit From Left", 1)
176
end event
177
178