public static StatArray GenerateRandomIVs() { StatArray ivs = new StatArray(); ivs.HP = GenerateRandomIV(); ivs.ATK = GenerateRandomIV(); ivs.DEF = GenerateRandomIV(); ivs.SP_ATK = GenerateRandomIV(); ivs.SP_DEF = GenerateRandomIV(); ivs.SPD = GenerateRandomIV(); return(ivs); }
public static StatArray CalculateStats(StatArray base_stats, StatArray ivs, StatArray evs, uint level, Natures nature) { StatArray stats = new StatArray(); stats.HP = CalculateHPStat(base_stats.HP, ivs.HP, evs.HP, level); stats.ATK = CalculateStat(Stats.Attack, base_stats.ATK, ivs.ATK, evs.ATK, level, nature); stats.DEF = CalculateStat(Stats.Defense, base_stats.DEF, ivs.DEF, evs.DEF, level, nature); stats.SP_ATK = CalculateStat(Stats.SpecialAttack, base_stats.SP_ATK, ivs.SP_ATK, evs.SP_ATK, level, nature); stats.SP_DEF = CalculateStat(Stats.SpecialDefense, base_stats.SP_DEF, ivs.SP_DEF, evs.SP_DEF, level, nature); stats.SPD = CalculateStat(Stats.Speed, base_stats.SPD, ivs.SPD, evs.SPD, level, nature); return(stats); }
public Pokemon(Species species, uint level, uint form_id = 0, string nickname = "", Nullable <int> ability_id = null, Nullable <Genders> gender = null, Nullable <Natures> nature = null, Nullable <bool> is_shiny = null, Items.Items ball_used = Items.Items.PokeBall, Trainer ot = null, ObtainModes obtain_mode = ObtainModes.Met) { // Trainer if (ot == null) { ot = GameObject.FindObjectOfType <PlayerTrainer>(); } this.trainer_id = ot.trainer_id; this.original_trainer = ot.name; this.original_trainer_gender = ot.gender; // Form Form alt_form = Form.GetFormData(species, form_id); if (alt_form != null) { this.form_id = alt_form.form_id; } else { this.form_id = 0; } // Personal ID Creation this.personal_id = GeneratePokemonID(); this.public_id = this.personal_id & 0x0000FFFF; // Constant among species Specie specie = Specie.species[species]; this.species = species; if (alt_form != null && alt_form.types.Length > 0) { this.types = alt_form.types; } else { this.types = specie.types; } // Level and experience this.level = level; this.exp = Experience.GetLevelTotalExp(level, specie.growth_rate); // Nickname this.nickname = nickname; // Ability (determined by personal id) if (ability_id != null) { this.force_ability = ability_id; if (ability_id == 0) { if (alt_form != null && alt_form.abilities.Length > 0) { this.ability = alt_form.abilities[0]; } else { this.ability = specie.abilities[0]; } } else if (ability_id == 1) { if (alt_form != null && alt_form.abilities.Length > 1) { this.ability = alt_form.abilities[1]; } else if (specie.abilities.Length > 1) { this.ability = specie.abilities[1]; } else { this.ability = Ability.GetAbilityFromID(this.personal_id, specie.abilities); } } else if (ability_id == 2) { if (alt_form != null && alt_form.hidden_ability.Length > 0) { this.ability = alt_form.hidden_ability[0]; } else if (specie.hidden_ability.Length > 0) { this.ability = specie.hidden_ability[0]; } else { this.ability = Ability.GetAbilityFromID(this.personal_id, specie.abilities); } } else { this.ability = Ability.GetAbilityFromID(this.personal_id, specie.abilities); } } else { if (alt_form != null && alt_form.abilities.Length > 0) { this.ability = Ability.GetAbilityFromID(this.personal_id, alt_form.abilities); } else { this.ability = Ability.GetAbilityFromID(this.personal_id, specie.abilities); } } // Gender (determined by personal id) if (gender != null) { this.force_gender = (Genders)gender; if (gender == Genders.Male && specie.gender_rate != GenderRates.Genderless && specie.gender_rate != GenderRates.AlwaysFemale) { this.gender = (Genders)gender; } else if (gender == Genders.Female && specie.gender_rate != GenderRates.Genderless && specie.gender_rate != GenderRates.AlwaysMale) { this.gender = (Genders)gender; } else { this.gender = Breeding.GetGenderFromID(this.personal_id, specie.gender_rate); } } else { this.gender = Breeding.GetGenderFromID(this.personal_id, specie.gender_rate); } // Nature (determined by personal id) if (nature != null) { this.force_nature = nature; if ((int)nature >= 0 && (int)nature < 25) { this.nature = (Natures)nature; } else { this.nature = Nature.GetNatureFromID(this.personal_id); } } else { this.nature = Nature.GetNatureFromID(this.personal_id); } // Shininess (determined by personal id and trainer id) if (is_shiny != null) { this.force_shiny = is_shiny; this.is_shiny = (bool)is_shiny; } else { this.is_shiny = GetShininessFromIDs(this.personal_id, ot.trainer_id, ot.secret_id); } // IVs and EVs StatArray ivs = Stat.GenerateRandomIVs(); this.ivs = ivs; StatArray evs = new StatArray(); this.evs = evs; // Stats if (alt_form != null && alt_form.base_stats.HP > 0) { this.stats = Stat.CalculateStats(alt_form.base_stats, ivs, evs, level, this.nature); } else { this.stats = Stat.CalculateStats(specie.base_stats, ivs, evs, level, this.nature); } // Current HP this.current_HP = this.stats.HP; // Friendship if (alt_form != null && alt_form.happiness != 0 && alt_form.happiness != specie.happiness) { // TODO: If alt form has set happiness of 0 this doesn't work... // don't think this ever comes up though this.happiness = alt_form.happiness; } else { this.happiness = specie.happiness; } // Status Condition this.status = Statuses.None; this.status_parameter = 0; // Egg Steps this.egg_steps = 0; // Set Moves if (alt_form != null && alt_form.moves.Length > 0) { this.moves = Move.GeneratePokemonMoveSlots(alt_form.moves, level); } else { this.moves = Move.GeneratePokemonMoveSlots(specie.moves, level); } // Ball Used and Held Item this.ball_used = ball_used; this.held_item = Items.Items.None; this.mail = null; // Pokerus Status this.pokerus_status = 0; // Fused Pokemon this.fused_pokemon = null; // Contest Stats this.contest_stats = new ContestStatArray(); // Markings this.markings = new bool[Constants.NUM_MARKINGS]; // Ribbons this.ribbons = new bool[Ribbons.NUM_RIBBONS]; // Obtain info this.obtain_mode = obtain_mode; this.obtain_date = DateTime.Now; this.obtain_map = null; // TODO: Implement this this.obtain_level = level; this.hatched_map = null; this.obtain_text = null; // Language this.language = Languages.English; // TODO: Implement different options }