Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Global/SpecialRing.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Special Ring 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 0 : SPECIALRING_FLOATING
13
private alias 1 : SPECIALRING_DISAPPEARING
14
15
// Player Aliases
16
private alias object.type : player.type
17
private alias object.direction : player.direction
18
private alias object.controlMode : player.controlMode
19
private alias object.jumpPress : player.jumpPress
20
private alias object.jumpHold : player.jumpHold
21
private alias object.up : player.up
22
private alias object.down : player.down
23
private alias object.left : player.left
24
private alias object.right : player.right
25
private alias object.value0 : player.rings
26
private alias object.value16 : player.isSidekick
27
28
// Game Modes
29
private alias 2 : MODE_TIMEATTACK
30
31
// Super States
32
private alias 1 : SUPERSTATE_SUPER
33
34
35
// ========================
36
// Events
37
// ========================
38
39
event ObjectUpdate
40
if object.state == SPECIALRING_FLOATING
41
// Are 50 or more rings collected?
42
if player[0].rings > 49
43
// Did P1 collide with the special ring?
44
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, 0, C_BOX, C_BOX, C_BOX, C_BOX)
45
if checkResult == true
46
// Make P1 and their shield "disappear"
47
player[0].type = TypeName[Blank Object]
48
object[playerCount].type = TypeName[Blank Object]
49
player[0].controlMode = CONTROLMODE_NONE
50
player[0].direction = FACING_RIGHT
51
52
// Huh? What object is this supposed to be?
53
// Slot 4's never used in normal gameplay at all, so this shouldn't do anything
54
// If there are 4 players active then slot 4 would have P1's shield, but I doubt that's what this is meant to be for though...
55
ResetObjectEntity(4, TypeName[Blank Object], 0, 0, 0)
56
57
object.drawOrder = 4
58
object.state = SPECIALRING_DISAPPEARING
59
object.frame = 32
60
61
StopSfx(SfxName[Flying])
62
StopSfx(SfxName[Tired])
63
PlaySfx(SfxName[Special Ring], false)
64
65
player[0].left = false
66
player[0].right = false
67
68
if stage.player2Enabled == true
69
if player[1].isSidekick == true
70
player[1].controlMode = CONTROLMODE_NONE
71
player[1].up = false
72
player[1].down = false
73
player[1].left = false
74
player[1].right = false
75
player[1].jumpPress = false
76
player[1].jumpHold = false
77
end if
78
end if
79
end if
80
end if
81
end if
82
83
// If the player is Super, don't show up
84
// -> This should only happen in Debug Mode, since special rings are unloaded
85
// if the player has max emeralds during startup
86
if Player_superState == SUPERSTATE_SUPER
87
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
88
end if
89
end event
90
91
92
event ObjectDraw
93
switch object.state
94
case SPECIALRING_FLOATING
95
// Only show up if there are 50 or more rings collected
96
if player[0].rings >= 50
97
temp0 = object.frame
98
temp0 >>= 2
99
if temp0 > 3
100
object.direction = FLIP_X
101
else
102
object.direction = FLIP_NONE
103
end if
104
105
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
106
107
object.frame++
108
if object.frame > 31
109
object.frame = 0
110
end if
111
end if
112
break
113
114
case SPECIALRING_DISAPPEARING
115
// Determine whether to flip the sprite or not based on current frame
116
temp0 = object.frame
117
temp0 >>= 2
118
if temp0 > 11
119
object.direction = FLIP_X
120
else
121
object.direction = FLIP_NONE
122
end if
123
124
// Draw the sprite
125
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
126
127
if temp0 == 11
128
object.direction = FLIP_X
129
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
130
else
131
if temp0 == 15
132
object.direction = FLIP_X
133
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
134
end if
135
end if
136
137
object.frame++
138
if object.frame > 63 // Time to disappear?
139
// Clear this object
140
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
141
end if
142
break
143
144
end switch
145
end event
146
147
148
event ObjectStartup
149
LoadSpriteSheet("Global/Items2.gif")
150
151
// Sprite frames
152
153
// Special Ring Spinning - #0-7
154
SpriteFrame(-32, -32, 64, 64, 83, 1)
155
SpriteFrame(-28, -32, 56, 64, 199, 131)
156
SpriteFrame(-24, -32, 48, 64, 148, 1)
157
SpriteFrame(-16, -32, 32, 64, 223, 66)
158
SpriteFrame(-12, -32, 24, 64, 197, 1)
159
SpriteFrame(-16, -32, 32, 64, 223, 66)
160
SpriteFrame(-24, -32, 48, 64, 148, 1)
161
SpriteFrame(-28, -32, 56, 64, 199, 131)
162
163
// Special Ring Warping - #8-15
164
SpriteFrame(0, -32, 32, 64, 222, 1)
165
SpriteFrame(-16, -32, 48, 64, 101, 66)
166
SpriteFrame(-24, -32, 56, 64, 150, 66)
167
SpriteFrame(0, -32, 32, 64, 156, 131)
168
SpriteFrame(-24, -32, 56, 64, 150, 66)
169
SpriteFrame(-16, -32, 48, 64, 101, 66)
170
SpriteFrame(0, -32, 32, 64, 222, 1)
171
SpriteFrame(-32, -32, 32, 64, 124, 131)
172
173
// Find max emerald count
174
if options.superStates == false
175
temp0 = 0x3F // 6 emeralds
176
else
177
temp0 = 0x7F // 7 emeralds
178
end if
179
180
// Are all emeralds already gathered?
181
if specialStage.emeralds >= temp0
182
// Big rings aren't needed anymore, delete them
183
foreach (TypeName[Special Ring], arrayPos0, ALL_ENTITIES)
184
ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
185
next
186
end if
187
188
if options.gameMode == MODE_TIMEATTACK
189
// Delete every big ring, they shouldn't be in time attack
190
foreach (TypeName[Special Ring], arrayPos0, ALL_ENTITIES)
191
ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
192
next
193
end if
194
end event
195
196
197
// ========================
198
// Editor Events
199
// ========================
200
201
event RSDKDraw
202
DrawSprite(0)
203
end event
204
205
206
event RSDKLoad
207
LoadSpriteSheet("Global/Items2.gif")
208
SpriteFrame(-32, -32, 64, 64, 83, 1)
209
210
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
211
end event
212
213