Exemple #1
0
 public void Init(Battle b, PokemonSet set, Battle.Team t)
 {
     pokemonData  = new Pokemon(b, set, t, this);
     targetScript = GetComponent <TargetableElement>();
     targetScript.sourceElement = this;
     this.id           = pokemonData.speciesId;
     currentActiveMove = null;
 }
Exemple #2
0
    bool CanMegaEvolve(TemplateData baseTemplate, PokemonSet set)
    {
        //Has no alternate forms, It should have one in the template
        if (baseTemplate.otherFormes == null)
        {
            return(false);
        }

        ItemData     item = (Items.BattleItems.ContainsKey(set.itemId) ? Items.BattleItems[set.itemId] : null);
        TemplateData altForme;

        for (int i = 0; i < baseTemplate.otherFormes.Length; ++i)
        {
            //Doesnt exist in the database
            if (!Pokedex.BattlePokedex.ContainsKey(baseTemplate.otherFormes[i]))
            {
                continue;
            }
            altForme = Pokedex.BattlePokedex[baseTemplate.otherFormes[i]];
            //Not a mega form
            if (!altForme.isMega)
            {
                continue;
            }
            //Check if can evolve by Move
            if (altForme.requiredMove != "")
            {
                //Holds a Z item, so, cant mega evolve
                if (item != null && item.iszMove)
                {
                    continue;
                }

                //Checking if the pokemon has the required move
                for (int j = 0; j < set.movesId.Length; ++j)
                {
                    //If the pokemon has the move and it is in the database
                    if (altForme.requiredMove == set.movesId[j] && Moves.BattleMovedex.ContainsKey(set.movesId[j]))
                    {
                        return(true);
                    }
                }
            }
            //Check if can evolve by item
            if (item == null)
            {
                continue;
            }
            //if it megaevolves from the baseSpecies and the pokemon is not the megaevolution
            if (item.megaEvolves == baseTemplate.baseSpecies && item.megaStone != baseTemplate.species && item.megaStone == altForme.species)
            {
                return(true);
            }
        }
        return(false);
    }
Exemple #3
0
        public void SetBattleStats(PokemonSet set)
        {
            //Math.floor(Math.floor(2 * stat + set.ivs[statName] + ) * set.level / 100 + 5);
            atk = (2 * atk + set.ivs.atk + (set.evs.atk / 4)) * set.level / 100 + 5;
            def = (2 * def + set.ivs.def + (set.evs.def / 4)) * set.level / 100 + 5;
            spa = (2 * spa + set.ivs.spa + (set.evs.spa / 4)) * set.level / 100 + 5;
            spd = (2 * spd + set.ivs.spd + (set.evs.spd / 4)) * set.level / 100 + 5;
            spe = (2 * spe + set.ivs.spe + (set.evs.spe / 4)) * set.level / 100 + 5;

            //HP
            //Math.floor(Math.floor(2 * stat + set.ivs['hp'] + Math.floor(set.evs['hp'] / 4) + 100) * set.level / 100 + 10);
            hp = (2 * hp + set.ivs.hp + (set.evs.hp / 4) + 100) * set.level / 100 + 10;

            NatureModify(set.nature);
        }
Exemple #4
0
    bool CanUltraBurst(TemplateData currentTemplate, PokemonSet set)
    {
        TemplateData baseTemplate = currentTemplate;

        //other formes are only placed in the baseForme, so we have to get it
        if (baseTemplate.species != baseTemplate.baseSpecies)
        {
            string baseTemplateId = Globals.getId(baseTemplate.baseSpecies);
            if (!Pokedex.BattlePokedex.ContainsKey(baseTemplateId))
            {
                return(false);
            }
            baseTemplate = Pokedex.BattlePokedex[baseTemplateId];
        }
        //Has no alternate forms, It should have one in the template
        if (baseTemplate.otherFormes == null)
        {
            return(false);
        }

        ItemData     item = (Items.BattleItems.ContainsKey(set.itemId) ? Items.BattleItems[set.itemId] : null);
        TemplateData altForme;

        for (int i = 0; i < baseTemplate.otherFormes.Length; ++i)
        {
            //Doesnt exist in the database
            if (!Pokedex.BattlePokedex.ContainsKey(baseTemplate.otherFormes[i]))
            {
                continue;
            }
            altForme = Pokedex.BattlePokedex[baseTemplate.otherFormes[i]];
            //Not a ultra form
            if (!altForme.isUltra)
            {
                continue;
            }
            //Check if can burst by Move
            if (altForme.requiredMove != "")
            {
                //Holds a Z item, so, cant ultra burst
                if (item != null && item.iszMove)
                {
                    continue;
                }

                //Checking if the pokemon has the required move
                for (int j = 0; j < set.movesId.Length; ++j)
                {
                    //If the pokemon has the move and it is in the database
                    if (altForme.requiredMove == set.movesId[j] && Moves.BattleMovedex.ContainsKey(set.movesId[j]))
                    {
                        return(true);
                    }
                }
            }
            //Check if can burst by item
            if (item == null || item.ultraBursts == null)
            {
                continue;
            }
            //Already ultra bursted
            if (item.ultraEffect == currentTemplate.species)
            {
                continue;
            }
            //if it ultra bursts from the species and the evolution exists
            for (int j = 0; j < item.ultraBursts.Length; ++j)
            {
                if (item.ultraBursts[j] == currentTemplate.species && item.ultraEffect == altForme.species)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Z))
        {
            //TYPECHART
            int    value  = TypeChart.BattleTypeChart["" + typeDefense].damageTaken["" + typeAttack];
            string result = (value == 0) ? " is ok against " : (value == 1) ? " is super effective against " : (value == 2) ? "is not very effective against " : (value == 3) ? " does not affect " : "wat";
            Debug.Log(typeAttack + result + typeDefense);
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            //LOG TEMPLATEDATA
            LogPokemon();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            //BOOSTMODIFIERS STUFF
            int   previousMod = 6144;
            int   nextMod     = 5325;
            int   nextValue   = (previousMod * nextMod + 2048);
            int   test        = nextValue >> 12;
            float end         = (float)test / 4096f;
            float wat         = (6144f / 4096f) * (5325f / 4096f);
            Debug.Log("((previousMod * nextMod + 2048) >> 12) / 4096 \n" +
                      "((" + previousMod + "*" + nextMod + "+ 2048) >> 12) / 4096 \n" +
                      "((" + previousMod + " * " + nextMod + " + 2048) = " + nextValue + "\n" +
                      nextValue + " >> 12 = " + test + "\n" +
                      test + " / 4096 = " + end
                      );

            Debug.Log("" + 6144f / 4096f + " * " + 5325f / 4096f + " = " + wat);
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            //LOG BATTLE STATS
            Globals.StatsTable baseStats = new Globals.StatsTable(hp: 45, atk: 49, def: 49, spa: 65, spd: 65, spe: 45);
            Globals.StatsTable stats     = baseStats.ShallowCopy();// new Globals.StatsTable(hp: 45, atk: 49, def: 49, spa: 65, spd: 65, spe: 45);
            PokemonSet         set       = new PokemonSet();
            set.ivs    = new Globals.StatsTable();
            set.evs    = new Globals.StatsTable();
            set.level  = 50;
            set.nature = new Globals.Nature("Testing");//, plus: "hp", minus: "spe");

            stats.SetBattleStats(set);
            Debug.Log("Testing Stats: hp: " + stats.hp + ", atk:" + stats.atk + ", def:" + stats.def + ", spa:" + stats.spa + ", spd:" + stats.spd + ", spe:" + stats.spe);
            Debug.Log("Base stats used: hp: " + baseStats.hp + ", atk:" + baseStats.atk + ", def:" + baseStats.def + ", spa:" + baseStats.spa + ", spd:" + baseStats.spd + ", spe:" + baseStats.spe);
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            //LOG HIDDEN POWER
            Globals.HiddenPower hp = new Globals.HiddenPower(hpIvs);
            Debug.Log("Hidden Power: " + hp.hpType + " " + hp.hpPower);
        }

        if (Input.GetKeyDown(KeyCode.N))
        {
            //LOG CAN MEGA EVOLVE
            TemplateData templateData = Pokedex.BattlePokedex["rayquaza"];
            PokemonSet   set          = new PokemonSet();
            set.itemId  = "abomasite";
            set.movesId = new string[] { "tackle" };
            Debug.Log("Can mega evolve " + CanMegaEvolve(templateData, set));
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            //LOG CAN ULTRA BURST
            TemplateData templateData = Pokedex.BattlePokedex["necrozmadawnwings"];
            PokemonSet   set          = new PokemonSet();
            set.itemId  = "ultranecroziumz";
            set.movesId = new string[] { "tackle" };
            Debug.Log("Can ultra burst " + CanUltraBurst(templateData, set));
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            //LOG POKEMON DATA
            Battle     battle = new Battle();
            PokemonSet set    = new PokemonSet(
                speciesId: "bulbasaur",
                name: "Flamenco",
                level: 50,
                gender: Globals.GenderName.M,
                happiness: 100,
                pokeball: "MajoBall",
                shiny: false,
                abilityId: "overgrow",
                itemId: "normaliumz",
                movesId: new string[] { "tackle", "absorb", "caca", "10000000voltthunderbolt" },
                evs: new Globals.StatsTable(spd: 252, def: 252, spe: 6),
                ivs: BestHiddenPowers.HiddenPowers["Ice"],
                nature: Natures.BattleNatures["adamant"],
                ppBoosts: new int[] { 3, 1, 0, 2 }
                );
            Pokemon testPoke = new Pokemon(battle, set, new Battle.Team(new PokemonSet[] { set }), null);
            testPoke.LogPokemon();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            //TESTING CALLBACK GETTERS AND CALLERS
            MoveData move = Moves.BattleMovedex["test"];
            Debug.Log(move.id);

            Debug.Log(move.eventMethods.HasCallback("onModifyAtk"));
            Debug.Log(move.eventMethods.HasCallback("onTakeItem"));
            Debug.Log(move.eventMethods.HasCallback("caca"));
            Debug.Log(move.eventMethods.HasCallback("id"));

            Battle.RelayVar relayVar = new Battle.RelayVar();

            Debug.Log("I was a " + relayVar.integerValue + " before");
            move.eventMethods.StartCallback("onModifyAtk", null, relayVar, null, null, null);
            Debug.Log("But now, thanks to the StartCallback method, I am a " + relayVar.integerValue);
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            //Single event test
            Battle   b    = new Battle();
            MoveData move = Moves.BattleMovedex["test"];

            Battle.RelayVar tororo = b.SingleEvent("ModifyAtk", move);
            Debug.Log(tororo.integerValue);
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
        }


        if (Input.GetKeyDown(KeyCode.Q))
        {
            Battle           b    = new Battle();
            PokemonSet       set1 = new PokemonSet(speciesId: "bulbasaur", name: "Tentomon", level: 50, gender: Globals.GenderName.F, abilityId: "testingrunevent", itemId: "testingrunevent", movesId: new string[] { "testingrunevent" });
            Battle.Team      t1   = new Battle.Team(new PokemonSet[] { set1 });
            GameObject       go1  = new GameObject();
            PokemonCharacter pc1  = go1.AddComponent <PokemonCharacter>();
            pc1.Init(b, set1, t1);
            pc1.pokemonData.isActive = true;
            t1.pokemons  = new PokemonCharacter[] { pc1 };
            t1.teamMoves = new List <ActiveMove>();

            PokemonSet       set2 = new PokemonSet(speciesId: "bulbasaur", name: "Tentomon", level: 50, gender: Globals.GenderName.F, abilityId: "testingrunevent", itemId: "testingrunevent", movesId: new string[] { "testingrunevent" });
            Battle.Team      t2   = new Battle.Team(new PokemonSet[] { set2 });
            GameObject       go2  = new GameObject();
            PokemonCharacter pc2  = go2.AddComponent <PokemonCharacter>();
            pc2.Init(b, set2, t2);
            pc2.pokemonData.isActive = true;
            t2.pokemons  = new PokemonCharacter[] { pc2 };
            t2.teamMoves = new List <ActiveMove>();


            b.teams = new Battle.Team[] { t1, t2 };

            MoveData        move     = Moves.BattleMovedex["testingrunevent"];
            Battle.RelayVar relayVar = new Battle.RelayVar(integerValue: move.basePower);
            relayVar = b.RunEvent("BasePower", pc1.targetScript, pc2, move, relayVar, true);
            Debug.Log(relayVar.integerValue);

            //public int GetDamage(Pokemon pokemon, Pokemon target, ActiveMove activeMove, int directDamage = -1)//movedata comes from active move?? //DirectDamage for confusion and stuff
            GameObject go3 = new GameObject();
            ActiveMove am  = go3.AddComponent <ActiveMove>();
            am.activeData = new ActiveMove.ActiveMoveData(move.id);
            int damage = b.GetDamage(pc1.pokemonData, pc2.pokemonData, am);

            Debug.Log("Damage " + damage);
        }
    }