Help with preventing PlayerMobiles from engaging in combat with BaseHires

Archaaz

Squire
Sep 17, 2016
225
74
28
I want to prevent PlayerMobiles from being able to engage in combat with BaseHires in their employ, and was hoping someone might point me to the right script and method.

I made BaseHires a bit more powerful (and hopefully useful), and want to prevent characters from using Hireables to train combat skills, resist, etc.

Thanks in advance for any help.
 

Falkor

Squire
Apr 11, 2018
362
127
43
wpshard.com
Shard Name
Whispering Pines
You need to edit /misc/Notoriety.cs

Find this section:
Code:
public static bool Mobile_AllowHarmful( Mobile from, Mobile target )
and add something like:

Code:
if( from is PlayerMobile && target is BaseHire)
            {
            from.SendMessage( 33, "You cannot attack your hire!" );    
            return false; 
            }
 
  • Like
Reactions: Archaaz

Falkor

Squire
Apr 11, 2018
362
127
43
wpshard.com
Shard Name
Whispering Pines
It might need a little more polish in the logic department, like

Code:
if( from is PlayerMobile && target is BaseHire  && (target.ControlMaster == from) )
to make sure it's the hire's controller doing the attacking and not another player. That's off the top of my head -- if it doesn't work, it should get you close.

There are other checks that can be done, like in case another player attacks a basehire. Just remember the checks are done in order they're in the script. The logic here can get pretty involved!
 
  • Like
Reactions: Archaaz

Archaaz

Squire
Sep 17, 2016
225
74
28
Thanks! Yes, I will have to fiddle with it once I decide exactly how I want it to work, but now know which script and method to use. Many thanks again! I will likely modify BaseAI as well to disallow having BaseHires attack blue PlayerMobiles or BaseCreatures.