Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/Ring.txt
1319 views
1
//-------------------Sonic CD Ring Script---------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.PropertyValue : Object.DrawingPlane
7
8
// Drawing Plane Aliases
9
#alias 0 : DRAWINGPLANE_A
10
#alias 1 : DRAWINGPLANE_B
11
12
// Player Alias
13
#alias Player.Value0 : Player.Rings
14
15
// Pan
16
#alias 0 : PAN_RIGHT
17
#alias 1 : PAN_LEFT
18
19
// Player
20
#alias 0 : PLAYER_SONIC_A
21
22
// Game Mode Aliases
23
#alias 2 : MODE_TIMEATTACK
24
25
// Global SFX
26
#alias 20 : SFX_G_1UP
27
#alias 21 : SFX_G_ACHIEVEMENT
28
29
30
sub ObjectPlayerInteraction
31
if Player.State != Player_State_Hurt
32
33
if Player.CollisionPlane == Object.DrawingPlane
34
35
PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)
36
if CheckResult == true
37
Object.Type = TypeName[Ring Sparkle]
38
Player.Rings++
39
if Player.Rings > 999
40
Player.Rings = 999
41
end if
42
43
if Player.Rings >= Ring.ExtraLife
44
if Options.GameMode != MODE_TIMEATTACK
45
#platform: Use_Origins
46
if game.coinMode == false
47
Player.Lives++
48
else
49
game.callbackParam0 = 1 // Set the amount of coins to add
50
EngineCallback(NOTIFY_ADD_COIN)
51
end if
52
#endplatform
53
54
#platform: Use_Standalone
55
Player.Lives++
56
#endplatform
57
58
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
59
PlaySfx(SFX_G_1UP, false)
60
else
61
PlaySfx(SFX_G_ACHIEVEMENT, false)
62
end if
63
end if
64
65
Ring.ExtraLife += 100
66
67
// You can only achieve 3 extra lives via rings
68
if Ring.ExtraLife > 300
69
Ring.ExtraLife = 1000
70
end if
71
72
// King of the Rings achievement criteria
73
if Player.Rings >= 200
74
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
75
if Stage.DebugMode == false
76
SetAchievement(4, 100)
77
end if
78
end if
79
end if
80
end if
81
82
if Ring.Pan == PAN_RIGHT
83
SetSfxAttributes(1, -1, -100)
84
Ring.Pan = PAN_LEFT
85
else
86
SetSfxAttributes(2, -1, 100)
87
Ring.Pan = PAN_RIGHT
88
end if
89
end if
90
91
end if
92
93
end if
94
95
end sub
96
97
98
sub ObjectDraw
99
DrawSprite(Ring.Frame)
100
end sub
101
102
103
sub ObjectStartup
104
LoadSpriteSheet("Global/Items.gif")
105
106
SpriteFrame(-8, -8, 16, 16, 1, 1) // #0 - Ring Frame 0
107
SpriteFrame(-8, -8, 16, 16, 1, 18) // #1 - Ring Frame 1
108
SpriteFrame(-8, -8, 16, 16, 1, 35) // #2 - Ring Frame 2
109
SpriteFrame(-8, -8, 16, 16, 1, 52) // #3 - Ring Frame 3
110
SpriteFrame(-8, -8, 16, 16, 1, 69) // #4 - Ring Frame 4
111
SpriteFrame(-8, -8, 16, 16, 1, 86) // #5 - Ring Frame 5
112
SpriteFrame(-8, -8, 16, 16, 1, 103) // #6 - Ring Frame 6
113
SpriteFrame(-8, -8, 16, 16, 1, 120) // #7 - Ring Frame 7
114
115
// Used to be below LoadSpriteSheet, moved here for consistency
116
ArrayPos0 = 32
117
while ArrayPos0 < 1056
118
if Object[ArrayPos0].Type == TypeName[Ring]
119
if Object[ArrayPos0].DrawingPlane == DRAWINGPLANE_A
120
Object[ArrayPos0].DrawOrder = 4
121
else
122
Object[ArrayPos0].DrawOrder = 2
123
end if
124
end if
125
ArrayPos0++
126
loop
127
128
end sub
129
130
131
// ========================
132
// Editor Subs
133
// ========================
134
135
sub RSDKEdit
136
if Editor.ReturnVariable == true
137
switch Editor.VariableID
138
case EDIT_VAR_PROPVAL // Property Value
139
CheckResult = Object.PropertyValue
140
break
141
case 0 // Plane Type
142
CheckResult = Object.PropertyValue
143
break
144
end switch
145
else
146
switch Editor.VariableID
147
case EDIT_VAR_PROPVAL // Property Value
148
Object.PropertyValue = Editor.VariableValue
149
break
150
case 0 // Plane Type
151
Object.PropertyValue = Editor.VariableValue
152
break
153
end switch
154
end if
155
end sub
156
157
158
sub RSDKDraw
159
Object.InkEffect = Object.PropertyValue
160
DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)
161
end sub
162
163
164
sub RSDKLoad
165
LoadSpriteSheet("Global/Items.gif")
166
SpriteFrame(-8, -8, 16, 16, 1, 1) // #0 - Ring Frame 0
167
168
AddEditorVariable("Plane Type")
169
SetActiveVariable("Plane Type")
170
AddEnumVariable("Plane A", 0)
171
AddEnumVariable("Plane B", 1)
172
end sub
173
174