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/LightningShield.txt
1481 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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
if object.animationTimer <= 0
70
71
object.frameTimer++
72
if object.frameTimer >= 12
73
object.frameTimer = 0
74
end if
75
76
object.animTimer++
77
if object.animTimer >= 24
78
object.animTimer = 0
79
end if
80
81
GetTableValue(object.animationTimer, object.frameTimer, LightningShield_durationTable)
82
GetTableValue(object.sortedDrawOrder, object.animTimer, LightningShield_planeTable)
83
GetTableValue(object.direction, object.animTimer, LightningShield_directionTable)
84
85
end if
86
87
GetTableValue(object.frame, object.frameTimer, LightningShield_frameTable)
88
end event
89
90
91
event ObjectDraw
92
if Player_superState != SUPERSTATE_SUPER
93
DrawSpriteFX(object.frame, FX_FLIP, player[-playerCount].xpos, player[-playerCount].ypos)
94
end if
95
end event
96
97
98
event ObjectStartup
99
LoadSpriteSheet("Global/Items3.gif")
100
101
// Sprite frames
102
SpriteFrame(-8, -24, 31, 48, 191, 1)
103
SpriteFrame(-1, -24, 24, 48, 223, 1)
104
SpriteFrame(-8, -24, 31, 48, 174, 52)
105
SpriteFrame(-8, -24, 32, 48, 206, 52)
106
SpriteFrame(-8, -24, 16, 48, 239, 52)
107
SpriteFrame(-24, -24, 48, 48, 1, 83)
108
SpriteFrame(-24, -24, 48, 48, 50, 91)
109
SpriteFrame(-24, -24, 48, 48, 99, 91)
110
SpriteFrame(0, 0, 1, 1, 1, 1) // Empty frame
111
end event
112
113
114
// ========================
115
// Editor Events
116
// ========================
117
118
event RSDKDraw
119
DrawSprite(0)
120
end event
121
122
123
event RSDKLoad
124
LoadSpriteSheet("Global/Display.gif")
125
SpriteFrame(-16, -16, 32, 32, 1, 143)
126
127
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
128
end event
129
130