public override void OnSingleClick(Mobile from) { LabelTo(from, m_Commodity == null ? "Commodity deed" : "Filled commodity deed"); if (m_Commodity != null && m_Commodity is ICommodity) { if (string.IsNullOrEmpty(m_Commodity.Name)) { LabelTo(from, m_Commodity.Amount + " " + CliLoc.LocToString(m_Commodity.LabelNumber) + (m_Commodity.Amount != 1 ? "s" : "")); } else { LabelTo(from, m_Commodity.Amount + " " + m_Commodity.Name + (m_Commodity.Amount != 1 ? "s" : "")); } } /* * * from.Send(new MessageLocalizedAffix( * Serial, * ItemID, * MessageType.Label, * 0x3B2, * 3, * (m_Commodity.Name == null) ? ((ICommodity) m_Commodity).DescriptionNumber : 0, * (m_Commodity.Name != null) ? m_Commodity.Name : null, * AffixType.Append, * String.Format(": {0}", m_Commodity.Amount), * null) * ); * }*/ }
public override void OnSingleClick(Mobile from) { if (m_Completed) { LabelTo(from, string.Format("Treasure map completed by {0}", m_CompletedBy != null ? m_CompletedBy.Name : "someone")); //from.Send( new MessageLocalizedAffix( Serial, ItemID, MessageType.Label, 0x3B2, 3, 1048030, "", AffixType.Append, String.Format( " completed by {0}", m_CompletedBy == null ? "someone" : m_CompletedBy.Name ), "" ) ); } else if (m_Decoder != null) { if (m_Level == 6) { LabelTo(from, 1063453); } else { LabelTo(from, 1041516 + m_Level); } } else { /*if ( m_Level == 6 ) * LabelTo( from, 1041522, String.Format( "#{0}\t \t#{1}", 1063452, m_Map == Map.Felucca ? 1041502 : 1041503 ) ); * else * LabelTo( from, 1041522, String.Format( "#{0}\t \t#{1}", 1041510 + m_Level, m_Map == Map.Felucca ? 1041502 : 1041503 ) );*/ LabelTo(from, "{0} {1}", CliLoc.LocToString(m_Level == 6 ? 1063452 : 1041510 + m_Level), CliLoc.LocToString(m_Map == Map.Felucca ? 1041502 : 1041503)); } }
public static string GenerateName(SkillMod mod, string item) { var name = ""; if (mod.Value <= 1.0) { name = "Lighter "; } else if (mod.Value <= 2.0) { name = "Light "; } else if (mod.Value <= 3.0) { name = ""; } else if (mod.Value <= 4.0) { name = "Great "; } else if (mod.Value <= 5.0) { name = "Greater "; } name += item + " of " + CliLoc.LocToString(1042347 + (int)mod.Skill); return(name); }
public ItemListEntry[] CreateGroupList() { CraftGroupCol craftGroupCol = CurrentCraftSystem.CraftGroups; List <ItemListEntry> toReturn = new List <ItemListEntry>(); int hue = 0; if (SelectedResourceIndex > 0) { hue = ResourceInfoList[CurrentCraftSystem.CraftSubRes.GetAt(SelectedResourceIndex)].Hue; } if (hue > 1) { --hue; } for (int i = 0; i < craftGroupCol.Count; i++) { int itemID; CraftGroup craftGroup = craftGroupCol.GetAt(i); if (craftGroup.CraftItems.Count >= 1) { itemID = CraftItem.ItemIDOf(craftGroup.CraftItems.GetAt(0).ItemType); } else { itemID = 5360; //Deed ID } if (craftGroup.NameNumber > 0) { ItemListEntry ile = new ItemListEntry(CliLoc.LocToString(craftGroup.NameNumber), itemID, hue); if (!FilterIndex(i)) { toReturn.Add(ile); } localGroupIndexList.Add(ile, i); } else { ItemListEntry ile = new ItemListEntry(craftGroup.NameString, itemID, hue); if (!FilterIndex(i)) { toReturn.Add(ile); } localGroupIndexList.Add(ile, i); } } toReturn.AddRange(AddSpecialGroups()); return(toReturn.ToArray()); }
public string GetName() { if (m_LocName != null) { return(m_LocName); } if (m_Num > 0) { return(CliLoc.LocToString(m_Num)); } return("Name error"); }
public ItemListEntry[] CreateResList() { CraftSubResCol res = CurrentCraftSystem.CraftSubRes; List <ItemListEntry> toReturn = new List <ItemListEntry>(); CraftSubRes subResource; if (CurrentCraftSystem.CraftSubRes.Init && CurrentCraftSystem.CraftSubRes.Count >= 1) { for (int i = 0; i < res.Count; ++i) { subResource = res.GetAt(i); int hue = ResourceInfoList[subResource].Hue; if (hue > 1) { hue--; } if (subResource.NameNumber > 0) { toReturn.Add(new ItemListEntry(CliLoc.LocToString(subResource.NameNumber), ResourceInfoList[subResource].ItemID, hue)); } else { toReturn.Add(new ItemListEntry(subResource.NameString, ResourceInfoList[subResource].ItemID, hue)); } } } if (CurrentCraftSystem.CraftSubRes2.Init) { res = CurrentCraftSystem.CraftSubRes2; for (int i = 0; i < res.Count; ++i) { subResource = res.GetAt(i); if (subResource.NameNumber > 0) { toReturn.Add(new ItemListEntry(CliLoc.LocToString(subResource.NameNumber), ResourceInfoList[subResource].ItemID, ResourceInfoList[subResource].Hue)); } else { toReturn.Add(new ItemListEntry(subResource.NameString, ResourceInfoList[subResource].ItemID, ResourceInfoList[subResource].Hue)); } } } return(toReturn.ToArray()); }
public override void OnSingleClick(Mobile from) { if (!string.IsNullOrEmpty(m_Description)) { LabelTo(from, m_Description); } if (m_Crafter != null) { LabelTo(from, "{0} crafted by {1}", CliLoc.LocToString(LabelNumber), m_Crafter.Name); } else { base.OnSingleClick(from); } }
//master constructor public SeedListEntry(Item item) : base(item) { Seed seed = (Seed)item; _PlantType = seed.PlantType; _PlantHue = seed.PlantHue; _ShowType = seed.ShowType; //TODO: find a way to using the PlantTypeInfo cliloc values PlantHueInfo hueInfo = PlantHueInfo.GetInfo(seed.PlantHue); PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(seed.PlantType); _Name = CliLoc.LocToString(hueInfo.IsBright() ? 1061918 : 1061917, String.Concat("#", hueInfo.Name.ToString(), "\t#", typeInfo.Name.ToString())); // [bright] ~1_COLOR~ ~2_TYPE~ seed //_PlantType.ToString(); }
public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) { BaseWeapon w = BaseWeapon.CreateRandomWeapon(); while (w is BaseRanged) { w.Delete(); w = BaseWeapon.CreateRandomWeapon(); } w.Identified = true; w.DamageLevel = (WeaponDamageLevel)Utility.Random(6); w.Name = CliLoc.LocToString(w.LabelNumber) + " (gift)"; int roll = Utility.Random(99); if (roll < 51) { w.AccuracyLevel = WeaponAccuracyLevel.Accurate; } else if (roll < 77) { w.AccuracyLevel = WeaponAccuracyLevel.Surpassingly; } else if (roll < 90) { w.AccuracyLevel = WeaponAccuracyLevel.Eminently; } else if (roll < 97) { w.AccuracyLevel = WeaponAccuracyLevel.Exceedingly; } else if (roll < 100) { w.AccuracyLevel = WeaponAccuracyLevel.Supremely; } from.AddToBackpack(w); Delete(); } else { from.SendAsciiMessage("That must be in your backpack for you to use it."); } }
protected override void OnTick() { BaseCreature targ = (BaseCreature)m_Targeted; if (m_From.CheckTargetSkill(SkillName.Anatomy, targ, 0, 100)) { m_From.CloseGump(typeof(AnatomyGump)); m_From.SendGump(new AnatomyGump(targ)); } else { targ.PrivateOverheadMessage(MessageType.Regular, 906, true, CliLoc.LocToString(1042666), m_From.NetState); // You can not quite get a sense of their physical characteristics. } if (m_From is PlayerMobile) { ((PlayerMobile)m_From).EndPlayerAction(); } }
protected override void OnTarget(Mobile from, object targeted) { bool releaseLock = true; SpellHelper.Turn(from, targeted); if (targeted is Mobile) { releaseLock = false; new InternalTimer(from, (Mobile)targeted).Start(); } else if (targeted is Item) { from.SendAsciiMessage(CliLoc.LocToString(500908)); // It looks smarter than a rock, but dumber than a piece of wood. } if (releaseLock && from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } }
public override int OnHit(BaseWeapon weapon, int damage) { Mobile owner = Parent as Mobile; if (owner == null) { return(damage); } double chance = (owner.Skills[SkillName.Parry].Value) / (15 / ((owner.Skills[SkillName.Parry].Value) / 100)); chance /= 100; if (chance < 0.005) { chance = 0.005; } //gains owner.CheckSkill(SkillName.Parry, chance); if (Utility.RandomDouble() <= chance) { damage = 0; owner.SendAsciiMessage("You parry the blow."); } if (Durability != ArmorDurabilityLevel.Indestructible && 3 > Utility.Random(100)) // 3%(1.5 due to code below) chance to lower durability if not invul { int wear = Utility.Random(2); if (wear > 0) { if (HitPoints > wear) { HitPoints -= wear; if (Parent is Mobile && HitPoints * 6 < MaxHitPoints) //Display message at 1/6th of the hp { ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); // Your equipment is severely damaged. } } else { if (Parent is Mobile) { ((Mobile)Parent).PublicOverheadMessage(MessageType.Emote, 0x22, true, string.Format("*{0}'s {1} is destroyed", ((Mobile)Parent).Name, string.IsNullOrEmpty(Name) ? CliLoc.LocToString(LabelNumber) : Name)); } Delete(); } } } return(damage); }
protected override void OnTarget(Mobile from, object targeted) { bool releaseLock = true; if (targeted is Dragon || targeted is Drake || targeted is AncientWyrm || targeted is SwampDragon || targeted is Ridgeback || targeted is WhiteWyrm || targeted is Wyvern || targeted is Daemon) { if (from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } from.SendAsciiMessage("You can't tame that!"); return; } if (targeted is GoodMustang) { if (from.Karma < 7499) { if (from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } from.SendAsciiMessage("You are not righteous enough to tame this animal"); return; } } if (targeted is EvilMustang) { if (from.Karma > -7499) { if (from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } from.SendAsciiMessage("You are not wicked enough to tame this animal"); return; } } if (targeted is Mobile) { if (targeted is BaseCreature) { BaseCreature creature = (BaseCreature)targeted; bool alreadyOwned = creature.Owners.Contains(from); if (!creature.Tamable) { from.SendAsciiMessage(CliLoc.LocToString(1049655)); // That creature cannot be tamed. } else if (creature.Controlled) { from.SendAsciiMessage(CliLoc.LocToString(502804)); // That animal looks tame already. } else if (from.Female && !creature.AllowFemaleTamer) { from.SendAsciiMessage(CliLoc.LocToString(1049653)); // That creature can only be tamed by males. } else if (!from.Female && !creature.AllowMaleTamer) { from.SendAsciiMessage(CliLoc.LocToString(1049652)); // That creature can only be tamed by females. } else if (creature.Owners.Count >= BaseCreature.MaxOwners && !creature.Owners.Contains(from)) { from.SendAsciiMessage(CliLoc.LocToString(1005615)); // This animal has had too many owners and is too upset for you to tame. } else if (MustBeSubdued(creature)) { from.SendAsciiMessage(CliLoc.LocToString(1054025)); // You must subdue this creature before you can tame it! } else if (alreadyOwned) { from.SendAsciiMessage("{0} remembers you and accepts you once more as its master.", creature.Name); creature.SetControlMaster(from); } else if (CheckMastery(from, creature) || from.Skills[SkillName.AnimalTaming].Value >= creature.MinTameSkill) { FactionWarHorse warHorse = creature as FactionWarHorse; if (warHorse != null) { Faction faction = Faction.Find(from); if (faction == null || faction != warHorse.Faction) { if (from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } from.SendAsciiMessage(CliLoc.LocToString(1042590)); // You cannot tame this creature. return; } } if (creature.CanAngerOnTame && 0.95 >= Utility.RandomDouble()) { from.SendAsciiMessage(CliLoc.LocToString(502805)); // You seem to anger the beast! creature.PlaySound(creature.GetAngerSound()); from.Direction = creature.GetDirectionTo(from); if (creature.BardPacified && Utility.RandomDouble() > .24) { Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(ResetPacify), creature); } else { creature.BardEndTime = DateTime.Now; } creature.BardPacified = false; creature.Move(creature.Direction); if (from is PlayerMobile && !((PlayerMobile)from).HonorActive) { creature.Combatant = from; } } else { releaseLock = false; m_BeingTamed[targeted] = from; from.SendAsciiMessage("You start to tame the creature."); new InternalTimer(from, creature, Utility.Random(4, 4)).Start(); m_SetSkillTime = false; } } else if (CheckMastery(from, creature) || from.Skills[SkillName.AnimalTaming].Value <= creature.MinTameSkill) { FactionWarHorse warHorse = creature as FactionWarHorse; if (warHorse != null) { Faction faction = Faction.Find(from); if (faction == null || faction != warHorse.Faction) { if (from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } from.SendAsciiMessage(CliLoc.LocToString(1042590)); // You cannot tame this creature. return; } } if (creature.CanAngerOnTame && 0.95 >= Utility.RandomDouble()) { from.SendAsciiMessage(CliLoc.LocToString(502805)); // You seem to anger the beast! creature.PlaySound(creature.GetAngerSound()); from.Direction = creature.GetDirectionTo(from); creature.Combatant = from; } else { releaseLock = false; m_BeingTamed[targeted] = from; from.SendAsciiMessage("You start to tame the creature."); new InternalTimer(from, creature, Utility.Random(4, 4)).Start(); m_SetSkillTime = false; } } else { creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502806, from.NetState); // You have no chance of taming this creature. } } else { ((Mobile)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502469, from.NetState); // That being cannot be tamed. } } else { from.SendLocalizedMessage(502801); // You can't tame that! } if (releaseLock && from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } }
public static void PlayDrinkEffect(Mobile m, BasePotion potion) { if (m is PlayerMobile && !(m as PlayerMobile).HiddenWithSpell) { m.RevealingAction(); } m.PlaySound(0x31); if (potion != null) { if (!potion.EventItem || (potion.EventItem && potion.EventItemConsume)) { Bottle b = new Bottle(); if (potion.EventItem) { b.EventItem = true; b.Hue = potion.Hue; b.Name = "event Empty bottle"; } #region Add to pack or ground if overweight //Taran: Check to see if player is overweight. If they are and the item drops to the //ground then a check is made to see if it can be stacked. If it can't and more than //20 items of the same type exist in the same tile then the last item gets removed. This //check is made so thousands of items can't exist in 1 tile and crash people in the same area. if (!m.AddToBackpack(b)) { IPooledEnumerable eable = m.Map.GetItemsInRange(m.Location, 0); int amount = 0; Item toRemove = null; foreach (Item i in eable) { if (i != b && i.ItemID == b.ItemID) { if (i.StackWith(m, b, false)) { toRemove = b; break; } amount++; } } m.SendAsciiMessage("You are overweight and put the {0} on the ground.", b.Name ?? CliLoc.LocToString(b.LabelNumber)); if (toRemove != null) { toRemove.Delete(); } else if (amount >= 5 && amount < 20) { m.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount)); } else if (amount >= 20) { m.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!"); b.Delete(); } eable.Free(); } #endregion potion.Consume(1); } } if (m.Body.IsHuman) { m.Animate(m.Mounted ? 28 : 34, 5, 1, true, false, 0); } }
public string CrafterSkill() { return(CliLoc.LocToString(RepairSkillInfo.GetInfo(m_Skill).Name)); }
public void EndHeal(Bandage origin) { StopHeal(); if (m_Healer is PlayerMobile) { ((PlayerMobile)m_Healer).WeaponTimerCheck(); } int healerNumber = -1; int patientNumber = -1; bool checkSkills = false; SkillName primarySkill = GetPrimarySkill(m_Patient); SkillName secondarySkill = GetSecondarySkill(m_Patient); BaseCreature petPatient = m_Patient as BaseCreature; if (!m_Healer.Alive) { healerNumber = 500962; // You were unable to finish your work before you died. } else if (m_Healer.Paralyzed) { m_Healer.SendAsciiMessage("You were unable to finish your work before you got paralyzed"); return; } else if (!m_Healer.InRange(m_Patient, Bandage.Range)) { healerNumber = 500963; // You did not stay close enough to heal your target. } else if (!m_Patient.Alive || (petPatient != null && petPatient.IsDeadPet)) { double healing = m_Healer.Skills[primarySkill].Value; double anatomy = m_Healer.Skills[secondarySkill].Value; double chance = ((healing - 68.0) / 50.0) - (m_Slips * 0.02); if (((checkSkills = (healing >= 80.0 && anatomy >= 80.0)) && chance > Utility.RandomDouble()) || (Core.SE && petPatient is FactionWarHorse && petPatient.ControlMaster == m_Healer)) //TODO: Dbl check doesn't check for faction of the horse here? { if (m_Patient.Map == null || !m_Patient.Map.CanFit(m_Patient.Location, 16, false, false)) { healerNumber = 501042; // Target can not be resurrected at that location. } else if (m_Patient.Region != null && m_Patient.Region.IsPartOf("Khaldun")) { healerNumber = 1010395; // The veil of death in this area is too strong and resists thy efforts to restore life. } else { healerNumber = 500965; // You are able to resurrect your patient. m_Patient.FixedEffect(0x376A, 10, 16); if (petPatient != null && petPatient.IsDeadPet) { Mobile master = petPatient.ControlMaster; if (master != null && m_Healer == master) { petPatient.ResurrectPet(); for (int i = 0; i < petPatient.Skills.Length; ++i) { petPatient.Skills[i].Base -= 0.1; } } else if (master != null && master.InRange(petPatient, 3)) { healerNumber = 503255; // You are able to resurrect the creature. master.CloseGump(typeof(PetResurrectGump)); master.SendGump(new PetResurrectGump(m_Healer, petPatient)); } else { bool found = false; List <Mobile> friends = petPatient.Friends; for (int i = 0; friends != null && i < friends.Count; ++i) { Mobile friend = friends[i]; if (friend.InRange(petPatient, 3)) { healerNumber = 503255; // You are able to resurrect the creature. friend.CloseGump(typeof(PetResurrectGump)); friend.SendGump(new PetResurrectGump(m_Healer, petPatient)); found = true; break; } } if (!found) { healerNumber = 1049670; // The pet's owner must be nearby to attempt resurrection. } } } else { m_Patient.CloseGump(typeof(ResurrectGump)); m_Patient.SendGump(new ResurrectGump(m_Patient, m_Healer)); } } } else { if (petPatient != null && petPatient.IsDeadPet) { healerNumber = 503256; // You fail to resurrect the creature. } else { healerNumber = 500966; // You are unable to resurrect your patient. } } } else if (m_Patient.Poisoned) { m_Healer.SendLocalizedMessage(500969); // You finish applying the bandages. double healing = m_Healer.Skills[primarySkill].Value; double anatomy = m_Healer.Skills[secondarySkill].Value; double chance = ((healing - 40.0) / 50.0) - (m_Patient.Poison.Level * 0.11) - (m_Slips * 0.02); if ((checkSkills = (healing >= 60.0 && anatomy >= 60.0)) && chance > Utility.RandomDouble()) { if (m_Patient.CurePoison(m_Healer)) { healerNumber = (m_Healer == m_Patient) ? -1 : 1010058; // You have cured the target of all poisons. patientNumber = 1010059; // You have been cured of all poisons. } else { healerNumber = -1; patientNumber = -1; } } else { healerNumber = 1010060; // You have failed to cure your target! patientNumber = -1; } } else if (BleedAttack.IsBleeding(m_Patient)) { BleedAttack.EndBleed(m_Patient, false); } else if (MortalStrike.IsWounded(m_Patient)) { healerNumber = (m_Healer == m_Patient ? 1005000 : 1010398); } else if (m_Patient.Hits == m_Patient.HitsMax) { healerNumber = 500967; // You heal what little damage your patient had. } else { checkSkills = true; patientNumber = -1; Bandage bandage = null; if (origin.Parent == null && !origin.Deleted) { origin.Consume(1); } else if ((bandage = m_Healer.Backpack.FindItemByType(typeof(Bandage), true) as Bandage) == null) { m_Healer.SendAsciiMessage("You don't have any bandages."); return; } else { bandage.Consume(1); } double healing = m_Healer.Skills[primarySkill].Base; double anatomy = m_Healer.Skills[secondarySkill].Base; //Loki edit: Dexterity improves healing chance double chance = (healing / 100.0) * (0.91 + (((double)m_Healer.RawDex - 80.0) / 1000.0)); if (chance > Utility.RandomDouble()) { double min, max; min = 0.04 * ((anatomy / 4.0) + (healing / 4.0)); max = ((anatomy / 4.0) + (healing / 4.0)) - 4; //Loki edit: Bonus from dexterity double dexbonus = ((double)m_Healer.RawDex - 80.0) / 10.0; min += dexbonus; max += dexbonus / 2; if (max < 2) { max = 2; } double toHeal = Utility.RandomMinMax((int)min, (int)max); if (toHeal < 1) { toHeal = 1; healerNumber = 500968; // You apply the bandages, but they barely help. } else if ((!origin.Deleted && (!origin.EventItem || (origin.EventItem && origin.EventItemConsume))) || (bandage != null && (!bandage.EventItem || (bandage.EventItem && bandage.EventItemConsume)))) { Item item = new BloodyBandage(); if (origin.EventItem || (bandage != null && bandage.EventItem)) { item.EventItem = true; item.Hue = origin.Hue; item.Name = "event Bloody bandage"; } Mobile from = m_Healer; if (from.AddToBackpack(item)) { from.SendAsciiMessage("You put the {0} in your pack.", item.Name ?? CliLoc.LocToString(item.LabelNumber)); } else //Taran: Bloody bandages stack on ground if the player is overweight { from.SendAsciiMessage("You are overweight and put the {0} on the ground.", item.Name ?? CliLoc.LocToString(item.LabelNumber)); IPooledEnumerable eable = from.Map.GetItemsInRange(from.Location, 0); foreach (Item i in eable) { if (i is BloodyBandage) { if (i.Serial != item.Serial) { i.Amount++; item.Delete(); } break; } } eable.Free(); } } else if (!origin.Deleted && (origin.EventItem && !origin.EventItemConsume)) { Mobile from = m_Healer; from.PlaySound(0x57); from.SendAsciiMessage("You are able to re-use your bandage and put it in your pack."); } //m_Patient.Heal( (int)toHeal ); //Rev ~ 140 update m_Patient.Heal((int)toHeal, m_Healer, false); } else { healerNumber = 500968; // You apply the bandages, but they barely help. } m_Healer.CheckSkill(secondarySkill, 0.0, 120.0); m_Healer.CheckSkill(primarySkill, 0.0, 120.0); } if (healerNumber != -1) { m_Healer.SendAsciiMessage(CliLoc.LocToString(healerNumber)); } if (patientNumber != -1) { m_Patient.SendLocalizedMessage(patientNumber); } if (checkSkills) { m_Healer.CheckSkill(secondarySkill, 0.0, 100.0); m_Healer.CheckSkill(primarySkill, 0.0, 100.0); } }
public virtual bool Eat(Mobile from) { // Fill the Mobile with FillFactor if (FillHunger(from, m_FillFactor)) { // Play a random "eat" sound from.PlaySound(Utility.Random(0x3A, 3)); from.PublicOverheadMessage(MessageType.Emote, 0x22, true, string.Format("*You see {0} eating some {1}*", from.Name, Name == null ? CliLoc.LocToString(LabelNumber) : Name)); if (from.Body.IsHuman && !from.Mounted) { from.Animate(34, 5, 1, true, false, 0); } if (m_Poison != null) { from.ApplyPoison(m_Poisoner, m_Poison); } Consume(); return(true); } return(false); }
protected override void OnTarget(Mobile from, object targeted) { bool hasForge, hasAnvil; DefBlacksmithy.CheckAnvilAndForge(from, 4, out hasAnvil, out hasForge); if (targeted is BaseIngot && m_Tool is BaseTool) { if (hasAnvil && hasForge) { BaseTool tool = (BaseTool)m_Tool; BaseIngot ingot = (BaseIngot)targeted; CraftSubRes subRes = CustomCraftMenu.GetSubRes(DefBlacksmithy.CraftSystem, targeted.GetType(), null); int num = CraftResources.GetIndex(ingot.Resource); if (subRes == null || !CustomCraftMenu.ResourceInfoList.ContainsKey(subRes)) { from.SendAsciiMessage("You can't use that."); return; } if (from.Skills[DefBlacksmithy.CraftSystem.MainSkill].Base < subRes.RequiredSkill) { from.SendAsciiMessage("You cannot work this strange and unusual metal."); return; } from.SendGump(new CraftGump(from, m_CraftSystem, tool, null, num)); //from.SendMenu( new CustomCraftMenu( from, DefBlacksmithy.CraftSystem, ( (BaseTool)m_Tool ), -1, targeted.GetType(), CustomCraftMenu.ResourceInfoList[subRes].ResourceIndex ) ); } else { from.SendAsciiMessage("You need to be close to a forge and anvil to smith."); } } else if (targeted is BaseIngot && !(m_Tool is BaseTool)) { from.SendAsciiMessage("You need to use a smith's hammer on that."); } else { if (!hasAnvil) { from.SendAsciiMessage("You need to be close to an anvil to repair."); return; } int number; 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 = 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 && !IsSpecialWeapon(weapon)) { number = 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract. } 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 { number = 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } } } 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 = 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) { number = 1044277; } // That item cannot be repaired. // You cannot repair that item with this type of repair contract. 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 { number = 1044280; // You fail to repair the item. [And the contract is destroyed] m_CraftSystem.PlayCraftEffect(from); } } } else if (targeted is Item) { number = 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. } from.SendAsciiMessage(CliLoc.LocToString(number)); } }
public ItemListEntry[] CreateItemList() { CraftGroupCol craftGroupCol = CurrentCraftSystem.CraftGroups; CraftGroup craftGroup = craftGroupCol.GetAt(SelectedGroupIndex); CraftItemCol craftItemCol = craftGroup.CraftItems; ItemListEntry[] toReturn = new ItemListEntry[craftItemCol.Count + 1]; toReturn[0] = new ItemListEntry("Previous menu", 4766);//Previous page int hue = 0; if (CurrentCraftSystem.CraftSubRes.Init && CurrentCraftSystem.CraftSubRes.Count >= 1 && SelectedResType != CurrentCraftSystem.CraftSubRes.GetAt(0).ItemType) { hue = ResourceInfoList[CurrentCraftSystem.CraftSubRes.GetAt(SelectedResourceIndex)].Hue; } if (hue > 1) { --hue; } string resourceList = string.Empty; for (int i = 0; i < craftItemCol.Count; ++i) { CraftItem craftItem = craftItemCol.GetAt(i); //Get the item id and resources required for the items int itemID; if (craftItemCol.Count >= 1) { itemID = CraftItem.ItemIDOf(craftItemCol.GetAt(i).ItemType); int amount = CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).Amount; if (SelectedResType == null) { if (!string.IsNullOrEmpty(CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameString)) { resourceList = string.Format(" [{0} {1}]", resourceList, amount); } else if (CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameNumber > 0) { resourceList = string.Format(" [{0} {1}]", amount, CliLoc.LocToString(CurrentCraftSystem.CraftGroups.GetAt(SelectedGroupIndex).CraftItems.GetAt(i).Resources.GetAt(0).NameNumber)); } } else { resourceList = string.Format(" [{0} {1}]", amount, CraftResources.GetName(CraftResources.GetFromType(SelectedResType))); } } else { itemID = 5360; //Deed ID } //Becomes 0 if we use a string instead if (craftItem.NameNumber > 0) { toReturn[i + 1] = new ItemListEntry(CliLoc.LocToString(craftItem.NameNumber) + resourceList, itemID, hue); } else { toReturn[i + 1] = new ItemListEntry(craftItem.NameString + resourceList, itemID, hue); } } return(toReturn); }
public static string GetItemName(Item item) { if (StringList == null || item.Name != null) { return(item.Name); } ObjectPropertyList opl = new ObjectPropertyList(item); item.GetProperties(opl); if (opl == null) { //if there was a problem with this process, just return null return(null); } //since the object property list is based on a packet object, the property info is packed away in a packet format byte[] data = opl.UnderlyingStream.UnderlyingStream.ToArray(); int index = 15; // First localization number index string basestring = null; //reset the number property uint number = 0; //if there's not enough room for another record, quit if (index + 4 >= data.Length) { return(null); } //read number property from the packet data number = (uint)(data[index++] << 24 | data[index++] << 16 | data[index++] << 8 | data[index++]); //reset the length property ushort length = 0; //if there's not enough room for another record, quit if (index + 2 > data.Length) { return(null); } //read length property from the packet data length = (ushort)(data[index++] << 8 | data[index++]); //determine the location of the end of the string int end = index + length; //truncate if necessary if (end >= data.Length) { end = data.Length - 1; } //read the string into a StringBuilder object StringBuilder s = new StringBuilder(); while (index + 2 <= end + 1) { short next = (short)(data[index++] | data[index++] << 8); if (next == 0) { break; } s.Append(Encoding.Unicode.GetString(BitConverter.GetBytes(next))); } basestring = CliLoc.LocToString((int)number);// StringList.GetString((int)number); string args = s.ToString(); if (args == null || args == String.Empty) { return(basestring); } string[] parms = args.Split('\t'); try { if (parms.Length > 1) { for (int i = 0; i < parms.Length; i++) { parms[i] = parms[i].Trim(' '); if (parms[i].IndexOf("#") == 0) { parms[i] = CliLoc.LocToString(Convert.ToInt32(parms[i].Substring(1, parms[i].Length - 1))); } } } else if (parms.Length == 1 && parms[0].IndexOf("#") == 0) { parms[0] = CliLoc.LocToString(Convert.ToInt32(args.Substring(1, parms[0].Length - 1))); } } catch { return(null); } var entry = CliLoc.LocToString((int)number, parms); if (entry != null) { return(entry); } return(basestring); }
public virtual void Send(Packet p) { if (m_Socket == null || m_BlockAllPackets) { p.OnSend(); return; } if (this.Version != null && this.Version.Major <= 3) { if (p is ObjectPropertyList || p is OPLInfo) { return; } if (p is MobileMovingOld) { var packet = p as MobileMovingOld; var newBody = Mythik.BodyConverter.ConvertBody203(packet.Body, this.Mobile); if (packet.Body != newBody) { var oldpos = p.UnderlyingStream.Position; p.UnderlyingStream.UnderlyingStream.Seek(5, SeekOrigin.Begin); p.UnderlyingStream.Write((short)newBody); p.UnderlyingStream.UnderlyingStream.Position = oldpos; } } if (p is MobileUpdateOld) { var packet = p as MobileUpdateOld; var newBody = Mythik.BodyConverter.ConvertBody203(packet.Body, this.Mobile); if (packet.Body != newBody) { var oldpos = p.UnderlyingStream.Position; p.UnderlyingStream.UnderlyingStream.Seek(5, SeekOrigin.Begin); p.UnderlyingStream.Write((short)newBody); p.UnderlyingStream.UnderlyingStream.Position = oldpos; } } //skils gump, journal gump, char creation //Lets check for unsupported packets. if (p is MessageLocalized) { var packet = p as MessageLocalized; if (packet.labelNumber > 0)// 1053000) { string nameString = ""; if (packet.labelNumber > 0 || packet.m_ItemID > 0) { nameString = CliLoc.LocToString(packet.labelNumber, packet.args); } Send(new AsciiMessage(packet.m_Serial, packet.m_ItemID, packet.type, packet.hue, packet.font, "", nameString)); } return; } if (p is MessageLocalizedAffix) { var packet = p as MessageLocalizedAffix; var nameString = ""; nameString = CliLoc.LocToString(packet.number, packet.args); Send(new AsciiMessage(packet.m_Serial, packet.m_ItemID, packet.label, packet.hue, packet.font, "", packet.affix.Replace(":", "") + " " + nameString)); return; } if (p is UnicodeMessage) { var packet = p as UnicodeMessage; Send(new AsciiMessage(packet._serial, packet._graphic, packet._type, packet._hue, packet._font, packet._name, packet._text)); return; } } PacketSendProfile prof = PacketSendProfile.Acquire(p.GetType()); int length; byte[] buffer = p.Compile(m_CompressionEnabled, out length); if (buffer != null) { if (buffer.Length <= 0 || length <= 0) { p.OnSend(); return; } if (prof != null) { prof.Start(); } if (m_Encoder != null) { m_Encoder.EncodeOutgoingPacket(this, ref buffer, ref length); } try { SendQueue.Gram gram; lock ( m_SendQueue ) { gram = m_SendQueue.Enqueue(buffer, length); } if (gram != null) { #if NewAsyncSockets m_SendEventArgs.SetBuffer(gram.Buffer, 0, gram.Length); Send_Start(); #else try { m_Socket.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, m_Socket); } catch (Exception ex) { TraceException(ex); Dispose(false); } #endif } } catch (CapacityExceededException) { Console.WriteLine("Client: {0}: Too much data pending, disconnecting...", this); Dispose(false); } p.OnSend(); if (prof != null) { prof.Finish(length); } } else { Console.WriteLine("Client: {0}: null buffer send, disconnecting...", this); using (StreamWriter op = new StreamWriter("null_send.log", true)) { op.WriteLine("{0} Client: {1}: null buffer send, disconnecting...", DateTime.UtcNow, this); op.WriteLine(new System.Diagnostics.StackTrace()); } Dispose(); } }
public static string LocToString(int index) { //scan through the cliloc's for the correct entry return(CliLoc.LocToString(index)); }
public void EndHeal() { StopHeal(); int healerNumber = -1, patientNumber = -1; bool playSound = true; bool checkSkills = false; SkillName primarySkill = GetPrimarySkill(m_Patient); SkillName secondarySkill = GetSecondarySkill(m_Patient); BaseCreature petPatient = m_Patient as BaseCreature; if (!m_Healer.Alive) { healerNumber = 500962; // You were unable to finish your work before you died. patientNumber = -1; playSound = false; } else if (!m_Healer.InRange(m_Patient, Bandage.Range)) { healerNumber = 500963; // You did not stay close enough to heal your target. patientNumber = -1; playSound = false; } else if (!m_Patient.Alive || (petPatient != null && petPatient.IsDeadPet)) { double healing = m_Healer.Skills[primarySkill].Value; double anatomy = m_Healer.Skills[secondarySkill].Value; double chance = ((healing - 68.0) / 50.0) - (m_Slips * 0.02); if (((checkSkills = (healing >= 80.0 && anatomy >= 80.0)) && chance > Utility.RandomDouble()) || (Core.SE && petPatient is Factions.FactionWarHorse && petPatient.ControlMaster == m_Healer)) //TODO: Dbl check doesn't check for faction of the horse here? { if (m_Patient.Map == null || !m_Patient.Map.CanFit(m_Patient.Location, 16, false, false)) { healerNumber = 501042; // Target can not be resurrected at that location. patientNumber = 502391; // Thou can not be resurrected there! } else if (m_Patient.Region != null && m_Patient.Region.IsPartOf("Khaldun")) { healerNumber = 1010395; // The veil of death in this area is too strong and resists thy efforts to restore life. patientNumber = -1; } else { healerNumber = 500965; // You are able to resurrect your patient. patientNumber = -1; m_Patient.PlaySound(0x214); m_Patient.FixedEffect(0x376A, 10, 16); if (petPatient != null && petPatient.IsDeadPet) { Mobile master = petPatient.ControlMaster; if (master != null && m_Healer == master) { petPatient.ResurrectPet(); for (int i = 0; i < petPatient.Skills.Length; ++i) { petPatient.Skills[i].Base -= 0.1; } } else if (master != null && master.InRange(petPatient, 3)) { healerNumber = 503255; // You are able to resurrect the creature. master.CloseGump(typeof(PetResurrectGump)); master.SendGump(new PetResurrectGump(m_Healer, petPatient)); } else { bool found = false; List <Mobile> friends = petPatient.Friends; for (int i = 0; friends != null && i < friends.Count; ++i) { Mobile friend = friends[i]; if (friend.InRange(petPatient, 3)) { healerNumber = 503255; // You are able to resurrect the creature. friend.CloseGump(typeof(PetResurrectGump)); friend.SendGump(new PetResurrectGump(m_Healer, petPatient)); found = true; break; } } if (!found) { healerNumber = 1049670; // The pet's owner must be nearby to attempt resurrection. } } } else { m_Patient.CloseGump(typeof(ResurrectGump)); m_Patient.SendGump(new ResurrectGump(m_Patient, m_Healer)); } } } else { if (petPatient != null && petPatient.IsDeadPet) { healerNumber = 503256; // You fail to resurrect the creature. } else { healerNumber = 500966; // You are unable to resurrect your patient. } patientNumber = -1; } } else if (m_Patient.Poisoned) { m_Healer.SendLocalizedMessage(500969); // You finish applying the bandages. double healing = m_Healer.Skills[primarySkill].Value; double anatomy = m_Healer.Skills[secondarySkill].Value; double chance = ((healing - 30.0) / 50.0) - (m_Patient.Poison.Level * 0.1) - (m_Slips * 0.02); if ((checkSkills = (healing >= 60.0 && anatomy >= 60.0)) && chance > Utility.RandomDouble()) { if (m_Patient.CurePoison(m_Healer)) { healerNumber = (m_Healer == m_Patient) ? -1 : 1010058; // You have cured the target of all poisons. patientNumber = 1010059; // You have been cured of all poisons. } else { healerNumber = -1; patientNumber = -1; } } else { healerNumber = 1010060; // You have failed to cure your target! patientNumber = -1; } } else if (BleedAttack.IsBleeding(m_Patient)) { healerNumber = 1060088; // You bind the wound and stop the bleeding patientNumber = 1060167; // The bleeding wounds have healed, you are no longer bleeding! BleedAttack.EndBleed(m_Patient, false); } else if (MortalStrike.IsWounded(m_Patient)) { healerNumber = (m_Healer == m_Patient ? 1005000 : 1010398); patientNumber = -1; playSound = false; } else if (m_Patient.Hits == m_Patient.HitsMax) { healerNumber = 500967; // You heal what little damage your patient had. patientNumber = -1; } else { checkSkills = true; patientNumber = -1; double healing = m_Healer.Skills[primarySkill].Value; double anatomy = m_Healer.Skills[secondarySkill].Value; double chance = ((healing + 10.0) / 100.0) - (m_Slips * 0.02); if (chance > Utility.RandomDouble()) { healerNumber = 500969; // You finish applying the bandages. double min, max; if (Core.AOS) { min = (anatomy / 8.0) + (healing / 5.0) + 4.0; max = (anatomy / 6.0) + (healing / 2.5) + 4.0; } else { min = (anatomy / 5.0) + (healing / 5.0) + 3.0; max = (anatomy / 5.0) + (healing / 2.0) + 10.0; } double toHeal = min + (Utility.RandomDouble() * (max - min)); if (m_Patient.Body.IsMonster || m_Patient.Body.IsAnimal) { toHeal += m_Patient.HitsMax / 100; } if (Core.AOS) { toHeal -= toHeal * m_Slips * 0.35; // TODO: Verify algorithm } else { toHeal -= m_Slips * 4; } if (toHeal < 1) { toHeal = 1; healerNumber = 500968; // You apply the bandages, but they barely help. } m_Patient.Heal((int)toHeal, m_Healer, false); } else { healerNumber = 500968; // You apply the bandages, but they barely help. playSound = false; } } if (healerNumber != -1) { m_Healer.SendLocalizedMessage(healerNumber); } if (patientNumber != -1) { m_Patient.SendLocalizedMessage(patientNumber); } if (playSound) { m_Patient.PlaySound(0x57); } if (checkSkills) { m_Healer.CheckSkill(secondarySkill, 0.0, 120.0); m_Healer.CheckSkill(primarySkill, 0.0, 120.0); } //90% chance to get a bloody bandage back, lets have some consumption even 10% if (Utility.Random(10) <= 9) { var bloody = new BloodyBandage(); m_Healer.AddToBackpack(bloody); m_Healer.SendAsciiMessage("You put the {0} in your pack.", bloody.Name ?? CliLoc.LocToString(bloody.LabelNumber)); } }
public virtual int OnHit(BaseWeapon weapon, int damageTaken) { int Absorbed = Utility.RandomMinMax(1, 4); damageTaken -= Absorbed; if (damageTaken < 0) { damageTaken = 0; } if (25 > Utility.Random(100)) // 25% chance to lower durability { if (Core.AOS && m_AosClothingAttributes.SelfRepair > Utility.Random(10)) { HitPoints += 2; } else { int wear; if (weapon.Type == WeaponType.Bashing) { wear = Absorbed / 2; } else { wear = Utility.Random(2); } if (wear > 0 && m_MaxHitPoints > 0) { if (m_HitPoints >= wear) { HitPoints -= wear; wear = 0; } else { wear -= HitPoints; HitPoints = 0; } if (wear > 0) { if (m_MaxHitPoints > wear) { MaxHitPoints -= wear; if (Parent is Mobile) { ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); // Your equipment is severely damaged. } } else { if (Parent is Mobile) { ((Mobile)Parent).PublicOverheadMessage(MessageType.Emote, 0x22, true, string.Format("*{0}'s {1} is destroyed", ((Mobile)Parent).Name, string.IsNullOrEmpty(Name) ? CliLoc.LocToString(LabelNumber) : Name)); } Delete(); } } } } } return(damageTaken); }
public InternalTimer(Mobile tamer, BaseCreature creature, int count) : base(TimeSpan.FromSeconds(3.0), TimeSpan.FromSeconds(3.0), count) { m_Tamer = tamer; m_Creature = creature; m_MaxCount = count; m_Paralyzed = creature.Paralyzed; m_StartTime = DateTime.Now; Priority = TimerPriority.TwoFiftyMS; if (tamer is PlayerMobile) { ((PlayerMobile)tamer).ResetPlayerAction(this); } m_Tamer.RevealingAction(); string msg = ""; switch (Utility.Random(3)) { case 0: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("I always wanted {0} like you.", m_Creature.Name); } else { msg = CliLoc.LocToString(502790); } break; case 1: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("Good {0}.", m_Creature.Name); } else { msg = CliLoc.LocToString(1005608); } break; case 2: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("Here {0}.", m_Creature.Name); } else { msg = CliLoc.LocToString(1010593); } break; case 3: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("I won't hurt you"); } else { msg = CliLoc.LocToString(1010593); } break; } SpellHelper.Turn(m_Tamer, m_Creature); m_Tamer.PublicOverheadMessage(MessageType.Regular, 906, true, msg); }
protected override void OnTarget(Mobile from, object targeted) { bool releaseLock = true; if (m_Potion.Deleted) { if (releaseLock && from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } return; } bool startTimer = false; if (targeted is Food || targeted is FukiyaDarts || targeted is Shuriken) { startTimer = true; } else if (targeted is BaseWeapon) { BaseWeapon weapon = (BaseWeapon)targeted; if (Core.AOS) { startTimer = (weapon.PrimaryAbility == WeaponAbility.InfectiousStrike || weapon.SecondaryAbility == WeaponAbility.InfectiousStrike); } else if (weapon.Layer == Layer.OneHanded && !(weapon is SuperiorDiamondKatana || weapon is DiamondKatana || weapon is HellsHalberd || weapon is SuperiorDragonsBlade || weapon is DragonsBlade || weapon is HeavensFury || weapon is SoV)) //Loki edit: 1H blades only { startTimer = (weapon.Type == WeaponType.Slashing || weapon.Type == WeaponType.Piercing); } } if (startTimer) { releaseLock = false; new InternalTimer(from, (Item)targeted, m_Potion).Start(); from.PlaySound(0x4F); if (!m_Potion.EventItem) //Loki edit: Event pots are not consumed and don't create empty bottles { m_Potion.Consume(); Bottle bottle = new Bottle(); #region Add to pack or ground if overweight //Taran: Check to see if player is overweight. If they are and the item drops to the //ground then a check is made to see if it can be stacked. If it can't and more than //20 items of the same type exist in the same tile then the last item gets removed. This //check is made so thousands of items can't exist in 1 tile and crash people in the same area. if (from.AddToBackpack(bottle)) { from.SendAsciiMessage("You put the {0} in your pack.", bottle.Name ?? CliLoc.LocToString(bottle.LabelNumber)); } else if (!bottle.Deleted) { IPooledEnumerable eable = from.Map.GetItemsInRange(from.Location, 0); int amount = 0; Item toRemove = null; foreach (Item i in eable) { if (i != bottle && i.ItemID == bottle.ItemID) { if (i.StackWith(from, bottle, false)) { toRemove = bottle; break; } amount++; } } from.SendAsciiMessage("You are overweight and put the {0} on the ground.", bottle.Name ?? CliLoc.LocToString(bottle.LabelNumber)); if (toRemove != null) { toRemove.Delete(); } else if (amount >= 5 && amount < 20) { from.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount)); } else if (amount >= 20) { from.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!"); bottle.Delete(); } eable.Free(); } #endregion } } else // Target can't be poisoned { if (Core.AOS) { from.SendLocalizedMessage(1060204); // You cannot poison that! You can only poison infectious weapons, food or drink. } else { //from.SendLocalizedMessage( 502145 ); // You cannot poison that! You can only poison bladed or piercing weapons, food or drink. from.SendAsciiMessage("You cannot poison that! You can only poison certain weapons, food or drink."); } } if (releaseLock && from is PlayerMobile) { ((PlayerMobile)from).EndPlayerAction(); } }
protected override void OnTick() { m_Count++; DamageEntry de = m_Creature.FindMostRecentDamageEntry(false); bool alreadyOwned = (m_Creature.LastOwner == m_Tamer); if (!m_Tamer.InRange(m_Creature, 6)) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(502795)); // You are too far away to continue taming. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (!m_Tamer.CheckAlive()) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(502796)); // You are dead, and cannot continue taming. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (!m_Tamer.CanSee(m_Creature) || !m_Tamer.InLOS(m_Creature))// || !CanPath()) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(1049654)); // You do not have a clear path to the animal you are taming, and must cease your attempt. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (!m_Creature.Tamable) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(1049655)); // That creature cannot be tamed. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (m_Creature.Controlled) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(502804)); // That animal looks tame already. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (m_Creature.Owners.Count >= BaseCreature.MaxOwners && !m_Creature.Owners.Contains(m_Tamer)) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(1005615)); // This animal has had too many owners and is too upset for you to tame. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (MustBeSubdued(m_Creature)) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(1054025)); // You must subdue this creature before you can tame it! Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (de != null && de.LastDamage > m_StartTime) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = DateTime.Now; m_Tamer.SendAsciiMessage(CliLoc.LocToString(502794)); // The animal is too angry to continue taming. Stop(); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else if (m_Count < m_MaxCount) { m_Tamer.RevealingAction(); string msg = ""; switch (Utility.Random(4)) { case 0: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("I always wanted a {0} like you.", m_Creature.Name); } else { msg = CliLoc.LocToString(502790); } break; case 1: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("Good {0}.", m_Creature.Name); } else { msg = CliLoc.LocToString(1005608); } break; case 2: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("Here {0}.", m_Creature.Name); } else { msg = CliLoc.LocToString(1010593); } break; case 3: if (!string.IsNullOrEmpty(m_Creature.Name)) { msg = string.Format("I won't hurt you"); } else { msg = CliLoc.LocToString(1010593); } break; } SpellHelper.Turn(m_Tamer, m_Creature); m_Tamer.PublicOverheadMessage(MessageType.Regular, 906, true, msg); if (!alreadyOwned) // Passively check animal lore for gain { m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0); } if (m_Creature.Paralyzed) { m_Paralyzed = true; } } else { m_Tamer.RevealingAction(); m_Tamer.NextSkillTime = DateTime.Now; m_BeingTamed.Remove(m_Creature); if (m_Creature.Paralyzed) { m_Paralyzed = true; } if (!alreadyOwned) // Passively check animal lore for gain { m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0); } double minSkill = m_Creature.MinTameSkill; //+ (m_Creature.Owners.Count * 6.0); Taran - Same chance to tame no matter how many owners the mount has had if (minSkill > -29.9 && CheckMastery(m_Tamer, m_Creature)) { minSkill = -29.9; // 50% at 0.0? } double tamerSkill = m_Tamer.Skills[SkillName.AnimalTaming].Value; if (minSkill > tamerSkill) //Taran - Adding chance to tame and gain even if you have lower Animal Taming than MinTameSkill { if (minSkill - tamerSkill <= 5) //1% chance to tame when less than 5% difference in taming and mintameskill { minSkill = tamerSkill + 19.3; } else if (minSkill - tamerSkill <= 10) //0.5% chance to tame when less than 10% difference in taming and mintameskill { minSkill = tamerSkill + 19.65; } else if (minSkill - tamerSkill <= 20) //0.25% chance to tame when less than 20% difference in taming and mintameskill { minSkill = tamerSkill + 19.825; } else if (minSkill - tamerSkill > 20) //0.1% chance to tame when more than 20% difference in taming and mintameskill { minSkill = tamerSkill + 19.93; } } //Taran - Changed the chance to tame below if (alreadyOwned || m_Tamer.CheckTargetSkill(SkillName.AnimalTaming, m_Creature, minSkill - 20.0, minSkill + 50.0)) { if (m_Creature.Owners.Count == 0) // First tame { if (m_Paralyzed) { ScaleSkills(m_Creature, 0.86); // 86% of original skills if they were paralyzed during the taming } else { ScaleSkills(m_Creature, 0.90); // 90% of original skills } if (m_Creature.StatLossAfterTame) { ScaleStats(m_Creature, 0.50); } } if (alreadyOwned) { //m_Tamer.SendLocalizedMessage( 502797 ); // That wasn't even challenging. m_Tamer.SendAsciiMessage("{0} remembers you and accepts you once more as its master.", m_Creature.Name); if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else { if (m_Creature.Controlled && m_Creature.ControlMaster != null) { m_Tamer.SendAsciiMessage("Someone else tamed that creature before you."); } else { m_Tamer.SendAsciiMessage(CliLoc.LocToString(502799)); //m_Tamer.SendAsciiMessage("The {0} accepts you as its master.", m_Creature); m_Creature.Owners.Add(m_Tamer); } } if (!m_Creature.Controlled && m_Creature.ControlMaster == null) { //m_Tamer.SendAsciiMessage("The {0} accepts you as its master.", m_Creature.Name); m_Creature.SetControlMaster(m_Tamer); } else { m_Tamer.SendAsciiMessage("Someone else tamed that creature before you."); } m_Creature.IsBonded = false; if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } else { m_Tamer.SendAsciiMessage(CliLoc.LocToString(502798)); // You fail to tame the creature. if (m_Tamer is PlayerMobile) { ((PlayerMobile)m_Tamer).EndPlayerAction(); } } } }
protected override void OnTick() { if (m_From.Alive) { double bonus = 0.0; int range = Math.Min((int)((100 - m_From.Skills[SkillName.Hiding].Value) / 2) + 8, 18); //Cap of 18 not OSI-exact, intentional difference bool badCombat = (m_From.Combatant != null && m_From.InRange(m_From.Combatant.Location, range) && m_From.Combatant.InLOS(m_From)); bool ok = (!badCombat && m_From.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus)); if (ok) { foreach (Mobile check in m_From.GetMobilesInRange(range)) { if (check.InLOS(m_From) && check.Combatant == m_From) { badCombat = true; ok = false; break; } } ok = (!badCombat && m_From.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus)); } if (badCombat) { m_From.RevealingAction(); m_From.SendAsciiMessage("You can't seem to hide here."); } else { if (ok) { m_From.Hidden = true; m_From.Warmode = false; Stealth.SetAllowedStealthSteps(m_From); m_From.LocalOverheadMessage(MessageType.Regular, 906, true, CliLoc.LocToString(501240)); // You have hidden yourself well. } else { m_From.RevealingAction(); m_From.SendLocalizedMessage(501241); // You can't seem to hide here. } } } if (m_From is PlayerMobile) { ((PlayerMobile)m_From).EndPlayerAction(); } }
protected override void OnTick() { //m_From.EndAction( typeof( CookableFood ) ); if (m_From.Map != m_Map || (m_Point != null && m_From.GetDistanceToSqrt(m_Point) > 3)) { m_From.SendLocalizedMessage(500686); // You burn the food to a crisp! It's ruined. if (m_From is PlayerMobile) { ((PlayerMobile)m_From).EndPlayerAction(); } return; } if (m_From.CheckSkill(SkillName.Cooking, m_CookableFood.CookingLevel, 100)) { Food cookedFood = m_CookableFood.Cook(); m_From.SendAsciiMessage("Mmm, smells good"); //Taran: Check to see if player is overweight. If they are and the item drops to the //ground then a check is made to see if more than 20 items of the same type exist in //the same tile. If that's the case the last item gets removed. This check is made so //thousands of items can't exist in 1 tile and crash people in the same area. if (m_From.AddToBackpack(cookedFood)) { m_From.SendAsciiMessage("You put the {0} in your pack.", cookedFood.Name ?? CliLoc.LocToString(cookedFood.LabelNumber)); } else { IPooledEnumerable eable = m_From.Map.GetItemsInRange(m_From.Location, 0); int amount = 0; Item toRemove = null; foreach (Item i in eable) { if (i != cookedFood && i.ItemID == cookedFood.ItemID) { if (i.StackWith(m_From, cookedFood, false)) { toRemove = cookedFood; break; } amount++; } } m_From.SendAsciiMessage("You are overweight and put the {0} on the ground.", cookedFood.Name ?? CliLoc.LocToString(cookedFood.LabelNumber)); if (toRemove != null) { toRemove.Delete(); } else if (amount >= 5 && amount < 20) { m_From.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount)); } else if (amount >= 20) { m_From.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!"); cookedFood.Delete(); } eable.Free(); } } else { m_From.SendLocalizedMessage(500686); // You burn the food to a crisp! It's ruined. } if (m_From is PlayerMobile) { ((PlayerMobile)m_From).EndPlayerAction(); } }
private static void GenerateTable(CraftSystem system) { var stw = new StreamWriter("web/" + system.MainSkill.ToString() + ".json"); using (JsonWriter writer = new JsonTextWriter(stw)) { writer.Formatting = Formatting.Indented; //writer.WritePropertyName("items"); writer.WriteStartArray(); foreach (CraftItem item in system.CraftItems) { writer.WriteStartObject(); writer.WritePropertyName("Name"); if (item.NameNumber == 0) { writer.WriteValue(item.NameString); } else { writer.WriteValue(CliLoc.LocToString(item.NameNumber)); } writer.WritePropertyName("hue"); writer.WriteValue(item.ItemHue); writer.WritePropertyName("type"); writer.WriteValue(CraftItem.ItemIDOf(item.ItemType)); writer.WritePropertyName("skills"); writer.WriteStartArray(); foreach (CraftSkill skill in item.Skills) { writer.WriteStartObject(); writer.WritePropertyName("skill"); writer.WriteValue(skill.SkillToMake.ToString()); writer.WritePropertyName("minskill"); writer.WriteValue(skill.MinSkill); writer.WritePropertyName("maxskill"); writer.WriteValue(skill.MaxSkill); writer.WriteEndObject(); } writer.WriteEndArray(); writer.WritePropertyName("resources"); writer.WriteStartArray(); foreach (CraftRes res in item.Resources) { writer.WriteStartObject(); writer.WritePropertyName("res"); if (res.NameNumber != 0) { writer.WriteValue(CliLoc.LocToString(res.NameNumber)); } else if (res.NameString?.Length > 2) { writer.WriteValue(res.NameString); } else { if (CraftResources.GetFromType(res.ItemType) != CraftResource.None) { var resource = CraftResources.GetName(CraftResources.GetFromType(res.ItemType)); writer.WriteValue(resource); } } writer.WritePropertyName("qty"); writer.WriteValue(res.Amount); writer.WriteEndObject(); } writer.WriteEndArray(); writer.WriteEndObject(); } writer.WriteEndArray(); } }