Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/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.Value0 : Object.ZPos
7
#alias Object.Value1 : Object.XVelocity
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.ZVelocity
10
#alias Object.Value4 : Object.Timer
11
#alias Object.Value5 : Object.ScreenDepth
12
#alias Object.Value6 : Object.ScreenXPos
13
14
15
sub ObjectMain
16
// Update movements
17
Object.XPos += Object.XVelocity
18
Object.YPos += Object.YVelocity
19
Object.ZPos += Object.ZVelocity
20
21
// Apply a gravity of an eight of a pixel per frame
22
Object.YVelocity -= 0x2000
23
24
if Object.YPos < 0
25
// If the ring has hit the floor, then bounce back up
26
27
Object.YPos = 0
28
FlipSign(Object.YVelocity)
29
end if
30
31
TempValue0 = Object.XPos
32
TempValue0 -= TileLayer[0].XPos
33
TempValue0 >>= 8
34
35
TempValue1 = Object.ZPos
36
TempValue1 -= TileLayer[0].ZPos
37
TempValue1 >>= 8
38
39
Sin(TempValue2, TileLayer[0].Angle)
40
TempValue2 *= TempValue1
41
Cos(TempValue3, TileLayer[0].Angle)
42
TempValue3 *= TempValue0
43
44
Object.ScreenXPos = TempValue2
45
Object.ScreenXPos -= TempValue3
46
Object.ScreenXPos >>= 9
47
48
Cos(TempValue2, TileLayer[0].Angle)
49
TempValue2 *= TempValue1
50
Sin(TempValue3, TileLayer[0].Angle)
51
TempValue3 *= TempValue0
52
53
Object.ScreenDepth = TempValue2
54
Object.ScreenDepth += TempValue3
55
Object.ScreenDepth >>= 9
56
57
// Make the ring despawn after a little bit
58
Object.Timer++
59
if Object.Timer == 160
60
Object.Type = TypeName[Blank Object]
61
end if
62
63
end sub
64
65
66
sub ObjectDraw
67
if Object.ScreenDepth > 256 // Don't draw if the Ring is too close to the screen
68
69
// Do some maths to find the position & scale the Ring should be at
70
71
Object.Scale = 0xC00000
72
Object.Scale /= Object.ScreenDepth
73
74
TempValue0 = 768
75
TempValue0 -= Object.Scale
76
TempValue0 /= 6
77
78
TempValue1 = Object.ScreenDepth
79
TempValue1 >>= 12
80
81
if TempValue0 > 0
82
Object.Scale += TempValue0
83
Object.Scale -= TempValue1
84
end if
85
86
TempValue0 = Object.ScreenXPos
87
TempValue0 *= 192
88
TempValue0 /= Object.ScreenDepth
89
TempValue0 += Screen.CenterX
90
91
TempValue1 = TileLayer[0].YPos
92
TempValue1 -= Object.YPos
93
TempValue1 >>= 8
94
TempValue1 *= 96
95
TempValue1 /= Object.ScreenDepth
96
TempValue1 += 128
97
98
// Find the sprite to draw the Ring with
99
TempValue2 = Object.Timer
100
TempValue2 &= 31
101
TempValue2 >>= 3
102
103
DrawSpriteScreenFX(TempValue2, FX_SCALE, TempValue0, TempValue1)
104
105
// Find the position of the ground where the ring is
106
TempValue1 = TileLayer[0].YPos
107
TempValue1 >>= 8
108
TempValue1 *= 96
109
TempValue1 /= Object.ScreenDepth
110
TempValue1 += 128
111
112
// Draw a shadow there
113
DrawSpriteScreenFX(4, FX_SCALE, TempValue0, TempValue1)
114
115
end if
116
117
end sub
118
119
120
sub ObjectStartup
121
122
LoadSpriteSheet("Special/Objects.gif")
123
124
// Ring Frames
125
SpriteFrame(-10, -24, 20, 24, 52, 59)
126
SpriteFrame(-7, -24, 15, 24, 73, 59)
127
SpriteFrame(-4, -24, 9, 24, 89, 59)
128
SpriteFrame(-7, -24, 15, 24, 99, 59)
129
130
// Shadow Frame
131
SpriteFrame(-9, -4, 18, 8, 83, 117)
132
133
end sub
134
135
136
// ========================
137
// Editor Subs
138
// ========================
139
140
sub RSDKDraw
141
DrawSprite(0)
142
end sub
143
144
145
sub RSDKLoad
146
LoadSpriteSheet("Special/Objects.gif")
147
SpriteFrame(-10, -24, 20, 24, 52, 59)
148
149
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
150
end sub
151
152