Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/Dust.txt
1319 views
1
//------------------Sonic CD DustPuff Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
8
// Property Values
9
#alias 0 : DUSTPUFF_SPAWNER
10
#alias 1 : DUSTPUFF_CHILD
11
12
// Player aliases
13
#alias Player.XPos : SSSonic.XPos
14
#alias Player.YPos : SSSonic.YPos
15
#alias Object.Value0 : SSSonic.ZPos
16
17
// Stage SFX
18
#alias 0 : SFX_S_GRITTYGROUND
19
20
// Tile Info
21
#alias 6 : TILEINFO_ANGLEA
22
23
24
sub ObjectMain
25
if Object.PropertyValue == DUSTPUFF_SPAWNER
26
// The Spawner is, well, spawned by the [Sonic] object in order to spawn more Dust Puffs
27
// Sure is a lot of spawning, huh?
28
29
if SSSonic.YPos > 0
30
// If the player is in the air, then unload
31
ResetObjectEntity(3, TypeName[Blank Object], 0, 0, 0)
32
else
33
34
// Get Sonic's truncated X and Z Positions
35
TempValue0 = SSSonic.XPos
36
TempValue0 >>= 16
37
38
TempValue1 = SSSonic[-1].ZPos
39
TempValue1 >>= 16
40
41
// Get what type of tile it is
42
Get16x16TileInfo(CheckResult, TempValue0, TempValue1, TILEINFO_ANGLEA)
43
44
// Is it a non-standard tile?
45
if CheckResult > 0
46
Object.Timer++
47
48
if Object.Timer > 2
49
Object.Timer = 0
50
51
PlayStageSfx(SFX_S_GRITTYGROUND, false)
52
53
// Randomise the dust position a little
54
Rand(TempValue0, 40)
55
TempValue0 -= 20
56
Rand(TempValue1, 8)
57
TempValue1 -= 8
58
59
TempValue0 += Screen.CenterX
60
TempValue1 += 224
61
62
TempValue0 <<= 16
63
TempValue1 <<= 16
64
65
// Create the Dust Puff child object, no need to setup any ZPos stuff since it's a purely 2d object
66
CreateTempObject(TypeName[Dust Puff], DUSTPUFF_CHILD, TempValue0, TempValue1)
67
Object[TempObjectPos].DrawOrder = 4
68
end if
69
else
70
Object.Type = TypeName[Blank Object]
71
Object.Timer = 0
72
end if
73
end if
74
else
75
// Child Dust Puff object
76
77
Object.Timer++
78
if Object.Timer == 9
79
Object.Type = TypeName[Blank Object]
80
end if
81
82
// If the Player's moving, then we gotta follow along too!
83
84
if Player.Left == true
85
Object.XPos += 0x10000
86
end if
87
88
if Player.Right == true
89
Object.XPos -= 0x10000
90
end if
91
end if
92
93
end sub
94
95
96
sub ObjectDraw
97
if Object.PropertyValue == DUSTPUFF_CHILD
98
// Find the Frame to display based on how much time the object has left
99
Object.Frame = Object.Timer
100
Object.Frame /= 3
101
102
// Draw the Sprite, note the use of standard DrawSprite rather than anything fancy like the other SS objects
103
// This is because the object should only ever exist on a 2d plane anyway
104
DrawSprite(Object.Frame)
105
end if
106
107
// DUSTPUFF_SPAWNER doesn't draw, it spawns other Dust Puff objects to draw instead
108
109
end sub
110
111
112
sub ObjectStartup
113
114
LoadSpriteSheet("Special/Objects.gif")
115
116
// Dust Puff Frames
117
SpriteFrame(-5, -4, 10, 8, 27, 58)
118
SpriteFrame(-5, -4, 11, 8, 10, 58)
119
SpriteFrame(-4, -4, 8, 8, 1, 58)
120
121
end sub
122
123
124
// ========================
125
// Editor Subs
126
// ========================
127
128
sub RSDKDraw
129
DrawSprite(0)
130
end sub
131
132
133
sub RSDKLoad
134
LoadSpriteSheet("Special/Objects.gif")
135
SpriteFrame(-5, -4, 10, 8, 27, 58)
136
137
// Although it's used by the Object, it's not to be set from the editor
138
// (This Object shouldn't be placed into a scene directly at all, really...)
139
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
140
end sub
141
142