Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/HPlatform.txt
1319 views
1
//---------------Sonic CD Horz 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.XVelocity
9
#alias Object.Value3 : Object.OffSetXPos
10
#alias Object.Value4 : Object.YVelocity
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 <<= 1
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 *= 0x1800
28
Object.XVelocity += Object.XPos
29
Object.XVelocity &= 0xFFFF0000 // Truncate the value
30
Object.XVelocity -= Object.OffSetXPos
31
32
if Object.OnObject == true
33
// Loss a bit of height when stepped
34
if Object.Timer < 16
35
Object.Timer++
36
TempValue0 = Object.Timer
37
TempValue0 &= 3
38
if TempValue0 == 3
39
Object.YVelocity = 0x10000
40
else
41
Object.YVelocity = 0
42
end if
43
else
44
Object.YVelocity = 0
45
end if
46
else
47
// Restore original YPos
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 = false
62
end sub
63
64
65
sub ObjectPlayerInteraction
66
TempValue0 = Object.XPos
67
Object.XPos = Object.OffSetXPos
68
69
PlayerObjectCollision(C_PLATFORM, -32, -9, 32, 12)
70
if CheckResult == true
71
Object.OnObject = true
72
Player.XPos += Object.XVelocity
73
Player.YPos += Object.YVelocity
74
end if
75
76
Object.XPos = TempValue0
77
end sub
78
79
80
sub ObjectDraw
81
Cos(Object.OffSetXPos, Object.Angle)
82
Object.OffSetXPos *= 0x1800
83
Object.OffSetXPos += Object.XPos
84
Object.OffSetXPos &= 0xFFFF0000 // Truncate the value
85
86
Object.YPos += Object.YVelocity
87
DrawSpriteXY(0, Object.OffSetXPos, Object.YPos)
88
end sub
89
90
91
sub ObjectStartup
92
LoadSpriteSheet("R1/Objects.gif")
93
94
SpriteFrame(-32, -16, 64, 32, 101, 109) // #0 - Horizontal Platform
95
end sub
96
97
98
// ========================
99
// Editor Subs
100
// ========================
101
102
sub RSDKEdit
103
if Editor.ReturnVariable == true
104
switch Editor.VariableID
105
case EDIT_VAR_PROPVAL // Property Value
106
CheckResult = Object.PropertyValue
107
CheckResult &= 1
108
break
109
case 0 // type
110
CheckResult = Object.PropertyValue
111
CheckResult &= 1
112
break
113
end switch
114
else
115
switch Editor.VariableID
116
case EDIT_VAR_PROPVAL // Property Value
117
Object.PropertyValue = Editor.VariableValue
118
Object.PropertyValue &= 1
119
break
120
case 0 // type
121
Object.PropertyValue = Editor.VariableValue
122
Object.PropertyValue &= 1
123
break
124
end switch
125
end if
126
end sub
127
128
129
sub RSDKDraw
130
DrawSprite(0)
131
end sub
132
133
134
sub RSDKLoad
135
LoadSpriteSheet("R1/Objects.gif")
136
SpriteFrame(-32, -16, 64, 32, 101, 109) // #0 - Horizontal Platform
137
138
AddEditorVariable("startDir")
139
SetActiveVariable("startDir")
140
AddEnumVariable("Left", 0)
141
AddEnumVariable("Right", 1)
142
end sub
143
144