Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/FlipoutBlock.txt
1319 views
1
//---------------Sonic CD Flipout Block Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.YOffSet
7
8
// Property Values
9
#alias 0 : FLIPOUTBLOCK_FLOOR
10
#alias 1 : FLIPOUTBLOCK_FLOOR_NO_ATTACH
11
#alias 2 : FLIPOUTBLOCK_ROOF
12
#alias 3 : FLIPOUTBLOCK_ROOF_NO_ATTACH
13
14
15
sub ObjectPlayerInteraction
16
if Object.PropertyValue > 1
17
Object.YPos += Object.YOffSet
18
else
19
Object.YPos -= Object.YOffSet
20
end if
21
22
PlayerObjectCollision(C_BOX, -15, -16, 16, 16)
23
if Object.PropertyValue > 1
24
Object.YPos -= Object.YOffSet
25
else
26
Object.YPos += Object.YOffSet
27
end if
28
29
end sub
30
31
32
sub ObjectDraw
33
TempValue0 = Object.XPos
34
TempValue0 += 0x480000
35
if Player.XPos > TempValue0
36
if Object.YOffSet < 0x200000
37
Object.YOffSet += 0x80000
38
end if
39
end if
40
41
TempValue0 = Object.XPos
42
TempValue0 -= 0x100000
43
if Player.XPos < TempValue0
44
if Object.YOffSet > 0
45
Object.YOffSet -= 0x80000
46
end if
47
end if
48
49
TempValue1 = Object.PropertyValue
50
TempValue1 &= 1
51
TempValue0 = Object.YPos
52
if Object.PropertyValue > 1
53
TempValue0 += Object.YOffSet
54
if TempValue1 == 0
55
Object[+1].YPos = Object.YPos
56
Object[+1].YPos += Object.YOffSet
57
end if
58
59
else
60
61
TempValue0 -= Object.YOffSet
62
if TempValue1 == 0
63
Object[+1].YPos = Object.YPos
64
Object[+1].YPos -= Object.YOffSet
65
end if
66
67
end if
68
DrawSpriteXY(Object.PropertyValue, Object.XPos, TempValue0)
69
end sub
70
71
72
sub ObjectStartup
73
LoadSpriteSheet("R3/Objects.gif")
74
75
SpriteFrame(-16, -16, 32, 32, 34, 1) // #0 - Flipout Block
76
SpriteFrame(-16, -16, 32, 32, 34, 1) // #1 - Flipout Block
77
SpriteFrame(-16, -16, 32, 32, 67, 1) // #2 - Flipout Block Upside-Down
78
SpriteFrame(-16, -16, 32, 32, 67, 1) // #3 - Flipout Block Upside-Down
79
end sub
80
81
82
// ========================
83
// Editor Subs
84
// ========================
85
86
sub RSDKEdit
87
if Editor.ReturnVariable == true
88
switch Editor.VariableID
89
case EDIT_VAR_PROPVAL // Property Value
90
case 0 // Type
91
CheckResult = Object.PropertyValue
92
CheckResult &= 3
93
break
94
end switch
95
else
96
switch Editor.VariableID
97
case EDIT_VAR_PROPVAL // Property Value
98
case 0 // Type
99
Object.PropertyValue = Editor.VariableValue
100
Object.PropertyValue &= 3
101
break
102
end switch
103
end if
104
end sub
105
106
sub RSDKDraw
107
DrawSprite(Object.PropertyValue)
108
if Object.PropertyValue < 2
109
TempValue0 = Object.YPos
110
TempValue0 -= 0x200000
111
else
112
TempValue0 = Object.YPos
113
TempValue0 += 0x200000
114
end if
115
116
TempValue1 = Object.XPos
117
TempValue1 += 0x100000
118
119
TempValue2 = Object.XPos
120
TempValue2 -= 0x100000
121
122
TempValue3 = Object.YPos
123
TempValue3 -= 0x100000
124
125
126
if Editor.ShowGizmos == true
127
switch Object.PropertyValue
128
case 0
129
case 2
130
DrawArrow(TempValue1, Object.YPos, TempValue1, TempValue0, 255, 255, 255, 0)
131
DrawRectOutline(TempValue2, TempValue3, 0x40, 0x20, 255, 255, 255, 255)
132
break
133
case 1
134
case 3
135
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 255, 0)
136
DrawRectOutline(TempValue2, TempValue3, 0x20, 0x20, 255, 255, 255, 255)
137
break
138
end switch
139
end if
140
end sub
141
142
143
sub RSDKLoad
144
LoadSpriteSheet("R3/Objects.gif")
145
146
SpriteFrame(-16, -16, 32, 32, 34, 1) // #0 - Flipout Block
147
SpriteFrame(-16, -16, 32, 32, 34, 1) // #1 - Flipout Block
148
SpriteFrame(-16, -16, 32, 32, 67, 1) // #2 - Flipout Block Upside-Down
149
SpriteFrame(-16, -16, 32, 32, 67, 1) // #3 - Flipout Block Upside-Down
150
151
AddEditorVariable("Type")
152
SetActiveVariable("Type")
153
AddEnumVariable("Normal", FLIPOUTBLOCK_FLOOR)
154
AddEnumVariable("Without Attachment", FLIPOUTBLOCK_FLOOR_NO_ATTACH)
155
AddEnumVariable("Upside-Down", FLIPOUTBLOCK_ROOF)
156
AddEnumVariable("Upside-Down w/o Attachment", FLIPOUTBLOCK_ROOF_NO_ATTACH)
157
end sub
158
159