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/SBZ/PlasmaBall.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Plasma Ball 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
private alias object.value1 : object.targetPos.x
14
private alias object.value2 : object.animTimerMax
15
private alias object.value3 : object.animSpeed
16
private alias object.value4 : object.frameTable
17
18
private alias 0 : PLASMABALL_SETUP
19
private alias 1 : PLASMABALL_MOVETOPOS
20
private alias 2 : PLASMABALL_CHARGING
21
private alias 3 : PLASMABALL_ACTIVE
22
23
// Player Aliases
24
private alias object.xpos : player.xpos
25
26
27
// ========================
28
// Tables
29
// ========================
30
31
private table PlasmaBall_chargingFrames
32
0, 8, 1, 9, 6, 7, 0, 8, 1, 9, 6, 7, 2, 3, 4, 5
33
end table
34
35
private table PlasmaBall_attackingFrames
36
6, 1, 7, 1
37
end table
38
39
40
// ========================
41
// Events
42
// ========================
43
44
event ObjectUpdate
45
switch object.state
46
case PLASMABALL_SETUP
47
object.frameTable = PlasmaBall_chargingFrames
48
object.animTimerMax = 63
49
object.animSpeed = 2
50
object.xvel = object.targetPos.x
51
object.xvel -= object.xpos
52
object.xvel >>= 4
53
object.state++
54
break
55
56
case PLASMABALL_MOVETOPOS
57
if object.alpha < 192
58
object.alpha += 16
59
end if
60
61
object.xpos += object.xvel
62
if object.xpos <= object.targetPos.x
63
object.timer = 180
64
object.state++
65
end if
66
break
67
68
case PLASMABALL_CHARGING
69
object.timer--
70
if object.timer <= 0
71
object.animationTimer = 0
72
object.alpha = 128
73
object.frameTable = PlasmaBall_attackingFrames
74
object.animTimerMax = 7
75
object.animSpeed = 1
76
object.xvel = player[0].xpos
77
object.xvel -= object.xpos
78
object.xvel >>= 8
79
object.yvel = 0x14000
80
object.timer = 133
81
object.state++
82
end if
83
break
84
85
case PLASMABALL_ACTIVE
86
object.xpos += object.xvel
87
object.ypos += object.yvel
88
object.timer--
89
if object.timer <= 0
90
object.type = TypeName[Blank Object]
91
end if
92
break
93
94
end switch
95
96
object.animationTimer++
97
object.animationTimer &= object.animTimerMax
98
temp0 = object.animationTimer
99
temp0 >>= object.animSpeed
100
GetTableValue(object.frame, temp0, object.frameTable)
101
102
if object.frameTable == PlasmaBall_attackingFrames
103
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
104
BoxCollisionTest(C_TOUCH, object.entityPos, -12, -12, 12, 12, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
105
if checkResult == true
106
CallFunction(Player_LightningHit)
107
end if
108
next
109
end if
110
end event
111
112
113
event ObjectDraw
114
if object.frameTable == PlasmaBall_attackingFrames
115
DrawSpriteXY(object.frame, object.xpos, object.ypos)
116
DrawSpriteFX(5, FX_INK, object.xpos, object.ypos)
117
else
118
DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)
119
end if
120
end event
121
122
123
event ObjectStartup
124
LoadSpriteSheet("SBZ/Objects.gif")
125
SpriteFrame(-16, -16, 32, 32, 2, 397)
126
SpriteFrame(-12, -12, 24, 24, 35, 397)
127
SpriteFrame(-5, -5, 10, 10, 60, 397)
128
SpriteFrame(-7, -7, 14, 14, 71, 397)
129
SpriteFrame(-8, -8, 16, 16, 86, 397)
130
SpriteFrame(-12, -12, 24, 24, 103, 397)
131
SpriteFrame(-7, -7, 14, 15, 128, 397)
132
SpriteFrame(-7, -7, 14, 15, 145, 397)
133
SpriteFrame(-16, -16, 32, 32, 2, 430)
134
SpriteFrame(-12, -12, 24, 24, 35, 430)
135
136
// No Plasma Balls are even in the scene on startup...
137
foreach (TypeName[Plasma Ball], arrayPos0, ALL_ENTITIES)
138
object[arrayPos0].inkEffect = INK_ADD
139
object[arrayPos0].alpha = 0x80
140
next
141
end event
142
143
144
// ========================
145
// Editor Events
146
// ========================
147
148
event RSDKDraw
149
DrawSprite(0)
150
end event
151
152
153
event RSDKLoad
154
LoadSpriteSheet("SBZ/Objects.gif")
155
SpriteFrame(-16, -16, 32, 32, 2, 397)
156
157
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
158
end event
159
160