/// <summary> /// Cheat command to set the player's action to use a specified item on a specified party pokemon without taking the item from the player's inventory /// </summary> /// <param name="moveIndex">An optional parameter for the index of the move to use the item on (eg. for PP-restoring items)</param> public bool CheatCommand_SetPlayerAction_UseItem(Item item, int partyIndex, int moveIndex = -1) { PokemonInstance pokemon = partyIndex >= 0 ? battleData.participantPlayer.GetPokemon()[partyIndex] : battleData.participantPlayer.ActivePokemon; if (moveIndex >= 0 && PokemonMove.MoveIdIsUnset(pokemon.moveIds[moveIndex])) { return(false); } if (moveIndex < 0 && item is PPRestoreMedicineItem) { return(false); } battleData.participantPlayer.ForceSetChosenAction(new BattleParticipant.Action(battleData.participantPlayer) { type = BattleParticipant.Action.Type.UseItem, useItemItemToUse = item, useItemTargetPartyIndex = partyIndex >= 0 ? partyIndex : battleData.participantPlayer.activePokemonIndex, useItemTargetMoveIndex = moveIndex, useItemDontConsumeItem = true }); playerBattleUIController.DisableAllMenus(); return(true); }
protected static bool TryParseMoveIndex(string input, PokemonInstance pokemon, out int moveIndex, out string invalidityMessage) { if (!int.TryParse(input, out moveIndex)) { invalidityMessage = "Invalid index provided"; return(false); } if (0 > moveIndex || moveIndex > 3) { invalidityMessage = "Index provided out of range. N.B. move indexes are 0-indexed"; return(false); } if (!PokemonMove.MoveIdIsUnset(pokemon.moveIds[moveIndex])) { invalidityMessage = "The queried pokemon doesn't have that move set"; return(false); } invalidityMessage = ""; return(true); }
/// <summary> /// Cheat command to get the moves of one of the opponent's pokemon's moves /// </summary> public PokemonMove[] CheatCommand_GetOpponentPokemonMoves(int partyIndex, out byte[] movePPs) { PokemonInstance pokemon = partyIndex >= 0 ? battleData.participantOpponent.GetPokemon()[partyIndex] : battleData.participantOpponent.ActivePokemon; movePPs = pokemon.movePPs; return(pokemon .moveIds .Where(x => !PokemonMove.MoveIdIsUnset(x)) .Select(x => PokemonMove.GetPokemonMoveById(x)) .ToArray()); }
public override ItemUsageEffects GetUsageEffects(PokemonInstance pokemon) { if (singleMoveIndexToRecoverPP < 0 && isForSingleMove) { Debug.LogError("Usage effects requested before singleMoveIndexToRecoverPP was set"); } byte[] ppIncreases = new byte[4]; if (isForSingleMove) { byte missingPP = GetMissingPP(pokemon, singleMoveIndexToRecoverPP); if (fullyRestoresPP) { ppIncreases[singleMoveIndexToRecoverPP] = missingPP; } else { ppIncreases[singleMoveIndexToRecoverPP] = missingPP > ppRestored ? ppRestored : missingPP; } } else { for (int i = 0; i < ppIncreases.Length; i++) { if (PokemonMove.MoveIdIsUnset(pokemon.moveIds[i])) { continue; } byte missingPP = GetMissingPP(pokemon, i); if (fullyRestoresPP) { ppIncreases[i] = missingPP; } else { ppIncreases[i] = missingPP > ppRestored ? ppRestored : missingPP; } } } //Reset this to help discover potential errors later on singleMoveIndexToRecoverPP = -1; return(new ItemUsageEffects() { ppIncreases = ppIncreases }); }
private float[] GetMoveWeightings(PokemonInstance opposingPokemon) { float[] weightings = new float[ActivePokemon.moveIds.Length]; if (ActivePokemon.battleProperties.volatileStatusConditions.encoreTurns > 0) { weightings = GetEncoreMoveWeightings(); } else { for (int i = 0; i < ActivePokemon.moveIds.Length; i++) { weightings[i] = 1; //Move unset if (PokemonMove.MoveIdIsUnset(ActivePokemon.moveIds[i])) { weightings[i] = 0; continue; } //Out of PP if (ActivePokemon.movePPs[i] <= 0) { weightings[i] = 0; } PokemonMove move = PokemonMove.GetPokemonMoveById(ActivePokemon.moveIds[i]); //Being taunted if (ActivePokemon.battleProperties.volatileStatusConditions.tauntTurns > 0 && move.moveType == PokemonMove.MoveType.Status) { weightings[i] = 0; } //Being tormented if (ActivePokemon.battleProperties.volatileStatusConditions.torment && ActivePokemon.battleProperties.lastMoveId == move.id) { weightings[i] = 0; } //Type advantage weightings[i] *= GetTypeAdvantageWeighting(TypeAdvantage.CalculateMultiplier(move.type, opposingPokemon.species)); } } return(weightings); }
public override bool CheckCompatibility(PokemonInstance pokemon) { for (int moveIndex = 0; moveIndex < pokemon.moveIds.Length; moveIndex++) { if (!PokemonMove.MoveIdIsUnset(pokemon.moveIds[moveIndex])) { if (pokemon.movePPs[moveIndex] < PokemonMove.GetPokemonMoveById(pokemon.moveIds[moveIndex]).maxPP) { return(true); } } } return(false); }
public void RefreshButtons() { int[] moveIds = playerBattleParticipant.ActivePokemon.moveIds; for (int i = 0; i < moveIds.Length; i++) { if (PokemonMove.MoveIdIsUnset(moveIds[i])) { moveButtons[i].SetInteractable(false); } else { moveButtons[i].SetInteractable(true); moveButtons[i].SetName(PokemonMove.GetPokemonMoveById(moveIds[i]).name); } } }
protected int?FindUsablePriorityMoveIndex(PokemonInstance pokemon) { for (int i = 0; i < pokemon.moveIds.Length; i++) { if (PokemonMove.MoveIdIsUnset(pokemon.moveIds[i])) { continue; } if (PokemonMove.GetPokemonMoveById(pokemon.moveIds[i]).movePriority == true && pokemon.movePPs[i] > 0) { return(i); } } return(null); }
/// <summary> /// Cheat command to set the opponent's action to use a specified move /// </summary> /// <param name="moveIndex">The index of the move for the opponent to use</param> /// <param name="useStruggle">Whether the opponent should use struggle instead of an indexed move (moveIndex is ignored if useStruggle is true)</param> /// <returns>Whether the action-setting was successful</returns> public bool CheatCommand_SetOpponentAction_Fight(int moveIndex, bool useStruggle = false) { if (!useStruggle && PokemonMove.MoveIdIsUnset(battleData.participantOpponent.ActivePokemon.moveIds[moveIndex])) { return(false); } battleData.participantOpponent.ForceSetChosenAction(new BattleParticipant.Action(battleData.participantOpponent) { type = BattleParticipant.Action.Type.Fight, fightMoveTarget = battleData.participantPlayer, fightMoveIndex = useStruggle ? 0 : moveIndex, fightUsingStruggle = useStruggle }); return(true); }
public void SetMoveById(int id, byte currentPP) { if (PokemonMove.MoveIdIsUnset(id)) { SetShowState(false); return; } SetShowState(true); PokemonMove move = PokemonMove.GetPokemonMoveById(id); textName.text = move.name; textPP.text = currentPP.ToString() + "/" + move.maxPP.ToString(); textDescription.text = move.description; textPowerValue.text = move.power != 0 ? move.power.ToString() : "-"; textAccuracyValue.text = move.accuracy != 0 ? move.accuracy.ToString() : "-"; imageType.sprite = SpriteStorage.GetTypeSymbolSprite(move.type); imageCategory.sprite = SpriteStorage.GetMoveTypeSprite(move.moveType); }
/// <summary> /// Cheat command to set the opponent's action to use a specified item on a specified party pokemon /// </summary> /// <param name="moveIndex">An optional parameter for the index of the move to use the item on (eg. for PP-restoring items)</param> public bool CheatCommand_SetOpponentAction_UseItem(Item item, int partyIndex, int moveIndex = -1) { PokemonInstance pokemon = partyIndex >= 0 ? battleData.participantOpponent.GetPokemon()[partyIndex] : battleData.participantOpponent.ActivePokemon; if (moveIndex >= 0 && PokemonMove.MoveIdIsUnset(pokemon.moveIds[moveIndex])) { return(false); } if (moveIndex < 0 && item is PPRestoreMedicineItem) { return(false); } battleData.participantOpponent.ForceSetChosenAction(new BattleParticipant.Action(battleData.participantOpponent) { type = BattleParticipant.Action.Type.UseItem, useItemItemToUse = item, useItemTargetPartyIndex = partyIndex >= 0 ? partyIndex : battleData.participantOpponent.activePokemonIndex, useItemTargetMoveIndex = moveIndex }); return(true); }
private PokemonMove[] GetMoves() => PlayerData .singleton .partyPokemon[currentPokemonIndex] .moveIds .Select(x => !PokemonMove.MoveIdIsUnset(x) ? PokemonMove.GetPokemonMoveById(x) : null) .ToArray();
protected float[] GetMoveWeightings(PokemonInstance target) { float[] weightings = new float[4] { 1, 1, 1, 1 }; if (ActivePokemon.battleProperties.volatileStatusConditions.encoreTurns > 0) { weightings = GetEncoreMoveWeightings(); } else { for (int i = 0; i < ActivePokemon.moveIds.Length; i++) { //Move unset if (PokemonMove.MoveIdIsUnset(ActivePokemon.moveIds[i])) { weightings[i] = 0; continue; } PokemonMove move = PokemonMove.GetPokemonMoveById(ActivePokemon.moveIds[i]); //Being taunted if (ActivePokemon.battleProperties.volatileStatusConditions.tauntTurns > 0 && move.moveType == PokemonMove.MoveType.Status) { weightings[i] = 0; } //Being tormented if (ActivePokemon.battleProperties.volatileStatusConditions.torment && ActivePokemon.battleProperties.lastMoveId == move.id) { weightings[i] = 0; } float effectivenessModifier = target.species.type2 == null ? TypeAdvantage.CalculateMultiplier(move.type, target.species.type1) : TypeAdvantage.CalculateMultiplier(move.type, target.species.type1, (Type)target.species.type2); //Out of PP if (ActivePokemon.movePPs[i] <= 0) { weightings[i] = 0; } //Status or attack move if (move.moveType == PokemonMove.MoveType.Status) { weightings[i] *= GetStatOEWeighting(statOEMovesUsed); } else { weightings[i] *= GetAttackMoveWeighting(effectivenessModifier); } //Healing weight weightings[i] *= GetHealingMoveWeighint(ActivePokemon.HealthProportion); } } return(weightings); }
protected PokemonMove[] GetMoves() => GetSelectedPokemon() .moveIds .Where(x => !PokemonMove.MoveIdIsUnset(x)) .Select(x => PokemonMove.GetPokemonMoveById(x)) .ToArray();