public static BaseTalisman RandomTalisman() { var talisman = new BaseTalisman(BaseTalisman.GetRandomItemID()) { Summoner = BaseTalisman.GetRandomSummoner() }; if (talisman.Summoner.IsEmpty) { talisman.Removal = BaseTalisman.GetRandomRemoval(); if (talisman.Removal != TalismanRemoval.None) { talisman.MaxCharges = BaseTalisman.GetRandomCharges(); talisman.MaxChargeTime = 1200; } } else { talisman.MaxCharges = Utility.RandomMinMax(10, 50); talisman.MaxChargeTime = talisman.Summoner.IsItem ? 60 : 1800; } talisman.Blessed = BaseTalisman.GetRandomBlessed(); talisman.Slayer = BaseTalisman.GetRandomSlayer(); talisman.Protection = BaseTalisman.GetRandomProtection(); talisman.Killer = BaseTalisman.GetRandomKiller(); talisman.Skill = BaseTalisman.GetRandomSkill(); talisman.ExceptionalBonus = BaseTalisman.GetRandomExceptional(); talisman.SuccessBonus = BaseTalisman.GetRandomSuccessful(); talisman.Charges = talisman.MaxCharges; return(talisman); }
public GuaranteedSpellbookImprovementTalisman(int charges) : base(0x9E28) { Charges = charges; Skill = TalismanSkill.Inscription; SuccessBonus = BaseTalisman.GetRandomSuccessful(); ExceptionalBonus = BaseTalisman.GetRandomExceptional(); }
public MasterChefsApron() { Hue = 1990; while (_Bonus == 0) { _Bonus = BaseTalisman.GetRandomExceptional(); } }
private bool IsSpecialTalisman(BaseTalisman talisman) { // Talismans with durability if (m_CraftSystem is DefTinkering) { return(talisman is ManaPhasingOrb); } return(false); }
public double GetExceptionalChance(CraftSystem system, double chance, Mobile from) { if (m_ForceNonExceptional) { return 0.0; } double bonus = 0.0; if (from.Talisman is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)from.Talisman; if (talisman.Skill == system.MainSkill) { chance -= talisman.SuccessBonus / 100.0; bonus = talisman.ExceptionalBonus / 100.0; } } switch (system.ECA) { default: case CraftECA.ChanceMinusSixty: chance -= 0.6; break; case CraftECA.FiftyPercentChanceMinusTenPercent: chance = chance * 0.5 - 0.1; break; case CraftECA.ChanceMinusSixtyToFourtyFive: { double offset = 0.60 - ((from.Skills[system.MainSkill].Value - 95.0) * 0.03); if (offset < 0.45) { offset = 0.45; } else if (offset > 0.60) { offset = 0.60; } chance -= offset; break; } } if (chance > 0) { return chance + bonus; } return chance; }
public MasterCraftsmanTalisman(int charges, int itemID, TalismanSkill skill) : base(itemID) { Skill = skill; SuccessBonus = GetRandomSuccessful(); ExceptionalBonus = BaseTalisman.GetRandomExceptional(); Blessed = GetRandomBlessed(); _Type = charges; Charges = charges; }
public static void OnManaConsumed(Mobile m) { if (m_UnderEffect.ContainsKey(m)) { BaseTalisman talisman = m_UnderEffect[m]; talisman.Charges--; m_Cooldown.Add(m); Timer.DelayCall(Cooldown, () => m_Cooldown.Remove(m)); m_UnderEffect.Remove(m); } }
public double GetSuccessChance(Mobile from, Type typeRes, CraftSystem craftSystem, bool gainSkills, ref bool allRequiredSkills) { double minMainSkill = 0.0; double maxMainSkill = 0.0; double valMainSkill = 0.0; allRequiredSkills = true; for (int i = 0; i < m_arCraftSkill.Count; i++) { CraftSkill craftSkill = m_arCraftSkill.GetAt(i); double minSkill = craftSkill.MinSkill; double maxSkill = craftSkill.MaxSkill; double valSkill = from.Skills[craftSkill.SkillToMake].Value; if (valSkill < minSkill) allRequiredSkills = false; if (craftSkill.SkillToMake == craftSystem.MainSkill) { minMainSkill = minSkill; maxMainSkill = maxSkill; valMainSkill = valSkill; } if (gainSkills) // This is a passive check. Success chance is entirely dependant on the main skill from.CheckSkill(craftSkill.SkillToMake, minSkill, maxSkill); } double chance; if (allRequiredSkills) chance = craftSystem.GetChanceAtMin(this) + ((valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) * (1.0 - craftSystem.GetChanceAtMin(this))); else chance = 0.0; if (allRequiredSkills && from.Talisman is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)from.Talisman; if (talisman.Skill == craftSystem.MainSkill) chance += talisman.SuccessBonus / 100.0; } if (allRequiredSkills && valMainSkill == maxMainSkill) chance = 1.0; return chance; }
public static BaseTalisman RandomTalisman() { BaseTalisman talisman = new BaseTalisman(BaseTalisman.GetRandomItemID()); talisman.MaxCharges = BaseTalisman.GetRandomCharges(); talisman.Summoner = BaseTalisman.GetRandomSummoner(); if (talisman.Summoner.IsEmpty) { talisman.Removal = BaseTalisman.GetRandomRemoval(); if (talisman.Removal != TalismanRemoval.None) { talisman.MaxChargeTime = 1200; } else { talisman.MaxCharges = 0; } } else if (talisman.MaxCharges > 0) { if (talisman.Summoner.IsItem) { talisman.MaxChargeTime = 60; } else { talisman.MaxChargeTime = 1800; } } else { talisman.MaxChargeTime = 1800; } talisman.Blessed = BaseTalisman.GetRandomBlessed(); talisman.Slayer = BaseTalisman.GetRandomSlayer(); talisman.Protection = BaseTalisman.GetRandomProtection(); talisman.Killer = BaseTalisman.GetRandomKiller(); talisman.Skill = BaseTalisman.GetRandomSkill(); talisman.ExceptionalBonus = BaseTalisman.GetRandomExceptional(); talisman.SuccessBonus = BaseTalisman.GetRandomSuccessful(); talisman.Charges = talisman.MaxCharges; return(talisman); }
public static void OnUse(Mobile m, BaseTalisman talisman) { if (m_Cooldown.Contains(m)) { // You must wait a few seconds before attempting to phase mana again. m.SendLocalizedMessage(1116163); } else if (m_UnderEffect.ContainsKey(m)) { // You will no longer attempt to draw magical energy from the void. m.SendLocalizedMessage(1116165); m_UnderEffect.Remove(m); } else { // Your next use of magical energy will draw its power from the void. m.SendLocalizedMessage(1116164); m_UnderEffect.Add(m, talisman); } }
public RandomTalisman() : base(GetRandomItemID()) { Summoner = BaseTalisman.GetRandomSummoner(); if (Summoner.IsEmpty) { Removal = BaseTalisman.GetRandomRemoval(); if (Removal != TalismanRemoval.None) { MaxCharges = BaseTalisman.GetRandomCharges(); MaxChargeTime = 1200; } } else { MaxCharges = Utility.RandomMinMax(10, 50); if (Summoner.IsItem) { MaxChargeTime = 60; } else { MaxChargeTime = 1800; } } Blessed = BaseTalisman.GetRandomBlessed(); Slayer = BaseTalisman.GetRandomSlayer(); Protection = BaseTalisman.GetRandomProtection(); Killer = BaseTalisman.GetRandomKiller(); Skill = BaseTalisman.GetRandomSkill(); ExceptionalBonus = BaseTalisman.GetRandomExceptional(); SuccessBonus = BaseTalisman.GetRandomSuccessful(); Charges = MaxCharges; }
protected override void OnTarget(Mobile from, object targeted) { int number; if (!this.CheckDeed(from)) { return; } bool usingDeed = (this.m_Deed != null); bool toDelete = false; if (!AllowsRepair(targeted as Item, m_CraftSystem)) { from.SendLocalizedMessage(500426); // You can't repair that. return; } if (this.m_CraftSystem.CanCraft(from, this.m_Tool, targeted.GetType()) == 1044267) { number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's * } else if (this.m_CraftSystem is DefTinkering && targeted is Golem) { Golem g = (Golem)targeted; int damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { number = 500426; // You can't repair that. } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { double skillValue = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. //TODO: How does OSI handle this with deeds with golems? } else if (!from.CanBeginAction(typeof(Golem))) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } Container pack = from.Backpack; if (pack != null) { int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += v * 5; number = 1044279; // You repair the item. toDelete = true; from.BeginAction(typeof(Golem)); Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from); } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = this.m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (this.m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !this.IsSpecialWeapon(weapon)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (!Core.AOS && weapon.PoisonCharges != 0) { number = 1005012; // You cannot repair an item while a caustic substance is on it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (weapon.BlockRepair || weapon.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (this.CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken); } if (this.CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { number = 1044279; // You repair the item. this.m_CraftSystem.PlayCraftEffect(from); weapon.HitPoints = weapon.MaxHitPoints; //daat99 OWLTR start - tokens on repairs if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.CRAFT_GIVE_TOKENS)) { TokenSystem.GiveTokensToPlayer(from as PlayerMobile, Utility.Random(5)); } //daat99 OWLTR end - tokens on repairs } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] this.m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = this.m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (this.m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !this.IsSpecialArmor(armor)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (armor.BlockRepair || armor.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (this.CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints)) { armor.MaxHitPoints -= toWeaken; armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken); } if (this.CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints)) { number = 1044279; // You repair the item. this.m_CraftSystem.PlayCraftEffect(from); armor.HitPoints = armor.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] this.m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseJewel) { BaseJewel jewel = (BaseJewel)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!jewel.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (jewel.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (jewel.BlockRepair || jewel.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { jewel.MaxHitPoints -= toWeaken; jewel.HitPoints = Math.Max(0, jewel.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); jewel.HitPoints = jewel.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseClothing) { BaseClothing clothing = (BaseClothing)targeted; SkillName skill = this.m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (this.m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !this.IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask))) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (clothing.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (clothing.BlockRepair || clothing.NegativeAttributes.NoRepair > 0) // quick fix { number = 1044277; // That item cannot be repaired. } else { if (this.CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { clothing.MaxHitPoints -= toWeaken; clothing.HitPoints = Math.Max(0, clothing.HitPoints - toWeaken); } if (this.CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { number = 1044279; // You repair the item. this.m_CraftSystem.PlayCraftEffect(from); clothing.HitPoints = clothing.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] this.m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)targeted; SkillName skill = this.m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (talisman is IRepairable && ((IRepairable)talisman).RepairSystem != m_CraftSystem) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!talisman.IsChildOf(from.Backpack) && (!Core.ML || talisman.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (talisman.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (!talisman.CanRepair) // quick fix { number = 1044277; // That item cannot be repaired. } else { if (this.CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { talisman.MaxHitPoints -= toWeaken; talisman.HitPoints = Math.Max(0, talisman.HitPoints - toWeaken); } if (this.CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { number = 1044279; // You repair the item. this.m_CraftSystem.PlayCraftEffect(from); talisman.HitPoints = talisman.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] this.m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (!usingDeed && targeted is BlankScroll) { SkillName skill = this.m_CraftSystem.MainSkill; if (from.Skills[skill].Value >= 50.0) { ((BlankScroll)targeted).Consume(1); RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(this.m_CraftSystem), from.Skills[skill].Value, from); from.AddToBackpack(deed); number = 500442; // You create the item and put it in your backpack. } else { number = 1047005; // You must be at least apprentice level to create a repair service contract. } } else if (targeted is Item) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else { number = 500426; // You can't repair that. } if (!usingDeed) { CraftContext context = this.m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, this.m_CraftSystem, this.m_Tool, number)); } else { from.SendLocalizedMessage(number); if (toDelete) { this.m_Deed.Delete(); } } }
public static void AwardKarma(Mobile m, int offset, bool message) { #region Mondain's Legacy if (m.Talisman is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)m.Talisman; if (talisman.KarmaLoss > 0) { offset *= (1 + (int)(((double)talisman.KarmaLoss) / 100)); } else if (talisman.KarmaLoss < 0) { offset *= (1 - (int)(((double)-talisman.KarmaLoss) / 100)); } } #endregion #region Heritage Items int karmaLoss = AosAttributes.GetValue(m, AosAttribute.IncreasedKarmaLoss); if (karmaLoss != 0 && offset < 0) { offset -= (int)(offset * (karmaLoss / 100.0)); } #endregion if (offset > 0) { if (m is PlayerMobile && ((PlayerMobile)m).KarmaLocked) { return; } if (m.Karma >= MaxKarma) { return; } offset -= m.Karma / 100; if (offset < 0) { offset = 0; } } else if (offset < 0) { if (m.Karma <= MinKarma) { return; } offset -= m.Karma / 100; if (offset > 0) { offset = 0; } } if ((m.Karma + offset) > MaxKarma) { offset = MaxKarma - m.Karma; } else if ((m.Karma + offset) < MinKarma) { offset = MinKarma - m.Karma; } bool wasPositiveKarma = (m.Karma >= 0); m.Karma += offset; if (message) { if (offset > 40) { m.SendMessage("Voce ganhou muuuuito karma"); // You have gained a lot of karma. } else if (offset > 20) { m.SendMessage("Voce ganhou uma boa quantia de karma"); // You have gained a good amount of karma. } else if (offset > 10) { m.SendMessage("Voce ganhou karma"); // You have gained some karma. } else if (offset > 0) { m.SendMessage("Voce ganhou um pouquinho de karma"); // You have gained a little karma. } else if (offset < -40) { m.SendMessage("Voce perdeu muuuuuito karma"); // You have lost a lot of karma. } else if (offset < -20) { m.SendMessage("Voce perdeu uma boa quantidade de karma"); // You have lost a good amount of karma. } else if (offset < -10) { m.SendMessage("Voce perdeu karma"); // You have lost some karma. } else if (offset < 0) { m.SendMessage("Voce perdeu um pouquinho de karma"); // You have lost a little karma. } } if (!Core.AOS && wasPositiveKarma && m.Karma < 0 && m is PlayerMobile && !((PlayerMobile)m).KarmaLocked) { ((PlayerMobile)m).KarmaLocked = true; m.SendLocalizedMessage(1042511, "", 0x22); // Karma is locked. A mantra spoken at a shrine will unlock it again. } }
protected override void OnTarget(Mobile from, object targeted) { bool usingDeed = (m_Deed != null); bool toDelete = false; int number; if (m_CraftSystem is DefTinkering && targeted is IRepairableMobile) { if (TryRepairMobile(from, (IRepairableMobile)targeted, usingDeed, out toDelete)) { number = 1044279; // You repair the item. } else { number = 500426; // You can't repair that. } } else if (targeted is Item) { if (from.InRange(((Item)targeted).GetWorldLocation(), 2)) { if (!CheckDeed(from)) { return; } if (!AllowsRepair(targeted, m_CraftSystem)) { from.SendLocalizedMessage(500426); // You can't repair that. return; } if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267) { number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's * } else if (!usingDeed && m_CraftSystem is DefTinkering && targeted is BrokenAutomatonHead) { if (((BrokenAutomatonHead)targeted).TryRepair(from)) { number = 1044279; // You repair the item. } else { number = 1044280; // You fail to repair the item. } } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !CheckSpecial(weapon)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (!Core.AOS && weapon.PoisonCharges != 0) { number = 1005012; // You cannot repair an item while a caustic substance is on it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (weapon.BlockRepair || weapon.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.HitPoints = weapon.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !CheckSpecial(armor)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (armor.BlockRepair || armor.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints)) { armor.MaxHitPoints -= toWeaken; armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.HitPoints = armor.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseJewel) { BaseJewel jewel = (BaseJewel)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null && !CheckSpecial(jewel)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!jewel.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (jewel.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (jewel.BlockRepair || jewel.NegativeAttributes.NoRepair > 0) { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { jewel.MaxHitPoints -= toWeaken; jewel.HitPoints = Math.Max(0, jewel.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); jewel.HitPoints = jewel.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseClothing) { BaseClothing clothing = (BaseClothing)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !CheckSpecial(clothing)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (clothing.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (clothing.BlockRepair || clothing.NegativeAttributes.NoRepair > 0) // quick fix { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { clothing.MaxHitPoints -= toWeaken; clothing.HitPoints = Math.Max(0, clothing.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); clothing.HitPoints = clothing.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (targeted is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 0; if (Core.AOS) { toWeaken = 1; } else if (skill != SkillName.Tailoring) { double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) { toWeaken = 1; } else if (skillLevel >= 70.0) { toWeaken = 2; } else { toWeaken = 3; } } if (!(m_CraftSystem is DefTinkering)) { number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } else if (!talisman.IsChildOf(from.Backpack) && (!Core.ML || talisman.Parent != from)) { number = 1044275; // The item must be in your backpack to repair it. } else if (talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (talisman.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else if (!talisman.CanRepair) // quick fix { number = 1044277; // That item cannot be repaired. } else { if (CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { talisman.MaxHitPoints -= toWeaken; talisman.HitPoints = Math.Max(0, talisman.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); talisman.HitPoints = talisman.MaxHitPoints; } else { number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } toDelete = true; } } else if (!usingDeed && targeted is BlankScroll) { SkillName skill = m_CraftSystem.MainSkill; if (from.Skills[skill].Value >= 50.0) { ((BlankScroll)targeted).Consume(1); RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from); from.AddToBackpack(deed); number = 500442; // You create the item and put it in your backpack. } else { number = 1047005; // You must be at least apprentice level to create a repair service contract. } } else { number = 500426; // You can't repair that. } } else { number = 500446; // That is too far away. } } else { number = 500426; // You can't repair that. } if (!usingDeed) { CraftContext context = m_CraftSystem.GetContext(from); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); } else { from.SendLocalizedMessage(number); if (toDelete) { m_Deed.Delete(); } } }
public static int Damage(bool directDamage, Mobile m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, int chao, bool keepAlive) { if (m == null || m.Deleted || !m.Alive || damage <= 0) { return(0); } if (phys == 0 && fire == 100 && cold == 0 && pois == 0 && nrgy == 0) { Mobiles.MeerMage.StopEffect(m, true); } Fix(ref phys); Fix(ref fire); Fix(ref cold); Fix(ref pois); Fix(ref nrgy); Fix(ref chao); switch (Utility.RandomMinMax(1, 5)) { case 1: phys += chao; break; case 2: fire += chao; break; case 3: cold += chao; break; case 4: pois += chao; break; case 5: nrgy += chao; break; } chao = 0; int resPhys = m.PhysicalResistance; int resFire = m.FireResistance; int resCold = m.ColdResistance; int resPois = m.PoisonResistance; int resNrgy = m.EnergyResistance; if (m_ArmorIgnore) { resPhys = fire = cold = pois = nrgy = 0; phys = 100; } if (m_ArmorPierce) { double delta = 0.6; // is this correct? resPhys -= (int)(delta * resPhys); } int totalDamage; totalDamage = damage * phys * (100 - resPhys); totalDamage += damage * fire * (100 - resFire); totalDamage += damage * cold * (100 - resCold); totalDamage += damage * pois * (100 - resPois); totalDamage += damage * nrgy * (100 - resNrgy); totalDamage /= 10000; if (totalDamage < 1) { totalDamage = 1; } int absorbed; #region Damage Eater int dmgEater = Math.Min((int)AbsorptionAttributes.GetValue(m, AbsorptionAttribute.DamageEater), 18); int physEater = dmgEater; int fireEater = dmgEater; int coldEater = dmgEater; int poisEater = dmgEater; int nrgyEater = dmgEater; if (!m_ArmorIgnore) { physEater = Math.Min(Math.Max(AbsorptionAttributes.GetValue(m, AbsorptionAttribute.KineticEater), dmgEater), 30); fireEater = Math.Min(Math.Max(AbsorptionAttributes.GetValue(m, AbsorptionAttribute.FireEater), dmgEater), 30); coldEater = Math.Min(Math.Max(AbsorptionAttributes.GetValue(m, AbsorptionAttribute.ColdEater), dmgEater), 30); poisEater = Math.Min(Math.Max(AbsorptionAttributes.GetValue(m, AbsorptionAttribute.PoisonEater), dmgEater), 30); nrgyEater = Math.Min(Math.Max(AbsorptionAttributes.GetValue(m, AbsorptionAttribute.EnergyEater), dmgEater), 30); } absorbed = damage * phys * (100 - resPhys) * physEater; absorbed += damage * fire * (100 - resFire) * fireEater; absorbed += damage * cold * (100 - resCold) * coldEater; absorbed += damage * pois * (100 - resPois) * poisEater; absorbed += damage * nrgy * (100 - resNrgy) * nrgyEater; absorbed /= 1000000; if (m is PlayerMobile) { ((PlayerMobile)m).EatDamage(absorbed); } #endregion if (!m_ArmorIgnore) { #region Resonance if (m.Spell is Spell && m.Spell.IsCasting) { for (int i = 0; i < 5; i++) { double chance = 0.0; switch (i) { case 0: chance = (double)AbsorptionAttributes.GetValue(m, AbsorptionAttribute.KineticResonance) / phys; break; case 1: chance = (double)AbsorptionAttributes.GetValue(m, AbsorptionAttribute.FireResonance) / fire; break; case 2: chance = (double)AbsorptionAttributes.GetValue(m, AbsorptionAttribute.ColdResonance) / cold; break; case 3: chance = (double)AbsorptionAttributes.GetValue(m, AbsorptionAttribute.PoisonResonance) / pois; break; case 4: chance = (double)AbsorptionAttributes.GetValue(m, AbsorptionAttribute.EnergyResonance) / nrgy; break; } if (chance > Utility.RandomDouble()) { ((Spell)m.Spell).Resonates = true; break; } } } #endregion } #region Dragon Barding if ((from == null || !from.IsPlayer) && m.IsPlayer && m.Mount is SwampDragon) { SwampDragon pet = m.Mount as SwampDragon; if (pet != null && pet.HasBarding) { int percent = (pet.BardingExceptional ? 20 : 10); absorbed = Scale(totalDamage, percent); totalDamage -= absorbed; if (!(pet is ParoxysmusSwampDragon)) { pet.BardingHP -= absorbed; } if (pet.BardingHP < 0) { pet.HasBarding = false; pet.BardingHP = 0; m.SendLocalizedMessage(1053031); // Your dragon's barding has been destroyed! } } } #endregion if (keepAlive && totalDamage > m.Hits) { totalDamage = m.Hits; } if (from != null) { int reflectPhys = m.GetMagicalAttribute(MagicalAttribute.ReflectPhysical); if (reflectPhys != 0) { if (from is ExodusMinion && ((ExodusMinion)from).FieldActive || from is ExodusOverseer && ((ExodusOverseer)from).FieldActive) { from.FixedParticles(0x376A, 20, 10, 0x2530, EffectLayer.Waist); from.PlaySound(0x2F4); m.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier"); } else { int rpd_damage = Scale((damage * phys * (100 - from.PhysicalResistance)) / 10000, reflectPhys); if (m is PlayerMobile && from is PlayerMobile && directDamage) { rpd_damage = Math.Min(rpd_damage, 35); } from.Damage(rpd_damage, m); } } } if (from is BaseCreature) { Mobile master = ((BaseCreature)from).ControlMaster; if (master != null) { master.RevealingAction(); } #region Talismans BaseTalisman talis = BaseTalisman.GetTalisman(m); if (talis != null && talis.ProtectionTalis != NPC_Name.None && talis.ProtectionValue > 0) { if (ProtectionKillerEntry.IsProtectionKiller(talis.ProtectionTalis, from)) { totalDamage = totalDamage - ((totalDamage * talis.ProtectionValue) / 100); } } #endregion } if (from != null) { Item cloak = from.FindItemOnLayer(Layer.Cloak); Item twohanded = from.FindItemOnLayer(Layer.TwoHanded); if (directDamage && cloak is BaseQuiver && twohanded is BaseRanged) { BaseQuiver quiver = cloak as BaseQuiver; totalDamage += (int)(totalDamage * quiver.DamageModifier * 0.01); } } if (m is PlayerMobile && from is PlayerMobile && directDamage) { totalDamage = Math.Min(totalDamage, 35); } /* TODO: El efecto del Attunement debería ir despues de aplicar el Blood Oath. * Según parece, en OSI los Necro-Arcanists lo usan mucho en PvP, de manera que * el daño recibido se refleja al atacante por Blood Oath, pero luego es * absorbido por el Attunement en el defensor. */ if (directDamage) { Spells.Spellweaving.AttunementSpell.TryAbsorb(m, ref totalDamage); } if (from != null) { SpellHelper.DoLeech(totalDamage, from, m); } m.Damage(totalDamage, from); return(totalDamage); }
public static int Damage(Mobile m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct, bool keepAlive, bool archer) { if (m == null || m.Deleted || !m.Alive || damage <= 0) { return(0); } if (phys == 0 && fire == 100 && cold == 0 && pois == 0 && nrgy == 0) { Mobiles.MeerMage.StopEffect(m, true); } if (!Core.AOS) { m.Damage(damage, from); return(damage); } #region Mondain's Legacy BaseTalisman talisman = m.Talisman as BaseTalisman; if (talisman != null && talisman.Protection != null) { damage = talisman.Protection.ScaleDamage(from, damage); } #endregion Fix(ref phys); Fix(ref fire); Fix(ref cold); Fix(ref pois); Fix(ref nrgy); Fix(ref chaos); Fix(ref direct); if (Core.ML && chaos > 0) { switch (Utility.Random(5)) { case 0: phys += chaos; break; case 1: fire += chaos; break; case 2: cold += chaos; break; case 3: pois += chaos; break; case 4: nrgy += chaos; break; } } BaseQuiver quiver = null; if (archer && from != null) { quiver = from.FindItemOnLayer(Layer.Cloak) as BaseQuiver; } int totalDamage; if (!ignoreArmor) { // Armor Ignore on OSI ignores all defenses, not just physical. int resPhys = m.PhysicalResistance; int resFire = m.FireResistance; int resCold = m.ColdResistance; int resPois = m.PoisonResistance; int resNrgy = m.EnergyResistance; totalDamage = damage * phys * (100 - resPhys); totalDamage += damage * fire * (100 - resFire); totalDamage += damage * cold * (100 - resCold); totalDamage += damage * pois * (100 - resPois); totalDamage += damage * nrgy * (100 - resNrgy); totalDamage /= 10000; if (Core.ML) { totalDamage += damage * direct / 100; if (quiver != null) { totalDamage += totalDamage * quiver.DamageIncrease / 100; } } if (totalDamage < 1) { totalDamage = 1; } } else if (Core.ML && m is PlayerMobile && from is PlayerMobile) { if (quiver != null) { damage += damage * quiver.DamageIncrease / 100; } totalDamage = Math.Min(damage, 35); //Direct Damage cap of 35 } else { totalDamage = damage; if (Core.ML && quiver != null) { totalDamage += totalDamage * quiver.DamageIncrease / 100; } } #region Dragon Barding if ((from == null || !from.Player) && m.Player && m.Mount is SwampDragon) { SwampDragon pet = m.Mount as SwampDragon; if (pet != null && pet.HasBarding) { int percent = (pet.BardingExceptional ? 20 : 10); int absorbed = Scale(totalDamage, percent); totalDamage -= absorbed; // Mondain's Legacy mod if (!(pet is ParoxysmusSwampDragon)) { pet.BardingHP -= absorbed; } if (pet.BardingHP < 0) { pet.HasBarding = false; pet.BardingHP = 0; m.SendLocalizedMessage(1053031); // Your dragon's barding has been destroyed! } } } #endregion if (keepAlive && totalDamage > m.Hits) { totalDamage = m.Hits; } if (from != null && !from.Deleted && from.Alive) { int reflectPhys = AosAttributes.GetValue(m, AosAttribute.ReflectPhysical); if (reflectPhys != 0) { if (from is ExodusMinion && ((ExodusMinion)from).FieldActive || from is ExodusOverseer && ((ExodusOverseer)from).FieldActive) { from.FixedParticles(0x376A, 20, 10, 0x2530, EffectLayer.Waist); from.PlaySound(0x2F4); m.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier"); } else { from.Damage(Scale((damage * phys * (100 - (ignoreArmor ? 0 : m.PhysicalResistance))) / 10000, reflectPhys), m); } } } m.Damage(totalDamage, from); return(totalDamage); }
public static void AwardKarma(Mobile m, int offset, bool message) { int karma = m.Karma; if (m.Talisman is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)m.Talisman; if (talisman.KarmaLoss > 0) { offset *= (1 + (int)(((double)talisman.KarmaLoss) / 100)); } else if (talisman.KarmaLoss < 0) { offset *= (1 - (int)(((double)-talisman.KarmaLoss) / 100)); } } int karmaLoss = AosAttributes.GetValue(m, AosAttribute.IncreasedKarmaLoss); if (karmaLoss != 0 && offset < 0) { offset -= (int)(offset * (karmaLoss / 100.0)); } if (offset > 0) { if (m is PlayerMobile && ((PlayerMobile)m).KarmaLocked) { return; } if (karma >= MaxKarma) { return; } offset -= karma / 100; if (offset < 0) { offset = 0; } } else if (offset < 0) { if (karma <= MinKarma) { return; } offset -= karma / 100; if (offset > 0) { offset = 0; } } if ((karma + offset) > MaxKarma) { offset = MaxKarma - karma; } else if ((karma + offset) < MinKarma) { offset = MinKarma - karma; } m.Karma += offset; if (message) { if (offset > 40) { m.SendLocalizedMessage(1019062); // You have gained a lot of karma. } else if (offset > 20) { m.SendLocalizedMessage(1019061); // You have gained a good amount of karma. } else if (offset > 10) { m.SendLocalizedMessage(1019060); // You have gained some karma. } else if (offset > 0) { m.SendLocalizedMessage(1019059); // You have gained a little karma. } else if (offset < -40) { m.SendLocalizedMessage(1019066); // You have lost a lot of karma. } else if (offset < -20) { m.SendLocalizedMessage(1019065); // You have lost a good amount of karma. } else if (offset < -10) { m.SendLocalizedMessage(1019064); // You have lost some karma. } else if (offset < 0) { m.SendLocalizedMessage(1019063); // You have lost a little karma. } } }
public static void AwardKarma(Mobile m, int offset, bool message) { var karma = m.Karma; if (m.Talisman is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)m.Talisman; if (talisman.KarmaLoss > 0) { offset *= (1 + (int)(((double)talisman.KarmaLoss) / 100)); } else if (talisman.KarmaLoss < 0) { offset *= (1 - (int)(((double)-talisman.KarmaLoss) / 100)); } } int karmaLoss = AosAttributes.GetValue(m, AosAttribute.IncreasedKarmaLoss); if (karmaLoss != 0 && offset < 0) { offset -= (int)(offset * (karmaLoss / 100.0)); } if (offset > 0) { if (m is PlayerMobile && ((PlayerMobile)m).KarmaLocked) { return; } if (karma >= MaxKarma) { return; } offset -= karma / 100; if (offset < 0) { offset = 0; } } else if (offset < 0) { if (karma <= MinKarma) { return; } offset -= karma / 100; if (offset > 0) { offset = 0; } } if ((karma + offset) > MaxKarma) { offset = MaxKarma - karma; } else if ((karma + offset) < MinKarma) { offset = MinKarma - karma; } bool wasPositiveKarma = (karma >= 0); m.Karma += offset; if (message) { if (offset > 40) { m.SendLocalizedMessage(1019062); // You have gained a lot of karma. } else if (offset > 20) { m.SendLocalizedMessage(1019061); // You have gained a good amount of karma. } else if (offset > 10) { m.SendLocalizedMessage(1019060); // You have gained some karma. } else if (offset > 0) { m.SendLocalizedMessage(1019059); // You have gained a little karma. } else if (offset < -40) { m.SendLocalizedMessage(1019066); // You have lost a lot of karma. } else if (offset < -20) { m.SendLocalizedMessage(1019065); // You have lost a good amount of karma. } else if (offset < -10) { m.SendLocalizedMessage(1019064); // You have lost some karma. } else if (offset < 0) { m.SendLocalizedMessage(1019063); // You have lost a little karma. } } if (!Core.AOS && wasPositiveKarma && m.Karma < 0 && m is PlayerMobile && !((PlayerMobile)m).KarmaLocked) { ((PlayerMobile)m).KarmaLocked = true; m.SendLocalizedMessage(1042511, "", 0x22); // Karma is locked. A mantra spoken at a shrine will unlock it again. } }
protected override void OnTarget(Mobile from, object targeted) { int number; if (m_CraftSystem is DefBlacksmithy) { bool anvil, forge; DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge); if (anvil && forge) { // You must be near a forge and and anvil to repair items. number = 1044282; } } if (m_CraftSystem is DefTinkering && targeted is BaseCreature && ((BaseCreature)targeted).IsGolem) { BaseCreature g = (BaseCreature)targeted; int damage = g.HitsMax - g.Hits; if (g.IsDeadBondedPet) { number = 500426; // You can't repair that. } else if (damage <= 0) { number = 500423; // That is already in full repair. } else { double skillValue = from.Skills[SkillName.Tinkering].Value; if (skillValue < 60.0) { number = 1044153; // You don't have the required skills to attempt this item. } else if (!from.CanBeginAction(typeof(Golem))) { number = 501789; // You must wait before trying again. } else { if (damage > (int)(skillValue * 0.3)) { damage = (int)(skillValue * 0.3); } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) { damage /= 2; } Container pack = from.Backpack; if (pack != null) { int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5); if (v > 0) { g.Hits += v * 5; number = 1044279; // You repair the item. from.BeginAction(typeof(Golem)); Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from); if (m_Contract != null) { m_Contract.Delete(); } } else { number = 1044037; // You do not have sufficient metal to make that. } } else { number = 1044037; // You do not have sufficient metal to make that. } } } } else if (targeted is IFactionArtifact) { // That item cannot be repaired number = 1044277; } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon)) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // You cannot repair that using this type of tool. number = 1061139; } } else if (!weapon.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (weapon.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { weapon.MaxHitPoints -= toWeaken; weapon.HitPoints = Math.Max(0, weapon.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); weapon.HitPoints = weapon.MaxHitPoints; } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } else if (targeted is BaseArmor) { BaseArmor armor = (BaseArmor)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !IsSpecialArmor(armor)) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // You cannot repair that using this type of tool. number = 1061139; } } else if (!armor.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (armor.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints)) { armor.MaxHitPoints -= toWeaken; armor.HitPoints = Math.Max(0, armor.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); armor.HitPoints = armor.MaxHitPoints; } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } else if (targeted is BaseClothing) { BaseClothing clothing = (BaseClothing)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing)) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // That item cannot be repaired number = 1044277; } } else if (!clothing.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (clothing.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { clothing.MaxHitPoints -= toWeaken; clothing.HitPoints = Math.Max(0, clothing.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); clothing.HitPoints = clothing.MaxHitPoints; } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } else if (targeted is BaseJewel) { BaseJewel jewel = (BaseJewel)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null && !(jewel is SilverBracelet || jewel is SilverRing)) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // That item cannot be repaired number = 1044277; } } else if (!jewel.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (!jewel.CanLoseDurability || jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (jewel.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { jewel.MaxHitPoints -= toWeaken; jewel.HitPoints = Math.Max(0, jewel.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); jewel.HitPoints = jewel.MaxHitPoints; } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } else if (targeted is BaseTalisman) { BaseTalisman talisman = (BaseTalisman)targeted; SkillName skill = m_CraftSystem.MainSkill; int toWeaken = 1; if (!IsSpecialTalisman(talisman)) { if (m_Contract != null) { // You cannot repair that item with this type of repair contract. number = 1061136; } else { // That item cannot be repaired number = 1044277; } } else if (!talisman.IsChildOf(from.Backpack)) { number = 1044275; // The item must be in your backpack to repair it. } else if (!talisman.CanLoseDurability || talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints) { number = 1044281; // That item is in full repair } else if (talisman.MaxHitPoints <= toWeaken) { number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again. } else { if (CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { talisman.MaxHitPoints -= toWeaken; talisman.HitPoints = Math.Max(0, talisman.HitPoints - toWeaken); } if (CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints)) { number = 1044279; // You repair the item. m_CraftSystem.PlayCraftEffect(from); talisman.HitPoints = talisman.MaxHitPoints; } else { if (m_Contract != null) { // You fail to repair the item and the repair contract is destroyed. number = 1061137; } else { // You fail to repair the item. number = 1044280; } m_CraftSystem.PlayCraftEffect(from); } if (m_Contract != null) { m_Contract.Delete(); } } } else if (targeted is Item) { number = 1044283; // You cannot repair that. SkillName skill = m_CraftSystem.MainSkill; double value = from.Skills[skill].Value; if (targeted is BlankScroll) { Item contract = null; if (value < 50.0) { // You must be at least apprentice level to create a repair service contract. number = 1047005; } else { if (skill == SkillName.Blacksmith) { contract = new RepairContract(ContractType.Blacksmith, value, from.Name); } else if (skill == SkillName.Carpentry) { contract = new RepairContract(ContractType.Carpenter, value, from.Name); } else if (skill == SkillName.Fletching) { contract = new RepairContract(ContractType.Fletcher, value, from.Name); } else if (skill == SkillName.Tailoring) { contract = new RepairContract(ContractType.Tailor, value, from.Name); } else if (skill == SkillName.Tinkering) { contract = new RepairContract(ContractType.Tinker, value, from.Name); } } if (contract != null) { from.AddToBackpack(contract); number = 1044154; // You create the item. BlankScroll scroll = targeted as BlankScroll; if (scroll.Amount >= 2) { scroll.Amount -= 1; } else { scroll.Delete(); } } } } else { number = 500426; // You can't repair that. } if (m_Tool != null) { //CraftContext context = m_CraftSystem.GetContext( from ); from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number)); } else { from.SendLocalizedMessage(number); } }