public ActivePokemon(List <BaseStat> baseStatList) { baseStat = baseStatList[0]; Random random = new Random(); IVHP = random.Next(0, 31); IVAttack = random.Next(0, 31); IVDefense = random.Next(0, 31); IVSPAtk = random.Next(0, 31); IVSPDef = random.Next(0, 31); IVSpeed = random.Next(0, 31); nature = (NatureType)random.Next(0, 24); EVHP = 0; EVAttack = 0; EVDefense = 0; EVSPAtk = 0; EVSPDef = 0; EVSpeed = 0; status = MajorStatus.None; isNamed = false; nickname = baseStat.Name; level = 1; currentHP = HP; move = new ActiveMove[4]; move[0] = null; move[1] = null; move[2] = null; move[3] = null; }
/// <summary> /// Whether this pokemon hits the target pokemon /// </summary> /// <param name="attack">attack used</param> /// <param name="target">target pokemon</param> /// <returns></returns> public bool hits(ActiveMove attack, BattlePokemon target) { bool doesHit = false; double chance = target.chanceToHit(this, attack.bMove); if (chance < 1.0 && chance > 0.0) { Random random = new Random(); double roll = random.NextDouble(); if (roll < chance) { doesHit = true; } else { doesHit = false; } } //chance greater than 1 will always hit else if (chance >= 1.0) { doesHit = true; } //chance less than 0 will never hit else { doesHit = false; } return(doesHit); }
public BattleChoice() { choiceType = ChoiceType.NONE; pMove = null; pSwitchTo = null; target = null; pItem = null; }
/// <summary> /// Returns a new battlechoice containing instructions to use the specified move on the specified target /// </summary> /// <param name="move">move to use</param> /// <param name="inTarget">target battleposition</param> /// <returns></returns> public static BattleChoice UseMove(ActiveMove move, BattlePosition inTarget) { BattleChoice choice = new BattleChoice(); choice.choiceType = ChoiceType.MOVE; choice.target = inTarget; choice.pMove = move; return(choice); }
//This region is for saving and loading moves that active pokemon have #region ActiveMove public static void SaveActiveMove(ActiveMove inMove, BinaryWriter writer) { //moveID //currentPP //PPUPuses writer.Write(MoveList.getIndex(inMove.bMove.name)); writer.Write(inMove.currentPP); writer.Write(inMove.PPUpUses); }
public static ActiveMove LoadActiveMove(BinaryReader reader) { ActiveMove move = new ActiveMove(MoveList.move[reader.ReadInt32()]); move.currentPP = reader.ReadInt32(); move.PPUpUses = reader.ReadByte(); move.maxPP = move.bMove.basePP + Convert.ToInt32(0.2 * Convert.ToDouble(move.PPUpUses)); return(move); }
/// <summary> /// Does damage to the target based on stats and attack power and hidden move type and also STAB /// </summary> /// <param name="attack"></param> /// <param name="target"></param> public void doHiddenPowerDamageTo(ActiveMove attack, BattlePokemon target) { double dDamage = 0.0; int damage = 0; //only this part changes for hidden power double strength = TypeStrengths.typeStrength(pokemon.hiddenPowerType, target); double stab = 1.0; //calculate Same Type Attack Bonus if (attack.bMove.moveType == pokemon.baseStat.Type1.ToString() || attack.bMove.moveType == pokemon.baseStat.Type2.ToString()) { stab = 1.5; } if (strength > 0.0) { Random random = new Random(); double modifier = Convert.ToDouble(random.Next(85, 100)) / 100.0; if (attack.bMove.moveKind == "Special") { dDamage = stab * strength * modifier * (((2.0 * pokemon.level + 10.0) / 250.0) * (Convert.ToDouble(effectiveSpAtk) / Convert.ToDouble(target.effectiveSpDef)) * pokemon.hiddenPowerPower + 2); damage = Convert.ToInt32(Math.Floor(dDamage)); target.currentHealth -= damage; } //I know that hidden power is only special, but screw you! else if (attack.bMove.moveKind == "Physical") { dDamage = stab * strength * modifier * (((2.0 * pokemon.level + 10.0) / 250.0) * (Convert.ToDouble(effectiveAtk) / Convert.ToDouble(target.effectiveDef)) * pokemon.hiddenPowerPower + 2); damage = Convert.ToInt32(Math.Floor(dDamage)); target.currentHealth -= damage; } //show message saying it hit, or was supereffective } else { //show message saying it was ineffective } }
public ActivePokemon(int id, Trainer _trainer) { trainer = _trainer; baseStat = BaseStatsList.GetBaseStats(id); //individual stuff Random random = new Random(); IVHP = random.Next(0, 31); IVAttack = random.Next(0, 31); IVDefense = random.Next(0, 31); IVSPAtk = random.Next(0, 31); IVSPDef = random.Next(0, 31); IVSpeed = random.Next(0, 31); nature = (NatureType)random.Next(0, 24); EVHP = 0; EVAttack = 0; EVDefense = 0; EVSPAtk = 0; EVSPDef = 0; EVSpeed = 0; status = MajorStatus.None; isNamed = false; nickname = baseStat.Name; level = 1; currentHP = HP; move = new ActiveMove[4]; move[0] = null; move[1] = null; move[2] = null; move[3] = null; }
private double typeModifier(ActiveMove attack, BattlePokemon target) { return(TypeStrengths.typeStrength(attack, target)); }
//I think it will be used for direct damages public int GetDamage(Pokemon pokemon, Pokemon target, ActiveMove activeMove, int directDamage = -1)//movedata comes from active move?? //DirectDamage for confusion and stuff { MoveData moveData = activeMove.activeData.moveData; RelayVar relayVar; if (moveData == null && directDamage == -1) { return(-1); //No moveData and no directDamage } if (directDamage != -1) { moveData = new MoveData(basePower: directDamage, type: Globals.Type.Unknown, category: Globals.MoveCategory.Physical, willCrit: false); } //if not ignoreImmunity return false (do it before? /*RETURN DIRECT DAMAGE*/ if (moveData.ohko != Globals.OHKO.Null) { return(target.maxhp); //Fissure, Sheer cold } if (moveData.eventMethods.damageCallback != null) //mirro coat, naturesmaddnes, hyper fang... { relayVar = new RelayVar(); moveData.eventMethods.StartCallback("damageCallback", this, relayVar, target.targetData, pokemon.myPokemon, null); return(relayVar.integerValue); } if (moveData.damageByLevel) { return(pokemon.level); //nightshade, seismic toss } if (moveData.damage != -1) { return(moveData.damage); //Dragon rage, sonic boom } /*USING BASE POWER*/ //Category Globals.MoveCategory category = (moveData.category == Globals.MoveCategory.Null) ? Globals.MoveCategory.Physical : moveData.category; if (moveData.defensiveCategory != Globals.MoveCategory.Null) { category = moveData.defensiveCategory; } //BasePower int basePower = moveData.basePower; if (moveData.eventMethods.basePowerCallback != null) { relayVar = new RelayVar(); moveData.eventMethods.StartCallback("basePowerCallback", this, relayVar, target.targetData, pokemon.myPokemon, moveData); basePower = relayVar.integerValue; } if (basePower < 0) { return(-1); //Return -1 means no dealing damage } basePower = Mathf.Max(1, basePower); //Min value will be 1 Debug.Log("Power after basePowerCallback: " + basePower); //CritRatio int[] critMultiplier = { 0, 24, 8, 2, 1 }; relayVar = new RelayVar(integerValue: moveData.critRatio); relayVar = RunEvent("ModifyCritRatio", pokemon.targetData, target.myPokemon, moveData, relayVar); int critRatio = Mathf.Clamp(relayVar.integerValue, 0, 4); //Set crit activeMove.activeData.crit = moveData.willCrit; if (!activeMove.activeData.crit) { activeMove.activeData.crit = RandomScript.RandomChance(1, critMultiplier[critRatio]); } if (activeMove.activeData.crit) { relayVar = new RelayVar(booleanValue: activeMove.activeData.crit); relayVar = RunEvent("CriticalHit", target.targetData, null, moveData); activeMove.activeData.crit = relayVar.booleanValue; } //Happens after crit calculation relayVar = new RelayVar(integerValue: basePower); relayVar = RunEvent("BasePower", pokemon.targetData, target.myPokemon, moveData, relayVar, true); if (relayVar.getEndEvent() && relayVar.integerValue != -1) { return(-1); } basePower = Mathf.Max(1, relayVar.integerValue); Debug.Log("Power after basepower: " + basePower); //Starting? int level = pokemon.level; Pokemon attacker = pokemon; Pokemon defender = target; string attackStat = (category == Globals.MoveCategory.Physical) ? "Atk" : "SpA"; string defenseStat = (category == Globals.MoveCategory.Physical) ? "Def" : "SpD"; //statTable int attack; int defense; int atkBoosts = (moveData.useTargetOffensive) ? defender.boosts.GetBoostValue(attackStat) : attacker.boosts.GetBoostValue(attackStat); int defBoosts = (moveData.useSourceDefensive) ? attacker.boosts.GetBoostValue(defenseStat) : defender.boosts.GetBoostValue(defenseStat); bool ignoreNegativeOffensive = moveData.ignoreNegativeOffensive; bool ignorePositiveDefensive = moveData.ignorePositiveDefensive; if (activeMove.activeData.crit) { ignoreNegativeOffensive = true; ignorePositiveDefensive = true; } bool ignoreOffensive = moveData.ignoreOffensive || (ignoreNegativeOffensive && atkBoosts < 0); bool ignoreDefensive = moveData.ignoreDefensive || (ignorePositiveDefensive && defBoosts > 0); if (ignoreOffensive) { //this.debug('Negating (sp)atk boost/penalty.'); atkBoosts = 0; } if (ignoreDefensive) { //this.debug('Negating (sp)def boost/penalty.'); defBoosts = 0; } if (moveData.useTargetOffensive) { attack = defender.CalculateStat(attackStat, atkBoosts); } else { attack = attacker.CalculateStat(attackStat, atkBoosts); } if (moveData.useSourceDefensive) { defense = attacker.CalculateStat(defenseStat, defBoosts); } else { defense = defender.CalculateStat(defenseStat, defBoosts); } Debug.Log("attack: " + attack + " defense: " + defense); //Apply stat modifiers relayVar = new RelayVar(integerValue: attack); relayVar = RunEvent("Modify" + attackStat, attacker.targetData, defender.myPokemon, moveData, relayVar); attack = relayVar.integerValue; relayVar = new RelayVar(integerValue: defense); relayVar = RunEvent("Modify" + defenseStat, defender.targetData, attacker.myPokemon, moveData, relayVar); defense = relayVar.integerValue; Debug.Log("After modifiers attack: " + attack + " defense: " + defense); //int(int(int(2 * L / 5 + 2) * A * P / D) / 50); int baseDamage = Mathf.FloorToInt(Mathf.FloorToInt(Mathf.FloorToInt(2f * level / 5f + 2f) * basePower * attack / defense) / 50f); Debug.Log("baseDamage: " + baseDamage); // Calculate damage modifiers separately (order differs between generations) return(ModifyDamage(baseDamage, pokemon, target, activeMove)); }
// Use this for initialization void Start() { projectiles = new List <GameObject>(); am = GetComponent <ActiveMove>(); am.source.canMove = false; }
public OperaMove2NPC(SceneEntity hero) : base("OperaMove2NPC", hero) { action = new ActiveMove(hero); }
public void AddNewMove(ActiveMove move) { activeMoves.Add(move); }
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)); }
public ActionMovingAOE(SceneEntity hero) : base("ActionMovingAOE", hero) { actionMove = new ActiveMove(hero); }
public OperaSkill(SceneEntity hero) : base("OperaSkill", hero) { actionType = Action.ACTION_TYPE.OPERA; action = new ActiveMove(hero); }
public static double typeStrength(ActiveMove inMove, ActivePokemon inPoke) { return(typeStrength(inMove.bMove.moveType, inPoke.baseStat.Type1.ToString(), inPoke.baseStat.Type2.ToString())); }
// 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); } }
public ActionWalk(SceneEntity hero):base("ActionWalk",hero) { action = new ActiveMove(hero); }