I do not want the pet to attack the player,or that the pet can't do harm to the player.
The injury behavior includes the common attack,the magic, weaponability.
How should I modify it? thanks
 
You want NO pet to be able to damage ANY player, or just your own pet to not damage you?
 
Anyway, add something like this. If this method already exists, just place one of these "if" statements near the top of the method.

Code:
        //Somewhere in BaseCreature.cs
        public override bool CanBeHarmful(Mobile to)
        {
            //use this if you want to prevent harm to anyone by pets
            if (this.Controlled) return false;
          
            //use this if you want to prevent a pet from harming it's owner
            if (this.Controlled && this.Owner != null && this.Owner == to) return false;
        }

You might have to substitute ControlMaster for Owner, not sure. This should get you started.
 
Anyway, add something like this. If this method already exists, just place one of these "if" statements near the top of the method.

Code:
        //Somewhere in BaseCreature.cs
        public override bool CanBeHarmful(Mobile to)
        {
            //use this if you want to prevent harm to anyone by pets
            if (this.Controlled) return false;
         
            //use this if you want to prevent a pet from harming it's owner
            if (this.Controlled && this.Owner != null && this.Owner == to) return false;
        }

You might have to substitute ControlMaster for Owner, not sure. This should get you started.
Thanks Lokai.I'll test it later.
[doublepost=1516919631][/doublepost]
Code:
public override bool CanBeHarmful(Mobile target, bool message, bool ignoreOurBlessedness)
        {
            if (target is BaseFactionGuard)
            {
                return false;
            }
           
            if (this.Controlled && target.Player)
            {
                return false;
            }

            if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier)
            {
                if (message)
                {
                    if (target.Title == null)
                    {
                        SendMessage("{0} the vendor cannot be harmed.", target.Name);
                    }
                    else
                    {
                        SendMessage("{0} {1} cannot be harmed.", target.Name, target.Title);
                    }
                }

                return false;
            }

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

I got the effect I wanted。Thanks Lokai.
 

Attachments

  • QQ截图20180126063029.jpg
    QQ截图20180126063029.jpg
    34.6 KB · Views: 21
Back