public TacticsSubMenu() { Position = new Vector2(230, 150); BattleEntity entity = BattleManager.Instance.EntityTurn; //int quickChangeCount = entity.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.QuickChange); //Enumerations.CostDisplayTypes costDisplayType = Enumerations.CostDisplayTypes.Shown; //if (quickChangeCount > 0) costDisplayType = Enumerations.CostDisplayTypes.Special; BattleActions.Add(new MenuAction("Change Partner", null, "Change your current partner.", //costDisplayType, new ChangePartnerSubMenu())); #region Charge Menu BadgeGlobals.BadgeTypes chargeBadgeType = BadgeGlobals.BadgeTypes.Charge; //Check for a Player; if the Player is a Partner, check the number of Charge P's instead if (entity.EntityType == Enumerations.EntityTypes.Player) { BattlePlayer player = (BattlePlayer)entity; if (player.PlayerType == Enumerations.PlayerTypes.Partner) { chargeBadgeType = BadgeGlobals.BadgeTypes.ChargeP; } } //Charge action if the Charge or Charge P Badge is equipped int chargeCount = entity.GetEquippedBadgeCount(chargeBadgeType); if (chargeCount > 0) { //Charge starts out at 2 then increases by 1 for each additional Badge int chargeAmount = 2 + (chargeCount - 1); BattleActions.Add(new MoveAction("Charge", new MoveActionData(null, "Save up strength to power up your next attack", Enumerations.MoveResourceTypes.FP, chargeCount, Enumerations.CostDisplayTypes.Shown, Enumerations.MoveAffectionTypes.None, TargetSelectionMenu.EntitySelectionType.Single, false, null), new ChargeSequence(null, chargeAmount))); } #endregion //Defend action BattleActions.Add(new Defend()); //Do nothing action BattleActions.Add(new NoAction()); }
public static InteractionResult GetDamageInteractionOld(InteractionParamHolder interactionParam) { InteractionResult finalInteractionResult = new InteractionResult(); BattleEntity attacker = interactionParam.Attacker; BattleEntity victim = interactionParam.Victim; ContactTypes contactType = interactionParam.ContactType; Elements element = interactionParam.DamagingElement; StatusChanceHolder[] statuses = interactionParam.Statuses; int damage = interactionParam.Damage; bool piercing = interactionParam.Piercing; //Get contact results ContactResultInfo contactResultInfo = victim.EntityProperties.GetContactResult(attacker, contactType); ContactResult contactResult = contactResultInfo.ContactResult; //Retrieve an overridden type of Elemental damage to inflict based on the Victim's PhysicalAttributes //(Ex. The Ice Power Badge only deals Ice damage to Fiery entities) ElementOverrideHolder newElement = attacker.EntityProperties.GetTotalElementOverride(victim); if (newElement.Element != Elements.Invalid) { //Add the number of element overrides to the damage if the element used already exists as an override and the victim has a Weakness //to the Element. This allows Badges such as Ice Power to deal more damage if used in conjunction with attacks //that deal the same type of damage (Ex. Ice Power and Ice Smash deal 2 additional damage total rather than 1). //If any new knowledge is discovered to improve this, this will be changed //Ice Power is the only Badge of its kind across the first two PM games that does anything like this if (element == newElement.Element && victim.EntityProperties.HasWeakness(element) == true) { damage += newElement.OverrideCount; } element = newElement.Element; } /*Get the total damage dealt to the Victim. The amount of Full or Half Payback damage dealt to the Attacker * uses the resulting damage value from this because Payback uses the total damage that would be dealt to the Victim. * This occurs before factoring in elemental resistances/weaknesses from the Attacker*/ ElementDamageResultHolder victimElementDamage = GetElementalDamage(victim, element, damage); int unscaledVictimDamage = victimElementDamage.Damage; //Subtract damage reduction (P-Up, D-Down and P-Down, D-Up Badges) unscaledVictimDamage -= victim.BattleStats.DamageReduction; //Check if the attack hit. If not, then don't consider defensive actions bool attackHit = interactionParam.CantMiss == true ? true : attacker.AttemptHitEntity(victim); //Defense added from Damage Dodge Badges upon a successful Guard int damageDodgeDefense = 0; //Defensive actions take priority. If the attack didn't hit, don't check for defensive actions BattleGlobals.DefensiveActionHolder?victimDefenseData = null; if (attackHit == true) { victimDefenseData = victim.GetDefensiveActionResult(unscaledVictimDamage, statuses, interactionParam.DamageEffect); } if (victimDefenseData.HasValue == true) { unscaledVictimDamage = victimDefenseData.Value.Damage; statuses = victimDefenseData.Value.Statuses; //If the Defensive action dealt damage and the contact was direct //the Defensive action has caused a Failure for the Attacker (Ex. Superguarding) if ((contactType == ContactTypes.TopDirect || contactType == ContactTypes.SideDirect) && victimDefenseData.Value.ElementHolder.HasValue == true) { contactResult = ContactResult.Failure; } //Factor in the additional Guard defense for all DefensiveActions (for now, at least) damageDodgeDefense = victim.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.DamageDodge); } //Subtract Defense on non-piercing damage if (piercing == false) { int totalDefense = victim.BattleStats.TotalDefense + damageDodgeDefense; unscaledVictimDamage -= totalDefense; } int scaledVictimDamage = unscaledVictimDamage; //Factor in Double Pain for the Victim scaledVictimDamage *= (1 + victim.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.DoublePain)); //Factor in Last Stand for the Victim, if the Victim is in Danger or Peril if (victim.IsInDanger == true) { //PM rounds down, whereas TTYD rounds up. We're going with the latter //TTYD always ceilings the value (Ex. 3.2 turns to 4) int lastStandDivider = (1 + victim.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.LastStand)); scaledVictimDamage = (int)Math.Ceiling(scaledVictimDamage / (float)lastStandDivider); } /*If the Victim is Invincible, ignore all damage and Status Effects * If the Attacker is Invincible, ignore all Payback damage and Status Effects * * It won't ignore the Payback's effects automatically; that has to be done manually by adding * contact exceptions or something else*/ //Clamp Victim damage scaledVictimDamage = UtilityGlobals.Clamp(scaledVictimDamage, BattleGlobals.MinDamage, BattleGlobals.MaxDamage); #region Victim Damage Dealt //Calculating damage dealt to the Victim if (contactResult == ContactResult.Success || contactResult == ContactResult.PartialSuccess) { //Get the Status Effects to inflict on the Victim StatusChanceHolder[] victimInflictedStatuses = GetFilteredInflictedStatuses(victim, statuses); //Check if the Victim is Invincible. If so, ignore all damage and Status Effects if (victim.EntityProperties.GetAdditionalProperty <bool>(AdditionalProperty.Invincible) == true) { scaledVictimDamage = 0; victimElementDamage.InteractionResult = ElementInteractionResult.Damage; victimInflictedStatuses = null; } finalInteractionResult.VictimResult = new InteractionHolder(victim, scaledVictimDamage, element, victimElementDamage.InteractionResult, contactType, piercing, victimInflictedStatuses, attackHit, DamageEffects.None); } #endregion #region Attacker Damage Dealt //Calculating damage dealt to the Attacker if (contactResult == ContactResult.Failure || contactResult == ContactResult.PartialSuccess) { //The damage the Attacker dealt to the Victim int damageDealt = unscaledVictimDamage; PaybackHolder paybackHolder = contactResultInfo.Paybackholder; //Override the PaybackHolder with a Defensive Action's results, if any if (victimDefenseData.HasValue == true && victimDefenseData.Value.ElementHolder.HasValue == true) { damageDealt = victimDefenseData.Value.ElementHolder.Value.Damage; paybackHolder = new PaybackHolder(PaybackTypes.Constant, victimDefenseData.Value.ElementHolder.Value.Element, damageDealt); } //Get the damage done to the Attacker, factoring in Weaknesses/Resistances ElementDamageResultHolder attackerElementDamage = GetElementalDamage(attacker, paybackHolder.Element, damageDealt); //Get Payback damage - Payback damage is calculated after everything else, including Constant Payback. //However, it does NOT factor in Double Pain or any sort of Defense modifiers. int paybackDamage = paybackHolder.GetPaybackDamage(attackerElementDamage.Damage); //If Constant Payback, update the damage value to use the element if (paybackHolder.PaybackType == PaybackTypes.Constant) { paybackDamage = GetElementalDamage(attacker, paybackHolder.Element, paybackDamage).Damage; } //Clamp Attacker damage attackerElementDamage.Damage = UtilityGlobals.Clamp(paybackDamage, BattleGlobals.MinDamage, BattleGlobals.MaxDamage); //Get the Status Effects to inflict StatusChanceHolder[] attackerInflictedStatuses = GetFilteredInflictedStatuses(attacker, paybackHolder.StatusesInflicted); //Check if the Attacker is Invincible. If so, ignore all damage and Status Effects if (attacker.EntityProperties.GetAdditionalProperty <bool>(AdditionalProperty.Invincible) == true) { attackerElementDamage.Damage = 0; attackerElementDamage.InteractionResult = ElementInteractionResult.Damage; attackerInflictedStatuses = null; } finalInteractionResult.AttackerResult = new InteractionHolder(attacker, attackerElementDamage.Damage, paybackHolder.Element, attackerElementDamage.InteractionResult, ContactTypes.None, true, attackerInflictedStatuses, true, DamageEffects.None); } #endregion return(finalInteractionResult); }