RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

New proble trying to set KP evolution dragon to dont attack players.

rome1982

Sorceror
Hello all,thanks in advance for some help,im trying to get evo dragon (not xantos) to dont attack players.The code i use is:

Code:
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness )
        {             
         if (target is PlayerMobile) //Check if it's a player. Otherwise, it will attack.
        {
        return false;
        }
              return base.CanBeHarmful( target, message, ignoreOurBlessedness );
        }

The crash is a client crash not RunUo server,when somebody say "all kill" and target some enemie.
Thank you all.
 

pooka01

Sorceror
just: return (target != null && !target.Deleted && target is PlayerMobile) ? false : base.CanBeHarmful( target, message, ignoreOurBlessedness );
you need to check if the target exists.

if you don't understand that code structure just ask me for clarification, i love when codes are compacted xD
 

pooka01

Sorceror
this
return (target != null && !target.Deleted && target is PlayerMobile) ? false : base.CanBeHarmful( target, message, ignoreOurBlessedness );

is equal to this

if (target != null && !target.Deleted && target is PlayerMobile)
return false;
else
return base.CanBeHarmful( target, message, ignoreOurBlessedness );

it is just more compact, as:

a thing is red,
boolthing = (if that thing is red) ? true : false;
 
Top