public bool SetNextTurn() { if (Participants.Count == 1) { EndBattle(); return false; } CurrentTurn = NextTurn; if (CurrentTurn is Player) { CurrentTurn.SendMessage("\n\rBattle! Your turn, action?\n\r", "t=output~txt=Battle! Your turn.\n\r"); Skill skill; int count = 1; foreach(SkillInstance skillInstance in CurrentTurn.SkillSlots) { skill = skillInstance.Skill; CurrentTurn.SendMessage("- skill" + count + ": " + skill.Name + "\n\r"); count++; } } // Currently turn-based combat only supports two participants, the following will need to be changed to support more foreach (Mob mob in Participants) { if (mob != CurrentTurn) { NextTurn = mob; } } return true; }
public bool SetNextTurn() { if (Participants.Count == 1) { EndBattle(); return(false); } CurrentTurn = NextTurn; if (CurrentTurn is Player) { CurrentTurn.SendMessage("\n\rBattle! Your turn, action?\n\r", "t=output~txt=Battle! Your turn.\n\r"); Skill skill; int count = 1; foreach (SkillInstance skillInstance in CurrentTurn.SkillSlots) { skill = skillInstance.Skill; CurrentTurn.SendMessage("- skill" + count + ": " + skill.Name + "\n\r"); count++; } } // Currently turn-based combat only supports two participants, the following will need to be changed to support more foreach (Mob mob in Participants) { if (mob != CurrentTurn) { NextTurn = mob; } } return(true); }
public bool SetTargetAllyAsFirstArg(Mob user, string text) { Type type = typeof(Mob); Argument arg1 = Parser.GetArgument(text, 2, user, type, SearchLocations.Room); Mob target = (Mob)arg1.Reference; if (target == null) { if (user.TargetAlly == null) { user.SendMessage("They aren't here!\n\r"); return(false); } else { target = user.TargetAlly; } } if (user.TargetAlly == null) { user.TargetAlly = target; } return(true); }
public void EndBattle() { Mob mob = Participants[0]; mob.SendMessage("You won the battle!\n\r", "dupe"); mob.Menu = null; }
/// <summary> /// Delivers a single message, calling the SendMessage method of all appropriate /// Mobs in both the actor's and target's rooms ("appropriate" determined by /// messageType). /// </summary> /// <param name="actor">Mob performing the narrated action (if any!)</param> /// <param name="target">Mob receiving the narrated action (if any!)</param> /// <param name="messageType">Vector for the message (who it is sent to)</param> /// <returns>false if any error conditions are met or any messages fail to send</returns> public static bool DeliverMessage(Mob actor, Mob target, MessageVector messageType, String message, String mobileMessage) { // Early exit conditions if (message == null || message.Equals("")) return false; if (actor == null && target == null) return false; if (messageType == MessageVector.NotCharacter && actor == null) return false; if (messageType == MessageVector.NotTarget && target == null) return false; bool returner = true; // Format all of the $ arguments in message message = formatMessage(actor, target, message, mobileMessage); // Handle the easy ones first: Character & Target; no need to loop for these. if (messageType == MessageVector.Character) { if (actor == null) return false; return actor.SendMessage(message, mobileMessage); } else if (messageType == MessageVector.Target) { if (target == null) return false; return target.SendMessage(message, mobileMessage); } // Now we loop through the contents of the room. if (actor != null) { if (((Room)actor.Location) != null && ((Room)actor.Location).Contents != null) { foreach (Mob audience in ((Room)actor.Location).Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) continue; if (messageType == MessageVector.NotTarget && audience == target) continue; if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) continue; if (audience.SendMessage(message, mobileMessage) == false) returner = false; } } else { return false; } } // If the actor is null (for whatever reason) or the target is in a different room, we // need to display the message to the appropriate audience in the target's room. if (target != null && (actor == null || ((Room)target.Location).IndexNumber != ((Room)actor.Location).IndexNumber)) { if (((Room)target.Location) != null && ((Room)target.Location).Contents != null) { foreach (Mob audience in ((Room)target.Location).Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) continue; if (messageType == MessageVector.NotTarget && audience == target) continue; if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) continue; if (audience.SendMessage(message, mobileMessage) == false) returner = false; } } else { return false; } } return returner; }
public static int GetHeal(Mob attacker, Mob target, Skill skill) { double heal = 0; int critHeal = 2000; bool crit = false; if (skill.Components.ContainsKey("DamageTypePhysical")) { int damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); heal += attacker.PhysicalPower * damageTypePhysical; heal /= 100; if (Combat.Random.Next(0, 1000) <= attacker.PhysicalCritical * damageTypePhysical / 100) { crit = true; critHeal += attacker.PhysicalCriticalDamage * damageTypePhysical / 100; } } if (skill.Components.ContainsKey("DamageTypeMagical")) { int damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); heal += attacker.MagicPower * damageTypeMagical; heal /= 100; if (!skill.Components.ContainsKey("NoCritical")) { if (Combat.Random.Next(0, 1000) <= attacker.MagicalCritical * damageTypeMagical / 100) { crit = true; critHeal += attacker.MagicalCriticalDamage * damageTypeMagical; } } } if (crit) { heal *= critHeal; heal /= 1000; attacker.SendMessage("Crit! "); } if (skill.Components.ContainsKey("Randomize")) { int mod = Random.Next(100 - (int)skill.Components["Randomize"] / 2, 100 + (int)skill.Components["Randomize"] / 2); heal *= mod; heal /= 100; } if (heal <= 0) { heal = 1; } if (skill.Components.ContainsKey("DamageTypePhysical")) { int damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); } if (skill.Components.ContainsKey("DamageTypeMagical")) { int damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); } return(Convert.ToInt32(heal)); }
/// <summary> /// Returns the damage of the provided skill used by the attacker against the target, performing all necessary damage calculations /// </summary> /// <param name="attacker"></param> /// <param name="target"></param> /// <param name="skill"></param> /// <returns></returns> public static int GetOneHit(Mob attacker, Mob target, Skill skill) { if (target == null) { return(0); } double damage = 0; int critDamage = 2000; bool crit = false; bool autoPhys = false; bool autoMag = false; if (skill.Components.ContainsKey("Autoattack")) { int highestStat = 0; bool physical = false; if (attacker.PhysicalPower >= highestStat) { highestStat = attacker.PhysicalPower; physical = true; } if (attacker.MagicPower > highestStat) { highestStat = attacker.MagicPower; physical = false; } if (physical == true) { //addStatMods += attacker.PhysicalPower; autoPhys = true; } else { //addStatMods += attacker.MagicPower; autoMag = true; } damage *= 100; } if (skill.Components.ContainsKey("DamageTypePhysical") || autoPhys) { int damageTypePhysical = 0; if (autoPhys) { damageTypePhysical = 100; } else { damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); } damage += attacker.PhysicalPower * damageTypePhysical; damage /= 100; damage *= 10000 / ((target.Armor * damageTypePhysical / 100) + 100); damage /= 100; if (Combat.Random.Next(0, 1000) <= attacker.PhysicalCritical * damageTypePhysical / 100) { crit = true; critDamage += attacker.PhysicalCriticalDamage * damageTypePhysical / 100; } } if (skill.Components.ContainsKey("DamageTypeMagical") || autoMag) { int damageTypeMagical = 0; if (autoMag) { damageTypeMagical = 100; } else { damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); } damage += attacker.MagicPower * damageTypeMagical; damage /= 100; damage *= 10000 / ((target.Resistance * damageTypeMagical / 100) + 100); damage /= 100; if (!skill.Components.ContainsKey("NoCritical")) { if (Combat.Random.Next(0, 1000) <= attacker.MagicalCritical * damageTypeMagical / 100) { crit = true; critDamage += attacker.MagicalCriticalDamage * damageTypeMagical; } } } if (crit) { damage *= critDamage; damage /= 1000; attacker.SendMessage("Crit! "); } if (skill.Components.ContainsKey("Randomize")) { int mod = Random.Next(100 - (int)skill.Components["Randomize"] / 2, 100 + (int)skill.Components["Randomize"] / 2); damage *= mod; damage /= 100; } if (damage <= 0) { damage = 1; } if (skill.Components.ContainsKey("DamageTypePhysical") || autoPhys) { int damageTypePhysical = 0; if (autoPhys) { damageTypePhysical = 100; } else { damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); } } if (skill.Components.ContainsKey("DamageTypeMagical") || autoMag) { int damageTypeMagical = 0; if (autoMag) { damageTypeMagical = 100; } else { damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); } } return(Convert.ToInt32(damage)); }
/// <summary> /// Delivers a single message, calling the SendMessage method of all appropriate /// Mobs in both the actor's and target's rooms ("appropriate" determined by /// messageType). /// </summary> /// <param name="actor">Mob performing the narrated action (if any!)</param> /// <param name="target">Mob receiving the narrated action (if any!)</param> /// <param name="messageType">Vector for the message (who it is sent to)</param> /// <returns>false if any error conditions are met or any messages fail to send</returns> public static bool DeliverMessage(Mob actor, Mob target, MessageVector messageType, String message, String mobileMessage) { // Early exit conditions if (message == null || message.Equals("")) { return(false); } if (actor == null && target == null) { return(false); } if (messageType == MessageVector.NotCharacter && actor == null) { return(false); } if (messageType == MessageVector.NotTarget && target == null) { return(false); } bool returner = true; // Format all of the $ arguments in message message = formatMessage(actor, target, message, mobileMessage); // Handle the easy ones first: Character & Target; no need to loop for these. if (messageType == MessageVector.Character) { if (actor == null) { return(false); } return(actor.SendMessage(message, mobileMessage)); } else if (messageType == MessageVector.Target) { if (target == null) { return(false); } return(target.SendMessage(message, mobileMessage)); } // Now we loop through the contents of the room. if (actor != null) { if (actor.Room != null && actor.Room.Contents != null) { foreach (Mob audience in actor.Room.Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) { continue; } if (messageType == MessageVector.NotTarget && audience == target) { continue; } if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) { continue; } if (audience.SendMessage(message, mobileMessage) == false) { returner = false; } } } else { return(false); } } // If the actor is null (for whatever reason) or the target is in a different room, we // need to display the message to the appropriate audience in the target's room. if (target != null && (actor == null || target.Room.IndexNumber != actor.Room.IndexNumber)) { if (target.Room != null && target.Room.Contents != null) { foreach (Mob audience in target.Room.Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) { continue; } if (messageType == MessageVector.NotTarget && audience == target) { continue; } if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) { continue; } if (audience.SendMessage(message, mobileMessage) == false) { returner = false; } } } else { return(false); } } return(returner); }
public bool SetTargetAllyAsFirstArg(Mob user, string text) { Type type = typeof(Mob); Argument arg1 = Parser.GetArgument(text, 2, user, type, SearchLocations.Room); Mob target = (Mob)arg1.Reference; if (target == null) { if (user.TargetAlly == null) { user.SendMessage("They aren't here!\n\r"); return false; } else { target = user.TargetAlly; } } if (user.TargetAlly == null) user.TargetAlly = target; return true; }
/// <summary> /// Returns the damage of the provided skill used by the attacker against the target, performing all necessary damage calculations /// </summary> /// <param name="attacker"></param> /// <param name="target"></param> /// <param name="skill"></param> /// <returns></returns> public static int GetOneHit(Mob attacker, Mob target, Skill skill) { if (target == null) return 0; double damage = 0; int critDamage = 2000; bool crit = false; bool autoPhys = false; bool autoMag = false; if (skill.Components.ContainsKey("Autoattack")) { int highestStat = 0; bool physical = false; if (attacker.PhysicalPower >= highestStat) { highestStat = attacker.PhysicalPower; physical = true; } if (attacker.MagicPower > highestStat) { highestStat = attacker.MagicPower; physical = false; } if (physical == true) { //addStatMods += attacker.PhysicalPower; autoPhys = true; } else { //addStatMods += attacker.MagicPower; autoMag = true; } damage *= 100; } if (skill.Components.ContainsKey("DamageTypePhysical") || autoPhys) { int damageTypePhysical = 0; if (autoPhys) damageTypePhysical = 100; else damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); damage += attacker.PhysicalPower * damageTypePhysical; damage /= 100; damage *= 10000 / ((target.Armor * damageTypePhysical / 100) + 100); damage /= 100; if (Combat.Random.Next(0, 1000) <= attacker.PhysicalCritical * damageTypePhysical / 100) { crit = true; critDamage += attacker.PhysicalCriticalDamage * damageTypePhysical / 100; } } if (skill.Components.ContainsKey("DamageTypeMagical") || autoMag) { int damageTypeMagical = 0; if (autoMag) damageTypeMagical = 100; else damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); damage += attacker.MagicPower * damageTypeMagical; damage /= 100; damage *= 10000 / ((target.Resistance * damageTypeMagical / 100) + 100); damage /= 100; if (!skill.Components.ContainsKey("NoCritical")) { if (Combat.Random.Next(0, 1000) <= attacker.MagicalCritical * damageTypeMagical / 100) { crit = true; critDamage += attacker.MagicalCriticalDamage * damageTypeMagical; } } } if (crit) { damage *= critDamage; damage /= 1000; attacker.SendMessage("Crit! "); } if (skill.Components.ContainsKey("Randomize")) { int mod = Random.Next(100 - (int)skill.Components["Randomize"] / 2, 100 + (int)skill.Components["Randomize"] / 2); damage *= mod; damage /= 100; } if (damage <= 0) damage = 1; if (skill.Components.ContainsKey("DamageTypePhysical") || autoPhys) { int damageTypePhysical = 0; if (autoPhys) damageTypePhysical = 100; else damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); } if (skill.Components.ContainsKey("DamageTypeMagical") || autoMag) { int damageTypeMagical = 0; if (autoMag) damageTypeMagical = 100; else damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); } return Convert.ToInt32(damage); }
public static int GetHeal(Mob attacker, Mob target, Skill skill) { double heal = 0; int critHeal = 2000; bool crit = false; if (skill.Components.ContainsKey("DamageTypePhysical")) { int damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); heal += attacker.PhysicalPower * damageTypePhysical; heal /= 100; if (Combat.Random.Next(0, 1000) <= attacker.PhysicalCritical * damageTypePhysical / 100) { crit = true; critHeal += attacker.PhysicalCriticalDamage * damageTypePhysical / 100; } } if (skill.Components.ContainsKey("DamageTypeMagical")) { int damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); heal += attacker.MagicPower * damageTypeMagical; heal /= 100; if (!skill.Components.ContainsKey("NoCritical")) { if (Combat.Random.Next(0, 1000) <= attacker.MagicalCritical * damageTypeMagical / 100) { crit = true; critHeal += attacker.MagicalCriticalDamage * damageTypeMagical; } } } if (crit) { heal *= critHeal; heal /= 1000; attacker.SendMessage("Crit! "); } if (skill.Components.ContainsKey("Randomize")) { int mod = Random.Next(100 - (int)skill.Components["Randomize"] / 2, 100 + (int)skill.Components["Randomize"] / 2); heal *= mod; heal /= 100; } if (heal <= 0) heal = 1; if (skill.Components.ContainsKey("DamageTypePhysical")) { int damageTypePhysical = ((int)skill.Components["DamageTypePhysical"]); } if (skill.Components.ContainsKey("DamageTypeMagical")) { int damageTypeMagical = ((int)skill.Components["DamageTypeMagical"]); } return Convert.ToInt32(heal); }