/// <summary> /// General initiator for Pokemon. All details. Use for special cases. /// </summary> public void InitPokemon(PokemonData _pokemonData, string _nickname, Gender _gender, int _level, bool _shiny, ItemData _caughtBall, ItemData _heldItem, string _OT, int _IV_HP, int _IV_Attack, int _IV_Defense, int _IV_Speed, int _IV_SpecialAttack, int _IV_SpecialDefense, int _EV_HP, int _EV_Attack, int _EV_Defense, int _EV_Speed, int _EV_SpecialAttack, int _EV_SpecialDefense, Nature _nature, AbilityData _ability, MoveData[] _moveset, Status _status, int _sleepTurns) { ID = count; count++; pokemonData = _pokemonData; nickname = _nickname; gender = _gender; shiny = _shiny; caughtBall = _caughtBall; heldItem = _heldItem; OT = _OT; IV_HP = _IV_HP; IV_Attack = _IV_Attack; IV_Defense = _IV_Defense; IV_Speed = _IV_Speed; IV_SpecialAttack = _IV_SpecialAttack; IV_SpecialDefense = _IV_SpecialDefense; EV_HP = _EV_HP; EV_Attack = _EV_Attack; EV_Defense = _EV_Defense; EV_Speed = _EV_Speed; EV_SpecialAttack = _EV_SpecialAttack; EV_SpecialDefense = _EV_SpecialDefense; nature = _nature; ability = _ability; level = _level; XP = PokemonData.GetLevelXP(pokemonData.growthRate, level); UpdateStats(); currentHP = HP; happiness = pokemonData.baseHappiness; status = _status; sleepTurns = _sleepTurns; metLevel = level; metMap = "Somewhere"; metDate = System.DateTime.Today.Month + "/" + System.DateTime.Today.Day + "/" + System.DateTime.Today.Year; for (int i = 0; i < 4; i++) { if (_moveset[i] != null) { moveset[i] = new MoveInSet(_moveset[i]); } else { moveset[i] = null; } } }
public IEnumerator SingleAttack(Pokemon attacker, Pokemon defender, MoveInSet moveInSet) { float accuracyCheck = Random.Range(0, 100f); MoveData move = moveInSet.move; dialogueManager.AddDialogue(attacker.GetName() + " used " + move.name + "!"); yield return(StartCoroutine(dialogueManager.WaitForCaughtUpText())); if (move.accuracy > 0 && accuracyCheck > move.accuracy) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("But it missed!"); yield break; } float level = attacker.level; float power = move.basePower; float ratingMultiplier; float burn; if (move.isSpecial) { burn = 1.0f; ratingMultiplier = (float)attacker.specialAttack / defender.specialDefense; } else { burn = attacker.status.Equals(Status.BURN) ? .5f : 1.0f; ratingMultiplier = (float)attacker.attack / defender.defense; } float targets = 1.0f; float weather = 1.0f; float badge = 1.0f; float criticalChance = 1f / 16.0f; bool criticalHappened = Random.Range(0f, 1f) < criticalChance; float critical = (criticalHappened? 2.0f : 1.0f); float randomVariation = Random.Range(.85f, 1.0f); float STAB = (attacker.IsType(move.type) ? 1.5f : 1.0f); float typeEffectiveness = PokemonTypeData.Effectiveness(move.type, defender); float other = 1.0f; float modifier = targets * weather * badge * critical * randomVariation * STAB * typeEffectiveness * burn * other; int damage = Mathf.CeilToInt((2f + ((2f + (2f * level) / 5f) * power * ratingMultiplier) / 50f) * modifier); if (damage <= 0) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("It didn't effect " + defender.GetName() + "..."); yield break; } defender.ModHP(-damage); yield return(StartCoroutine(WaitForBarsToLoad())); if (criticalHappened) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("Critical hit!"); } if (typeEffectiveness > 1.0f) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("It was super effective!"); } if (typeEffectiveness < 1.0f) { yield return(StartCoroutine(dialogueManager.WaitForCaughtUpTextAndInput())); dialogueManager.AddDialogue("It wasn't very effective..."); } dialogueManager.DisplayNextSentence(); }
public IEnumerator SingleAttack(Pokemon attacker, Pokemon defender, int moveIndex) { MoveInSet moveInSet = attacker.moveset[moveIndex]; yield return(StartCoroutine(SingleAttack(attacker, defender, moveInSet))); }