Пример #1
0
    void TreatSecondaries(TargetableElement target, Globals.SecondaryEffect secondary, bool isSelf)
    {
        bool hitResult = false;

        if (target.sourceElement is PokemonCharacter)
        {
            int     didSomething = -1;
            Pokemon pokeTarget   = ((PokemonCharacter)target.sourceElement).pokemonData;

            //Secondary boosts
            if (secondary.boosts != null && !pokeTarget.fainted)
            {
                hitResult    = battle.Boost(secondary.boosts, target, source, secondary.SecondaryToMove());
                didSomething = (hitResult) ? 1 : 0;
            }

            //Secondary status
            if (secondary.status != "")
            {
                hitResult = pokeTarget.TrySetStatus(secondary.status, source, secondary.SecondaryToMove());
                if (!hitResult)
                {
                    return;
                }
                if (didSomething < 1)
                {
                    didSomething = (hitResult) ? 1 : 0;
                }
            }

            //Secondary volatile
            if (secondary.volatileStatus != "")
            {
                //FLONCH
                if (secondary.volatileStatus != "flinch")
                {
                    pokeTarget.StartActionCoolDown();
                }
                else
                {
                    hitResult = pokeTarget.AddVolatile(secondary.volatileStatus, source, secondary.SecondaryToMove());
                    if (didSomething < 1)
                    {
                        didSomething = (hitResult) ? 1 : 0;
                    }
                }
            }
        }
    }
Пример #2
0
    protected int MoveHit(TargetableElement target, EffectData moveData = null, bool isSecondary = false, bool isSelf = false)
    {
        int damage = -1;

        if (moveData == null)
        {
            moveData = activeData.moveData;
        }

        /*
         * TryHitField (singleevent)
         * TryHitSide (singleevent)
         * TryHit (singleevent)
         * TryPrimaryHit (runevent)
         */

        if (target.sourceElement is PokemonCharacter)
        {
            int     didSomething = -1;
            Pokemon pokeTarget   = ((PokemonCharacter)target.sourceElement).pokemonData;
            damage = GetDamage(pokeTarget);

            /*
             * selfdestruct stuff
             */
            if (damage >= 0 && !pokeTarget.fainted)
            {
                if (activeData.moveData.noFaint && damage >= pokeTarget.hp)
                {
                    damage = pokeTarget.hp - 1;
                }
                damage = battle.Damage(damage, target, source, activeData.moveData);
                //Damage interrumped
                if (damage <= 0)
                {
                    return(-1);
                }
                didSomething = 1;
            }

            /*
             * boosts stuff
             * heal stuff
             * status stuff
             * forceStatus stuff
             * volatileStatus stuff
             * sideCondition stuff
             * weather stuff
             * terrain stuff
             * pseudoWeather stuff
             * forceSwitch stuff
             * selfSwitch stuff
             *
             * //HIT EVENTS
             * HitField (singleevent)
             * HitSide (singleevent)
             * Hit (singleevent)
             * Hit (runevent)
             * AfterHit (singleevent)
             */
            //if the move didnt do someting return false
            if (didSomething < 0)
            {
                didSomething = 1;
            }

            if (didSomething == 0 && moveData.self == null &&
                (moveData is MoveData) && ((MoveData)moveData).selfdestruct == "")
            {
                return(-1);
            }
        }


        //Move has self && !selfdropped
        //move has secondaries
        if (moveData.secondaries != null)
        {
            Globals.SecondaryEffect[] secondaries = new Globals.SecondaryEffect[moveData.secondaries.Length];
            for (int i = 0; i < secondaries.Length; ++i)
            {
                secondaries[i] = moveData.secondaries[i].DeepCopy();
            }

            Battle.RelayVar relayVar = new Battle.RelayVar(secondaries: secondaries);
            secondaries = battle.RunEvent("ModifySecondaries", target, source, activeData.moveData, relayVar).secondaries;

            foreach (Globals.SecondaryEffect secondary in secondaries)
            {
                int secondaryRoll = RandomScript.RandomBetween(0, 100);
                if (secondary.chance < 0 || secondaryRoll < secondary.chance)
                {
                    TreatSecondaries(target, secondary, isSelf);
                }
            }
        }
        //Dragout
        //SelfSwitch
        return(damage);
    }