Example #1
0
    //If player attack, calculate damage
    public int BattleDamageCalculate(SkillInfo usedSkill, Student attacker, Student defenser, int[] _battleTempStat)
    {
        if (usedSkill.retGiveStatus() != status.none)
            defenser.giveAStatus(usedSkill.retGiveStatus());
        usedSkill.decChance();
        int attributeRelation1 = (int)attacker.getStuIndex() / 10;
        int attributeRelation2 = (int)defenser.getStuIndex() / 10;

        double AttackRate = 1;   //find attack is special attack or normal attack
        double damage = 0;       //return total damage that defenser have to take
        float AttributeCal = 1; //Calculate damage Changed by AttributeCal
        float[] battleTempStat = new float[12];

        if(usedSkill.retType() == attributeRelation1) //if Attacker type and used Skill type is same, get bonus damage
        {AttributeCal *= 1.5f;}

        int RandomRate  = (int)Random.Range(217,255)*100/255;    //make random damage;

        for (int i = 0; i < 12; i++)
        {
            if (_battleTempStat[i] > 0)
                battleTempStat[i] = (2 + _battleTempStat[i]) / (float)(_battleTempStat[i]);
            else if (_battleTempStat[i] < 0)
                battleTempStat[i] = (float)(2) / (2 + _battleTempStat[i]);
            else
                battleTempStat[i] = 1;
        }

        if (usedSkill.retAtkType() == 0)
        {  //calculate the damage of
            AttackRate = (usedSkill.retDamage())*(attacker.retStuStat(0))*battleTempStat[0]/(defenser.retStuStat(2)/battleTempStat[8]);
        }else        {
            AttackRate = (usedSkill.retDamage())*(attacker.retStuStat(1))*battleTempStat[1]/(defenser.retStuStat(3)/battleTempStat[9]);
        }

        damage =(((
                    (
                        (attacker.retStuStat(6)*2/5)+2  //attackers level
                    )
                    *AttackRate/50                          //used skill damage * attacker,defensers ability
                )+2)
                *RandomRate/100                             //random damage
                *AttributeCal*Attribute.attribute[attributeRelation1,attributeRelation2] //attribute;
                );

        return (int)damage;
    }
Example #2
0
 public void checkBattleTurnEndEvent(Student stu)
 {
     if (stu.retStuStatus() == status.poison)
         stu.getDamage((int)(stu.retStuStat(5)*5.0/8));
 }