Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/Forcefield.txt
1319 views
1
//------------------Sonic CD Forcefield Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.PropertyValue : Object.ScrollDistance
7
8
// States
9
#alias 0 : FORCEFIELD_MOVE_TO_SCREEN
10
#alias 1 : FORCEFIELD_IDLE
11
#alias 2 : FORCEFIELD_VANISH
12
13
// Ink Effects
14
#alias 2 : INK_ALPHA
15
16
17
sub ObjectMain
18
switch Object.State
19
case FORCEFIELD_MOVE_TO_SCREEN
20
if Object.ScrollDistance > 168
21
Object.ScrollDistance--
22
else
23
Object.State++
24
end if
25
26
Object.Frame = Object.AnimationTimer
27
Object.Frame >>= 2
28
29
Object.AnimationTimer++
30
Object.AnimationTimer &= 15
31
32
TempValue1 = Oscillation
33
TempValue1 <<= 3
34
Sin(TempValue0, TempValue1)
35
TempValue0 >>= 4
36
TempValue0 += 190
37
38
Object.Alpha = TempValue0
39
Object.InkEffect = INK_ALPHA
40
Object.DrawOrder = 4
41
break
42
43
case FORCEFIELD_IDLE
44
Object.Frame = Object.AnimationTimer
45
Object.Frame >>= 2
46
47
Object.AnimationTimer++
48
Object.AnimationTimer &= 15
49
50
TempValue1 = Oscillation
51
TempValue1 <<= 3
52
Sin(TempValue0, TempValue1)
53
TempValue0 >>= 4
54
TempValue0 += 190
55
56
Object.Alpha = TempValue0
57
break
58
59
case FORCEFIELD_VANISH
60
Object.Frame = 0
61
if Object.Alpha > 0
62
Object.Alpha -= 2
63
end if
64
break
65
end switch
66
end sub
67
68
69
sub ObjectPlayerInteraction
70
if Object.Alpha > 0
71
TempValue0 = Object.ScrollDistance
72
TempValue0 -= 8
73
PlayerObjectCollision(C_BOX, TempValue0, -96, 240, 96)
74
FlipSign(TempValue0)
75
PlayerObjectCollision(C_BOX, -240, -96, TempValue0, 96)
76
end if
77
end sub
78
79
80
sub ObjectDraw
81
TempValue0 = Object.ScrollDistance
82
TempValue0 *= -0x10000
83
TempValue0 += Object.XPos
84
DrawSpriteFX(4, FX_INK, TempValue0, Object.YPos)
85
DrawSpriteFX(5, FX_INK, TempValue0, Object.YPos)
86
87
Object.Direction = FACING_RIGHT
88
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, Object.YPos)
89
Object.Direction = 2
90
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, Object.YPos)
91
92
TempValue0 = Object.ScrollDistance
93
TempValue0 <<= 16
94
TempValue0 += Object.XPos
95
DrawSpriteFX(4, FX_INK, TempValue0, Object.YPos)
96
DrawSpriteFX(5, FX_INK, TempValue0, Object.YPos)
97
98
Object.Direction = FACING_RIGHT
99
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, Object.YPos)
100
Object.Direction = 2
101
DrawSpriteFX(Object.Frame, FX_FLIP, TempValue0, Object.YPos)
102
end sub
103
104
105
sub ObjectStartup
106
LoadSpriteSheet("R8/Objects3.gif")
107
108
SpriteFrame(-8, 80, 16, 16, 90, 35) // #0 - Forcefield machine frame 0
109
SpriteFrame(-8, 80, 16, 16, 107, 35) // #1 - Forcefield machine frame 1
110
SpriteFrame(-8, 80, 16, 16, 124, 35) // #2 - Forcefield machine frame 2
111
SpriteFrame(-8, 80, 16, 16, 107, 35) // #3 - Forcefield machine frame 3
112
113
SpriteFrame(-8, -82, 16, 82, 74, 114) // #4 - Forcefield Beam frame 0
114
SpriteFrame(-8, 0, 16, 82, 74, 114) // #5 - Forcefield Beam frame 1
115
end sub
116
117
118
// ========================
119
// Editor Subs
120
// ========================
121
122
sub RSDKDraw
123
TempValue0 = 168
124
TempValue0 *= -0x10000
125
TempValue0 += Object.XPos
126
DrawSpriteFX(1, FX_INK, TempValue0, Object.YPos)
127
DrawSpriteFX(2, FX_INK, TempValue0, Object.YPos)
128
129
Object.Direction = FACING_RIGHT
130
DrawSpriteFX(0, FX_FLIP, TempValue0, Object.YPos)
131
Object.Direction = 2
132
DrawSpriteFX(0, FX_FLIP, TempValue0, Object.YPos)
133
134
TempValue0 = 168
135
TempValue0 <<= 16
136
TempValue0 += Object.XPos
137
DrawSpriteFX(1, FX_INK, TempValue0, Object.YPos)
138
DrawSpriteFX(2, FX_INK, TempValue0, Object.YPos)
139
140
Object.Direction = FACING_RIGHT
141
DrawSpriteFX(0, FX_FLIP, TempValue0, Object.YPos)
142
Object.Direction = 2
143
DrawSpriteFX(0, FX_FLIP, TempValue0, Object.YPos)
144
end sub
145
146
147
sub RSDKLoad
148
LoadSpriteSheet("R8/Objects3.gif")
149
150
SpriteFrame(-8, 80, 16, 16, 90, 35) // #0 - Forcefield machine frame 0
151
152
SpriteFrame(-8, -82, 16, 82, 74, 114) // #1 - Forcefield Beam frame 0
153
SpriteFrame(-8, 0, 16, 82, 74, 114) // #2 - Forcefield Beam frame 1
154
155
SetVariableAlias(ALIAS_VAR_PROPVAL, "scrollDistance")
156
end sub
157
158