Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/DoublePlatform.txt
1319 views
1
//--------------Sonic CD Double Platform Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Angle
7
#alias Object.Value1 : Object.PlatformX
8
#alias Object.Value2 : Object.PlatformY
9
#alias Object.Value3 : Object.ChangeX
10
#alias Object.Value4 : Object.ChangeY
11
12
// HUD Alias
13
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
14
15
// Time Period Aliases
16
#alias 0 : TIME_PRESENT
17
#alias 1 : TIME_PAST
18
#alias 2 : TIME_GOOD_FUTURE
19
#alias 3 : TIME_BAD_FUTURE
20
21
22
sub ObjectMain
23
24
Object.Angle += 2
25
Object.Angle &= 511
26
27
if Object.Angle > 0
28
Object.ChangeX = Object.Angle
29
Object.ChangeX *= -0x4000
30
Object.ChangeX += Object.XPos
31
Object.ChangeX &= 0xFFFF0000 // Truncate the value
32
Object.ChangeX -= Object.PlatformX
33
else
34
Object.ChangeX = 0
35
end if
36
37
Cos(Object.ChangeY, Object.Angle)
38
Object.ChangeY *= 0x3000
39
Object.ChangeY += Object.YPos
40
Object.ChangeY &= 0xFFFF0000 // Truncate the value
41
Object.ChangeY -= Object.PlatformY
42
43
end sub
44
45
46
sub ObjectPlayerInteraction
47
48
// First, backup the Object's base position
49
TempValue0 = Object.XPos
50
TempValue1 = Object.YPos
51
52
// Now, move the Object to where it's Platforms really are
53
Object.XPos = Object.PlatformX
54
Object.YPos = Object.PlatformY
55
56
// Check Platform 1
57
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 16)
58
if CheckResult == true
59
Player.XPos += Object.ChangeX
60
Player.YPos += Object.ChangeY
61
end if
62
63
// Check Platform 2
64
PlayerObjectCollision(C_PLATFORM, 96, -16, 160, 16)
65
if CheckResult == true
66
Player.XPos += Object.ChangeX
67
Player.YPos += Object.ChangeY
68
end if
69
70
// We can restore the Object's base position now
71
Object.XPos = TempValue0
72
Object.YPos = TempValue1
73
74
end sub
75
76
77
sub ObjectDraw
78
79
Object.PlatformX = Object.Angle
80
Object.PlatformX *= -0x4000
81
Object.PlatformX += Object.XPos
82
Object.PlatformX &= 0xFFFF0000 // Truncate the value
83
84
Cos(Object.PlatformY, Object.Angle)
85
Object.PlatformY *= 0x3000
86
Object.PlatformY += Object.YPos
87
Object.PlatformY &= 0xFFFF0000 // Truncate the value
88
89
DrawSpriteXY(0, Object.PlatformX, Object.PlatformY)
90
DrawSpriteXY(1, Object.PlatformX, Object.PlatformY)
91
92
end sub
93
94
95
sub ObjectStartup
96
LoadSpriteSheet("R5/Objects3.gif")
97
98
// Use different sprites for the different time periods
99
switch HUD.CurrentTimePeriod
100
case TIME_PRESENT
101
SpriteFrame(-32, -16, 64, 32, 66, 98)
102
SpriteFrame(96, -16, 64, 32, 66, 98)
103
break
104
105
case TIME_PAST
106
SpriteFrame(-32, -16, 64, 32, 66, 98)
107
SpriteFrame(96, -16, 64, 32, 66, 98)
108
break
109
110
case TIME_GOOD_FUTURE
111
SpriteFrame(-32, -16, 64, 32, 66, 98)
112
SpriteFrame(96, -16, 64, 32, 66, 98)
113
break
114
115
case TIME_BAD_FUTURE
116
SpriteFrame(-32, -16, 64, 32, 131, 98)
117
SpriteFrame(96, -16, 64, 32, 131, 98)
118
break
119
120
end switch
121
122
end sub
123
124
125
// ========================
126
// Editor Subs
127
// ========================
128
129
sub RSDKDraw
130
TempValue1 = Object.XPos
131
TempValue1 &= 0xFFFF0000 // Truncate the value
132
Cos(TempValue2, 0)
133
TempValue2 *= 0x3000
134
TempValue2 += Object.YPos
135
TempValue2 &= 0xFFFF0000 // Truncate the value
136
DrawSpriteXY(0, TempValue1, TempValue2)
137
DrawSpriteXY(1, TempValue1, TempValue2)
138
end sub
139
140
141
sub RSDKLoad
142
LoadSpriteSheet("R5/Objects3.gif")
143
144
// TODO: support other time periods
145
// Surely there's a better way to do it than a bunch of unique and boring checkCurrentStageFolder checks?
146
SpriteFrame(-32, -16, 64, 32, 66, 98)
147
SpriteFrame(96, -16, 64, 32, 66, 98)
148
149
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
150
end sub
151
152