ID:2773359
 
mob
proc
Fire()
switch(ChargeLvl) // When you hold a key, a number goes up and the ChargeLvl changes at certain intervals; 5 seconds for 1, 15 seconds for 2, 45 seconds for Chargelvl 3.
if(0)
var/obj/Projectile/A = new()
if(src.Lvl == 4) A.icon += rgb(15,185,255)
else A.icon += rgb(255,185,15)
A.icon_state = "Fire0" // This line is where my actual problem comes up.
A.Attribute = "Fire"
A.loc = loc
A.atk = Atk * 0.8
if(S1 == "Hard-Hitting") A.kb = 1
A.Owner = src
A.OwnerName = src.name
walk(A,dir,0,2)
spawn(50) del(A)
cd = 10
if(1)
var/obj/Projectile/A = new()
if(src.Lvl == 4) A.icon += rgb(15,185,255)
else A.icon += rgb(255,185,15)
A.icon_state = "Fire1"
A.Attribute = "Fire"
A.loc = loc
A.atk = Atk * 1.8
if(S1 == "Hard-Hitting") A.kb = 1
A.Owner = src
A.OwnerName = src.name
walk(A,dir,0,2)
spawn(50) del(A)
cd = 25
if(2)
var/obj/Projectile/A = new()
if(src.Lvl == 4) A.icon += rgb(0,0,0)
else A.icon += rgb(135,45,255)
A.icon_state = "Fire2"
A.Attribute = "Fire"
A.loc = loc
A.atk = Atk * 4.2
if(S1 == "Hard-Hitting") A.kb = 1
A.Owner = src
A.OwnerName = src.name
walk(A,dir,0,2)
spawn(50) del(A)
cd = 60
if(3)
var/obj/Projectile/A = new()
if(src.Lvl == 4) A.icon += rgb(185,185,185)
else A.icon += rgb(255,95,15)
A.icon_state = "Fire3"
A.Attribute = "Fire"
A.loc = loc
A.atk = Atk * 12.8
if(S1 == "Hard-Hitting") A.kb = 1
A.Owner = src
A.OwnerName = src.name
walk(A,dir,0,2)
spawn(50) del(A)
cd = 300


Problem description:
I have one icon file; Projectiles.dmi with a bunch of icon_states for different projectiles (Fireball, Earth Spikes, etc.). Sometimes, when creating a projectile, the icon_state gets "stuck". No matter what ChargeLvl the skill has charged up to, the resulting projectile will have the "Fire2" icon state. There are a number of other skills, Water, Earth, etc. etc., and they each have their own isolated but identical incident. All Water skills will get stuck with Water1 icon, or Earth skills will be stuck on the Earth0 icon, and so on.

My first question is; can anyone tell what's causing this based on the description of the issue?

Second question; My first thought is to take each different icon_state and give them their own icon files. Is that already my best option, or is there a better way to deal with it?

Thanks in advance.
at the first place, you have check your code. To catch bugs i always printing my data to check where am I.

obj/Projectile
var
mob/owner
damage
cooldown

New(Loc, Dir, Owner, Icon_state, Damage, cooldown)
loc = Loc
dir = Dir
owner = Owner
icon_state = Icon_state
damage = Damage
walk(src,dir)
world<<"<B>DEBUG:</b> Loc: [Loc]"//check ChargeLvl
world<<"<B>DEBUG:</b> Dir: [Dir]"//check Dir
world<<"<B>DEBUG:</b> Loc: [Owner]"//check Owner
world<<"<B>DEBUG:</b> Loc: [Icon_state]"//check Icon_state
world<<"<B>DEBUG:</b> Loc: [Damage]"//check Damage
world<<"<B>DEBUG:</b> Loc: [cooldown]"//check cooldown
spawn (cooldown) del (src)



mob/proc/Fire(ChargeLvl)
// icon = 'projectle.dmi'
var
newIS
newDamage
newCooldown
switch(ChargeLvl)
if(1)
newIS="Fire1"
newDamage = 10
newCooldown = 10
if(2)
newIS="Fire2"
newDamage = 20
newCooldown = 20
if(3)
newIS="Fire3"
newDamage = 30
newCooldown = 30
world<<"<B>DEBUG:</b> [ChargeLvl]"//check ChargeLvl
world<<"<B>DEBUG:</b> [newIS]"//check newIS
new/obj/Projectile(get_step(src,src.dir), src.dir, src, newIS, newDamage, newCooldown)


mob/verb/Test_FB()
Fire(1)