Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
60
Scripts/Services/Monster Stealing/Core/BaseBalmOrLotion.cs
Normal file
60
Scripts/Services/Monster Stealing/Core/BaseBalmOrLotion.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class BaseBalmOrLotion : BaseThieveConsumable, ICommodity
|
||||
{
|
||||
public BaseBalmOrLotion(int itemId) : base(itemId)
|
||||
{
|
||||
m_EffectDuration = TimeSpan.FromMinutes(30);
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
protected override void OnUse(PlayerMobile by)
|
||||
{
|
||||
if (m_EffectType == ThieveConsumableEffect.None)
|
||||
{
|
||||
by.SendMessage("This balm or lotion is corrupted. Please contact a game master");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CanUse(by, this))
|
||||
{
|
||||
ApplyEffect(by);
|
||||
}
|
||||
else
|
||||
{
|
||||
by.SendLocalizedMessage(1095133);//You are already under the effect of a balm or lotion.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BaseBalmOrLotion(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TextDefinition ICommodity.Description { get { return LabelNumber; } }
|
||||
bool ICommodity.IsDeedable { get { return true; } }
|
||||
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
189
Scripts/Services/Monster Stealing/Core/BaseThieveConsumable.cs
Normal file
189
Scripts/Services/Monster Stealing/Core/BaseThieveConsumable.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
using System.Text;
|
||||
using Server;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum ThieveConsumableEffect
|
||||
{
|
||||
None,
|
||||
BalmOfStrengthEffect,
|
||||
BalmOfWisdomEffect,
|
||||
BalmOfSwiftnessEffect,
|
||||
BalmOfProtectionEffect,
|
||||
StoneSkinLotionEffect,
|
||||
LifeShieldLotionEffect,
|
||||
}
|
||||
|
||||
public class ThieveConsumableInfo
|
||||
{
|
||||
public ThieveConsumableEffect Effect;
|
||||
public Timer EffectTimer;
|
||||
|
||||
public ThieveConsumableInfo(BaseThieveConsumable.InternalTimer t, ThieveConsumableEffect e)
|
||||
{
|
||||
Effect = e;
|
||||
EffectTimer = t;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseThieveConsumable : Item
|
||||
{
|
||||
public BaseThieveConsumable(int itemId)
|
||||
: base(itemId)
|
||||
{
|
||||
}
|
||||
|
||||
public class InternalTimer : Timer
|
||||
{
|
||||
public PlayerMobile pm;
|
||||
public ThieveConsumableEffect effect;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
BaseThieveConsumable.RemoveEffect(pm,effect);
|
||||
}
|
||||
|
||||
public InternalTimer(PlayerMobile p, ThieveConsumableEffect e, TimeSpan delay)
|
||||
: base(delay)
|
||||
{
|
||||
pm = p;
|
||||
effect = e;
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan m_EffectDuration;
|
||||
protected ThieveConsumableEffect m_EffectType;
|
||||
|
||||
protected virtual void OnUse(PlayerMobile by)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void ApplyEffect(PlayerMobile pm)
|
||||
{
|
||||
|
||||
if (m_EffectDuration == TimeSpan.Zero)
|
||||
{
|
||||
m_EffectDuration = TimeSpan.FromMinutes(30);
|
||||
}
|
||||
|
||||
InternalTimer t = new InternalTimer(pm,m_EffectType,m_EffectDuration);
|
||||
t.Start();
|
||||
|
||||
ThieveConsumableInfo info = new ThieveConsumableInfo(t, this.m_EffectType);
|
||||
|
||||
if (EffectTable.ContainsKey(pm))
|
||||
{
|
||||
RemoveEffect(pm, EffectTable[pm].Effect);
|
||||
}
|
||||
|
||||
EffectTable.Add(pm, info);
|
||||
this.Consume();
|
||||
}
|
||||
|
||||
protected static void RemoveEffect(PlayerMobile pm, ThieveConsumableEffect effectType)
|
||||
{
|
||||
if (EffectTable.ContainsKey(pm))
|
||||
{
|
||||
|
||||
EffectTable[pm].EffectTimer.Stop();
|
||||
EffectTable.Remove(pm);
|
||||
|
||||
pm.SendLocalizedMessage(1095134);//The effects of the balm or lotion have worn off.
|
||||
|
||||
if (effectType == ThieveConsumableEffect.BalmOfStrengthEffect || effectType == ThieveConsumableEffect.BalmOfSwiftnessEffect || effectType == ThieveConsumableEffect.BalmOfWisdomEffect)
|
||||
{
|
||||
pm.RemoveStatMod("Balm");
|
||||
}
|
||||
else if (effectType == ThieveConsumableEffect.StoneSkinLotionEffect)
|
||||
{
|
||||
|
||||
List<ResistanceMod> list = pm.ResistanceMods;
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
ResistanceMod curr = list[i];
|
||||
if ((curr.Type == ResistanceType.Cold && curr.Offset == -5) || (curr.Type == ResistanceType.Fire && curr.Offset == -5) || (curr.Type == ResistanceType.Physical && curr.Offset == 30))
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<PlayerMobile, ThieveConsumableInfo> EffectTable = new Dictionary<PlayerMobile, ThieveConsumableInfo>();
|
||||
|
||||
public static bool CanUse(PlayerMobile pm, BaseThieveConsumable consum)
|
||||
{
|
||||
if (CheckThieveConsumable(pm) != ThieveConsumableEffect.None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsUnderThieveConsumableEffect(PlayerMobile pm, ThieveConsumableEffect eff)
|
||||
{
|
||||
if (EffectTable.ContainsKey(pm))
|
||||
{
|
||||
if (EffectTable[pm].Effect == eff)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ThieveConsumableEffect CheckThieveConsumable(PlayerMobile pm)
|
||||
{
|
||||
if (EffectTable.ContainsKey(pm))
|
||||
{
|
||||
return EffectTable[pm].Effect;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThieveConsumableEffect.None;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseThieveConsumable(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write((int)m_EffectType);
|
||||
writer.Write(m_EffectDuration);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_EffectType = (ThieveConsumableEffect)reader.ReadInt();
|
||||
m_EffectDuration = reader.ReadTimeSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
255
Scripts/Services/Monster Stealing/Core/StealingHandler.cs
Normal file
255
Scripts/Services/Monster Stealing/Core/StealingHandler.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using Server.Regions;
|
||||
using Server.Engines.CannedEvil;
|
||||
|
||||
namespace Server.Engines.CreatureStealing
|
||||
{
|
||||
class StealingHandler
|
||||
{
|
||||
private static Type[] SpecialItemList =
|
||||
{
|
||||
typeof(SeedOfLife),
|
||||
typeof(BalmOfStrength),
|
||||
typeof(BalmOfWisdom),
|
||||
typeof(BalmOfSwiftness),
|
||||
typeof(ManaDraught),
|
||||
typeof(BalmOfProtection),
|
||||
typeof(StoneSkinLotion),
|
||||
typeof(GemOfSalvation),
|
||||
typeof(LifeShieldLotion),
|
||||
typeof(SmugglersLantern),
|
||||
typeof(SmugglersToolBox)
|
||||
};
|
||||
|
||||
public static void HandleSteal(BaseCreature from, PlayerMobile thief)
|
||||
{
|
||||
if (from.HasBeenStolen)
|
||||
{
|
||||
thief.SendLocalizedMessage(1094948); //That creature has already been stolen from. There is nothing left to steal.
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.Controlled || from.Summoned)
|
||||
{
|
||||
thief.SendLocalizedMessage(502708); //You can't steal from this.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CheckLocation(thief, from))
|
||||
return;
|
||||
|
||||
double stealing = thief.Skills.Stealing.Value;
|
||||
|
||||
if (stealing < 100)
|
||||
return;
|
||||
|
||||
int chance = GetStealingChance(thief, from, stealing);
|
||||
|
||||
if ((Utility.Random(100)+1) <= chance)
|
||||
{
|
||||
thief.SendLocalizedMessage(1094947);//You successfully steal a special item from the creature!
|
||||
|
||||
Item item;
|
||||
|
||||
if (from is ExodusZealot)
|
||||
{
|
||||
item = Activator.CreateInstance(ExodusChest.RituelItem[Utility.Random(ExodusChest.RituelItem.Length)]) as Item;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = Activator.CreateInstance(SpecialItemList[Utility.Random(SpecialItemList.Length - 2)]) as Item;
|
||||
}
|
||||
|
||||
thief.AddToBackpack(item);
|
||||
}
|
||||
|
||||
from.HasBeenStolen = true;
|
||||
}
|
||||
|
||||
public static void HandleSmugglersEdgeSteal(BaseCreature from, PlayerMobile thief)
|
||||
{
|
||||
if (from.HasBeenStolen || !CheckLocation(thief, from))
|
||||
return;
|
||||
|
||||
if (0.05 > Utility.RandomDouble())
|
||||
{
|
||||
double tempSkill = Utility.RandomMinMax(80, 110);
|
||||
double realSkill = thief.Skills[SkillName.Stealing].Value;
|
||||
|
||||
if (realSkill > tempSkill)
|
||||
tempSkill = realSkill;
|
||||
|
||||
if (tempSkill > 100)
|
||||
{
|
||||
int chance = GetStealingChance(thief, from, tempSkill);
|
||||
|
||||
if (realSkill <= 109.9)
|
||||
chance += 1;
|
||||
else if (realSkill <= 114.9)
|
||||
chance += 2;
|
||||
else if (realSkill >= 115.0)
|
||||
chance += 3;
|
||||
|
||||
if (chance >= Utility.Random(100))
|
||||
{
|
||||
Item item = Activator.CreateInstance(SpecialItemList[Utility.Random(SpecialItemList.Length)]) as Item;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
thief.AddToBackpack(item);
|
||||
|
||||
thief.SendLocalizedMessage(1094947);//You successfully steal a special item from the creature!
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if (pack != null && pack.Items.Count > 0)
|
||||
{
|
||||
int randomIndex = Utility.Random(pack.Items.Count);
|
||||
|
||||
Item stolen = TryStealItem(pack.Items[randomIndex], tempSkill);
|
||||
|
||||
if (stolen != null)
|
||||
{
|
||||
thief.AddToBackpack(stolen);
|
||||
|
||||
thief.SendLocalizedMessage(502724); // You succesfully steal the item.
|
||||
}
|
||||
else
|
||||
{
|
||||
thief.SendLocalizedMessage(502723); // You fail to steal the item.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from.HasBeenStolen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckLocation(Mobile thief, Mobile from)
|
||||
{
|
||||
if (!((thief.Map == Map.Felucca && thief.Region is DungeonRegion) || thief.Region is ChampionSpawnRegion || from is ExodusZealot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int GetStealingChance(Mobile thief, BaseCreature from, double stealing)
|
||||
{
|
||||
int fame = from.Fame;
|
||||
|
||||
fame = Math.Max(1, fame);
|
||||
fame = Math.Min(30000, fame);
|
||||
|
||||
int chance = 0;
|
||||
|
||||
if (stealing == 120)
|
||||
chance += 10;
|
||||
else if (stealing >= 110.1)
|
||||
chance += 8;
|
||||
else if (stealing >= 100.1)
|
||||
chance += 5;
|
||||
else if (stealing == 100)
|
||||
chance += 2;
|
||||
|
||||
int level = (int)(40.0 / 29999.0 * fame - 40.0 / 29999.0);
|
||||
|
||||
if (level >= 40)
|
||||
chance += 5;
|
||||
else if (level >= 35)
|
||||
chance += 3;
|
||||
else if (level >= 30)
|
||||
chance += 2;
|
||||
else if (level >= 25)
|
||||
chance += 1;
|
||||
|
||||
return chance;
|
||||
}
|
||||
|
||||
private static Item TryStealItem(Item toSteal, double skill)
|
||||
{
|
||||
Item stolen = null;
|
||||
double w = toSteal.Weight + toSteal.TotalWeight;
|
||||
|
||||
if (w <= 10)
|
||||
{
|
||||
if (toSteal.Stackable && toSteal.Amount > 1)
|
||||
{
|
||||
int maxAmount = (int)((skill / 10.0) / toSteal.Weight);
|
||||
|
||||
if (maxAmount < 1)
|
||||
{
|
||||
maxAmount = 1;
|
||||
}
|
||||
else if (maxAmount > toSteal.Amount)
|
||||
{
|
||||
maxAmount = toSteal.Amount;
|
||||
}
|
||||
|
||||
int amount = Utility.RandomMinMax(1, maxAmount);
|
||||
|
||||
if (amount >= toSteal.Amount)
|
||||
{
|
||||
int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount);
|
||||
pileWeight *= 10;
|
||||
|
||||
double chance = (skill - (pileWeight - 22.5)) / ((pileWeight + 27.5) - (pileWeight - 22.5));
|
||||
|
||||
if (chance >= Utility.RandomDouble())
|
||||
{
|
||||
stolen = toSteal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount);
|
||||
pileWeight *= 10;
|
||||
|
||||
double chance = (skill - (pileWeight - 22.5)) / ((pileWeight + 27.5) - (pileWeight - 22.5));
|
||||
|
||||
if (chance >= Utility.RandomDouble())
|
||||
{
|
||||
stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount);
|
||||
|
||||
if (stolen == null)
|
||||
{
|
||||
stolen = toSteal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iw = (int)Math.Ceiling(w);
|
||||
iw *= 10;
|
||||
|
||||
double chance = (skill - (iw - 22.5)) / ((iw + 27.5) - (iw - 22.5));
|
||||
|
||||
if (chance >= Utility.RandomDouble())
|
||||
{
|
||||
stolen = toSteal;
|
||||
}
|
||||
}
|
||||
|
||||
if (stolen != null)
|
||||
{
|
||||
ItemFlags.SetTaken(stolen, true);
|
||||
ItemFlags.SetStealable(stolen, false);
|
||||
stolen.Movable = true;
|
||||
}
|
||||
}
|
||||
|
||||
return stolen;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user