Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/PastPost.txt
1319 views
1
//-----------------Sonic CD Past Post 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
#alias Object.Value1 : Object.CollisionPlane
8
9
// States
10
#alias 0 : PASTPOST_IDLE
11
#alias 1 : PASTPOST_ROTATE
12
#alias 2 : PASTPOST_USED
13
14
// Game Mode Aliases
15
#alias 2 : MODE_TIMEATTACK
16
17
// Priority
18
#alias 0 : PRIORITY_BOUNDS
19
#alias 1 : PRIORITY_ACTIVE
20
21
// Warp Destination
22
#alias 1 : WARPDEST_PAST
23
24
// Collision Plane
25
#alias 1 : COLLISION_PLANE_B
26
27
// Global SFX
28
#alias 13 : SFX_G_PAST
29
30
// Property Values
31
#alias 1 : DRAWING_PLANE_B
32
33
34
sub ObjectPlayerInteraction
35
if Object.State == PASTPOST_IDLE
36
if Player.CollisionPlane == Object.CollisionPlane
37
PlayerObjectCollision(C_TOUCH, -8, -24, 8, 32)
38
if CheckResult == true
39
Warp.Destination = WARPDEST_PAST
40
Object.State = PASTPOST_ROTATE
41
Object.Priority = PRIORITY_ACTIVE
42
Object.Frame = 1
43
PlaySfx(SFX_G_PAST, false)
44
45
#platform: Use_Haptics
46
HapticEffect(20, 0, 0, 0)
47
#endplatform
48
49
end if
50
end if
51
end if
52
end sub
53
54
55
sub ObjectDraw
56
switch Object.State
57
case PASTPOST_IDLE
58
DrawSprite(0)
59
DrawSprite(1)
60
break
61
62
case PASTPOST_ROTATE
63
DrawSprite(0)
64
Object.Timer++
65
if Object.Timer == 64
66
Object.Timer = 0
67
Object.State = PASTPOST_USED
68
Object.Priority = PRIORITY_BOUNDS
69
end if
70
DrawSprite(Object.Frame)
71
72
TempValue0 = Object.Timer
73
TempValue0 &= 1
74
Object.Frame += TempValue0
75
if Object.Frame > 8
76
Object.Frame = 1
77
end if
78
break
79
80
case PASTPOST_USED
81
DrawSprite(0)
82
DrawSprite(5)
83
break
84
end switch
85
end sub
86
87
88
sub ObjectStartup
89
LoadSpriteSheet("Global/Items.gif")
90
91
SpriteFrame(-8, -24, 16, 48, 35, 204) // #0 - Post Body
92
// Past Head
93
SpriteFrame(-16, -40, 32, 16, 118, 239) // #2 - Post Head
94
SpriteFrame(-8, -40, 16, 16, 51, 183) // #3 - Post Head Flip 1
95
SpriteFrame(-3, -40, 8, 16, 68, 183) // #4 - Post Head Flip 2
96
SpriteFrame(-8, -40, 16, 16, 52, 200) // #5 - Post Head Flip 3
97
SpriteFrame(-16, -40, 32, 16, 151, 239) // #6 - Post Head Backwards
98
SpriteFrame(-8, -40, 16, 16, 51, 183) // #7 - Post Head Flip 1
99
SpriteFrame(-3, -40, 8, 16, 68, 183) // #8 - Post Head Flip 2
100
SpriteFrame(-8, -40, 16, 16, 52, 200) // #9 - Post Head Flip 3
101
102
ArrayPos0 = 32
103
while ArrayPos0 < 1056
104
if Object[ArrayPos0].Type == TypeName[Past Post]
105
if Object[ArrayPos0].PropertyValue == DRAWING_PLANE_B
106
Object[ArrayPos0].DrawOrder = 1
107
Object[ArrayPos0].CollisionPlane = COLLISION_PLANE_B
108
end if
109
110
if Options.GameMode == MODE_TIMEATTACK
111
Object[ArrayPos0].Type = TypeName[Blank Object]
112
end if
113
end if
114
ArrayPos0++
115
loop
116
end sub
117
118
119
// ========================
120
// Editor Subs
121
// ========================
122
123
sub RSDKEdit
124
if Editor.ReturnVariable == true
125
switch Editor.VariableID
126
case EDIT_VAR_PROPVAL // Property Value
127
CheckResult = Object.PropertyValue
128
break
129
case 0 // CollisionPlane
130
CheckResult = Object.PropertyValue
131
CheckResult &= 1
132
break
133
end switch
134
else
135
switch Editor.VariableID
136
case EDIT_VAR_PROPVAL // Property Value
137
Object.PropertyValue = Editor.VariableValue
138
break
139
case 0 // CollisionPlane
140
Object.PropertyValue = Editor.VariableValue
141
Object.PropertyValue &= 1
142
break
143
end switch
144
end if
145
end sub
146
147
148
sub RSDKDraw
149
DrawSprite(0)
150
DrawSprite(1)
151
end sub
152
153
154
sub RSDKLoad
155
LoadSpriteSheet("Global/Items.gif")
156
SpriteFrame(-8, -24, 16, 48, 35, 204) // #0 - Post Body
157
SpriteFrame(-16, -40, 32, 16, 118, 239) // #1 - Post Head
158
159
160
AddEditorVariable("CollisionPlane")
161
SetActiveVariable("CollisionPlane")
162
AddEnumVariable("Plane A", 0)
163
AddEnumVariable("Plane B", 1)
164
end sub
165
166