Пример #1
0
    public DamageDetails TakeDamage(Move move, Pokemon attacker)
    {
        float critical = 1f;

        if (Random.value * 100f <= 6.25f)
        {
            critical = 2f;
        }

        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        var damageDetails = new DamageDetails()
        {
            TypeEffectiveness = type,
            Critical          = critical,
            Fainted           = false
        };

        float attack  = (move.Base.Category == MoveCategory.Special) ? attacker.SpAttack : attacker.Attack;
        float defense = (move.Base.Category == MoveCategory.Special) ? SpDefense : Defense;

        float modifiers = Random.Range(0.85f, 1f) * type * critical;
        float a         = (2 * attacker.Level + 10) / 250f;
        float d         = a * move.Base.Power * ((float)attack / defense) + 2;
        int   damage    = Mathf.FloorToInt(d * modifiers);

        UpdateHP(damage);

        return(damageDetails);
    }
Пример #2
0
    public DamageDetails TakeDamage(Move move, Pokemon attacker)
    {
        float critical = 1f;

        if (UnityEngine.Random.value * 100f <= 6.25f)
        {
            critical = 2f;
        }

        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        var damageDetails = new DamageDetails()
        {
            Type     = type,
            Critical = critical,
            Fainted  = false
        };

        float attack  = (move.Base.IsSpecial) ? attacker.SpAttack : attacker.Attack; // aixo es com un if else pero mes curt
        float defense = (move.Base.IsSpecial) ? SpDefense : Defense;

        float modifiers = UnityEngine.Random.Range(0.85f, 1f) * type * critical;
        float a         = (2 * attacker.Level + 10) / 250f;
        float d         = a * move.Base.Power * ((float)attack / defense) + 2;
        int   damage    = Mathf.FloorToInt(d * modifiers);

        HP -= damage;
        if (HP <= 0)
        {
            HP = 0;
            damageDetails.Fainted = true; //pokemon = fainted
        }
        return(damageDetails);
    }
Пример #3
0
    public DamageDetails TakeDamage(Move move, Nuzlon attacker)
    {
        //this is the damage magic. This is where you must look at the numbers to see how much damage moves should do
        float typeEffect = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        DamageDetails details = new DamageDetails()
        {
            TypeEffect = typeEffect,
            Fainted    = false
        };

        float attack  = (move.Base.IsRanged) ? attacker.SpecialAttack : attacker.Attack;
        float defense = (move.Base.IsRanged) ? SpecialDefense : Defense;

        float modifiers = Random.Range(0.85f, 1f) * typeEffect;
        float a         = (2f * attacker.Level + 10f) / 50f;
        float d         = a * move.Base.Power * (attack / defense) + 2f;
        int   damage    = Mathf.FloorToInt(d * modifiers);

        CurrentHP -= damage;
        if (CurrentHP <= 0)
        {
            CurrentHP       = 0;
            details.Fainted = true;
        }
        return(details);
    }
Пример #4
0
    public DamageDetails TakeDamage(Move move, Character attacker)
    {
        float critical = 1f;

        if (Random.value * 100f <= 6.25f)
        {
            critical = 2f;
        }

        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        var damageDetails = new DamageDetails()
        {
            TypeEffectiveness = type,
            Critical          = critical,
            Fainted           = false
        };

        float modifiers = Random.Range(0.85f, 1f) * type * critical;
        float a         = (2 * attacker.Level + 10) / 250f;
        float d         = a * move.Base.Power * ((float)attacker.Attack / Defense) + 2;
        int   damage    = Mathf.FloorToInt(d * modifiers);

        HP -= damage;
        if (HP <= 0)
        {
            HP = 0;
            damageDetails.Fainted = true;
        }

        return(damageDetails);
    }
Пример #5
0
    public DamageInfo TakeDamage(Move move, Pokemon attacker)
    {
        AudioManager.instance.PlaySound("Hit");

        float atk = 1.0f;
        float def = 1.0f;

        if (move.Base.AtkType == AttackType.Physical)
        {
            atk = attacker.Attack;
            def = Defence;
        }
        else if (move.Base.AtkType == AttackType.Special)
        {
            atk = attacker.SpAtk;
            def = SpDef;
        }

        float crit = 1.0f;

        if (Random.value * 100.0f <= 4.167f)
        {
            crit = 2.0f;
        }

        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        var dmgInfo = new DamageInfo()
        {
            Critical          = crit,
            TypeEffectiveness = type,
            Faint             = false
        };

        float modifiers = Random.Range(0.85f, 1.0f) * type * crit;
        float a         = (attacker.level * 0.4f + 2);
        float d         = (a * move.Base.Power * (atk / def) * 0.02f) + 2;

        if (move.Base.Power == 0)
        {
            d = 0.0f;
        }
        int dmg = Mathf.FloorToInt(d * modifiers);

        hp -= dmg;

        if (hp <= 0)
        {
            hp            = 0;
            dmgInfo.Faint = true;
        }

        return(dmgInfo);
    }
Пример #6
0
    public Move GetAIMove(Pokemon target, int depth = 0)
    {
        //Test random Move
        int r = Random.Range(0, Moves.Count);

        if (TypeChart.GetEffectiveness(Moves[r].Base.Type, target.Base.Type1) >= 1.0f)
        {
            return(Moves[r]); // Move is Effective
        }
        else if (depth > 4)
        {
            return(Moves[r]); // Take it or leave it
        }
        else
        {
            return(GetAIMove(target, ++depth)); // Try Again
        }
    }
Пример #7
0
    //this calculation is the same as the one preformed in a pokemon game, complicated. Yes.
    public DamageDetails TakeDamage(Move move, Creature attacker)
    {
        //crit hits happen only 6.25 percent of the time
        float critical = 1f;

        if (Random.value * 100f <= 6.25f)
        {
            critical = 2f;
        }

        //uses the type chart to get effectivenss of attacks
        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        var damageDetails = new DamageDetails()
        {
            TypeEffectiveness = type,
            Critical          = critical,
            Fainted           = false
        };

        //conditional operator, in place of an if else
        float attack  = (move.Base.Category == MoveCategory.Special) ? attacker.SpecialAttack : attacker.Attack;
        float defense = (move.Base.Category == MoveCategory.Special) ? SpecialDefense : Defense;

        //modifiers including random range, type bonus and critical bonus
        float modifiers = Random.Range(0.85f, 1f) * type * critical;
        float a         = (2 * attacker.Level + 10) / 250f;
        float d         = a * move.Base.Power * ((float)attack / defense) + 2;
        int   damage    = Mathf.FloorToInt(d * modifiers);

        //HP -= damage;
        //if(HP <= 0)
        //{
        //    HP = 0;
        //    damageDetails.Fainted = true;
        //}
        UpdateHP(damage);

        return(damageDetails);
    }
    public Move EnemyAtk(Pokemon playerPokemon)
    {
        PokemonType type1 = playerPokemon.Base.Type1;
        PokemonType type2 = playerPokemon.Base.Type2;

        List <MoveInfo> moveInfos = new List <MoveInfo>();

        foreach (var move in enemyUnit.Pokemon.Moves)
        {
            if (move.Base.AtkType != AttackType.StatChange)
            {
                MoveInfo info = new MoveInfo();
                info.move = move;
                info.typeEffectiveness = TypeChart.GetEffectiveness(move.Base.Type, type1) * TypeChart.GetEffectiveness(move.Base.Type, type2);
                moveInfos.Add(info);
            }
        }

        MoveInfo finalMove = new MoveInfo();

        finalMove = moveInfos[0];
        foreach (var moveInfo in moveInfos)
        {
            if (moveInfo.typeEffectiveness > finalMove.typeEffectiveness)
            {
                finalMove = moveInfo;
            }
            else if (moveInfo.typeEffectiveness == finalMove.typeEffectiveness)
            {
                if (moveInfo.move.Base.Power > finalMove.move.Base.Power)
                {
                    finalMove = moveInfo;
                }
            }
        }

        return(finalMove.move);
    }
Пример #9
0
    public DamageDetails TakeDamage(Move move, PokemonLevel attacker)
    {
        float criticalhit = 1.0f;

        if (Random.value * 100.0f <= 6.25)   // random value for critical hit
        {
            criticalhit = 2.0f;
        }

        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        var damageDetails = new DamageDetails()
        {
            TypeEffectiveness = type,
            Critical          = criticalhit,
            Fainted           = false
        };

        float attack  = (move.Base.Category == MoveCategory.Special)? attacker.SpAttack : attacker.Attack;
        float defense = (move.Base.Category == MoveCategory.Special) ? SpDefense : Defense;

        float modifiers = Random.Range(0.85f, 1.0f) * type * criticalhit;      // damage depend on the Level of the attacker // random range so that the damage is a lil bit different everytime
        float a         = (2 * attacker.Level + 10) / 250f;
        float d         = a * move.Base.Power * ((float)attack / defense) + 2; // depend the power of the move and the attack stats and the defense the pokemon.
        int   damage    = Mathf.FloorToInt(d * modifiers);

        UpdateHP(damage);

        //HP -= damage; // checking if the pokemon faint
        //if(HP <= 0)
        //{
        //    HP = 0;
        //    damageDetails.Fainted = true;
        //}

        return(damageDetails);
    }
Пример #10
0
    public DamageDetails TakeDamage(Move move, Pokemon attacker)
    {
        //Crtic hit prob
        float critical = 1f;

        if (Random.value * 100f <= criticalHitRate)
        {
            critical = 1.5f;
        }

        //Type efectivenes
        float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2);

        //STAB
        float stab = attacker.CalculateStab(move);

        float modifiers = Random.Range(0.85f, 1f) * type * critical * stab;

        var damageDetails = new DamageDetails()
        {
            Effectiveness = type,
            Critical      = critical,
            Fainted       = false
        };

        //Determinamos la categoría del movimiento:
        float attack  = (move.Base.Category == MoveCategory.Special) ? attacker.SpAttack : attacker.Attack;
        float defense = (move.Base.Category == MoveCategory.Special) ? attacker.SpDefense : attacker.Defense;

        //Formula real:
        float a      = ((2 * attacker.Level) / 5) + 2;
        float d      = ((a * move.Base.Power * (attack / defense)) / 50f) + 2;
        int   damage = Mathf.FloorToInt(d * modifiers);

        UpdateHP(damage);
        return(damageDetails);
    }
Пример #11
0
    public DamageDetails TakeDamage(Move move, Pokemon attacker)
    {
        float critical = 1f;

        if (Random.value * 100f <= 6.25f)
        {
            critical = 2f;
        }

        float type = TypeChart.GetEffectiveness(move.Base.GetType1(), this._base.GetType1()) * TypeChart.GetEffectiveness(move.Base.GetType1(), this._base.GetType2()) * TypeChart.GetEffectiveness(move.Base.GetType1(), this._base.GetType3());

        var damageDetails = new DamageDetails()
        {
            TypeEffectiveness = type,
            Critical          = critical,
            ko = false
        };

        float modifier = Random.Range(0.05f, 1f) * type * critical;
        float a        = (float)((0.4 * attacker.level) + 2);

        Debug.Log(a);
        float d = (float)(a * move.Base.GetPower() * (float)attacker.GetAttack() / (GetDefense() * 50)) + 2;

        Debug.Log(d);
        int damage = Mathf.FloorToInt(d * modifier);

        Debug.Log(damage);
        HP -= damage;
        if (HP <= 0)
        {
            HP = 0;
            damageDetails.ko = true;
        }
        return(damageDetails);
    }