Пример #1
0
        /*
         * PIX: this returns the special name hue for innocent names
         * It *assumes* that target is innocent to source otherwise.
         * Return 0 if no special name hue is to be displayed.
         */
        public static int MobileBeneficialActs(Mobile source, Mobile target)
        {
            if (source == target)
            {
                return(0);                              //if looking at oneself - return normal hue
            }
            #region FightBroker
            //FightBroker - blue fightbrokers should hue different to non-fightbrokers.
            if (FightBroker.IsAlreadyRegistered(target) ||
                FightBroker.IsHealerInterferer(target))
            {
                return(0x18);
            }
            #endregion

            #region kin
            //Kin - blue kin should hue differently to non-kin.
            //if (Engines.IOBSystem.KinSystemSettings.KinNameHueEnabled)
            {
                if (target is PlayerMobile && source is PlayerMobile)
                {
                    PlayerMobile pmsource = source as PlayerMobile;
                    PlayerMobile pmtarget = target as PlayerMobile;

                    if (pmtarget.IOBAlignment != IOBAlignment.None)
                    {
                        if (pmsource.IOBAlignment == IOBAlignment.None)
                        {
                            return(0x18);
                        }
                    }

                    //if we're looking at ourself and we're a healer, show our name in purple
                    if (pmsource == pmtarget && pmtarget.IOBAlignment == IOBAlignment.Healer)
                    {
                        return(0x18);
                    }
                }
            }
            #endregion

            return(0);
        }
Пример #2
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            #region Sanity
            // adam: sanity
            if (source == null || target == null)
            {
                if (source == null)
                {
                    Console.WriteLine("(source == null) in Notoriety::MobileNotoriety");
                }
                if (target == null)
                {
                    Console.WriteLine("(target == null) in Notoriety::MobileNotoriety");
                }
                //return;
            }
            #endregion

            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            if (target.AccessLevel > AccessLevel.Player && target.AccessLevel != AccessLevel.Ignore)
            {
                return(Notoriety.CanBeAttacked);
            }

            #region Duel

            /*
             * //Begin Challenge Duel Additions
             * if (target is PlayerMobile && source is PlayerMobile)
             * {
             *      bool tc = ((PlayerMobile)target).IsInChallenge;
             *      bool sc = (((PlayerMobile)source).IsInChallenge);
             *      if (tc && sc) //both in challenge
             *      {
             *              foreach (Item c in Challenge.Challenge.WorldStones)
             *              {
             *                      ChallengeStone cs = c as ChallengeStone;
             *                      if (cs.OpponentTeam.Contains(target) || cs.ChallengeTeam.Contains(target))
             *                      {
             *                              if (cs.OpponentTeam.Contains(source) || cs.ChallengeTeam.Contains(source))
             *                              {
             *                                      return Notoriety.CanBeAttacked;
             *                              }
             *                      }
             *              }
             *      }
             * }
             * //End Challenge Duel Additions
             */
            #endregion

            // it's a pet
            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                Mobile master = bc.GetMaster();

                if (master != null && master.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }

                if (Core.OldEthics)
                {
                    Ethics.Ethic srcEthic = Ethics.Ethic.Find(source);
                    Ethics.Ethic trgEthic = Ethics.Ethic.Find(target, true);

                    // outside of town: evil's the target: evil's are red
                    if (trgEthic != null && trgEthic == Ethics.Ethic.Evil && !target.Region.IsGuarded && target.Map == Map.Felucca)
                    {
                        return(Notoriety.Murderer);
                    }
                    // a fallen hero will flag gray and not enemy – this is per the original docs
                    else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.FallenHero))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    // An innocent that attacks an evil (evil noto) will be attackable by all evils for two minutes
                    else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.EvilNoto))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    // Hero/Evil always at war
                    else if (srcEthic != null && trgEthic != null && srcEthic != trgEthic)
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }

            if (target.Murderer || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if ((sourceGuild != null && targetGuild != null) && (sourceGuild.Peaceful == false && targetGuild.Peaceful == false))
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            #region Fightbroker
            //If both are registered with the fightbroker, they can both attack each other
            if (FightBroker.IsAlreadyRegistered(source) && FightBroker.IsAlreadyRegistered(target) &&
                (source != target))
            {
                return(Notoriety.Enemy);
            }
            //If the source is registered on the fightbroker and the target is an interferer, make the target fair game
            if (FightBroker.IsAlreadyRegistered(source) && FightBroker.IsHealerInterferer(target) &&
                (source != target))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Now handle pets of the people registered with the fightbroker
            if (source is BaseCreature && target is BaseCreature)
            {
                BaseCreature src = (BaseCreature)source;
                BaseCreature tgt = (BaseCreature)target;
                if (src.ControlMaster != null && tgt.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(src.ControlMaster) &&
                        FightBroker.IsAlreadyRegistered(tgt.ControlMaster) &&
                        (src.ControlMaster != tgt.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            else if (source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature tgt = (BaseCreature)target;
                if (tgt.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(source) &&
                        FightBroker.IsAlreadyRegistered(tgt.ControlMaster) &&
                        (source != tgt.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            else if (source is BaseCreature && target is PlayerMobile)
            {
                BaseCreature src = (BaseCreature)source;
                if (src.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(target) &&
                        FightBroker.IsAlreadyRegistered(src.ControlMaster) &&
                        (target != src.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            //done with pets/fightbroker status
            #endregion

            #region Kin
            //Now handle IOB status hueing
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.IOBShardWide) ||
                (Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(source) &&
                 Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(target)))
            {
                IOBAlignment srcIOBAlignment = IOBAlignment.None;
                IOBAlignment trgIOBAlignment = IOBAlignment.None;
                if (source is BaseCreature)
                {
                    srcIOBAlignment = ((BaseCreature)source).IOBAlignment;
                }
                else if (source is PlayerMobile)
                {
                    srcIOBAlignment = ((PlayerMobile)source).IOBAlignment;
                }
                if (target is BaseCreature)
                {
                    trgIOBAlignment = ((BaseCreature)target).IOBAlignment;
                }
                else if (target is PlayerMobile)
                {
                    trgIOBAlignment = ((PlayerMobile)target).IOBAlignment;
                }

                if (srcIOBAlignment != IOBAlignment.None &&
                    trgIOBAlignment != IOBAlignment.None &&
                    srcIOBAlignment != IOBAlignment.Healer
                    )
                {
                    //If they're different alignments OR target is OutCast, then they're an enemy
                    //Pix 12/3/07: added healer target
                    //Pix: 12/4/07 - now kin-healers flag canbeattacked to kin instead of enemy
                    if (trgIOBAlignment == IOBAlignment.Healer)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else if (srcIOBAlignment != trgIOBAlignment ||
                             trgIOBAlignment == IOBAlignment.OutCast)
                    {
                        return(Notoriety.Enemy);
                    }
                    else
                    {
                        if (source is PlayerMobile && target is BaseCreature)
                        {
                            return(Notoriety.Ally);
                        }
                        else
                        {
                            //Pix: 4/28/06 - removed Ally notoriety of same-aligned kin -
                            // this is now handled by guilds via allying
                            //return Notoriety.Ally;
                        }
                    }
                }

                //if we're looking at ourselves, and we're a KinHealer, show ourself as enemy
                if (source == target && srcIOBAlignment == IOBAlignment.Healer)
                {
                    return(Notoriety.Enemy);
                }
            }
            //done with IOB status hueing

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;
                if (bc.IOBFollower)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }
            #endregion

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
            {
                return(Notoriety.Enemy);
            }

            if (Core.OldEthics)
            {
                Ethics.Ethic srcEthic = Ethics.Ethic.Find(source);
                Ethics.Ethic trgEthic = Ethics.Ethic.Find(target);

                // outside of town: evil's the target: evil's are red
                if (trgEthic != null && trgEthic == Ethics.Ethic.Evil && !target.Region.IsGuarded && target.Map == Map.Felucca)
                {
                    return(Notoriety.Murderer);
                }
                // a fallen hero will flag gray and not enemy – this is per the original docs
                else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.FallenHero))
                {
                    return(Notoriety.CanBeAttacked);
                }
                // An innocent that attacks an evil (evil noto) will be attackable by all evils for two minutes
                else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.EvilNoto))
                {
                    return(Notoriety.CanBeAttacked);
                }
                // Hero/Evil always at war
                else if (srcEthic != null && trgEthic != null && srcEthic != trgEthic)
                {
                    return(Notoriety.Enemy);
                }
            }

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !TransformationSpellHelper.UnderTransformation(target) /*&& !AnimalForm.UnderTransformation(target) Ninja stuff*/)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (source is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)source;

                Mobile master = bc.GetMaster();
                if (master != null && CheckAggressor(master.Aggressors, target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            return(Notoriety.Innocent);
        }
Пример #3
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            // adam: sanity
            if (source == null || target == null)
            {
                if (source == null)
                {
                    Console.WriteLine("(source == null) in Notoriety::MobileNotoriety");
                }
                if (target == null)
                {
                    Console.WriteLine("(target == null) in Notoriety::MobileNotoriety");
                }
                //return;
            }

            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            /*
             * //Begin Challenge Duel Additions
             * if (target is PlayerMobile && source is PlayerMobile)
             * {
             *      bool tc = ((PlayerMobile)target).IsInChallenge;
             *      bool sc = (((PlayerMobile)source).IsInChallenge);
             *      if (tc && sc) //both in challenge
             *      {
             *              foreach (Item c in Challenge.Challenge.WorldStones)
             *              {
             *                      ChallengeStone cs = c as ChallengeStone;
             *                      if (cs.OpponentTeam.Contains(target) || cs.ChallengeTeam.Contains(target))
             *                      {
             *                              if (cs.OpponentTeam.Contains(source) || cs.ChallengeTeam.Contains(source))
             *                              {
             *                                      return Notoriety.CanBeAttacked;
             *                              }
             *                      }
             *              }
             *      }
             * }
             * //End Challenge Duel Additions
             */


            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if ((sourceGuild != null && targetGuild != null) && (sourceGuild.Peaceful == false && targetGuild.Peaceful == false))
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            //If both are registered with the fightbroker, they can both attack each other
            if (FightBroker.IsAlreadyRegistered(source) && FightBroker.IsAlreadyRegistered(target) &&
                (source != target))
            {
                return(Notoriety.Enemy);
            }
            //If the source is registered on the fightbroker and the target is an interferer, make the target fair game
            if (FightBroker.IsAlreadyRegistered(source) && FightBroker.IsHealerInterferer(target) &&
                (source != target))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Now handle pets of the people registered with the fightbroker
            if (source is BaseCreature && target is BaseCreature)
            {
                BaseCreature src = (BaseCreature)source;
                BaseCreature tgt = (BaseCreature)target;
                if (src.ControlMaster != null && tgt.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(src.ControlMaster) &&
                        FightBroker.IsAlreadyRegistered(tgt.ControlMaster) &&
                        (src.ControlMaster != tgt.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            else if (source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature tgt = (BaseCreature)target;
                if (tgt.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(source) &&
                        FightBroker.IsAlreadyRegistered(tgt.ControlMaster) &&
                        (source != tgt.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            else if (source is BaseCreature && target is PlayerMobile)
            {
                BaseCreature src = (BaseCreature)source;
                if (src.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(target) &&
                        FightBroker.IsAlreadyRegistered(src.ControlMaster) &&
                        (target != src.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            //done with pets/fightbroker status

            //Now handle IOB status hueing
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.IOBShardWide) ||
                (Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(source) &&
                 Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(target)))
            {
                IOBAlignment srcIOBAlignment = IOBAlignment.None;
                IOBAlignment trgIOBAlignment = IOBAlignment.None;
                if (source is BaseCreature)
                {
                    srcIOBAlignment = ((BaseCreature)source).IOBAlignment;
                }
                else if (source is PlayerMobile)
                {
                    srcIOBAlignment = ((PlayerMobile)source).IOBAlignment;
                }
                if (target is BaseCreature)
                {
                    trgIOBAlignment = ((BaseCreature)target).IOBAlignment;
                }
                else if (target is PlayerMobile)
                {
                    trgIOBAlignment = ((PlayerMobile)target).IOBAlignment;
                }

                if (srcIOBAlignment != IOBAlignment.None &&
                    trgIOBAlignment != IOBAlignment.None &&
                    srcIOBAlignment != IOBAlignment.Healer
                    )
                {
                    //If they're different alignments OR target is OutCast, then they're an enemy
                    //Pix 12/3/07: added healer target
                    //Pix: 12/4/07 - now kin-healers flag canbeattacked to kin instead of enemy
                    if (trgIOBAlignment == IOBAlignment.Healer)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else if (srcIOBAlignment != trgIOBAlignment ||
                             trgIOBAlignment == IOBAlignment.OutCast)
                    {
                        return(Notoriety.Enemy);
                    }
                    else
                    {
                        if (source is PlayerMobile && target is BaseCreature)
                        {
                            return(Notoriety.Ally);
                        }
                        else
                        {
                            //Pix: 4/28/06 - removed Ally notoriety of same-aligned kin -
                            // this is now handled by guilds via allying
                            //return Notoriety.Ally;
                        }
                    }
                }

                //if we're looking at ourselves, and we're a KinHealer, show ourself as enemy
                if (source == target && srcIOBAlignment == IOBAlignment.Healer)
                {
                    return(Notoriety.Enemy);
                }
            }
            //done with IOB status hueing

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent && ((BaseCreature)target).Controlled == false))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (source is BaseCreature)                  // here we're dealing with 2 BC
                {
                    BaseCreature sbc = (BaseCreature)source;
                    if (sbc.Controlled && bc.Controlled && sbc.ControlMaster == bc.ControlMaster)
                    {
                        //return Notoriety.CanBeAttacked;
                        return(Notoriety.Ally);
                    }
                }
            }

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;
                if (bc.IOBFollower)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

/*
 * Adam didn't want this way.
 *                      //Last check -- see if the target's region is a NoCount zone...
 *                      // if so, notoriety should be CanBeAttacked
 *                      CustomRegion targetRegion = target.Region as CustomRegion;
 *                      if( targetRegion != null )
 *                      {
 *                              RegionControl rc = targetRegion.GetRegionControler();
 *                              if( rc != null && rc.NoMurderZone )
 *                              {
 *                                      return Notoriety.CanBeAttacked;
 *                              }
 *                      }
 */
            return(Notoriety.Innocent);
        }