Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/ShrinkGrowLaser.txt
1319 views
1
//-------------Sonic CD Shrink Grow Laser 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.YDrawPos
8
9
// States
10
#alias 0 : SGLASER_SHOOT_LASER
11
#alias 1 : SGLASER_LASER
12
#alias 2 : SGLASER_SPLASH
13
14
// Property Values
15
#alias 0 : GIMMICK_SHRINK_LASER
16
#alias 1 : GIMMICK_GROW_LASER
17
18
// Gravity
19
#alias 1 : GRAVITY_AIR
20
21
// Collision Sides
22
#alias 0 : CSIDE_FLOOR
23
24
// Players
25
#alias 0 : PLAYER_SONIC_A
26
27
// Stage SFX
28
#alias 3 : SFX_S_SHRINKLASER
29
#alias 4 : SFX_S_TIMEUFO
30
31
32
sub ObjectMain
33
switch Object.State
34
case SGLASER_SHOOT_LASER
35
if Object.Timer < 24
36
TempValue0 = Object.Timer
37
TempValue0 &= 3
38
if TempValue0 == 0
39
CreateTempObject(TypeName[S G Laser], Object.PropertyValue, Object.XPos, Object.YPos)
40
Object[TempObjectPos].State = SGLASER_LASER
41
end if
42
end if
43
44
if Object.Timer == 0
45
PlayerObjectCollision(C_TOUCH, -96, -128, 96, 128)
46
if CheckResult == true
47
if Object.PropertyValue == GIMMICK_SHRINK_LASER
48
PlayStageSfx(SFX_S_SHRINKLASER, false)
49
else
50
PlayStageSfx(SFX_S_TIMEUFO, false)
51
end if
52
end if
53
end if
54
Object.Timer++
55
Object.Timer &= 31
56
break
57
58
case SGLASER_LASER
59
Object.YPos += 0x40000
60
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
61
if CheckResult == true
62
Object.YDrawPos = Object.YPos
63
Object.State++
64
end if
65
break
66
67
case SGLASER_SPLASH
68
if Object.Timer < 4
69
Object.YPos += 0x40000
70
Object.Timer++
71
else
72
Object.Type = TypeName[Blank Object]
73
end if
74
break
75
end switch
76
end sub
77
78
79
sub ObjectPlayerInteraction
80
if Object.State > SGLASER_SHOOT_LASER // Check that this is the laser and not the machine
81
if Object.PropertyValue == Mini_PlayerFlag
82
if Player.State != Player_State_SizeChange
83
PlayerObjectCollision(C_TOUCH, -4, -8, 4, 8)
84
if CheckResult == true
85
86
#platform: Use_Haptics
87
if Object.PropertyValue == GIMMICK_SHRINK_LASER
88
HapticEffect(39, 0, 0, 0)
89
else
90
HapticEffect(33, 0, 0, 0)
91
end if
92
#endplatform
93
94
Player.State = Player_State_SizeChange
95
Player.Animation = ANI_SIZE_CHANGE
96
Player.YVelocity = -0x40000
97
Player.Gravity = GRAVITY_AIR
98
if Player.XPos > Object.XPos
99
Player.Speed = 0x20000
100
else
101
Player.Speed = -0x20000
102
end if
103
end if
104
end if
105
end if
106
end if
107
end sub
108
109
110
sub ObjectDraw
111
switch Object.State
112
case SGLASER_SHOOT_LASER
113
DrawSprite(Object.PropertyValue)
114
break
115
116
case SGLASER_LASER
117
if Object.AnimationTimer < 2
118
TempValue0 = 2
119
TempValue0 += Object.PropertyValue
120
DrawSprite(TempValue0)
121
else
122
DrawSprite(4)
123
end if
124
Object.AnimationTimer++
125
Object.AnimationTimer &= 3
126
break
127
128
case SGLASER_SPLASH
129
if Object.AnimationTimer < 2
130
TempValue0 = 2
131
TempValue0 += Object.PropertyValue
132
DrawSprite(TempValue0)
133
TempValue0 += 3
134
DrawSpriteXY(TempValue0, Object.XPos, Object.YDrawPos)
135
else
136
DrawSprite(4)
137
DrawSpriteXY(7, Object.XPos, Object.YDrawPos)
138
end if
139
Object.AnimationTimer++
140
Object.AnimationTimer &= 3
141
break
142
end switch
143
end sub
144
145
146
sub ObjectStartup
147
LoadSpriteSheet("R8/Objects2.gif")
148
149
// Origins loads this from playerobject so, goodbye!
150
#platform: Use_Standalone
151
Mini_PlayerFlag = false
152
if Stage.PlayerListPos == PLAYER_SONIC_A
153
LoadAnimation("MiniSonic.Ani")
154
else
155
LoadAnimation("MiniTails.Ani")
156
end if
157
#endplatform
158
159
SpriteFrame(-8, -12, 16, 24, 151, 144) // #0 - Shrink Grow Machine Red
160
SpriteFrame(-8, -12, 16, 24, 168, 144) // #1 - Shrink Grow Machine Blue
161
162
SpriteFrame(-4, -8, 8, 16, 82, 196) // #2 - Laser Red
163
SpriteFrame(-4, -8, 8, 16, 91, 196) // #3 - Laser Blue
164
SpriteFrame(-4, -8, 8, 16, 100, 196) // #4 - Laser White
165
166
SpriteFrame(-8, 0, 16, 8, 169, 169) // #5 - Laser Splash Red
167
SpriteFrame(-8, 0, 16, 8, 134, 178) // #6 - Laser Splash Blue
168
SpriteFrame(-8, 0, 16, 8, 152, 169) // #7 - Laser Splash White
169
170
ArrayPos0 = 32
171
while ArrayPos0 < 1056
172
if Object[ArrayPos0].Type == TypeName[S G Laser]
173
Object[ArrayPos0].DrawOrder = 4
174
end if
175
ArrayPos0++
176
loop
177
end sub
178
179
180
// ========================
181
// Editor Subs
182
// ========================
183
184
sub RSDKEdit
185
if Editor.ReturnVariable == true
186
switch Editor.VariableID
187
case EDIT_VAR_PROPVAL // Property Value
188
CheckResult = Object.PropertyValue
189
CheckResult &= 1
190
break
191
case 0 // laserType
192
CheckResult = Object.PropertyValue
193
CheckResult &= 1
194
break
195
end switch
196
else
197
switch Editor.VariableID
198
case EDIT_VAR_PROPVAL // Property Value
199
Object.PropertyValue = Editor.VariableValue
200
Object.PropertyValue &= 1
201
break
202
case 0 // laserType
203
Object.PropertyValue = Editor.VariableValue
204
Object.PropertyValue &= 1
205
break
206
end switch
207
end if
208
end sub
209
210
sub RSDKDraw
211
DrawSprite(Object.PropertyValue)
212
end sub
213
214
215
sub RSDKLoad
216
LoadSpriteSheet("R8/Objects2.gif")
217
SpriteFrame(-8, -12, 16, 24, 151, 144) // #0 - Shrink Grow Machine Red
218
SpriteFrame(-8, -12, 16, 24, 168, 144) // #1 - Shrink Grow Machine Blue
219
220
AddEditorVariable("laserType")
221
SetActiveVariable("laserType")
222
AddEnumVariable("Shrink Laser", GIMMICK_SHRINK_LASER)
223
AddEnumVariable("Growth Laser", GIMMICK_GROW_LASER)
224
end sub
225
226