Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Global/BubbleShield.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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
private alias object.state : player.state
24
private alias object.xpos : player.xpos
25
private alias object.ypos : player.ypos
26
27
// Super States
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
60
switch object.state
61
case BUBBLESHIELD_IDLE_SETUP
62
object.animationTimer = 0
63
object.timer = 0
64
GetTableValue(object.frame, object.timer, BubbleShield_frameTable)
65
object.state++
66
// [FallThrough]
67
case BUBBLESHIELD_IDLE
68
object.animationTimer++
69
if object.animationTimer >= 2
70
object.animationTimer = 0
71
object.timer++
72
if object.timer >= 54
73
object.timer = 0
74
end if
75
GetTableValue(object.frame, object.timer, BubbleShield_frameTable)
76
end if
77
break
78
79
case BUBBLESHIELD_BOUNCE_SETUP
80
object.animationTimer = 0
81
object.timer = 0
82
object.frame = 0
83
object.state++
84
// [FallThrough]
85
case BUBBLESHIELD_BOUNCE
86
if object.timer == 0
87
object.animationTimer++
88
if object.animationTimer >= 5
89
object.frame = 8
90
object.animationTimer = 0
91
object.timer++
92
end if
93
else
94
object.animationTimer++
95
if object.animationTimer >= 19
96
object.state = BUBBLESHIELD_IDLE_SETUP
97
end if
98
end if
99
break
100
101
case BUBBLESHIELD_RECOIL_SETUP
102
object.animationTimer = 0
103
object.timer = 0
104
object.frame = 7
105
object.state++
106
// [FallThrough]
107
case BUBBLESHIELD_RECOIL
108
if object.timer == 0
109
object.animationTimer++
110
if object.animationTimer >= 13
111
object.frame = 8
112
object.animationTimer = 0
113
object.timer++
114
end if
115
else
116
object.animationTimer++
117
if object.animationTimer >= 7
118
object.state = BUBBLESHIELD_IDLE_SETUP
119
end if
120
end if
121
break
122
123
end switch
124
end event
125
126
127
event ObjectDraw
128
if Player_superState != SUPERSTATE_SUPER
129
object.direction = FACING_RIGHT
130
if object.timer >= 30
131
if object.frame > 1
132
object.direction = FLIP_Y
133
end if
134
end if
135
136
// Draw at the player's position
137
DrawSpriteFX(object.frame, FX_FLIP, player[-playerCount].xpos, player[-playerCount].ypos)
138
end if
139
end event
140
141
142
event ObjectStartup
143
LoadSpriteSheet("Global/Items3.gif")
144
145
// Bubble shield frames
146
SpriteFrame(-24, -24, 48, 48, 1, 1)
147
SpriteFrame(-24, -24, 48, 48, 50, 1)
148
SpriteFrame(-16, -23, 32, 7, 99, 1)
149
SpriteFrame(-20, -22, 40, 12, 99, 9)
150
SpriteFrame(-22, -22, 44, 20, 99, 22)
151
SpriteFrame(-23, -20, 46, 19, 144, 1)
152
SpriteFrame(-23, -15, 46, 30, 144, 21)
153
SpriteFrame(-36, -16, 72, 32, 1, 50)
154
SpriteFrame(-28, -20, 56, 40, 74, 50)
155
SpriteFrame(0, 0, 1, 1, 1, 1) // (Empty)
156
end event
157
158
159
// ========================
160
// Editor Events
161
// ========================
162
163
event RSDKDraw
164
DrawSprite(0)
165
end event
166
167
168
event RSDKLoad
169
LoadSpriteSheet("Global/Display.gif")
170
SpriteFrame(-16, -16, 32, 32, 1, 143)
171
172
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
173
end event
174
175