public override int GetHashCode() { int hash = 1; if (activePokemon_ != null) { hash ^= ActivePokemon.GetHashCode(); } if (trainerPublicProfile_ != null) { hash ^= TrainerPublicProfile.GetHashCode(); } hash ^= reversePokemon_.GetHashCode(); hash ^= defeatedPokemon_.GetHashCode(); hash ^= lobbyPokemon_.GetHashCode(); if (DamageDealt != 0) { hash ^= DamageDealt.GetHashCode(); } if (SuperEffectiveChargeMove != false) { hash ^= SuperEffectiveChargeMove.GetHashCode(); } if (WeatherBoosted != false) { hash ^= WeatherBoosted.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Testing battle engine /// </summary> private void startBattle() { Trainer trainer = new Trainer(); //BaseStatsList.initialize(); BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35); tackle.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove scratch = new BaseMove("Scratch", "hits the opponent hard", 10, 100, "Normal", "Physical", 35); scratch.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove bubble = new BaseMove("Bubble", "waters the opponent", 20, 100, "Water", "Special", 30); bubble.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove ember = new BaseMove("Ember", "fires the opponent", 40, 100, "Fire", "Special", 25); ember.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; ActivePokemon charmander = new ActivePokemon(BaseStatsList.basestats); ActivePokemon squirtle = new ActivePokemon(BaseStatsList.basestats); charmander.baseStat = BaseStatsList.GetBaseStats("Charmander"); charmander.level = 20; charmander.currentHP = charmander.HP; charmander.setNickname("Charmander"); charmander.addExp(charmander.expAtLevel(charmander.level) - 1); squirtle.baseStat = BaseStatsList.GetBaseStats("Squirtle"); squirtle.level = 20; squirtle.currentHP = squirtle.HP; squirtle.setNickname("Squirtle"); squirtle.addExp(squirtle.expAtLevel(squirtle.level) - 1); charmander.move[0] = new ActiveMove(scratch); charmander.move[1] = new ActiveMove(ember); squirtle.move[0] = new ActiveMove(bubble); squirtle.move[1] = new ActiveMove(tackle); player.addPokemon(squirtle); trainer.addPokemon(charmander); ScreenHandler.TopScreen.IsVisible = false; ScreenHandler.PushScreen(new BattleScreen(graphics, content, font, player, trainer)); }
public void MergeFrom(BattleParticipant other) { if (other == null) { return; } if (other.activePokemon_ != null) { if (activePokemon_ == null) { activePokemon_ = new global::POGOProtos.Data.Battle.BattlePokemonInfo(); } ActivePokemon.MergeFrom(other.ActivePokemon); } if (other.trainerPublicProfile_ != null) { if (trainerPublicProfile_ == null) { trainerPublicProfile_ = new global::POGOProtos.Data.Player.PlayerPublicProfile(); } TrainerPublicProfile.MergeFrom(other.TrainerPublicProfile); } reversePokemon_.Add(other.reversePokemon_); defeatedPokemon_.Add(other.defeatedPokemon_); }
/// <summary> /// Checks if the player is able and allowed to use a specified item at the moment /// </summary> /// <param name="item">The item to consider</param> /// <param name="message">The message to display if the user tries to use this item</param> /// <returns>Whether the player can use the item</returns> public bool CheckIfItemUsageAllowed(Item item, out string message) { BattleData.ItemUsagePermissions itemPermissions = recentBattleData.itemUsagePermissions; if (!GetAllowedToUseItem()) { message = "You aren't able to use items"; return(false); } if (!itemPermissions.pokeBalls && item is PokeBall) { message = "You aren't allowed to use poke balls in this battle"; return(false); } else if (!itemPermissions.hpRestorationItems && item is HealthMedicineItem) { message = "You aren't allowed to use health-restoration items in this battle"; return(false); } else if (!itemPermissions.ppRestorationItems && item is PPRestoreMedicineItem) { message = "You aren't allowed to use PP-restoration items in this battle"; return(false); } else if (!itemPermissions.revivalItems && item is RevivalMedicineItem) { message = "You aren't allowed to use revival items in this battle"; return(false); } else if (!itemPermissions.statusItems && item is NVSCCureMedicineItem) { message = "You aren't allowed to use status items in this battle"; return(false); } else if (!itemPermissions.battleItems && item is BattleItem) { message = "You aren't allowed to use battle items in this battle"; return(false); } else if (item is BattleItem && !item.CheckCompatibility(ActivePokemon)) { message = ActivePokemon.GetDisplayName() + " can't use this item"; return(false); } else if (item is PokeBall && PlayerData.singleton.PartyIsFull && PlayerData.singleton.boxPokemon.IsFull) { message = "You have no space for another pokemon!"; return(false); } message = ""; return(true); }
void Awake() { if (pokemon != null) { if (!initialised) { Initialise(); } if (ownedByPlayer) { active = GameObject.Find("Active Pokemon Player").GetComponent <ActivePokemon>(); } } }
public override int GetHashCode() { int hash = 1; if (activePokemon_ != null) { hash ^= ActivePokemon.GetHashCode(); } if (trainerPublicProfile_ != null) { hash ^= TrainerPublicProfile.GetHashCode(); } hash ^= reversePokemon_.GetHashCode(); hash ^= defeatedPokemon_.GetHashCode(); return(hash); }
//This region saves and loads Active Pokemon, including EV and IVs and level, etc #region ActivePokemon public static void SaveActivePokemon(ActivePokemon pokemon, BinaryWriter writer) { writer.Write(pokemon.baseStat.ID); writer.Write(pokemon.baseStat.FormID); writer.Write(pokemon.IVHP); writer.Write(pokemon.IVAttack); writer.Write(pokemon.IVDefense); writer.Write(pokemon.IVSPAtk); writer.Write(pokemon.IVSPDef); writer.Write(pokemon.IVSpeed); writer.Write(pokemon.EVHP); writer.Write(pokemon.EVAttack); writer.Write(pokemon.EVDefense); writer.Write(pokemon.EVSPAtk); writer.Write(pokemon.EVSPDef); writer.Write(pokemon.EVSpeed); writer.Write(pokemon.currentHP); writer.Write((short)pokemon.status); writer.Write(pokemon.ability); writer.Write(pokemon.happiness); writer.Write(pokemon.isNamed); writer.Write(pokemon.Nickname); writer.Write(pokemon.level); writer.Write(pokemon.currentExp); writer.Write(pokemon.isShiny); writer.Write((short)pokemon.nature); int moves = 0; for (int i = 0; i < 4; i++) { if (pokemon.move[i] != null) { moves++; } } writer.Write(moves); for (int i = 0; i < 4; i++) { if (pokemon.move[i] != null) { SaveActiveMove(pokemon.move[i], writer); } } }
public void MergeFrom(BattleParticipant other) { if (other == null) { return; } if (other.activePokemon_ != null) { if (activePokemon_ == null) { activePokemon_ = new global::POGOProtos.Data.Battle.BattlePokemonInfo(); } ActivePokemon.MergeFrom(other.ActivePokemon); } if (other.trainerPublicProfile_ != null) { if (trainerPublicProfile_ == null) { trainerPublicProfile_ = new global::POGOProtos.Data.Player.PlayerPublicProfile(); } TrainerPublicProfile.MergeFrom(other.TrainerPublicProfile); } reversePokemon_.Add(other.reversePokemon_); defeatedPokemon_.Add(other.defeatedPokemon_); lobbyPokemon_.Add(other.lobbyPokemon_); if (other.DamageDealt != 0) { DamageDealt = other.DamageDealt; } if (other.SuperEffectiveChargeMove != false) { SuperEffectiveChargeMove = other.SuperEffectiveChargeMove; } if (other.WeatherBoosted != false) { WeatherBoosted = other.WeatherBoosted; } if (other.HighestFriendshipMilestone != 0) { HighestFriendshipMilestone = other.HighestFriendshipMilestone; } friendCodename_.Add(other.friendCodename_); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
/// <summary> /// removes a pokemon from the player's current pokemon /// </summary> /// <param name="poke">pokemon you wish to remove</param> public void removePoke(ActivePokemon inPoke) { if (currentPokemon.Contains(inPoke)) { int i = 0; bool done = false; while (done == false) { if (currentPokemon[i] == inPoke) { done = true; currentPokemon[i] = null; } else { i++; } } } }
/// <summary> /// adds a pokemon to the player's current pokemon /// </summary> /// <param name="inPoke">pokemon you want to add</param> public void addPokemon(ActivePokemon inPoke) { if (numCurrentPokemon < 6) { int i = 0; bool done = false; while (done == false) { if (currentPokemon[i] == null) { done = true; currentPokemon[i] = inPoke; } else { i++; } } } }
private void AttackTarget(ActivePokemon attacker, ActivePokemon target) { UniquePokemon pokemonAttacker = attacker.GetActive(); UniquePokemon pokemonTarget = target.GetActive(); int attackerLevel = pokemonAttacker.GetLevel(); int attackerAttackStat = pokemonAttacker.GetAttack(); int targetDefenceStat = pokemonTarget.GetDefence(); int damage = CalculateDamage(attackerLevel, attackerAttackStat, targetDefenceStat); target.TakeDamage(damage); if (target.GetCurrentHitPoints() == 0) { target.Faint(); if (attacker.IsPlayer()) { pokemonAttacker.GainExp(pokemonTarget.CalculateExperienceReward()); attacker.UpdateText(); } } }
public virtual void StartChoosingAction(BattleData battleData) { actionHasBeenChosen = false; //Forced to recharge if (ActivePokemon.battleProperties.volatileBattleStatus.rechargingStage > 0) { chosenAction = new Action(this) { type = Action.Type.Recharge }; actionHasBeenChosen = true; return; } //Force to continue thrashing if (ActivePokemon.battleProperties.volatileBattleStatus.thrashTurns > 0) { ChooseActionFight( battleData, false, ActivePokemon.GetMoveIndexById(ActivePokemon.battleProperties.volatileBattleStatus.thrashMoveId) ); return; } //Force to use the move that has charged for this turn if (ActivePokemon.battleProperties.IsUsingChargedMove) { ChooseActionFight( battleData, false, ActivePokemon.GetMoveIndexById(ActivePokemon.battleProperties.volatileBattleStatus.chargingMoveId) ); return; } }
/// <summary> /// Must have Pokemon List loaded in memory before calling this function /// </summary> /// <param name="reader"></param> /// <returns>Active Pokemon</returns> public static ActivePokemon LoadActivePokemon(BinaryReader reader) { int ID = reader.ReadInt32(); byte form = reader.ReadByte(); ActivePokemon pokemon = new ActivePokemon(BaseStatsList.basestats); pokemon.baseStat = BaseStatsList.GetBaseStats(ID, form); pokemon.IVHP = reader.ReadInt32(); pokemon.IVAttack = reader.ReadInt32(); pokemon.IVDefense = reader.ReadInt32(); pokemon.IVSPAtk = reader.ReadInt32(); pokemon.IVSPDef = reader.ReadInt32(); pokemon.IVSpeed = reader.ReadInt32(); pokemon.EVHP = reader.ReadInt32(); pokemon.EVAttack = reader.ReadInt32(); pokemon.EVDefense = reader.ReadInt32(); pokemon.EVSPAtk = reader.ReadInt32(); pokemon.EVSPDef = reader.ReadInt32(); pokemon.EVSpeed = reader.ReadInt32(); pokemon.currentHP = reader.ReadInt32(); pokemon.status = (MajorStatus)reader.ReadInt16(); pokemon.ability = reader.ReadString(); pokemon.happiness = reader.ReadInt32(); pokemon.isNamed = reader.ReadBoolean(); pokemon.setNickname(reader.ReadString()); pokemon.level = reader.ReadInt32(); pokemon.currentExp = reader.ReadInt32(); pokemon.isShiny = reader.ReadBoolean(); pokemon.nature = (NatureType)reader.ReadInt16(); int moves = reader.ReadInt32(); for (int i = 0; i < moves; i++) { pokemon.move[i] = LoadActiveMove(reader); } return(pokemon); }
/// <summary> /// Switches Pokemon in this spot /// </summary> /// <param name="inPokemon">pokemon to switch to</param> public void SwitchPokemon(ActivePokemon inPokemon) { pokemon = new BattlePokemon(inPokemon); //update texture UpdateTexture(); }
public static void StartRandomEncounter(Player player) { //This is only a test implementation for now //Starts random battle with Starly, Rattata, or HootHoot Trainer trainer = new Trainer(); BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35); tackle.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove scratch = new BaseMove("Scratch", "hits the opponent hard", 40, 100, "Normal", "Physical", 35); scratch.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove growl = new BaseMove("Growl", "Lowers target's attack", 0, 100, "Normal", "Special", 40); growl.moveScript = @" if user:hits(move, target) then target:changeStat('Attack', -1) ShowMessage(target.pokemon.Nickname .. 'has had their attack lowered') end "; BaseMove foresight = new BaseMove("Foresight", "Negates accuracy reduction moves", 0, "Normal", "Status", 40); foresight.moveScript = @"target:changeStat('Accuracy', 12) target:changeStat('Accuracy', -6) ShowMessage(target.pokemon.Nickname .. 'has had their accuracy reset') "; BaseMove quickattack = new BaseMove("Quick Attack", "Always strikes first", 40, 100, "Normal", "Physical", 30); quickattack.basePriority = 1; quickattack.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove tailwhip = new BaseMove("Tail Whip", "Lowers target's defense", 0, 100, "Normal", "Special", 40); tailwhip.moveScript = @" if user:hits(move, target) then target:changeStat('Defense', -1) ShowMessage(target.pokemon.Nickname .. 'has had their defense lowered') end "; ActivePokemon enemy = new ActivePokemon(BaseStatsList.basestats); Random random = new Random(); int r = random.Next(3); switch (r) { case 0: enemy.baseStat = BaseStatsList.GetBaseStats("Starly"); enemy.move[0] = new ActiveMove(tackle); enemy.move[1] = new ActiveMove(growl); enemy.move[2] = new ActiveMove(quickattack); break; case 1: enemy.baseStat = BaseStatsList.GetBaseStats("Hoothoot"); enemy.move[0] = new ActiveMove(tackle); enemy.move[1] = new ActiveMove(growl); enemy.move[2] = new ActiveMove(foresight); break; case 2: enemy.baseStat = BaseStatsList.GetBaseStats("Rattata"); enemy.move[0] = new ActiveMove(tackle); enemy.move[1] = new ActiveMove(tailwhip); enemy.move[2] = new ActiveMove(quickattack); break; default: return; } enemy.level = 5; enemy.currentHP = enemy.HP; enemy.addExp(enemy.expAtLevel(enemy.level) - 1); trainer.addPokemon(enemy); ScreenHandler.TopScreen.IsVisible = false; ScreenHandler.PushScreen(new BattleScreen(graphics, content, font, player, trainer)); }
public static void AddNewPokemon(Player player, string pokemonname, int level) { BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35); tackle.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove scratch = new BaseMove("Scratch", "hits the opponent hard", 40, 100, "Normal", "Physical", 35); scratch.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove pound = new BaseMove("Pound", "hits the opponent hard", 40, 100, "Normal", "Physical", 35); pound.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove growl = new BaseMove("Growl", "Lowers target's attack", 0, 100, "Normal", "Special", 40); growl.moveScript = @" if user:hits(move, target) then target:changeStat('Attack', -1) ShowMessage(target.pokemon.Nickname .. 'has had their attack lowered') end "; BaseMove foresight = new BaseMove("Foresight", "Negates accuracy reduction moves", 0, "Normal", "Status", 40); foresight.moveScript = @"target:changeStat('Accuracy', 12) target:changeStat('Accuracy', -6) ShowMessage(target.pokemon.Nickname .. 'has had their accuracy reset') "; BaseMove quickattack = new BaseMove("Quick Attack", "Always strikes first", 40, 100, "Normal", "Physical", 30); quickattack.basePriority = 1; quickattack.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove tailwhip = new BaseMove("Tail Whip", "Lowers target's defense", 0, 100, "Normal", "Special", 40); tailwhip.moveScript = @" if user:hits(move, target) then target:changeStat('Defense', -1) ShowMessage(target.pokemon.Nickname .. 'has had their defense lowered') end "; BaseMove ember = new BaseMove("Ember", "fires the opponent", 40, 100, "Fire", "Special", 25); ember.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove bubble = new BaseMove("Bubble", "waters the opponent", 20, 100, "Water", "Special", 30); bubble.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove razorleaf = new BaseMove("Razor Leaf", "Sends razor sharp leaves at the target", 55, 95, "Grass", "Special", 25); razorleaf.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; ActivePokemon newPokemon = new ActivePokemon(BaseStatsList.basestats); switch (pokemonname) { case "Charmander": newPokemon.baseStat = BaseStatsList.GetBaseStats("Charmander"); newPokemon.move[0] = new ActiveMove(scratch); newPokemon.move[1] = new ActiveMove(growl); newPokemon.move[2] = new ActiveMove(ember); break; case "Mudkip": newPokemon.baseStat = BaseStatsList.GetBaseStats("Piplup"); newPokemon.move[0] = new ActiveMove(pound); newPokemon.move[1] = new ActiveMove(growl); newPokemon.move[2] = new ActiveMove(bubble); break; case "Chikorita": newPokemon.baseStat = BaseStatsList.GetBaseStats("Chikorita"); newPokemon.move[0] = new ActiveMove(tackle); newPokemon.move[1] = new ActiveMove(growl); newPokemon.move[2] = new ActiveMove(razorleaf); break; default: newPokemon.baseStat = BaseStatsList.GetBaseStats("Piplup"); newPokemon.move[0] = new ActiveMove(pound); newPokemon.move[1] = new ActiveMove(growl); newPokemon.move[2] = new ActiveMove(bubble); break; } newPokemon.level = 7; newPokemon.currentHP = newPokemon.HP; newPokemon.addExp(newPokemon.expAtLevel(newPokemon.level) - 1); player.currentPokemon[0] = newPokemon; }
public static double typeStrength(ActiveMove inMove, ActivePokemon inPoke) { return(typeStrength(inMove.bMove.moveType, inPoke.baseStat.Type1.ToString(), inPoke.baseStat.Type2.ToString())); }
/// <summary> /// Testing battle engine /// </summary> private void startBattle() { Trainer trainer = new Trainer(); //BaseStatsList.initialize(); BaseMove tackle = new BaseMove("Tackle", "hits the opponent hard", 50, 100, "Normal", "Physical", 35); tackle.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove party = new BaseMove("Party", "hits the opponent hard", 10, 100, "Normal", "Physical", 35); party.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) ShowMessage(target.pokemon.Nickname..'\'s attack decreased!') end "; BaseMove bubble = new BaseMove("Bubble", "waters the opponent", 20, 100, "Water", "Special", 30); bubble.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove smile = new BaseMove("Smile", "waters the opponent", 100, 100, "Water", "Special", 30); smile.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) ShowMessage(target.pokemon.Nickname..' died of cuteness!') end "; BaseMove ember = new BaseMove("Ember", "fires the opponent", 40, 100, "Fire", "Special", 25); ember.moveScript = @" if user:hits(move, target) then user:doDamageTo(move, target) end "; BaseMove pinkiesense = new BaseMove("Pinkie Sense", "Confuses the opponent", 40, 100, "Fire", "Special", 25); pinkiesense.moveScript = @" if user:hits(move, target) then s = target.pokemon.Nickname..' is confused!' ShowMessage(s) end "; ActivePokemon charmander = new ActivePokemon(BaseStatsList.basestats); ActivePokemon squirtle = new ActivePokemon(BaseStatsList.basestats); charmander.baseStat = BaseStatsList.GetBaseStats("Charmander"); charmander.level = 20; charmander.currentHP = charmander.HP; charmander.setNickname("Charmander"); charmander.addExp(charmander.expAtLevel(charmander.level) - 1); squirtle.baseStat = BaseStatsList.GetBaseStats("Squirtle"); squirtle.level = 20; squirtle.currentHP = squirtle.HP; squirtle.setNickname("Pinkie Pie"); squirtle.addExp(squirtle.expAtLevel(squirtle.level) - 1); charmander.move[0] = new ActiveMove(tackle); charmander.move[1] = new ActiveMove(ember); squirtle.move[0] = new ActiveMove(party); squirtle.move[1] = new ActiveMove(smile); squirtle.move[2] = new ActiveMove(pinkiesense); player.addPokemon(squirtle); trainer.addPokemon(charmander); ScreenHandler.PushScreen(new BattleScreen(graphics, content, font, player, trainer)); }
public static double typeStrength(String atkType, ActivePokemon inPoke) { return(typeStrength(atkType, inPoke.baseStat.Type1.ToString(), inPoke.baseStat.Type2.ToString())); }