Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/TimeStone.txt
1319 views
1
//----------------Sonic CD Time Stone Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Sonic Aliases
6
#alias Object.State : SSSonic.State
7
#alias Object.Frame : SSSonic.Frame
8
9
// States
10
#alias 0 : TIMESTONE_FALLING
11
#alias 1 : TIMESTONE_HELD
12
13
// Special Stage Sonic States
14
#alias 10 : SSSONIC_STONEGRABBED
15
16
// SFX Aliases
17
#alias 21 : SFX_G_ACHIEVEMENT
18
19
20
sub ObjectDraw
21
// Get the frame the Stone should draw
22
// (But note that it's not drawn till the end, see there)
23
TempValue0 = Object.Frame
24
TempValue0 /= 12
25
26
// Animate the Stone
27
Object.Frame++
28
if Object.Frame > 47
29
Object.Frame = 0
30
end if
31
32
if Object.State == TIMESTONE_FALLING
33
// Stone's still falling, so draw the sparkles that it's dropping
34
35
// Smaller sparkle, to be 32 pixels above the Time Stone
36
TempValue1 = Object.YPos
37
TempValue1 -= 0x200000
38
DrawSpriteFX(5, FX_FLIP, Object.XPos, TempValue1)
39
40
// Bigger sparkle, 12 pixels below the smaller sparkle (absolute difference of 20 pixels above the Time Stone)
41
TempValue1 += 0xC0000
42
DrawSpriteFX(4, FX_FLIP, Object.XPos, TempValue1)
43
44
// Flip the object when needed in order to make the rotating animation appear smoother
45
Object.Direction = Object.Frame
46
Object.Direction %= 24
47
Object.Direction /= 6
48
49
if Object.iYPos < 200
50
// Time Stone isn't at its target destination yet, keep it falling at a rate of 1.5 px per frame
51
Object.YPos += 0x18000
52
else
53
54
// Snap to Sonic's hands
55
Object.iYPos = 200
56
57
// Stop further movement of the Stone
58
Object.State = TIMESTONE_HELD
59
PlaySfx(SFX_G_ACHIEVEMENT, false)
60
61
// Signal to the Sonic Object that he's grabbed the Stone, from here he'll handle the rest
62
SSSonic[2].State = SSSONIC_STONEGRABBED
63
SSSonic[2].Frame++
64
65
#platform: Use_Origins
66
// Let the Engine know we've touched an... "emerald"?
67
EngineCallback(NOTIFY_TOUCH_EMERALD)
68
#endplatform
69
70
end if
71
end if
72
73
// Draw the actual Stone sprite
74
// It's drawn all the way at the end of the process so that it stays above the sparkles, drawn before
75
DrawSprite(TempValue0)
76
77
end sub
78
79
80
sub ObjectStartup
81
82
LoadSpriteSheet("Special/Objects.gif")
83
84
// 0-3 - Time Stone Frames
85
SpriteFrame(-10, -12, 20, 24, 1, 232)
86
SpriteFrame(-10, -12, 20, 24, 22, 232)
87
SpriteFrame(-10, -12, 20, 24, 43, 232)
88
SpriteFrame(-10, -12, 20, 24, 64, 232)
89
90
// 4-5 - Sparkles
91
SpriteFrame(-12, -12, 24, 24, 83, 143)
92
SpriteFrame(-8, -8, 16, 16, 83, 126)
93
94
// No extra sprites needed for alternate colors - they're handled via palettes stored in the StageConfig instead
95
96
end sub
97
98
99
// ========================
100
// Editor Subs
101
// ========================
102
103
sub RSDKDraw
104
DrawSprite(0)
105
end sub
106
107
108
sub RSDKLoad
109
LoadSpriteSheet("Special/Objects.gif")
110
SpriteFrame(-10, -12, 20, 24, 1, 232)
111
112
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
113
end sub
114
115