Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/HPlatform.txt
1319 views
1
//------------Sonic CD Horizontal Platform 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.Value1 : Object.Timer
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.XCollisionOffset
10
#alias Object.Value4 : Object.XVelocity
11
#alias Object.Value5 : Object.Angle
12
13
// Property Values
14
#alias 0 : START_MOVING_LEFT
15
#alias 1 : START_MOVING_RIGHT
16
17
18
sub ObjectMain
19
Object.Angle = Oscillation
20
Object.Angle *= 3
21
22
if Object.PropertyValue == START_MOVING_RIGHT
23
Object.Angle += 256
24
end if
25
26
Cos(Object.XVelocity, Object.Angle)
27
Object.XVelocity *= 0x2700
28
Object.XVelocity += Object.XPos
29
Object.XVelocity &= 0xFFFF0000 // Truncate the value
30
Object.XVelocity -= Object.XCollisionOffset
31
32
if Object.OnObject == true
33
if Object.Timer < 16
34
Object.Timer++
35
TempValue0 = Object.Timer
36
TempValue0 &= 3
37
38
if TempValue0 == 3
39
Object.YVelocity = 0x10000
40
else
41
Object.YVelocity = 0
42
end if
43
44
else
45
Object.YVelocity = 0
46
end if
47
else
48
if Object.Timer > 0
49
Object.Timer--
50
TempValue0 = Object.Timer
51
TempValue0 &= 3
52
if TempValue0 == 3
53
Object.YVelocity = -0x10000
54
else
55
Object.YVelocity = 0
56
end if
57
else
58
Object.YVelocity = 0
59
end if
60
end if
61
Object.OnObject = true
62
end sub
63
64
65
sub ObjectPlayerInteraction
66
TempValue0 = Object.XPos
67
Object.XPos = Object.XCollisionOffset
68
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)
69
if CheckResult == true
70
Object.OnObject = true
71
Player.XPos += Object.XVelocity
72
Player.YPos += Object.YVelocity
73
end if
74
Object.XPos = TempValue0
75
end sub
76
77
78
sub ObjectDraw
79
Cos(Object.XCollisionOffset, Object.Angle)
80
Object.XCollisionOffset *= 0x2700
81
Object.XCollisionOffset += Object.XPos
82
Object.XCollisionOffset &= 0xFFFF0000 // Truncate the value
83
84
Object.YPos += Object.YVelocity
85
DrawSpriteXY(0, Object.XCollisionOffset, Object.YPos)
86
end sub
87
88
89
sub ObjectStartup
90
LoadSpriteSheet("R3/Objects.gif")
91
92
SpriteFrame(-32, -16, 64, 32, 100, 1) // #0 - Horizontal Platform
93
end sub
94
95
96
// ========================
97
// Editor Subs
98
// ========================
99
100
sub RSDKEdit
101
if Editor.ReturnVariable == true
102
switch Editor.VariableID
103
case EDIT_VAR_PROPVAL // Property Value
104
CheckResult = Object.PropertyValue
105
CheckResult &= 1
106
break
107
case 0 // type
108
CheckResult = Object.PropertyValue
109
CheckResult &= 1
110
break
111
end switch
112
else
113
switch Editor.VariableID
114
case EDIT_VAR_PROPVAL // Property Value
115
Object.PropertyValue = Editor.VariableValue
116
Object.PropertyValue &= 1
117
break
118
case 0 // type
119
Object.PropertyValue = Editor.VariableValue
120
Object.PropertyValue &= 1
121
break
122
end switch
123
end if
124
end sub
125
126
127
sub RSDKDraw
128
DrawSprite(0)
129
switch Object.PropertyValue
130
case START_MOVING_LEFT
131
TempValue1 = 255
132
TempValue2 = 255
133
TempValue3 = 128
134
TempValue4 = 0
135
break
136
case START_MOVING_RIGHT
137
TempValue1 = 128
138
TempValue2 = 0
139
TempValue3 = 255
140
TempValue4 = 255
141
break
142
end switch
143
144
TempValue0 = Object.XPos
145
TempValue0 -= 0x620000
146
TempValue5 = Object.YPos
147
TempValue5 -= 0x100000
148
if object.PropertyValue == START_MOVING_LEFT
149
if Editor.ShowGizmos == true
150
Editor.DrawingOverlay = true
151
DrawRectOutline(TempValue0, TempValue5, 0xC4, 0x20, 255, 255, 255, 255)
152
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue1, TempValue2, 0)
153
Editor.DrawingOverlay = false
154
end if
155
else
156
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue1, TempValue2, 0)
157
end if
158
159
TempValue0 = Object.XPos
160
TempValue0 += 0x620000
161
if object.PropertyValue == START_MOVING_RIGHT
162
if Editor.ShowGizmos == true
163
Editor.DrawingOverlay = true
164
DrawRectOutline(TempValue0, TempValue5, 0xC4, 0x20, 255, 255, 255, 255)
165
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue3, TempValue4, 0)
166
Editor.DrawingOverlay = false
167
end if
168
else
169
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue3, TempValue4, 0)
170
end if
171
end sub
172
173
174
sub RSDKLoad
175
LoadSpriteSheet("R3/Objects.gif")
176
177
SpriteFrame(-32, -16, 64, 32, 100, 1) // #0 - Horizontal Platform
178
179
AddEditorVariable("startDir")
180
SetActiveVariable("startDir")
181
AddEnumVariable("Left", START_MOVING_LEFT)
182
AddEnumVariable("Right", START_MOVING_RIGHT)
183
end sub
184
185