public void OnContinuePressed() { SingletonProvider.MainEventPublisher.Publish(EventType.CombatResultsClosed, new CombatResultsClosedEvent(result)); SingletonProvider.MainPlayerWallet.AddGold(result.GainedGold); result = null; combatResultScreen.gameObject.SetActive(false); }
public void SetCombatResult(CombatResult player, CombatResult enemy) { _playerAttackResult.text = player.AttackSum.ToString(); _playerDefenseResult.text = player.DefenseSum.ToString(); _enemyAttackResult.text = enemy.AttackSum.ToString(); _enemyDefenseResult.text = enemy.DefenseSum.ToString(); }
public virtual CombatResult Attack(ref ControlledDivision division, float distanceToTarget) { CombatResult result = new CombatResult(); if (distanceToTarget < MinRange || distanceToTarget > MaxRange) { result.AttackSuccess = false; return(result); } result.Attacker = this; foreach (var defender in division.Soldiers) { if (defender.Health > 0) { result.DamageToDefender = DoDamage(this, defender); result.Defender = defender; result.DamageToAttacker = defender.Defend(this, distanceToTarget); break; } } return(result); }
//public override CombatResult Resolve(CombatMove OpponentMove) //{ // return base.Resolve(OpponentMove); //} /// <summary> /// This Fighter BLOCKS, Opponent Fighter BLOCKS /// If either false blocked previously then /// cant block next turn /// </summary> /// <param name="thisFighterId"></param> /// <param name="opponentFighterId"></param> /// <returns></returns> protected override CombatResult resolve(List <CombatMove> Moves) { string thisFighterId = Moves[0].FighterId; string opponentFighterId = Moves[1].FighterId; CombatResult combatResult = new CombatResult(); string comments = "Both knights block."; //ICombatHistoryResolver successfulBlockHistoryResolver = new SuccessfulBlockHistoryResolver(_combatSession); ICombatHistoryResolver falseBlockHistoryResolver = new FalseBlockHistoryResolver(_combatSession); //int numTimesThisFighterHasBeenBlocked = numberPreviousSuccessfulBlocks(opponentFighterId, thisFighterId); //int numTimesOpponentFighterHasBeenBlocked = numberPreviousSuccessfulBlocks(thisFighterId, opponentFighterId); //int numTimesThisFighterHasBeenBlocked = numberPreviousSuccessfulBlocks(opponentFighterId); //int numTimesOpponentFighterHasBeenBlocked = numberPreviousSuccessfulBlocks(thisFighterId); int numTimesThisFighterHasFalseBlocked = falseBlockHistoryResolver.Resolve(thisFighterId); int numTimesOpponentFighterHasFalseBlocked = falseBlockHistoryResolver.Resolve(opponentFighterId); //combatResult.CombatAnimationInstructions[thisFighterId].AnimCommand = AnimationCommands.AC_BLOCK; //combatResult.CombatAnimationInstructions[opponentFighterId].AnimCommand = AnimationCommands.AC_BLOCK; combatResult.CombatAnimationInstructions.Add(thisFighterId, new CombatAnimationInstruction() { FighterID = thisFighterId, AnimCommand = AnimationCommands.AC_BLOCK }); combatResult.CombatAnimationInstructions.Add(opponentFighterId, new CombatAnimationInstruction() { FighterID = opponentFighterId, AnimCommand = AnimationCommands.AC_BLOCK }); if (numTimesThisFighterHasFalseBlocked > 0) { comments = comments + string.Format(" {0} false blocked previoulsy, cannot block next turn. ", thisFighterId); //combatResult.ShieldTaunt.Add(opponentFighterId); //This Fighter cant block next turn combatResult.MoveRestrictions.Add(new KeyValuePair <string, CombatActions>(thisFighterId, CombatActions.BLOCK)); //So Opponent Fighter cant swing either //combatResult.MoveRestrictions.Add(new KeyValuePair<string, CombatActions>(opponentFighterId, CombatActions.SWING)); } if (numTimesOpponentFighterHasFalseBlocked > 0) { comments = comments + string.Format(" {0} false blocked previoulsy, cannot block next turn. ", opponentFighterId); //combatResult.ShieldTaunt.Add(thisFighterId); //Opponent Fighter cant block next turn combatResult.MoveRestrictions.Add(new KeyValuePair <string, CombatActions>(opponentFighterId, CombatActions.BLOCK)); //So This Fighter cant block either //combatResult.MoveRestrictions.Add(new KeyValuePair<string, CombatActions>(thisFighterId, CombatActions.BLOCK)); } //combatResult.TotalRunningHPs[thisFighterId] = totalHPs(thisFighterId); //combatResult.TotalRunningHPs[opponentFighterId] = totalHPs(opponentFighterId); combatResult.TotalRunningHPs.Add(thisFighterId, totalHPs(thisFighterId)); combatResult.TotalRunningHPs.Add(opponentFighterId, totalHPs(opponentFighterId)); combatResult.Comments = comments; return(combatResult); }
public CombatResult CalculateAverageDamage(Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic = true) { EnsureEffectProcs(); var result = new CombatResult(); foreach (var effect in Effects) { result.Add(effect.CalculateAverageDamage(myForce, enemyForce, boosts, vsEpic)); } // Apply Rally Effects - Rally will only work once for each ability and will affect abilities which deal no damage if (boosts != null) { foreach (var rallyEffect in boosts.Where(x => x.Type == EffectType.Rally)) { var abilBonus = rallyEffect.ParentAbilityProcChance*rallyEffect.EffectValue*this.ProcChance; if (HasEffect(EffectType.FlurryDamage)) { var baseBonus = abilBonus; abilBonus = 0; foreach (var effect in GetEffects(EffectType.FlurryDamage)) { abilBonus += baseBonus*effect.EffectValue; } } result.Damage += abilBonus; } } return result; }
private void CombatCheckout(CombatResult combatResult) { string msg = ""; if (combatResult.WinnerId == MatchSystem.instance.selfId) { msg = "我是冠军"; } else { msg = "你输了"; } var go = CanvasManager.instance.CreatePanel(CanvasManager.PanelLevelType.Top, "System/PnlComfirmView"); var wnd = go.GetComponent <ConfirmView>(); wnd.SetLogMessage(msg); wnd.onConfirm.AddListener(() => { foreach (var pair in m_States) { var state = pair.Value; state.ReleaseResource(); } SceneManager.LoadScene((Int32)GameConst.SceneType.Player); }); }
public object[] ReflectiveWard(CombatResult owner, CombatResult target) { if (target.SentHit) { if (Program.Chance(tier)) { long totalDamage = 0; for (int i = 0; i < target.baseDamage.Length; i++) { totalDamage += NumbersM.FloorParse <long> ((target.baseDamage[i] + target.bonusDamage[i]) * target.damageMultiplier[i]); target.damageMultiplier[i] = 0; } long returned = NumbersM.FloorParse <long>(totalDamage * (5.00 + tier) / 100); target.character.TakeDamage(returned); owner.perkProcs.Add($"Returned {returned} damage to {target.Name}"); } } return(R(owner, target)); }
public void OnCombatResult(CombatResult result) { this.CurrentLifeForce -= result.UsedLifeForce; if (!result.DefenseWon) { this.Health -= result.LifeDamage; if (this.Health <= 0) { this.TransferAllLifeForceTo(result.OpponentLifeForce.GetComponent <ILife>()); } } else { if (this.CurrentLifeForce <= this.MaxLifeForceUsage) { RunAway(); } } Transform spell = Instantiate(_lifeForceBallPrefab, this.transform.position, Quaternion.identity).transform; spell.GetComponent <SpellFollowTarget>().Cast(result.OpponentLifeForce.transform); spell.transform.parent = GameObject.Find("=== spells ===").transform; }
private void DisplayPostCombatPopup(CombatResult result) { var popup = FindObjectOfType <PostCombatResultsPopup>(); popup.Show(result); _eventMediator.Broadcast(CombatFinished, this); }
public object[] CleanSlate(CombatResult owner) { if (owner.character.status.Count == 0) { owner.character.StaminaE(0.05); } return(new object[] { owner }); }
void OnEvent(IEvent e) { if (e is CombatEndedEvent combatEnded) { combatResultScreen.gameObject.SetActive(true); combatResultScreen.SetCombatResult(combatEnded.Result); result = combatEnded.Result; } }
public object[] HunterTrap_End(CombatResult owner) { if (rank < 5) { rank++; } return(new object[] { owner }); }
public object[] Paralysis(CombatResult owner) { if (owner.action == CombatResult.Action.Cast && Program.Chance(tier)) { owner.action = CombatResult.Action.Paralyzed; } return(TurnPassed(owner)); }
public void AddResult(CombatResult res) { if (res == CombatResult.Win) Wins++; else if (res == CombatResult.Lose) Losses++; else Draws++; }
public object[] Underestimated(CombatResult owner, CombatResult enemy) { if (owner.character.level < enemy.character.level || owner.character.Rank() < enemy.character.Rank()) { owner.damageMultiplier = ArrayM.AddEach(owner.damageMultiplier, 0.1); } return(new object[] { owner, enemy }); }
public object[] Opportunist(CombatResult owner, CombatResult enemy) { if (enemy.character.status.Count > 0) { owner.damageMultiplier = ArrayM.AddEach(owner.damageMultiplier, 0.01 * enemy.character.status.Count); } return(new object[] { owner, enemy }); }
public static void Reflect(CombatResult caster, CombatResult target) { if (caster.SentHit) { Ability reflect = caster.abilityUsed; target.character.Status(reflect.statusEffect, 3 + (reflect.level / 5), reflect.level); caster.perkProcs.Add($"Applied {reflect.statusEffect} to {target.Name}"); } }
public static void KeenEye(CombatResult caster, CombatResult target) { if (caster.SentHit) { Ability keeneye = caster.abilityUsed; target.character.Status(keeneye.statusEffect, 5 + (keeneye.level / 10), 5 + (keeneye.level / 10)); caster.perkProcs.Add($"Applied {keeneye.statusEffect} to {target.Name}"); } }
public object[] Vengeful(CombatResult owner) { double per = (owner.character.health / owner.character.Health()) - 0.35; if (per > 0) { owner.damageMultiplier = ArrayM.AddEach(owner.damageMultiplier, per); } return(R(owner)); }
public static void WhiteBite(CombatResult caster, CombatResult target) { if (caster.SentHit) { Ability ability = caster.abilityUsed; target.character.Status(ability.statusEffect ?? "Energy Leak", 3 + (ability.level / 3), ability.level); caster.perkProcs.Add($"{caster.Name} applied Energy Leak to {target.Name}"); } }
public static void CounterPrep(CombatResult caster, CombatResult target) { if (caster.SentHit) { Ability counterPrep = caster.abilityUsed; target.character.Status(counterPrep.statusEffect ?? "Patient Requite", counterPrep.level, counterPrep.level); caster.perkProcs.Add($"Applied Patient Requite to {target.Name}"); } }
public void ReceiveCombatResult(CombatResult combatResult) { mCombatReceiverModel.AlterHealthPoints(-combatResult.DamageToReceiver); // Monitor health for killing actor. if (mCombatReceiverModel.HealthPoints <= 0) { mCombatReceiverModel.MarkedForDeath = true; } }
/// <summary> /// 战斗结束 /// </summary> void CombatComplete(CombatResult result) { if (state == State.Combating) { state = State.CombatComplete; GameEvent.TurnBaseEvent.FireOnCombatComplete(curTurnBase, result); curTurnBase = null; nextTurnBase = null; } }
/// <summary> /// Enter Combat mode. /// </summary> /// <param name="parts">Command as typed by the user split into individual words.</param> private static void ProcessFightCommand(string[] parts) { Creature creature; try { creature = CurrentArea.GetCreature(parts[1]); } catch (WorldException e) { if (CurrentArea.HasItem(parts[1])) { PrintLineWarning("You can't fight with that..."); } else { PrintLineDanger(e.Message); } return; } // This method is part of the MainClass but is defined in a different file. // Check out the Combat.cs file. CombatResult result = DoCombat(creature); switch (result) { case CombatResult.Win: PrintLinePositive("You win!"); Player.Stats.Exp += creature.Stats.Exp; CurrentArea.RemoveCreature(parts[1]); // TODO: Part of a larger achievement // After you gain Exp, how do you improve your stats? // there should be some rules to how this works. // But, you are the god of this universe. You make the rules. // TODO: Part of a larger achievement // After defeating an Enemy, they should drop their Inventory // into the CurrentArea so that the player can then PickUp those Items. break; case CombatResult.Lose: PrintLineDanger("You lose!"); // TODO: Easy Achievement: // What happens when you die? Deep questions. break; case CombatResult.RunAway: // TODO: Moderate Achievement // Handle running away. What happens if you run from a battle? break; default: break; } }
public static void SpiritRip(CombatResult caster, CombatResult target) { Ability ability = caster.abilityUsed; if (caster.SentHit && Program.Chance(38 + ability.level)) { target.character.Status(ability.statusEffect ?? "Energy Leak", ability.level, ability.level + 10); caster.perkProcs.Add($"{caster.Name} applied Energy Leak to {target.Name}"); } }
public static void ToxicStrike(CombatResult caster, CombatResult target) { Ability toxicStrike = caster.abilityUsed; if (caster.SentHit && Program.Chance(10 + toxicStrike.level)) { target.character.Status(toxicStrike.statusEffect ?? "Poisoned", 6, (int)Verify.Min(caster.character.TotalBaseDamage() / 10, 2)); caster.perkProcs.Add($"Applied Poisoned > {target.Name}"); } }
//public override CombatResult Resolve(CombatMove OpponentMove) //{ // return base.Resolve(OpponentMove); //} /// <summary> /// This Fighter BLOCKS, Opponent Fighter RESTS /// If This Fighter false blocked previously then /// cant block next turn. /// Opponent Fighter heals /// </summary> /// <param name="thisFighterId"></param> /// <param name="opponentFighterId"></param> /// <returns></returns> protected override CombatResult resolve(List <CombatMove> Moves) { string blockingFighterId = Moves.Where(x => x.Action == CombatActions.BLOCK).FirstOrDefault().FighterId; string restingFighterId = Moves.Where(x => x.Action == CombatActions.REST).FirstOrDefault().FighterId; CombatResult combatResult = new CombatResult(); string comments = "Player heals."; ICombatHistoryResolver falseBlockHistoryResolver = new FalseBlockHistoryResolver(_combatSession); //get count of how may times This Fighter has been previously false blocked //int previousFalseBlocks = numberPreviousFalseBlocks(thisFighterId, opponentFighterId); //int previousFalseBlocks = numberPreviousFalseBlocks(thisFighterId); int previousFalseBlocks = falseBlockHistoryResolver.Resolve(blockingFighterId); if (previousFalseBlocks > 0) { combatResult.MoveRestrictions.Add(new KeyValuePair <string, CombatActions>(blockingFighterId, CombatActions.BLOCK)); comments = string.Format("{0} false blocks and cannot block next turn", blockingFighterId); } //get count of how may times Opponent Fighter has previously healed //int previousHeals = numberPreviousSuccessfulHeals(opponentFighterId, thisFighterId); //int previousHeals = numberPreviousSuccessfulHeals(opponentFighterId); SuccessfulHealHistoryResolver successfulHealHistoryResolver = new SuccessfulHealHistoryResolver(_combatSession); int previousHeals = successfulHealHistoryResolver.Resolve(restingFighterId); //combatResult.CombatAnimationInstructions[thisFighterId].AnimCommand = AnimationCommands.AC_BLOCK; //combatResult.CombatAnimationInstructions[opponentFighterId].AnimCommand = AnimationCommands.AC_HEAL; combatResult.CombatAnimationInstructions.Add(blockingFighterId, new CombatAnimationInstruction() { FighterID = blockingFighterId, AnimCommand = AnimationCommands.AC_BLOCK }); combatResult.CombatAnimationInstructions.Add(restingFighterId, new CombatAnimationInstruction() { FighterID = restingFighterId, AnimCommand = AnimationCommands.AC_HEAL }); //damage is base 2 plus previous consecutive hits int totalHealing = 1 + previousHeals; //combatResult.HPAdjustments[opponentFighterId] = totalHealing; combatResult.HPAdjustments.Add(restingFighterId, totalHealing); //combatResult.TotalRunningHPs[opponentFighterId] = totalHPs(opponentFighterId) + totalHealing; //combatResult.TotalRunningHPs[thisFighterId] = totalHPs(thisFighterId); combatResult.TotalRunningHPs.Add(restingFighterId, totalHPs(restingFighterId) + totalHealing); combatResult.TotalRunningHPs.Add(blockingFighterId, totalHPs(blockingFighterId)); combatResult.Comments = comments; return(combatResult); }
public static void Taunt(CombatResult caster, CombatResult target) { if (caster.SentHit) { Ability ability = caster.abilityUsed; //Add agrro mechanics TODO caster.character.StaminaE(100); target.perkProcs.Add($"Was taunted by {caster.Name}!"); } }
public static void Vivace(CombatResult caster, CombatResult target) { if (caster.SentHit) { Ability vivace = caster.abilityUsed; int staminaDrained = Verify.Max(2 * vivace.level, target.character.stamina); target.character.StaminaE(-staminaDrained); caster.character.StaminaE(staminaDrained); caster.perkProcs.Add($"{caster.Name} drained {staminaDrained}SP from {target.Name}"); } }
//public override CombatResult Resolve(CombatMove OpponentMove) //{ // return base.Resolve(OpponentMove); //} /// <summary> /// This Fighter SWINGS, Opponent Fighter BLOCKS /// If This Fighter has been blocked previously then /// he cant swing again next turn /// </summary> /// <param name="thisFighterId"></param> /// <param name="opponentFighterId"></param> /// <returns></returns> protected override CombatResult resolve(List <CombatMove> Moves) { string swingingFighterId = Moves.Where(x => x.Action == CombatActions.SWING).FirstOrDefault().FighterId; string blockingFighterId = Moves.Where(x => x.Action == CombatActions.BLOCK).FirstOrDefault().FighterId; CombatResult combatResult = new CombatResult(); ICombatHistoryResolver successfulBlockHistoryResolver = new SuccessfulBlockHistoryResolver(_combatSession); string comments; //get count of how may times Opponent Fighter has previously been blocked (consecutively) //int numberPreviousTimesBlocked = numberPreviousSuccessfulBlocks(thisFighterId, opponentFighterId); //int numberPreviousTimesBlocked = numberPreviousSuccessfulBlocks(thisFighterId); //int numberPreviousTimesBlocked = successfulBlockHistoryResolver.Resolve(swingingFighterId); int numberPreviousTimesBlocked = successfulBlockHistoryResolver.Resolve(blockingFighterId); //combatResult.CombatAnimationInstructions[thisFighterId].AnimCommand = AnimationCommands.AC_SWING; //combatResult.CombatAnimationInstructions[opponentFighterId].AnimCommand = AnimationCommands.AC_BLOCK; combatResult.CombatAnimationInstructions.Add(swingingFighterId, new CombatAnimationInstruction() { FighterID = swingingFighterId, AnimCommand = AnimationCommands.AC_SWING }); combatResult.CombatAnimationInstructions.Add(blockingFighterId, new CombatAnimationInstruction() { FighterID = blockingFighterId, AnimCommand = AnimationCommands.AC_BLOCK }); //add flag to signal recoil animation combatResult.ShieldRecoil.Add(blockingFighterId); comments = string.Format("{0} blocks.", blockingFighterId); //If This Player was blocked previously then trigger taunting animation and restrict next move: if (numberPreviousTimesBlocked >= 1) { combatResult.ShieldTaunt.Add(blockingFighterId); //This Player cant swing next turn combatResult.MoveRestrictions.Add(new KeyValuePair <string, CombatActions>(swingingFighterId, CombatActions.SWING)); //So opponent cant block combatResult.MoveRestrictions.Add(new KeyValuePair <string, CombatActions>(blockingFighterId, CombatActions.BLOCK)); comments = comments + string.Format(" {0} cannot swing next turn, so {1} cannot use shield", swingingFighterId, blockingFighterId); } //combatResult.TotalRunningHPs[thisFighterId] = totalHPs(thisFighterId); //combatResult.TotalRunningHPs[opponentFighterId] = totalHPs(opponentFighterId); combatResult.TotalRunningHPs.Add(swingingFighterId, totalHPs(swingingFighterId)); combatResult.TotalRunningHPs.Add(blockingFighterId, totalHPs(blockingFighterId)); combatResult.Comments = comments; return(combatResult); }
public static void Blunt(CombatResult caster, CombatResult target) { Ability sunder = caster.abilityUsed; if (caster.SentHit && (35 + sunder.level) <= Program.rng.Next(101)) { if (target.character.Status(sunder.statusEffect, 3 + (sunder.level / 5), 10 + sunder.level) == 1) { caster.perkProcs.Add($"{caster.Name} {sunder.statusEffect} {target.Name}"); } } }
public CombatResult CalculateAverageDamage(Force myForce, Force enemyForce, bool vsEpic = true) { var result = new CombatResult(); foreach (var ability in Abilities) { // Formations can never recieve Boosts result.Add(ability.CalculateAverageDamage(myForce, enemyForce, null, vsEpic)); } return result; }
public void NewBrokenShield(Vector3 position) { GameObject obj = m_brokenShields.GetPooledObject(); if (obj != null) { obj.transform.position = position; CombatResult newBrokenShield = new CombatResult(); newBrokenShield.obj = obj; newBrokenShield.time = 3.0f; m_activeBrokenShields.Add(newBrokenShield); } }
public CombatResult CalculateAverageDamage(Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic = true) { var result = new CombatResult(); var useableBoosts = new List<Effect>(); if(boosts != null) { useableBoosts.AddRange(boosts.Where(effect => effect.IsBoostEffect() && this.IsClassification(effect.TargetType)).ToList()); } foreach (var ability in Abilities) { result.Add(ability.CalculateAverageDamage(myForce, enemyForce, useableBoosts, vsEpic)); } return result; }
// This is the main controller for combat. It arbitrates the interaction, records what took place // into a combat result, and sends out a message to both parties about the combat result. public static void ResolveAttackCollision(CombatAttackModel attack, CombatReceiverModel receiver) { CombatResult result; result = new CombatResult(); // Record models result.Attack = attack; result.Receiver = receiver; result.DamageToReceiver = attack.Damage; result.DamageToAttacker = receiver.DamageToAttackerOnHit; if (receiver.AllowColorLeech) { result.ColorChangeAttacker = DetermineColorLeech(attack, receiver, result.DamageToReceiver/receiver.InitialHealthPoints); } else { result.ColorChangeAttacker = Vector3.zero; } // Determine if attack will kill the receiver. if ( (receiver.HealthPoints - result.DamageToReceiver) <= 0) { result.DamageToAttacker += receiver.DamageToAttackerOnKill; } // Send result back to the receiver. receiver.SendMessage("ReceiveCombatResult", result, SendMessageOptions.DontRequireReceiver); attack.SendMessage("AttackCombatResult", result, SendMessageOptions.DontRequireReceiver); // Inform the owner of the attack success. if (attack.Owner) { attack.Owner.SendMessage("AttackCombatResult", result, SendMessageOptions.DontRequireReceiver); } }
public void AttackCombatResult(CombatResult combatResult) { AlterColor(combatResult.ColorChangeAttacker); }
/// <summary> /// Computes a fight between the currently selected unit /// and the best one from the selected destination. /// </summary> /// <param name="unit">The unit who fight.</param> /// <returns>A constant from the CombatResult enumeration to describe the result.</returns> private CombatResult Combat(IUnit unit) { IUnit enemy = GetBestUnit(); Random randCombat = new Random(); Random rand = new Random(); int nbRound = 3 + randCombat.Next((Math.Max(unit.LifePoints, enemy.LifePoints)) + 2); int n = 0; while(nbRound > n && unit.IsAlive() && enemy.IsAlive()) { double ratioLife = (double)unit.LifePoints / (double)unit.DefaultLifePoints; double ratioLifeDef = (double)enemy.LifePoints / (double)enemy.DefaultLifePoints; double attaUnit = (double)unit.Attack * (double)ratioLife; double defUnitdef = (double)enemy.Defense * (double)ratioLifeDef; double ratioAttDef = (double)(attaUnit / defUnitdef); double ratioChanceDef = 0; if(ratioAttDef > 1) { // Advantage for the attacker. ratioChanceDef = (1 / ratioAttDef) / 2; ratioChanceDef = (0.5 - ratioChanceDef) + 0.5; } else if(ratioAttDef == 1) { // Draw: 50% chances to win. ratioChanceDef = 0.5; } else { // Advantage for the defender. ratioChanceDef = ratioAttDef / 2; } double ratioCombat = (double)((double)rand.Next(100) / 100); if(ratioCombat <= ratioChanceDef) { enemy.DecreaseLifePoints(); } else { unit.DecreaseLifePoints(); } n++; } // Computes the result of the fight: if(!unit.IsAlive()) { this.game.Map.RemoveUnit(unit, this.selectedPosition); this.lastMoveInfo = this.player.Name + " lost the fight."; this.lastCombatResult = CombatResult.LOSE; } else if(!enemy.IsAlive()) { this.game.Map.RemoveUnit(enemy, this.destination); this.lastMoveInfo = this.player.Name + " won the fight."; this.lastCombatResult = CombatResult.WIN; } else { this.lastMoveInfo = "The fight ended with a draw"; this.lastCombatResult = CombatResult.DRAW; } return this.lastCombatResult; }
public CombatResult CalculateTotalDamageContribution(Guid claimerID, Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic = true) { var result = new CombatResult(); result.Add(this.CalculateAverageDamage(myForce, enemyForce, boosts, vsEpic)); result.Add(this.CalculateReinforcedDamage(claimerID, myForce, enemyForce, boosts, vsEpic)); return result; }
public CombatResult CalculateReinforcedDamage(Guid claimerID, Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic = true) { EnsureEffectProcs(); var result = new CombatResult(); if (HasEffect(EffectType.Reinforce) == false) { return result; } foreach (var effect in GetEffects(EffectType.Reinforce)) { result.Add(effect.CalculateReinforcedDamage(claimerID, myForce, enemyForce, boosts, vsEpic)); } return result; }
private static void ExitCombat() { try { _combatLoopThread.Abort(); } catch { } try { _combatThread.Abort(); } catch { } MoveHelper.ReleaseKeys(); if (_combatResult == CombatResult.OtherPlayerTag) { PBlackList.Blacklist(Unit, 1200, false); } if (_combatResult == CombatResult.Bugged && ObjectManager.MyPlayer.HasLivePet) { KeyHelper.SendKey("PetFollow"); } if (Unit.IsDead) { _combatResult = CombatResult.Success; } if (!ObjectManager.MyPlayer.IsAlive) { _combatResult = CombatResult.Died; } Logging.Write("Combat done, result : " + _combatResult); InvokeCombatStatusChanged(new GCombatEventArgs(CombatType.CombatDone, Unit)); CombatDone(); try { Stop(); } catch { } }
internal static void StartCombat(PUnit u) { if (ObjectManager.MyPlayer.IsDead) { Stop(); return; } Unit.BaseAddress = u.BaseAddress; InvokeCombatStatusChanged(new GCombatEventArgs(CombatType.CombatStarted)); _combatThread = new Thread(CombatThread) {IsBackground = true}; _combatThread.Name = "CombatThread"; _combatThread.Start(); _combatResult = CombatResult.Unknown; while (_combatThread.IsAlive) { try { if (Unit.IsDead) { _combatResult = CombatResult.Success; break; } if (!Unit.IsValid || PBlackList.IsBlacklisted(Unit)) { if (!Langs.TrainingDummy(ObjectManager.MyPlayer.Target.Name)) { _combatResult = CombatResult.Bugged; break; } } if (ObjectManager.MyPlayer.IsDead) { _combatResult = CombatResult.Died; break; } if (Unit.IsPet || Unit.IsTotem) { Logging.Write("We are attacking a totem or a pet... doh"); _combatResult = CombatResult.Bugged; break; } if (!Langs.TrainingDummy(Unit.Name) && Unit.IsTagged && !Unit.IsTaggedByMe && !Unit.IsTargetingMe && Unit != ObjectManager.MyPlayer) { Logging.Write("Other player tag"); _combatResult = CombatResult.OtherPlayerTag; break; } } catch (Exception e) { Logging.Write("Exeption in combat handler: " + e); } Thread.Sleep(160); } ExitCombat(); }
private static void CombatThread() { try { Logging.Write("Started combat engine"); if (ObjectManager.MyPlayer.IsMounted && !ObjectManager.MyPlayer.TravelForm) KeyHelper.SendKey("GMount"); MoveHelper.ReleaseKeys(); if (DefendAgainst() == null) { Logging.Write("Pulling: " + Unit.Name + " " + Unit.GUID); MoveHelper.MoveToUnit(Unit, 30); if (!Unit.TargetHostile()) { if (ObjectManager.GetAttackers.Count == 0) PPullBlackList.Blacklist(Unit, 800, true); } Unit.Face(); MoveHelper.ReleaseKeys(); PullResult result = Pull(); Logging.Write("Pull result: " + result); if (result.Equals(PullResult.CouldNotPull)) { PPullBlackList.Blacklist(Unit, 800, true); return; } if (PPullBlackList.IsBlacklisted(Unit)) { return; } } else { Logging.Write("Got into combat with: " + Unit.Name); Unit.TargetHostile(); Unit.Face(); } Ticker combatTimeout; if (ObjectManager.MyPlayer.Level > 10) { combatTimeout = new Ticker(20*1000); } else { combatTimeout = new Ticker(40*1000); } while (!Unit.IsDead) { _combatLoopThread = new Thread(DoCombat) {IsBackground = true}; _combatLoopThread.Name = "DoCombat"; _combatLoopThread.SetApartmentState(ApartmentState.STA); _combatLoopThread.Start(); while (_combatLoopThread.IsAlive) { Thread.Sleep(50); if (!Langs.TrainingDummy(Unit.Name) && combatTimeout.IsReady && Unit.Health > 85) { Logging.Write("Combat took to long, bugged - blacklisting"); _combatResult = CombatResult.Bugged; if (!PBlackList.IsBlacklisted(Unit)) PBlackList.Blacklist(Unit, 1200, false); return; } } } } catch { } }
public CombatResult CalculateAverageForceDamage(Force enemy) { var total = new CombatResult(); foreach (var unit in GetUnits()) { total.Add(unit.CalculateTotalDamageContribution(this, enemy, this.GetBoostAbilities(), enemy.IsEpicBoss)); } return total; }
public CombatResult CalculateReinforcedDamage(Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic = true) { var result = new CombatResult(); foreach (var ability in Abilities.Where(x => x.HasEffect(EffectType.Reinforce))) { result.Add(ability.CalculateReinforcedDamage(this.ID, myForce, enemyForce, boosts, vsEpic)); } return result; }
public void AttackCombatResult(CombatResult combatResult) { mCombatReceiverModel.AlterHealthPoints(-combatResult.DamageToAttacker); }
// boosts is populated with only effects that can boost the source abilities unit public CombatResult CalculateAverageDamage(Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic = true) { var result = new CombatResult(); if (VsEpicOnly && (vsEpic == false)) { return result; } var min = Min + (vsEpic ? MinBonusVsEpic : 0); var max = Max + (vsEpic ? MaxBonusVsEpic : 0); var avg = ((min + max)/2.0); if (IsDamageEffect()) { if (Type == EffectType.FlurryDamage) { avg *= EffectValue; } if (Type == EffectType.ConditionalDamage && enemyForce != null) { avg *= enemyForce.AvgNumOfUnitTypeAfterReinforcements(TargetType); } result.Damage += (avg*ParentAbilityProcChance); // Apply Percentile Boosts if (boosts != null) { foreach (var boostEffect in boosts.Where(x => x.Type == EffectType.Boost)) { var boostBonus = 1 + (boostEffect.ParentAbilityProcChance*(boostEffect.EffectValue*0.01)); result.Damage *= boostBonus; } } } if (IsHealingEffect()) { if (Type == EffectType.ConditionalHeal && myForce != null) { avg *= myForce.AvgNumOfUnitTypeAfterReinforcements(TargetType); } result.Healing += (avg*ParentAbilityProcChance); } if (Type == EffectType.AntiHeal) { result.AntiHeal += (avg*ParentAbilityProcChance); } return result; }
public CombatResult CalculateReinforcedDamage(Guid claimerID, Force myForce, Force enemyForce, List<Effect> boosts, bool vsEpic) { var result = new CombatResult(); foreach (var unit in myForce.ClaimReinforcements(claimerID, TargetType, EffectValue)) { // Add each reinforced units total average damage potential (including reinforcements it might bring in too) var baseDamage = unit.CalculateTotalDamageContribution(myForce, enemyForce, boosts, vsEpic); result.Add(baseDamage.AdjustToProcChance(ParentAbilityProcChance)); } return result; }