Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello again Yal! Hope you're having a good summer,

I've been working on a shield system by copying how HP works and changing all the variables to ShieldHP essentially. I'm having trouble figuring out how to get the damage to "jump" over to reducing normal HP after the shield bar has been destroyed. ( I have separate dmgapply scripts for shield dmg and normal dmg below) It seems like the damage is stuck on trying to take from the sheildHP pool even after it has reached zero. Probably some simple thing i've overlooked :) Here's what I'm working with: 


//Damage

if(pow > 0){

        var dmgdata = compute_damage(a_user,trg,a_comm);

if(sheildcheck >0){

n = instance_create_depth(trg.x,trg.y,depth,obj_dmgapplyshld)

n.my_dmg = ceil(dmgdata[0]*ail_power_multiplier)

n.my_mul = dmgdata[1]

n.my_eff = dmgdata[2]

n.my_mon = trg

n.my_user = a_user

n.my_move = a_comm

n.this_is_an_attack = true

}

//********************

if(sheildcheck < 1){

n = instance_create_depth(trg.x,trg.y,depth,obj_damageapply)

n.my_dmg = ceil(dmgdata[0]*ail_power_multiplier)

n.my_mul = dmgdata[1]

n.my_eff = dmgdata[2]

n.my_mon = trg

n.my_user = a_user

n.my_move = a_comm

n.this_is_an_attack = true

//User might hold an item that improves attack effectiveness

if(battle_item_might_affect_this(a_user.amp_id,itemvalidflag_AUTO_ATTACKING)){

var it = amp_read_var(a_user.amp_id,amp_HELDITEM)

n.my_mul *= script_execute(global.item_data[it,id_USESCRIPT],[a_user.amp_id,trg.amp_id,a_comm],global.item_data[it,id_USEARG])

}

}

}


Thanks!!

The code you posted seems to make sense. The interesting thing here is how you compute sheildcheck, and you didn't include that bit of code...

Also, just to get the obvious out of the way: obj_damageapply still does HP damage and not shield damage, right? (So you didn't accidentally change that one as well when you changed all the variables)

(Also note that your two sheildcheck checks are >0 and <1 so both of them will occur for values between zero and one! Is this intentional?)

trg here is the target monster object and we've already checked that it's alive, so you really only need to check if amp_read_var(trg.amp_id,amp_SHIELDHP) is greater than zero: if so, deal shield damage, else deal regular damage.