Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/BigPlatform.txt
1319 views
1
//----------------Sonic CD Big Platform Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.YDrawPos
7
#alias Object.Value2 : Object.YOffSet
8
#alias Object.Value3 : Object.Oscillation
9
10
// HUD Alias
11
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
12
13
// States
14
#alias 0 : BIGPLATFORM_INACTIVE
15
#alias 1 : BIGPLATFORM_OPEN
16
#alias 2 : BIGPLATFORM_CLOSE
17
18
// Collision
19
#alias 1 : PLAYER_COL_FLOOR
20
21
// Priority
22
#alias 0 : PRIORITY_BOUNDS
23
#alias 1 : PRIORITY_ACTIVE
24
25
// Time Periods
26
#alias 0 : TIME_PRESENT
27
#alias 1 : TIME_PAST
28
#alias 2 : TIME_GOOD_FUTURE
29
#alias 3 : TIME_BAD_FUTURE
30
31
32
33
sub ObjectMain
34
switch Object.State
35
case BIGPLATFORM_INACTIVE
36
PlayerObjectCollision(C_TOUCH, -96, -160, 128, 160)
37
if CheckResult == true
38
TempValue0 = Player.XPos
39
TempValue0 -= Object.XPos
40
// Check that the player is 128 pixels away to the right from this
41
if TempValue0 > 0x800000
42
Object.State = BIGPLATFORM_CLOSE
43
Object.Priority = PRIORITY_ACTIVE
44
else
45
Object.State = BIGPLATFORM_OPEN
46
Object.Priority = PRIORITY_ACTIVE
47
end if
48
end if
49
break
50
51
case BIGPLATFORM_OPEN
52
TempValue0 = Player.XPos
53
TempValue0 -= Object.XPos
54
// Check that the player is 128 pixels away to the right from this
55
if TempValue0 > 0x800000
56
Object.State = BIGPLATFORM_CLOSE
57
end if
58
59
if Object.Oscillation > 0
60
Object.Oscillation -= 2
61
end if
62
break
63
64
case BIGPLATFORM_CLOSE
65
if Player.XPos < Object.XPos
66
Object.State = BIGPLATFORM_OPEN
67
end if
68
if Object.Oscillation < 256
69
Object.Oscillation += 2
70
end if
71
break
72
73
end switch
74
75
Cos(Object.YOffSet, Object.Oscillation)
76
Object.YOffSet <<= 13
77
Object.YOffSet += 0x400000
78
Object.YOffSet += Object.YPos
79
Object.YOffSet &= 0xFFFF0000 // Truncate the value
80
Object.YOffSet -= Object.YDrawPos
81
82
PlayerObjectCollision(C_TOUCH, -328, -256, 328, 256)
83
if CheckResult == false
84
Object.State = BIGPLATFORM_INACTIVE
85
Object.Priority = PRIORITY_BOUNDS
86
Object.Oscillation = 256
87
end if
88
end sub
89
90
91
sub ObjectPlayerInteraction
92
TempValue0 = Object.YPos
93
Object.YPos = Object.YDrawPos
94
PlayerObjectCollision(C_BOX, -48, -81, 48, 80)
95
if CheckResult == PLAYER_COL_FLOOR
96
Player.YPos += Object.YOffSet
97
Player.YPos += 0x10000
98
end if
99
Object.YPos = TempValue0
100
end sub
101
102
103
sub ObjectDraw
104
Cos(Object.YDrawPos, Object.Oscillation)
105
Object.YDrawPos <<= 13
106
Object.YDrawPos += 0x400000
107
Object.YDrawPos += Object.YPos
108
Object.YDrawPos &= 0xFFFF0000 // Truncate the value
109
DrawSpriteXY(0, Object.XPos, Object.YDrawPos)
110
end sub
111
112
113
sub ObjectStartup
114
LoadSpriteSheet("R6/Objects4.gif")
115
116
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
117
SpriteFrame(-48, -80, 96, 192, 98, 1) // #0 - Big Platform
118
else
119
SpriteFrame(-48, -80, 96, 192, 1, 1) // #0 - Big Platform
120
end if
121
122
ArrayPos0 = 32
123
while ArrayPos0 < 1056
124
if Object[ArrayPos0].Type == TypeName[Big Platform]
125
Object[ArrayPos0].Oscillation = 256
126
end if
127
ArrayPos0++
128
loop
129
end sub
130
131
132
// ========================
133
// Editor Subs
134
// ========================
135
136
sub RSDKDraw
137
DrawSprite(0)
138
end sub
139
140
141
sub RSDKLoad
142
LoadSpriteSheet("R6/Objects4.gif")
143
144
CallFunction(EditorHelpers_FindTimePeriod)
145
if CheckResult == TIME_GOOD_FUTURE
146
SpriteFrame(-48, -80, 96, 192, 98, 1) // #0 - Big Platform
147
else
148
SpriteFrame(-48, -80, 96, 192, 1, 1) // #0 - Big Platform
149
end if
150
151
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
152
end sub
153
154