Can someone point me in the right direction maybe? I am having issues with mercs and pets with other AoE skills. They are hitting each other and/or the control master. I would really like to figure out where this is and disable this "friendly fire" for my server. Thanks guys.
 
The below should take care of hitting master and master's pets. You should look into the ValidIndirectTarget() stuff too. Oh, and make sure that you CanDoHarmful() to the target!

Run this through when checking targets in range:

if (target == GetMaster() || (target is BaseCreature && ((BaseCreature)target).GetMaster() == GetMaster()))
{
continue;
}
 
Should I edit this in base creature? Just trying to figure out where they all get their targeting parameters from I guess. Thanks for the reply and the information you have provided so far.

***EDIT***

Code:
public static bool ValidIndirectTarget(Mobile from, Mobile to)
        {
            if (from == to)
                return true;

            if (to.Hidden && to.AccessLevel > from.AccessLevel)
                return false;

            #region Dueling
            PlayerMobile pmFrom = from as PlayerMobile;
            PlayerMobile pmTarg = to as PlayerMobile;

            if (pmFrom == null && from is BaseCreature)
            {
                BaseCreature bcFrom = (BaseCreature)from;

                if (bcFrom.Summoned)
                    pmFrom = bcFrom.SummonMaster as PlayerMobile;
            }

            if (pmTarg == null && to is BaseCreature)
            {
                BaseCreature bcTarg = (BaseCreature)to;

                if (bcTarg.Summoned)
                    pmTarg = bcTarg.SummonMaster as PlayerMobile;
            }

            if (pmFrom != null && pmTarg != null)
            {
                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null)
                    return (pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant);
            }
            #endregion

            Guild fromGuild = GetGuildFor(from);
            Guild toGuild = GetGuildFor(to);

            if (fromGuild != null && toGuild != null && (fromGuild == toGuild || fromGuild.IsAlly(toGuild)))
                return false;

            Party p = Party.Get(from);

            if (p != null && p.Contains(to))
                return false;

            if (to is BaseCreature)
            {
                BaseCreature c = (BaseCreature)to;

                if (c.Controlled || c.Summoned)
                {
                    if (c.ControlMaster == from || c.SummonMaster == from)
                        return false;

                    if (p != null && (p.Contains(c.ControlMaster) || p.Contains(c.SummonMaster)))
                        return false;
                }
            }

            if (from is BaseCreature)
            {
                BaseCreature c = (BaseCreature)from;

                if (c.Controlled || c.Summoned)
                {
                    if (c.ControlMaster == to || c.SummonMaster == to)
                        return false;

                    p = Party.Get(to);

                    if (p != null && (p.Contains(c.ControlMaster) || p.Contains(c.SummonMaster)))
                        return false;
                }
            }

            // Non-enemy monsters will no longer flag area spells on each other
            if (from is BaseCreature && to is BaseCreature)
            {
                BaseCreature fromBC = (BaseCreature)from;
                BaseCreature toBC = (BaseCreature)to;

                if (fromBC.GetMaster() is BaseCreature)
                    fromBC = fromBC.GetMaster() as BaseCreature;

                if (toBC.GetMaster() is BaseCreature)
                    toBC = toBC.GetMaster() as BaseCreature;

                if (toBC.IsEnemy(fromBC))   //Natural Enemies
                    return true;

                // All involved are monsters- no damage. If falls through this statement, normal noto rules apply
                if (!toBC.Controlled && !toBC.Summoned && !fromBC.Controlled && !fromBC.Summoned) //All involved are monsters- no damage
                    return false;
            }

            if (to is BaseCreature && !((BaseCreature)to).Controlled && ((BaseCreature)to).InitialInnocent)
                return true;

            int noto = Notoriety.Compute(from, to);

            return (noto != Notoriety.Innocent || from.Kills >= 5);
        }
This code seems to say that merc weapons should not be hitting allies.

Code:
public virtual void DrainLife()
        {
            List<Mobile> list = new List<Mobile>();

            foreach (Mobile m in this.GetMobilesInRange(2))
            {
                if (m == this || !CanBeHarmful(m))
                    continue;

                if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team))
                    list.Add(m);
                else if (m.Player)
                    list.Add(m);
            }

            foreach (Mobile m in list)
            {
                DoHarmful(m);

                m.FixedParticles(0x374A, 10, 15, 5013, 0x496, 0, EffectLayer.Waist);
                m.PlaySound(0x231);

                m.SendMessage("You feel the life drain out of you!");

                int toDrain = DrainAmount;

                //Monster Stealables
                if (m is PlayerMobile)
                {
                    PlayerMobile pm = m as PlayerMobile;
                    toDrain = (int)drNO.ThieveItems.LifeShieldLotion.HandleLifeDrain(pm, toDrain);
                }
                //end


                Hits += toDrain;
                m.Damage(toDrain, this);
            }
        }
This seems to take in to account the player and party members as well. Am I missing something or did I read this code wrong?

Merc weapons and Drain life seem to be the two big things that are still happening to my players. So I just want to try and wrap my head around this. Thanks guys.
 
Last edited:
Back