public override float cast(gameChar source, gameChar target, int currentRound) { float sourceMP = source.getCurrentMP(); if (sourceMP < cost) { return(-1); } source.setCurrentMP(sourceMP - cost); float effectingVal = 0; float magicDef = target.getIntVal() + target.getIntMod(); effectingVal = effectVal * (source.getIntVal() + source.getIntMod()) * 1 + magicDef; //value = -(spellAmount * intelligence * amplifier - targetIntelligence) 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) base.setTargetParam(target, 0, (int)(effectingVal)); return(-(effectingVal)); //effectingVal must be <0 and negate it }
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 override float cast(gameChar source, gameChar target, int currentRound) { float sourceMP = source.getCurrentMP(); if (sourceMP < cost) { return(-1); } source.setCurrentMP(sourceMP - cost); float effectingVal = 0; effectingVal = effectVal * (source.getIntVal() + source.getIntMod()) * 1; //value = spellAmount * intelligence * amplifier if ((target.getCurrentHP() + effectingVal) >= target.getMaxHP()) { effectingVal = target.getMaxHP() - target.getCurrentHP(); } //if amount + current health > max health, set difference = max hp - current hp setTargetParam(target, 0, (int)(effectingVal)); return(effectingVal); //effectingVal must be <0 and negate it }
public void setTargetParam(gameChar target, int field, int effectVal) { switch (field) { case 0: target.setCurrentHP(target.getCurrentHP() + effectVal); break; case 1: target.setCurrentMP(target.getCurrentMP() + effectVal); break; case 2: target.setAttMod(target.getAttMod() + effectVal); break; case 3: target.setDefMod(target.getDefMod() + effectVal); break; case 4: target.setIntMod(target.getIntMod() + effectVal); break; } }
public bool unEquipChar(gameChar equiped) { for (int i = 0; i < rank; i++) //for each rank, unset owner's attribute { float effectingVal = attributePair[i].second; switch ((int)(attributePair[i].first)) { case 0: { equiped.setMaxHP(equiped.getMaxHP() - effectingVal); equiped.setCurrentHP(equiped.getCurrentHP() - effectingVal); break; } case 1: { equiped.setMaxMP(equiped.getMaxMP() - effectingVal); equiped.setCurrentMP(equiped.getCurrentMP() - effectingVal); break; } case 2: { equiped.setAttack(equiped.getAttack() - effectingVal); break; } case 3: { equiped.setDefense(equiped.getDefense() - effectingVal); break; } case 4: { equiped.setIntelligence(equiped.getIntelligence() - effectingVal); break; } default: { return(false); break; } } } return(true); }