public virtual TimeSpan BondingDelay { get { return TimeSpan.FromDays(7.0); } }
public virtual TimeSpan BondingAbandonDelay { get { return TimeSpan.FromDays(1.0); } }
if (c.IsDeadPet)
{
Mobile owner = c.ControlMaster;
if (!c.IsStabled &&
(owner == null || owner.Deleted || owner.Map != c.Map || !owner.InRange(c, 12) || !c.CanSee(owner) ||
!c.InLOS(owner)))
{
if (c.OwnerAbandonTime == DateTime.MinValue)
{
c.OwnerAbandonTime = DateTime.UtcNow;
}
else if ((c.OwnerAbandonTime + c.BondingAbandonDelay) <= DateTime.UtcNow)
{
toRemove.Add(c);
}
}
else
{
c.OwnerAbandonTime = DateTime.MinValue;
}
}
else if (c.Controlled && c.Commandable)
{
c.OwnerAbandonTime = DateTime.MinValue;
if (c.Map != Map.Internal)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 10);
if (c.Loyalty < (BaseCreature.MaxLoyalty / 10))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
if (c.Loyalty <= 0)
{
toRelease.Add(c);
}
}
}
if (c.Map != Map.Internal)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
if (c.Loyalty < (BaseCreature.MaxLoyalty / 25))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
if (c.Loyalty <= 0)
{
toRelease.Add(c);
}
}
if (c.IsBonded)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 25))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 10);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 10))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
}
if (c.IsBonded)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 10);
}
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 10))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
else if (c.Controlled && c.Commandable)
{
c.OwnerAbandonTime = DateTime.MinValue;
if (c.Map != Map.Internal)
{
if (c.IsBonded)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 48);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 48))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 24);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 24))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
if (c.Loyalty <= 0)
//toRelease.Add(c);
toRemove.Add(c);
}
}
// added lines to check if a wild creature in a house region has to be removed or not
if ( /*(!c.Controlled && !c.IsStabled && ( c.Region.IsPartOf( typeof( HouseRegion ) ) && c.CanBeDamaged()) || */(c.RemoveIfUntamed && c.Spawner == null))
{
c.RemoveStep++;
if (c.RemoveStep >= 20)
toRemove.Add(c);
}
else
{
c.RemoveStep = 0;
}
/// edit: homerange spawns
if (c.Map != Map.Internal && c.Spawner != null)
{
if (!c.Controlled && c.LastOwner == null && !c.InRange(((Item)c.Spawner).Location, c.Spawner.HomeRange))
{
if (c.Spawner is XmlSpawner)
{
if (((XmlSpawner)c.Spawner).WayPoint != null)
continue;
}
toMove.Add(c);
}
}
}
if (c.IsBonded)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 50);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 50))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
if (c.Loyalty <= 0)
{
toRelease.Add(c);
}
}
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 25))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
if (c.Loyalty <= 0)
{
toRemove.Add(c);
}
}
}
protected override void OnTick()
{
if (DateTime.Now >= m_NextHourlyCheck)
m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours(1.0);
else
return;
List<BaseCreature> toRelease = new List<BaseCreature>();
// added array for wild creatures in house regions to be removed
List<BaseCreature> toRemove = new List<BaseCreature>();
// Taran: Added array for untamed mobiles moving back to their spawnpoint
List<BaseCreature> toMove = new List<BaseCreature>();
foreach (Mobile m in World.Mobiles.Values)
{
if (m is BaseMount && ((BaseMount)m).Rider != null)
{
((BaseCreature)m).OwnerAbandonTime = DateTime.MinValue;
continue;
}
if (m is BaseCreature)
{
BaseCreature c = (BaseCreature)m;
if (c.IsDeadPet)
{
Mobile owner = c.ControlMaster;
if (!c.IsStabled && (owner == null || owner.Deleted || owner.Map != c.Map || !owner.InRange(c, 12) || !c.CanSee(owner) || !c.InLOS(owner)))
{
if (c.OwnerAbandonTime == DateTime.MinValue)
c.OwnerAbandonTime = DateTime.Now;
else if ((c.OwnerAbandonTime + c.BondingAbandonDelay) <= DateTime.Now)
toRemove.Add(c);
}
else
{
c.OwnerAbandonTime = DateTime.MinValue;
}
}
else if (c.Controlled && c.Commandable)
{
c.OwnerAbandonTime = DateTime.MinValue;
if (c.Map != Map.Internal)
{
if (c.IsBonded) //CRIATURAS LEALES DEJAN DE SERLO TRAS DOS DIAS SIN SER RESUCITADAS
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 50);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 50))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
if (c.Loyalty <= 0)
{
toRelease.Add(c);
}
}
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 25))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
if (c.Loyalty <= 0)
{
toRemove.Add(c);
}
}
// added lines to check if a wild creature in a house region has to be removed or not
if ( /*(!c.Controlled && !c.IsStabled && ( c.Region.IsPartOf( typeof( HouseRegion ) ) && c.CanBeDamaged()) || */(c.RemoveIfUntamed && c.Spawner == null))
{
c.RemoveStep++;
if (c.RemoveStep >= 20)
toRemove.Add(c);
}
else
{
c.RemoveStep = 0;
}
/* Taran: Added check to see if any mobile that has a spawner is further away than *
* their spawners homerange. In that case the mobile teleports back to the spawner *
* again. *
* */
if (c.Map != Map.Internal && c.Spawner != null)
{
if (!c.Controlled && c.LastOwner == null && !c.InRange(((Item)c.Spawner).Location, c.Spawner.HomeRange))
{
if (c.Spawner is XmlSpawner)
{
if (((XmlSpawner)c.Spawner).WayPoint != null) //Mobiles with waypoints will not be moved
continue;
}
toMove.Add(c);
}
}
}
}
foreach (BaseCreature c in toRelease)
{
c.Say(1043255, c.Name); // ~1_NAME~ appears to have decided that is better off without a master!
c.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully Happy
c.IsBonded = false;
c.BondingBegin = DateTime.MinValue;
c.OwnerAbandonTime = DateTime.MinValue;
c.ControlTarget = null;
//c.ControlOrder = OrderType.Release;
c.AIObject.DoOrderRelease(); // this will prevent no release of creatures left alone with AI disabled (and consequent bug of Followers)
c.DropBackpack();
}
//// added code to handle removing of wild creatures in house regions
//foreach ( BaseCreature c in toRemove )
//{
// c.Delete();
//}
foreach (BaseCreature c in toMove)
{
Item spawner = c.Spawner as Item;
Point3D from = c.Location;
if (spawner != null)
{
Point3D to = spawner.Location;
Effects.SendLocationParticles(EffectItem.Create(from, c.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
Effects.SendLocationParticles(EffectItem.Create(to, spawner.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
c.MoveToWorld(to, spawner.Map);
}
c.PlaySound(0x1FE);
}
}
}
}
}
}
}
//bonded pets edit 5/11/2016
Me too! very easy ,intuitive and lightHeh, I use Notepad++. Note quite THAT obvious, but the tab indicator runs off either into nowhere or into text if you have it indented corectly and make a mistake
protected override void OnTick()
{
if (DateTime.Now >= m_NextHourlyCheck)
m_NextHourlyCheck = DateTime.Now + TimeSpan.FromHours(1.0);
else
return;
List<BaseCreature> toRelease = new List<BaseCreature>();
// added array for wild creatures in house regions to be removed
List<BaseCreature> toRemove = new List<BaseCreature>();
// : Added array for untamed mobiles moving back to their spawnpoint
List<BaseCreature> toMove = new List<BaseCreature>();
foreach (Mobile m in World.Mobiles.Values)
{
if (m is BaseMount && ((BaseMount)m).Rider != null)
{
((BaseCreature)m).OwnerAbandonTime = DateTime.MinValue;
continue;
}
if (m is BaseCreature)
{
BaseCreature c = (BaseCreature)m;
if (c.IsDeadPet)
{
Mobile owner = c.ControlMaster;
if (!c.IsStabled && (owner == null || owner.Deleted || owner.Map != c.Map || !owner.InRange(c, 12) || !c.CanSee(owner) || !c.InLOS(owner)))
{
if (c.OwnerAbandonTime == DateTime.MinValue)
c.OwnerAbandonTime = DateTime.Now;
else if ((c.OwnerAbandonTime + c.BondingAbandonDelay) <= DateTime.Now)
toRemove.Add(c);
}
else
{
c.OwnerAbandonTime = DateTime.MinValue;
}
}
else if (c.Controlled && c.Commandable)
{
c.OwnerAbandonTime = DateTime.MinValue;
if (c.Map != Map.Internal)
{
if (c.IsBonded)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 50);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 50))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
if (c.Loyalty <= 0)
{
toRelease.Add(c);
}
}
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 25))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
if (c.Loyalty <= 0)
{
toRemove.Add(c);
}
}
// added lines to check if a wild creature in a house region has to be removed or not
if ( /*(!c.Controlled && !c.IsStabled && ( c.Region.IsPartOf( typeof( HouseRegion ) ) && c.CanBeDamaged()) || */(c.RemoveIfUntamed && c.Spawner == null))
{
c.RemoveStep++;
if (c.RemoveStep >= 20)
toRemove.Add(c);
}
else
{
c.RemoveStep = 0;
}
/* check to see if any mobile that has a spawner is further away than *
* their spawners homerange. In that case the mobile teleports back to the spawner *
* again. *
* */
if (c.Map != Map.Internal && c.Spawner != null)
{
if (!c.Controlled && c.LastOwner == null && !c.InRange(((Item)c.Spawner).Location, c.Spawner.HomeRange))
{
if (c.Spawner is XmlSpawner)
{
if (((XmlSpawner)c.Spawner).WayPoint != null) //Mobiles with waypoints will not be moved
continue;
}
toMove.Add(c);
}
}
}
}
}
}
foreach (BaseCreature c in toRelease)
{
c.Say(1043255, c.Name); // ~1_NAME~ appears to have decided that is better off without a master!
c.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully Happy
c.IsBonded = false;
c.BondingBegin = DateTime.MinValue;
c.OwnerAbandonTime = DateTime.MinValue;
c.ControlTarget = null;
//c.ControlOrder = OrderType.Release;
c.AIObject.DoOrderRelease(); // this will prevent no release of creatures left alone with AI disabled (and consequent bug of Followers)
c.DropBackpack();
}
//// added code to handle removing of wild creatures in house regions
//foreach ( BaseCreature c in toRemove )
//{
// c.Delete();
//}
foreach (BaseCreature c in toMove)
{
Item spawner = c.Spawner as Item;
Point3D from = c.Location;
if (spawner != null)
{
Point3D to = spawner.Location;
Effects.SendLocationParticles(EffectItem.Create(from, c.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
Effects.SendLocationParticles(EffectItem.Create(to, spawner.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
c.MoveToWorld(to, spawner.Map);
}
c.PlaySound(0x1FE);
}
}
}
}
}
[*]else
[*] {
[*] c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
[*] if (c.Loyalty <= (BaseCreature.MaxLoyalty / 25))
[*] {
[*] c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
[*] c.PlaySound(c.GetIdleSound());
[*] if (c.Loyalty <= 0)
[*] {
[*] toRemove.Add(c);
[*] }
[*] }
[*] //// added code to handle removing of wild creatures in house regions
[*] //foreach ( BaseCreature c in toRemove )
[*] //{
[*] // c.Delete();
[*] //}
if (c.Map != Map.Internal)
{
if (c.IsBonded)
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 50);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 50))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
}
else
{
c.Loyalty -= (BaseCreature.MaxLoyalty / 25);
if (c.Loyalty <= (BaseCreature.MaxLoyalty / 25))
{
c.Say(1043270, c.Name); // * ~1_NAME~ looks around desperately *
c.PlaySound(c.GetIdleSound());
}
if (c.Loyalty <= 0)
toRelease.Add(c);
//toRemove.Add(c);
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.