Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/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.Value1 : Object.OffSetXPos
7
#alias Object.Value2 : Object.XVelocity
8
#alias Object.Value3 : Object.Angle
9
10
// Property Values
11
// This property values only cover the starting position
12
#alias 0 : START_MOVING_LEFT
13
#alias 1 : START_MOVING_RIGHT
14
15
16
sub ObjectMain
17
Object.Angle = Oscillation
18
Object.Angle <<= 1
19
20
if Object.PropertyValue == START_MOVING_RIGHT
21
Object.Angle += 256
22
end if
23
24
Sin(Object.XVelocity, Object.Angle)
25
Object.XVelocity <<= 13
26
Object.XVelocity += Object.XPos
27
Object.XVelocity &= 0xFFFF0000 // Truncate the value
28
Object.XVelocity -= Object.OffSetXPos
29
end sub
30
31
32
sub ObjectPlayerInteraction
33
TempValue0 = Object.XPos
34
Object.XPos = Object.OffSetXPos
35
36
PlayerObjectCollision(C_PLATFORM, -24, -12, 24, 8)
37
if CheckResult == true
38
Player.XPos += Object.XVelocity
39
if Player.State == Player_State_SpinningTop
40
Player.State = Player_State_Ground
41
end if
42
end if
43
Object.XPos = TempValue0
44
end sub
45
46
47
sub ObjectDraw
48
Sin(Object.OffSetXPos, Object.Angle)
49
Object.OffSetXPos <<= 13
50
Object.OffSetXPos += Object.XPos
51
Object.OffSetXPos &= 0xFFFF0000 // Truncate the value
52
53
DrawSpriteXY(0, Object.OffSetXPos, Object.YPos)
54
DrawSpriteXY(1, Object.OffSetXPos, Object.YPos)
55
end sub
56
57
58
sub ObjectStartup
59
LoadSpriteSheet("R6/Objects.gif")
60
61
SpriteFrame(-24, -16, 48, 32, 1, 84) // #0 - Horizontal Platform
62
SpriteFrame(-8, 16, 16, 16, 35, 117) // #1 - Platform Light
63
64
ArrayPos0 = 32
65
while ArrayPos0 < 1056
66
if Object[ArrayPos0].Type == TypeName[H Platform]
67
Object[ArrayPos0].DrawOrder = 4
68
end if
69
ArrayPos0++
70
loop
71
end sub
72
73
74
// ========================
75
// Editor Subs
76
// ========================
77
78
sub RSDKEdit
79
if Editor.ReturnVariable == true
80
switch Editor.VariableID
81
case EDIT_VAR_PROPVAL // Property Value
82
CheckResult = Object.PropertyValue
83
CheckResult &= 1
84
break
85
case 0 // startDir
86
CheckResult = Object.PropertyValue
87
CheckResult &= 1
88
break
89
end switch
90
else
91
switch Editor.VariableID
92
case EDIT_VAR_PROPVAL // Property Value
93
Object.PropertyValue = Editor.VariableValue
94
Object.PropertyValue &= 1
95
break
96
case 0 // startDir
97
Object.PropertyValue = Editor.VariableValue
98
Object.PropertyValue &= 1
99
break
100
end switch
101
end if
102
end sub
103
104
105
sub RSDKDraw
106
DrawSprite(0)
107
DrawSprite(1)
108
switch Object.PropertyValue
109
case START_MOVING_LEFT
110
TempValue1 = 255
111
TempValue2 = 255
112
TempValue3 = 128
113
TempValue4 = 0
114
break
115
case START_MOVING_RIGHT
116
TempValue1 = 128
117
TempValue2 = 0
118
TempValue3 = 255
119
TempValue4 = 255
120
break
121
end switch
122
TempValue0 = Object.XPos
123
TempValue0 -= 0x490000
124
TempValue5 = Object.YPos
125
TempValue5 -= 0x100000
126
if object.PropertyValue == START_MOVING_LEFT
127
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue3, TempValue4, 0)
128
if Editor.ShowGizmos == true
129
Editor.DrawingOverlay = true
130
DrawRectOutline(TempValue0, TempValue5, 0x90, 0x30, 255, 255, 255, 255)
131
TempValue0 = Object.XPos
132
TempValue0 += 0x490000
133
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue1, TempValue2, 0)
134
Editor.DrawingOverlay = false
135
end if
136
else
137
TempValue0 = Object.XPos
138
TempValue0 += 0x490000
139
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue1, TempValue2, 0)
140
if Editor.ShowGizmos == true
141
Editor.DrawingOverlay = true
142
TempValue0 = Object.XPos
143
TempValue0 -= 0x490000
144
DrawRectOutline(TempValue0, TempValue5, 0x90, 0x30, 255, 255, 255, 255)
145
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue3, TempValue4, 0)
146
Editor.DrawingOverlay = false
147
end if
148
end if
149
150
end sub
151
152
153
sub RSDKLoad
154
LoadSpriteSheet("R6/Objects.gif")
155
SpriteFrame(-24, -16, 48, 32, 1, 84) // #0 - Horizontal Spin Platform frame 0
156
SpriteFrame(-8, 16, 16, 16, 35, 117) // #1 - Spin Platform Light
157
158
AddEditorVariable("startDir")
159
SetActiveVariable("startDir")
160
AddEnumVariable("Left", START_MOVING_LEFT)
161
AddEnumVariable("Right", START_MOVING_RIGHT)
162
end sub
163