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/LightningShield.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: LightningShield 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.frameTimer
13
private alias object.value1 : object.animTimer
14
private alias object.value18 : object.sortedDrawOrder
15
16
// Player aliases
17
private alias object.state : player.state
18
private alias object.xpos : player.xpos
19
private alias object.ypos : player.ypos
20
21
// Super States
22
private alias 1 : SUPERSTATE_SUPER
23
24
25
// ========================
26
// Tables
27
// ========================
28
29
private table LightningShield_frameTable
30
0, 1, 2, 3, 4, 3, 2, 1, 0, 5, 6, 7
31
end table
32
33
private table LightningShield_planeTable
34
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1
35
1, 1, 1, 1, 1, 0, 0, 0
36
end table
37
38
private table LightningShield_directionTable
39
0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1
40
0, 0, 0, 0, 0, 0, 0, 0
41
end table
42
43
private table LightningShield_durationTable
44
4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2
45
end table
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
// Bug Details:
54
// Unlike the other shields which set its draw order to -1, this one sets it to 7
55
// This would act the same way... if your name isn't Origins and you didn't make draw order 7 an actual thing
56
// Otherwise it'll end up drawing in front of every tile regardless of the player's draw order
57
object.drawOrder = 7
58
59
// Unload if the player shouldn't have a shield
60
if player[-playerCount].state == Player_State_Death
61
object.type = TypeName[Blank Object]
62
end if
63
if player[-playerCount].state == Player_State_Drown
64
object.type = TypeName[Blank Object]
65
end if
66
67
// Update animation
68
object.animationTimer--
69
70
if object.animationTimer <= 0
71
72
object.frameTimer++
73
if object.frameTimer >= 12
74
object.frameTimer = 0
75
end if
76
77
object.animTimer++
78
if object.animTimer >= 24
79
object.animTimer = 0
80
end if
81
82
GetTableValue(object.animationTimer, object.frameTimer, LightningShield_durationTable)
83
GetTableValue(object.sortedDrawOrder, object.animTimer, LightningShield_planeTable)
84
GetTableValue(object.direction, object.animTimer, LightningShield_directionTable)
85
86
end if
87
88
GetTableValue(object.frame, object.frameTimer, LightningShield_frameTable)
89
end event
90
91
92
event ObjectDraw
93
if Player_superState != SUPERSTATE_SUPER
94
DrawSpriteFX(object.frame, FX_FLIP, object[-playerCount].xpos, object[-playerCount].ypos)
95
end if
96
end event
97
98
99
event ObjectStartup
100
LoadSpriteSheet("Global/Items3.gif")
101
102
// Sprite frames
103
SpriteFrame(-8, -24, 31, 48, 191, 1)
104
SpriteFrame(-1, -24, 24, 48, 223, 1)
105
SpriteFrame(-8, -24, 31, 48, 174, 52)
106
SpriteFrame(-8, -24, 32, 48, 206, 52)
107
SpriteFrame(-8, -24, 16, 48, 239, 52)
108
SpriteFrame(-24, -24, 48, 48, 1, 83)
109
SpriteFrame(-24, -24, 48, 48, 50, 91)
110
SpriteFrame(-24, -24, 48, 48, 99, 91)
111
SpriteFrame(0, 0, 1, 1, 1, 1) // Empty frame
112
end event
113
114
115
// ========================
116
// Editor Events
117
// ========================
118
119
event RSDKDraw
120
DrawSprite(0)
121
end event
122
123
124
event RSDKLoad
125
LoadSpriteSheet("Global/Items3.gif")
126
SpriteFrame(-8, -24, 31, 48, 191, 1)
127
128
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
129
end event
130
131