Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/Lightning.txt
1319 views
1
//-----------------Sonic CD Lightning Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.Flash
8
9
// Note - Object.Alpha is used for the actual lightning sprites, while Object.Flash is used for the screen-wide lightning flash
10
11
// States
12
#alias 0 : LIGHTNING_WAIT
13
#alias 1 : LIGHTNING_FALL
14
15
// Priority
16
#alias 1 : PRIORITY_ACTIVE
17
18
// Ink Effects
19
#alias 2 : INK_ALPHA
20
21
22
sub ObjectMain
23
switch Object.State
24
case LIGHTNING_WAIT
25
if Object.Timer < 256
26
Object.Timer++
27
else
28
Object.Timer = 0
29
Object.Alpha = 254
30
Object.Flash = 128
31
Object.State++
32
end if
33
break
34
35
case LIGHTNING_FALL
36
if Object.Alpha > 0
37
Object.Alpha -= 2
38
else
39
Object.State = LIGHTNING_WAIT
40
Object.Frame++
41
Object.Frame &= 3
42
end if
43
44
if Object.Flash > 0
45
Object.Flash -= 4
46
end if
47
break
48
49
end switch
50
51
end sub
52
53
54
sub ObjectDraw
55
if Object.State > LIGHTNING_WAIT
56
if Object.DrawOrder == 1
57
// In this Draw Order, we're in the BG
58
59
Object.YPos = Screen.YOffset
60
Object.YPos *= Object.PropertyValue
61
Object.YPos >>= 7
62
FlipSign(Object.YPos)
63
Object.YPos += 312
64
65
TempValue0 = Object.Flash
66
TempValue0 >>= 1
67
DrawRect(0, 0, Screen.XSize, Screen.YSize, 224, 192, 128, TempValue0)
68
69
TempValue0 = Screen.XOffset
70
TempValue0 >>= 3
71
TempValue0 &= 511
72
FlipSign(TempValue0)
73
74
TempValue1 = Object.Frame
75
TempValue0 += 64
76
if TempValue0 < -64
77
TempValue0 += 512
78
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
79
TempValue0 -= 512
80
else
81
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
82
end if
83
84
TempValue1++
85
TempValue1 &= 3
86
TempValue0 += 128
87
if TempValue0 < -64
88
TempValue0 += 512
89
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
90
TempValue0 -= 512
91
else
92
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
93
end if
94
95
TempValue1++
96
TempValue1 &= 3
97
TempValue0 += 128
98
if TempValue0 < -64
99
TempValue0 += 512
100
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
101
TempValue0 -= 512
102
else
103
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
104
end if
105
106
TempValue1++
107
TempValue1 &= 3
108
TempValue0 += 96
109
if TempValue0 < -64
110
TempValue0 += 512
111
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
112
TempValue0 -= 512
113
else
114
DrawSpriteScreenFX(TempValue1, FX_INK, TempValue0, Object.YPos)
115
end if
116
117
// For the flash, add this Object to a higher draw list
118
SetDrawListEntityRef(Object.EntityNo, 5, Screen.DrawListSize[5])
119
Screen[5].DrawListSize++
120
Object.DrawOrder = 5
121
else
122
// On this Draw Order, we're between the game objects and the HUD
123
124
DrawRect(0, 0, Screen.XSize, Screen.YSize, 224, 224, 192, Object.Flash)
125
Object.DrawOrder = 1
126
end if
127
end if
128
129
end sub
130
131
132
sub ObjectStartup
133
134
LoadSpriteSheet("R7/Objects3.gif")
135
136
// Lightning Frames
137
SpriteFrame(-8, 0, 16, 40, 43, 140)
138
SpriteFrame(-8, 0, 16, 24, 60, 140)
139
SpriteFrame(-16, 0, 32, 40, 77, 132)
140
SpriteFrame(-8, 0, 16, 24, 60, 140)
141
142
// Go through the level to find and setup the Lightning object
143
ArrayPos0 = 32
144
while ArrayPos0 < 1056
145
if Object[ArrayPos0].Type == TypeName[Lightning]
146
147
// Lightning never stops, make it always active
148
// (In terms of the actual object layout, normally this object is far out of bounds!)
149
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
150
151
// The lightning should be in the BG, so give it a low draw order
152
Object[ArrayPos0].DrawOrder = 1
153
154
// Lightning flashes and pulses, so give it the INK_ALPHA effect
155
Object[ArrayPos0].InkEffect = INK_ALPHA
156
157
end if
158
159
ArrayPos0++
160
loop
161
162
end sub
163
164
165
// ========================
166
// Editor Subs
167
// ========================
168
169
sub RSDKDraw
170
DrawSprite(0)
171
end sub
172
173
174
sub RSDKLoad
175
LoadSpriteSheet("R7/Objects3.gif")
176
SpriteFrame(-16, 0, 32, 40, 77, 132)
177
178
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
179
end sub
180
181