Kamras
Member
This is my OnDamage section from basecreature.cs .
Desired Results. Equipment reaches X Level. Once X Level is reached, the code does a check against the players current level. If players current level is lower then the equipment level , equipment will not gain anymore exp. If players level is higher then the equipment then the equipment will gain exp.
So far the below code works as intended with one flaw. Once a layer of equipment reaches it's max level (first sequence in order from top to bottom, two handed sword, one handed sword) all the layers below that code does not gain exp. So ultimately the check comes in, and once equipment reaching max level is detected everything else below is ignored.
I'm sure this is something simple and my return method is wrong... I just cant put my finger on it.
Desired Results. Equipment reaches X Level. Once X Level is reached, the code does a check against the players current level. If players current level is lower then the equipment level , equipment will not gain anymore exp. If players level is higher then the equipment then the equipment will gain exp.
So far the below code works as intended with one flaw. Once a layer of equipment reaches it's max level (first sequence in order from top to bottom, two handed sword, one handed sword) all the layers below that code does not gain exp. So ultimately the check comes in, and once equipment reaching max level is detected everything else below is ignored.
I'm sure this is something simple and my return method is wrong... I just cant put my finger on it.
Code:
public override void OnDamage(int amount, Mobile from, bool willKill)
{
if (BardPacified && (HitsMax - Hits) * 0.001 > Utility.RandomDouble())
{
Unpacify();
}
int disruptThreshold;
//NPCs can use bandages too!
if (!Core.AOS)
{
disruptThreshold = 0;
}
else if (from != null && from.Player)
{
disruptThreshold = 18;
}
else
{
disruptThreshold = 25;
}
if (amount > disruptThreshold)
{
BandageContext c = BandageContext.GetContext(this);
if (c != null)
{
c.Slip();
}
}
if (Confidence.IsRegenerating(this))
{
Confidence.StopRegenerating(this);
}
WeightOverloading.FatigueOnDamage(this, amount);
InhumanSpeech speechType = SpeechType;
if (speechType != null && !willKill)
{
speechType.OnDamage(this, amount);
}
if (m_ReceivedHonorContext != null)
{
m_ReceivedHonorContext.OnTargetDamaged(from, amount);
}
//Level System
if (willKill && En.Enabled)
LevelHandler.Set(from, this);
//End Level System
if (!willKill)
{
if (CanBeDistracted && ControlOrder == OrderType.Follow)
{
CheckDistracted(from);
}
}
else if (from is PlayerMobile)
{
Timer.DelayCall(TimeSpan.FromSeconds(10), ((PlayerMobile)@from).RecoverAmmo);
}
#region XmlSpawner
if (!Summoned && willKill && from != null)
{
PlayerMobile pm = (PlayerMobile)from;
//////CUSTOMIZATION - Alfheim Online!//////
//Find Item on Layer and Name it
Item bwtwohanded = from.FindItemOnLayer(Layer.TwoHanded);//two handed or shield
Item bwonehanded = from.FindItemOnLayer(Layer.FirstValid); //One handed Sword
Item baHelm = from.FindItemOnLayer(Layer.Helm); //helm
Item baGloves = from.FindItemOnLayer(Layer.Gloves);//Gloves
Item baNeck = from.FindItemOnLayer(Layer.Neck);
Item baInntertorso = from.FindItemOnLayer(Layer.InnerTorso);
Item bamIddletorso = from.FindItemOnLayer(Layer.MiddleTorso);
Item baOutertorso = from.FindItemOnLayer(Layer.OuterTorso);
Item baBracelet = from.FindItemOnLayer(Layer.Bracelet);
Item baArms = from.FindItemOnLayer(Layer.Arms);
Item baPants = from.FindItemOnLayer(Layer.Pants);
//Find XmlLevelItem on equipment and name it
XmlLevelItem bwtwohandedlevel = (XmlLevelItem)XmlAttach.FindAttachment(bwtwohanded, typeof(XmlLevelItem));
XmlLevelItem bwonehandedlevel = (XmlLevelItem)XmlAttach.FindAttachment(bwonehanded, typeof(XmlLevelItem));
XmlLevelItem baHelmLevel = (XmlLevelItem)XmlAttach.FindAttachment(baHelm, typeof(XmlLevelItem));
XmlLevelItem baGlovesLevel = (XmlLevelItem)XmlAttach.FindAttachment(baGloves, typeof(XmlLevelItem));
XmlLevelItem baNeckLevel = (XmlLevelItem)XmlAttach.FindAttachment(baNeck, typeof(XmlLevelItem));
XmlLevelItem baInntertorsoLevel = (XmlLevelItem)XmlAttach.FindAttachment(baInntertorso, typeof(XmlLevelItem));
XmlLevelItem bamIddletorsoLevel = (XmlLevelItem)XmlAttach.FindAttachment(bamIddletorso, typeof(XmlLevelItem));
XmlLevelItem baOutertorsoLevel = (XmlLevelItem)XmlAttach.FindAttachment(baOutertorso, typeof(XmlLevelItem));
XmlLevelItem baBraceletLevel = (XmlLevelItem)XmlAttach.FindAttachment(baBracelet, typeof(XmlLevelItem));
XmlLevelItem baArmsLevel = (XmlLevelItem)XmlAttach.FindAttachment(baArms, typeof(XmlLevelItem));
XmlLevelItem baPantsLevel = (XmlLevelItem)XmlAttach.FindAttachment(baPants, typeof(XmlLevelItem));
//Check for Weapon and XML Level Item to apply check for EXP
if (bwtwohanded != null )
{
if (bwtwohandedlevel != null && pm.Levell > bwtwohandedlevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (bwonehanded != null )
{
if (bwonehandedlevel != null && pm.Levell > bwonehandedlevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baHelm != null )
{
if (baHelmLevel != null && pm.Levell > baHelmLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baGloves != null )
{
if (baGlovesLevel != null && pm.Levell > baGlovesLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baNeck != null )
{
if (baNeckLevel != null && pm.Levell > baNeckLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baInntertorso != null )
{
if (baInntertorsoLevel != null && pm.Levell > baInntertorsoLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (bamIddletorso != null )
{
if (bamIddletorsoLevel != null && pm.Levell > bamIddletorsoLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baOutertorso != null )
{
if (baOutertorsoLevel != null && pm.Levell > baOutertorsoLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baBracelet != null )
{
if (baBraceletLevel != null && pm.Levell > baBraceletLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baArms != null )
{
if (baArmsLevel != null && pm.Levell > baArmsLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
if (baPants != null )
{
if (baPantsLevel != null && pm.Levell > baPantsLevel.Level )
{
LevelItemManager.CheckItems(from, this);
}
else
return;
}
// LevelItemManager.CheckItems(from, this);
}
#endregion
base.OnDamage(amount, from, willKill);
}