Resource icon

Edits to make NPC Vendors and Town Criers Killable

This took me a bit to figure it out but, I figured out how to successfully without an issue change NPC Vendors and Towncriers to be vulnerable and able to be attacked. I decided player vendors shouldn't be attacked as some players spend a lot of gold keeping their vendors up. With that said - Here is the changes needed to make your NPC Vendors and Town Criers killable.

(And the reason I had to make these changes in case someone asks is because changing it in BaseVendor didn't work and I wanted a solid work around that works.)

In BaseVendor find
C#:
public override bool IsInvulnerable { get { return true; } }
Change it to
C#:
public override bool IsInvulnerable { get { return false; } }


In BaseCreature
find

C#:
        public override bool CanBeHarmful(IDamageable damageable, bool message, bool ignoreOurBlessedness)
        {
            Mobile target = damageable as Mobile;

            if (RecentSetControl && GetMaster() == target)
            {
                return false;
            }

            if (target is BaseFactionGuard)
            {
                return false;
            }

            if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier)
            {
                return false;
            }

            if (damageable is IDamageableItem && !((IDamageableItem)damageable).CanDamage)
            {
                return false;
            }

Change to:
C#:
public override bool CanBeHarmful(IDamageable damageable, bool message, bool ignoreOurBlessedness)
        {
            Mobile target = damageable as Mobile;

            if (RecentSetControl && GetMaster() == target)
            {
                return false;
            }

            if (target is BaseFactionGuard)
            {
                return false;
            }

            if ((target is PlayerVendor))
            {
                false;
            }

            if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is TownCrier)
            {
                return true;
            }


            if (damageable is IDamageableItem && !((IDamageableItem)damageable).CanDamage)
            {
                return false;
            }

            return base.CanBeHarmful(damageable, message, ignoreOurBlessedness);
        }


Also find in base creature

C#:
public override bool CanBeHarmful(IDamageable damageable, bool message, bool ignoreOurBlessedness)
        {
            Mobile target = damageable as Mobile;
            if (RecentSetControl && GetMaster() == target)
            {
                return false;
            }
            if (target is BaseFactionGuard)
            {
                return false;
            }
            if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier)
            {
                return false;
            }
            if (damageable is IDamageableItem && !((IDamageableItem)damageable).CanDamage)
            {
                return false;
            }
            return base.CanBeHarmful(damageable, message, ignoreOurBlessedness);
        }
        public override bool CanBeRenamedBy(Mobile from)
        {
            bool ret = base.CanBeRenamedBy(from);
            if (Controlled && from == ControlMaster && !from.Region.IsPartOf<Jail>())
            {
                ret = true;
            }
            return ret;
        }

Change to:
C#:
public override bool CanBeHarmful(IDamageable damageable, bool message, bool ignoreOurBlessedness)
        {
            Mobile target = damageable as Mobile;

            if (RecentSetControl && GetMaster() == target)
            {
                return false;
            }

            if (target is BaseFactionGuard)
            {
                return false;
            }

            if ((target is PlayerVendor))
            {
                false;
            }

            if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is TownCrier)
            {
                return true;
            }


            if (damageable is IDamageableItem && !((IDamageableItem)damageable).CanDamage)
            {
                return false;
            }

            return base.CanBeHarmful(damageable, message, ignoreOurBlessedness);
        }

        public override bool CanBeRenamedBy(Mobile from)
        {
            bool ret = base.CanBeRenamedBy(from);

            if (Controlled && from == ControlMaster && !from.Region.IsPartOf<Jail>())
            {
                ret = true;
            }

            return ret;
        }

Also find in Base Creature
C#:
public override bool CanBeDamaged()
        {
            if (IsDeadPet || IsInvulnerable)
            {
                return false;
            }

            return base.CanBeDamaged();
        }

Change to:

C#:
public override bool CanBeDamaged()
        {
            if (IsDeadPet || IsInvulnerable)
            {
                return false;
            }
            if (target is BaseVendor || target is TownCrier)
            {
                return true;
            }

            return base.CanBeDamaged();
        }

Change to
In Player Mobile Find:

C#:
    public override bool CanBeHarmful(IDamageable damageable, bool message, bool ignoreOurBlessedness)
        {
            Mobile target = damageable as Mobile;

            if (m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null))
            {
                return false;
            }

            #region Mondain's Legacy
            if (Peaced)
            {
                //!+ TODO: message
                return false;
            }
            #endregion

Change to:

C#:
public override bool CanBeHarmful(IDamageable damageable, bool message, bool ignoreOurBlessedness)
        {
            Mobile target = damageable as Mobile;

            if (m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null))
            {
                return false;
            }
            if (target is BaseVendor)
            {
                return true;
            }
            if ( target is TownCrier)
            {
                return true;
            }

            #region Mondain's Legacy
            if (Peaced)
            {
                //!+ TODO: message
                return false;
            }
            #endregion
  • Like
Reactions: Sareus
Author
TheArt
Views
83
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from TheArt