Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/InvBlock.txt
1319 views
1
//---------------Sonic CD Invisible Block Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.OnObject
7
#alias Object.Value2 : Object.YOriginPos
8
9
// HUD Alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// State
13
#alias 0 : INVBLOCK_IDLE
14
#alias 1 : INVBLOCK_FALL
15
#alias 2 : INVBLOCK_RESTORE
16
17
// Priority
18
#alias 0 : PRIORITY_BOUNDS
19
#alias 1 : PRIORITY_ACTIVE
20
21
// Time Periods
22
#alias 0 : TIME_PRESENT
23
#alias 1 : TIME_PAST
24
#alias 2 : TIME_GOOD_FUTURE
25
#alias 3 : TIME_BAD_FUTURE
26
27
28
sub ObjectPlayerInteraction
29
if Object.State < INVBLOCK_RESTORE
30
PlayerObjectCollision(C_PLATFORM, -12, -12, 12, 12)
31
Object.OnObject = CheckResult
32
end if
33
34
if HUD.CurrentTimePeriod > 1 // Inv Blocks in the future fall upon contact
35
switch Object.State
36
case INVBLOCK_IDLE
37
if Object.OnObject == true
38
Object.State = INVBLOCK_FALL
39
Object.Priority = PRIORITY_ACTIVE
40
Player.YPos += 0x20000
41
end if
42
break
43
44
case INVBLOCK_FALL
45
if Object.OnObject == true
46
Player.YPos += 0x20000
47
end if
48
break
49
end switch
50
end if
51
end sub
52
53
54
sub ObjectDraw
55
switch Object.State
56
case INVBLOCK_FALL
57
Object.YPos += 0x20000
58
if Object.OutOfBounds == true
59
Object.State = INVBLOCK_RESTORE
60
Object.YPos = Object.YOriginPos
61
end if
62
break
63
64
case INVBLOCK_RESTORE
65
if Object.OutOfBounds == true
66
Object.State = INVBLOCK_IDLE
67
Object.Priority = PRIORITY_BOUNDS
68
end if
69
break
70
71
end switch
72
73
switch HUD.CurrentTimePeriod // they are invisible only in the present
74
case TIME_PRESENT
75
if Object.OnObject == true
76
if Object.Frame < 24
77
Object.Frame++
78
end if
79
else
80
if Object.Frame > 0
81
Object.Frame--
82
end if
83
end if
84
DrawSprite(Object.Frame)
85
break
86
87
case TIME_PAST
88
DrawSprite(5)
89
break
90
91
case TIME_GOOD_FUTURE
92
case TIME_BAD_FUTURE
93
if Object.State < INVBLOCK_RESTORE
94
DrawSprite(5)
95
end if
96
break
97
98
end switch
99
end sub
100
101
102
sub ObjectStartup
103
LoadSpriteSheet("R1/Objects.gif")
104
105
SpriteFrame(0, 0, 4, 4, 68, 162) // #0 - Cheat Sprite
106
SpriteFrame(-12, -12, 24, 24, 93, 142) // #1 - Inv Block Appearing Frame 0
107
SpriteFrame(-12, -12, 24, 24, 93, 142) // #2 - Inv Block Appearing Frame 1
108
SpriteFrame(-12, -12, 24, 24, 93, 142) // #3 - Inv Block Appearing Frame 2
109
SpriteFrame(-12, -12, 24, 24, 93, 142) // #4 - Inv Block Appearing Frame 3
110
SpriteFrame(-12, -12, 24, 24, 68, 142) // #5 - Inv Block Appearing Frame 4 / Main Frame in other time zones
111
SpriteFrame(-12, -12, 24, 24, 68, 142) // #6 - Inv Block Appearing Frame 5
112
SpriteFrame(-12, -12, 24, 24, 68, 142) // #7 - Inv Block Appearing Frame 6
113
SpriteFrame(-12, -12, 24, 24, 68, 142) // #8 - Inv Block Appearing Frame 7
114
SpriteFrame(-12, -12, 24, 24, 118, 142) // #9 - Inv Block Appearing Frame 8
115
SpriteFrame(-12, -12, 24, 24, 118, 142) // #10 - Inv Block Appearing Frame 9
116
SpriteFrame(-12, -12, 24, 24, 118, 142) // #11 - Inv Block Appearing Frame 10
117
SpriteFrame(-12, -12, 24, 24, 68, 142) // #12 - Inv Block Appearing Frame 11
118
SpriteFrame(-12, -12, 24, 24, 68, 142) // #13 - Inv Block Appearing Frame 12
119
SpriteFrame(-12, -12, 24, 24, 68, 142) // #14 - Inv Block Appearing Frame 13
120
SpriteFrame(-12, -12, 24, 24, 143, 142) // #15 - Inv Block Appearing Frame 14
121
SpriteFrame(-12, -12, 24, 24, 143, 142) // #16 - Inv Block Appearing Frame 15
122
SpriteFrame(-12, -12, 24, 24, 143, 142) // #17 - Inv Block Appearing Frame 16
123
SpriteFrame(-12, -12, 24, 24, 68, 142) // #18 - Inv Block Appearing Frame 17
124
SpriteFrame(-12, -12, 24, 24, 68, 142) // #19 - Inv Block Appearing Frame 18
125
SpriteFrame(-12, -12, 24, 24, 68, 142) // #20 - Inv Block Appearing Frame 19
126
SpriteFrame(-12, -12, 24, 24, 168, 142) // #21 - Inv Block Appearing Frame 20
127
SpriteFrame(-12, -12, 24, 24, 168, 142) // #22 - Inv Block Appearing Frame 21
128
SpriteFrame(-12, -12, 24, 24, 168, 142) // #23 - Inv Block Appearing Frame 22
129
SpriteFrame(-12, -12, 24, 24, 68, 142) // #24 - Inv Block Appearing Frame 23 / Main Frame in the Present
130
131
// Used to be below LoadSpriteSheet, moved here for consistency
132
ArrayPos0 = 32
133
while ArrayPos0 < 1056
134
if Object[ArrayPos0].Type == TypeName[Invisible Block]
135
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
136
end if
137
ArrayPos0++
138
loop
139
140
end sub
141
142
143
// ========================
144
// Editor Subs
145
// ========================
146
147
sub RSDKDraw
148
DrawSprite(0)
149
end sub
150
151
152
sub RSDKLoad
153
LoadSpriteSheet("R1/Objects.gif")
154
SpriteFrame(-12, -12, 24, 24, 68, 142) // #0 - Inv Block Appearing Frame 23 / Main Frame in the Present
155
156
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
157
end sub
158
159