public int ComparePokeSpeed(PokemonCharacter a, PokemonCharacter b) { if (a.pokemonData.speed != b.pokemonData.speed) { return(b.pokemonData.speed - a.pokemonData.speed); } return(Mathf.FloorToInt(RandomScript.GetRandomValue() - .5f)); }
public void InitPokemons(Battle b) { pokemons = new PokemonCharacter[pokemonsSets.Length]; for (int i = 0; i < pokemonsSets.Length; ++i) { GameObject poke = Object.Instantiate(Meshes.GetMeshSync(pokemonsSets[i].speciesId)); PokemonCharacter pC = poke.AddComponent <PokemonCharacter>(); pC.Init(b, pokemonsSets[i], this); pokemons[i] = pC; } }
public void Init(Battle battle, PokemonCharacter source, ActiveMoveData activeData, Pokemon.TargetLocation targetLocation) { this.battle = battle; this.battle.AddNewMove(this); targetScript = GetComponent <TargetableElement>(); targetScript.sourceElement = this; this.source = source; this.activeData = activeData; this.targetLocation = targetLocation; PrepareDamageData(); OnCreatedMove(); }
// 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); } }