public override float cast(gameChar source, gameChar target, int currentRound) { float effectingVal = 0; int chance = Random.Range(0, 100); if (chance < 40) { return(0); } effectingVal = effectVal * (source.getAttVal() + source.getAttMod()) - (target.getDefVal() + target.getDefMod()); //damage = val * att - def if (effectingVal <= 0) { effectingVal = 1; //if no damage, set damage to 1 } effectingVal = -(effectingVal); if (Mathf.Abs(effectingVal) >= target.getCurrentHP()) { effectingVal = -(target.getCurrentHP()); } //if damage > current health, set difference = currentHP (currentHP - currentHP = 0) setTargetParam(target, 0, (int)(effectingVal)); return(-(effectingVal)); //effectingVal must be <0 and negate it }
public float attackChar(gameChar target) //attack function { float ownAttack = getAttVal() + attMod; float targetDefense = target.getDefVal() + target.getDefMod(); float damage = (ownAttack - targetDefense) * 1.5f; if (damage <= 0) { damage = 1; } return(damage); }