Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Global/BubbleShield.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Bubble Shield Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
14
private alias 0 : BUBBLESHIELD_IDLE_SETUP
15
private alias 1 : BUBBLESHIELD_IDLE
16
private alias 2 : BUBBLESHIELD_BOUNCE_SETUP
17
private alias 3 : BUBBLESHIELD_BOUNCE
18
private alias 4 : BUBBLESHIELD_RECOIL_SETUP
19
private alias 5 : BUBBLESHIELD_RECOIL
20
21
private alias -1 : DRAWORDER_PLAYER
22
23
// Player aliases
24
private alias object.state : player.state
25
private alias object.xpos : player.xpos
26
private alias object.ypos : player.ypos
27
28
private alias 1 : SUPERSTATE_SUPER
29
30
31
// ========================
32
// Tables
33
// ========================
34
35
private table BubbleShield_frameTable
36
2, 0, 2, 0, 2, 0, 3, 1, 3, 1, 3, 1, 4, 0, 4, 0
37
4, 0, 5, 1, 5, 1, 5, 1, 6, 0, 6, 0, 6, 0, 5, 1
38
5, 1, 5, 1, 4, 0, 4, 0, 4, 0, 3, 1, 3, 1, 3, 1
39
2, 0, 2, 0, 2, 0
40
end table
41
42
43
// ========================
44
// Events
45
// ========================
46
47
event ObjectUpdate
48
// Remove the shield if the player shouldn't have it
49
if player[-playerCount].state == Player_State_Death
50
object.type = TypeName[Blank Object]
51
end if
52
53
if player[-playerCount].state == Player_State_Drown
54
object.type = TypeName[Blank Object]
55
end if
56
57
object.drawOrder = DRAWORDER_PLAYER
58
59
switch object.state
60
case BUBBLESHIELD_IDLE_SETUP
61
object.animationTimer = 0
62
object.timer = 0
63
GetTableValue(object.frame, object.timer, BubbleShield_frameTable)
64
object.state++
65
// [FallThrough]
66
case BUBBLESHIELD_IDLE
67
object.animationTimer++
68
if object.animationTimer >= 2
69
object.animationTimer = 0
70
object.timer++
71
if object.timer >= 54
72
object.timer = 0
73
end if
74
GetTableValue(object.frame, object.timer, BubbleShield_frameTable)
75
end if
76
break
77
78
case BUBBLESHIELD_BOUNCE_SETUP
79
object.animationTimer = 0
80
object.timer = 0
81
object.frame = 0
82
object.state++
83
// [FallThrough]
84
case BUBBLESHIELD_BOUNCE
85
if object.timer == 0
86
object.animationTimer++
87
if object.animationTimer >= 5
88
object.frame = 8
89
object.animationTimer = 0
90
object.timer++
91
end if
92
else
93
object.animationTimer++
94
if object.animationTimer >= 19
95
object.state = BUBBLESHIELD_IDLE_SETUP
96
end if
97
end if
98
break
99
100
case BUBBLESHIELD_RECOIL_SETUP
101
object.animationTimer = 0
102
object.timer = 0
103
object.frame = 7
104
object.state++
105
// [FallThrough]
106
case BUBBLESHIELD_RECOIL
107
if object.timer == 0
108
object.animationTimer++
109
if object.animationTimer >= 13
110
object.frame = 8
111
object.animationTimer = 0
112
object.timer++
113
end if
114
else
115
object.animationTimer++
116
if object.animationTimer >= 7
117
object.state = BUBBLESHIELD_IDLE_SETUP
118
end if
119
end if
120
break
121
122
end switch
123
end event
124
125
126
event ObjectDraw
127
if Player_superState != SUPERSTATE_SUPER
128
object.direction = FLIP_NONE
129
if object.timer >= 30
130
if object.frame > 1
131
object.direction = FLIP_Y
132
end if
133
end if
134
135
// Draw at the player's position
136
DrawSpriteFX(object.frame, FX_FLIP, player[-playerCount].xpos, player[-playerCount].ypos)
137
end if
138
end event
139
140
141
event ObjectStartup
142
LoadSpriteSheet("Global/Items3.gif")
143
144
// Bubble shield frames
145
SpriteFrame(-24, -24, 48, 48, 1, 1)
146
SpriteFrame(-24, -24, 48, 48, 50, 1)
147
SpriteFrame(-16, -23, 32, 7, 99, 1)
148
SpriteFrame(-20, -22, 40, 12, 99, 9)
149
SpriteFrame(-22, -22, 44, 20, 99, 22)
150
SpriteFrame(-23, -20, 46, 19, 144, 1)
151
SpriteFrame(-23, -15, 46, 30, 144, 21)
152
SpriteFrame(-36, -16, 72, 32, 1, 50)
153
SpriteFrame(-28, -20, 56, 40, 74, 50)
154
SpriteFrame(0, 0, 1, 1, 1, 1) // (Empty)
155
end event
156
157
158
// ========================
159
// Editor Events
160
// ========================
161
162
event RSDKDraw
163
DrawSprite(0)
164
end event
165
166
167
event RSDKLoad
168
LoadSpriteSheet("Global/Display.gif")
169
SpriteFrame(-16, -16, 32, 32, 1, 143)
170
171
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
172
end event
173
174