Esempio n. 1
0
    void PrepareDamageData()
    {
        activeData.pokemonLevel           = source.pokemonData.level;
        activeData.pokemonBoosts          = source.pokemonData.boosts.ShallowCopy();
        activeData.pokemonStats           = source.pokemonData.stats.ShallowCopy();
        activeData.pokemonWasInWonderRoom = source.pokemonData.inWonderRoom;

        Battle.RelayVar relayVar;

        //Weather modifier
        relayVar = new Battle.RelayVar(integerValue: 100);
        relayVar = battle.RunEvent("WeatherModifyDamage", source.targetScript, null, activeData.moveData, relayVar);
        activeData.weatherModifier = relayVar.integerValue / 100f;

        //Not a modifier
        activeData.randomModifier = RandomScript.Randomizer(100) / 100f;

        //STAB
        if (source.pokemonData.HasType(activeData.moveType))
        {
            activeData.stabModifier = ((activeData.stab != -1) ? activeData.stab : 1.5f);
        }
        else
        {
            activeData.stabModifier = 1;
        }

        bool hitResult = !battle.SingleEvent("PrepareHit", activeData.moveData, null, null, source, activeData.moveData).getEndEvent();

        //if (!hitResult) return false;

        battle.RunEvent("PrepareHit", source.targetScript, null, activeData.moveData);
    }
Esempio n. 2
0
    public int ModifyDamage(int baseDamage, Pokemon pokemon, Pokemon target, ActiveMove activeMove)
    {
        Globals.Type type = activeMove.activeData.moveData.type;
        baseDamage += 2;

        RelayVar relayVar;

        //MultiTarget should go here but not needed

        //Weather modifier
        relayVar   = new RelayVar(integerValue: baseDamage);
        relayVar   = RunEvent("WeatherModifyDamage", pokemon.targetData, target.myPokemon, activeMove.activeData.moveData, relayVar);
        baseDamage = relayVar.integerValue;

        Debug.Log("Weather modifier: " + baseDamage);


        //crit
        if (activeMove.activeData.crit)
        {
            baseDamage = Mathf.FloorToInt(baseDamage * 1.5f);
        }

        Debug.Log("Crit modifier: " + baseDamage);


        //Not a modifier
        baseDamage = RandomScript.Randomizer(baseDamage);
        Debug.Log("Random modifier: " + baseDamage);


        //STAB
        if (pokemon.HasType(type))
        {
            baseDamage = Mathf.FloorToInt(baseDamage * ((activeMove.activeData.stab != -1) ? activeMove.activeData.stab : 1.5f));
        }

        Debug.Log("STAB modifier: " + baseDamage);


        //Types
        activeMove.activeData.typeMod = Mathf.Clamp(target.RunEffectiveness(activeMove), -6, 6);
        if (activeMove.activeData.typeMod > 0)
        {
            for (int i = 0; i < activeMove.activeData.typeMod; i++)
            {
                baseDamage *= 2;
            }
        }

        if (activeMove.activeData.typeMod < 0)
        {
            for (int i = 0; i > activeMove.activeData.typeMod; i--)
            {
                baseDamage = Mathf.FloorToInt(baseDamage / 2f);
            }
        }

        Debug.Log("Types modifier: " + baseDamage);


        //Burn Status
        if (pokemon.statusId == "brn" && activeMove.activeData.moveData.category == Globals.MoveCategory.Physical && !pokemon.HasAbilityActive(new string[] { "guts" }))
        {
            if (activeMove.id != "facade")
            {
                baseDamage = Mathf.FloorToInt(baseDamage * 0.5f);
            }
        }

        Debug.Log("Burn modifier: " + baseDamage);


        // Final modifier. Modifiers that modify damage after min damage check, such as Life Orb.
        relayVar   = new RelayVar(integerValue: baseDamage);
        relayVar   = RunEvent("ModifyDamage", pokemon.targetData, target.myPokemon, activeMove.activeData.moveData, relayVar);
        baseDamage = relayVar.integerValue;

        Debug.Log("other modifier: " + baseDamage);


        //Z breaking protect
        if (activeMove.activeData.zPowered && activeMove.activeData.zBrokeProtect)
        {
            baseDamage = Mathf.FloorToInt(baseDamage * 0.25f);
        }

        Debug.Log("z break protect modifier: " + baseDamage);


        if (baseDamage < 1)
        {
            baseDamage = 1;
        }

        return(Mathf.FloorToInt(baseDamage));
    }