/// <summary>
 /// Slouzi pro klonovani
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="not"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="atribut"></param>
 public Unit(Unit unit, Notoriety not, int x, int y, AttributePair atribut)
     : base(unit.attack, unit.defense, unit.animatedSprite, x, y)
 {
     Name = unit.Name;
     Notoriety = not;
     isInHero = false;
     HitPoints = atribut;
 }
Example #2
0
        public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            Mobile target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            Map map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }

            BaseCreature bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile pm && pm.CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true); // Uncontrolled NPCs are only restricted by the young system
            }

            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
            {
                from = ((BaseCreature)from).SummonMaster;
            }

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
            {
                target = ((BaseCreature)target).SummonMaster;
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null)
            {
                if (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))
                {
                    return(true); // Guild allies or enemies can be harmful
                }
            }

            if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable))
            {
                return(true);
            }

            if (target is BaseCreature creature)
            {
                if (creature.Controlled)
                {
                    return(false); // Cannot harm other controlled mobiles
                }
                if (creature.Summoned && from != creature.SummonMaster)
                {
                    return(false); // Cannot harm other controlled mobiles
                }
            }

            if (target.Player)
            {
                return(false); // Cannot harm other players
            }
            if (!(target is BaseCreature baseCreature && baseCreature.InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false); // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #3
0
        public static bool ValidIndirectTarget(Mobile from, Mobile to)
        {
            if (from == to)
            {
                return(true);
            }

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

            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.Controled || 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.Controled || 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);
                    }
                }
            }

            if (to is BaseCreature && !((BaseCreature)to).Controled && ((BaseCreature)to).InitialInnocent)
            {
                return(true);
            }

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

            return(noto != Notoriety.Innocent || from.Kills >= 5);
        }
Example #4
0
        public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            Mobile target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                {
                    return(true);
                }

                from.SendLocalizedMessage(1075456); // You are not allowed to damage this NPC unless your on the Guilty Quest
                return(false);
            }
            #endregion

            Map map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }
            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
            {
                from = ((BaseCreature)from).SummonMaster;
            }

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
            {
                target = ((BaseCreature)target).SummonMaster;
            }

            BaseCreature bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true); // Uncontrolled NPCs are only restricted by the young system
            }

            if (XmlPoints.AreChallengers(from, target))
            {
                return(true);
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
            {
                return(true); // Guild allies or enemies can be harmful
            }
            if (target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)))
            {
                return(false); // Cannot harm other controlled mobiles
            }
            if (target.Player)
            {
                return(false); // Cannot harm other players
            }
            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false); // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #5
0
        public void TestMobileIncomingOld(
            ProtocolChanges protocolChanges, int hairItemId, int hairHue, int facialHairItemId, int facialHairHue
            )
        {
            var beholder = new Mobile(0x1)
            {
                Name = "Random Mobile 1"
            };

            beholder.DefaultMobileInit();

            var beheld = new Mobile(0x2)
            {
                Name = "Random Mobile 2"
            };

            beheld.DefaultMobileInit();
            beheld.AddItem(
                new Item((Serial)0x1000)
            {
                Layer = Layer.OneHanded
            }
                );

            // Test Dupe
            beheld.AddItem(
                new Item((Serial)0x1001)
            {
                Layer = Layer.OneHanded
            }
                );

            beheld.HairItemID       = hairItemId;
            beheld.HairHue          = hairHue;
            beheld.FacialHairItemID = facialHairItemId;
            beheld.FacialHairHue    = facialHairHue;

            var ns = new NetState(
                new AccountPacketTests.TestConnectionContext
            {
                RemoteEndPoint = IPEndPoint.Parse("127.0.0.1")
            }
                )
            {
                ProtocolChanges = protocolChanges
            };

            var data = (ns.StygianAbyss
                    ? (Packet) new MobileIncomingSA(beholder, beheld)
                    : new MobileIncomingOld(beholder, beheld))
                       .Compile();

            Span <bool> layers = stackalloc bool[256];

#if NO_LOCAL_INIT
            layers.Clear();
#endif

            var items = beheld.Items;
            var count = items.Count;

            if (beheld.HairItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHairItemID > 0)
            {
                count++;
            }

            var length = 23 + count * 9; // Max Size

            Span <byte> expectedData = stackalloc byte[length];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x78);
            pos += 2; // Length

            var isSolidHue = beheld.SolidHueOverride >= 0;

            expectedData.Write(ref pos, beheld.Serial);
            expectedData.Write(ref pos, (ushort)beheld.Body);
            expectedData.Write(ref pos, (ushort)beheld.X);
            expectedData.Write(ref pos, (ushort)beheld.Y);
            expectedData.Write(ref pos, (byte)beheld.Z);
            expectedData.Write(ref pos, (byte)beheld.Direction);
            expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.Hue));
            expectedData.Write(ref pos, (byte)(ns.StygianAbyss ? beheld.GetOldPacketFlags() : beheld.GetPacketFlags()));
            expectedData.Write(ref pos, (byte)Notoriety.Compute(beholder, beheld));

            byte layer;
            int  itemId;
            int  hue;

            for (var i = 0; i < items.Count; i++)
            {
                var item = items[i];

                layer = (byte)item.Layer;

                if (!item.Deleted && !layers[layer] && beholder.CanSee(item))
                {
                    layers[layer] = true;
                    itemId        = item.ItemID & 0x7FFF;
                    hue           = isSolidHue ? beheld.SolidHueOverride : item.Hue;

                    if (hue != 0)
                    {
                        itemId |= 0x8000;
                    }

                    expectedData.Write(ref pos, item.Serial);
                    expectedData.Write(ref pos, (ushort)itemId);
                    expectedData.Write(ref pos, layer);
                    expectedData.Write(ref pos, (ushort)hue);
                }
            }

            layer  = (byte)Layer.Hair;
            itemId = beheld.HairItemID & 0x7FFF;

            if (itemId > 0 && !layers[layer])
            {
                hue = isSolidHue ? beheld.SolidHueOverride : beheld.HairHue;

                if (hue != 0)
                {
                    itemId |= 0x8000;
                }

                expectedData.Write(ref pos, HairInfo.FakeSerial(beheld));
                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                expectedData.Write(ref pos, (ushort)hue);
            }

            layer  = (byte)Layer.FacialHair;
            itemId = beheld.FacialHairItemID & 0x7FFF;

            if (itemId > 0 && !layers[layer])
            {
                hue = isSolidHue ? beheld.SolidHueOverride : beheld.FacialHairHue;

                if (hue != 0)
                {
                    itemId |= 0x8000;
                }

                expectedData.Write(ref pos, FacialHairInfo.FakeSerial(beheld));
                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                expectedData.Write(ref pos, (ushort)hue);
            }

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, 0); // Zero serial, terminate list
#else
            pos += 4;
#endif

            expectedData.Slice(1, 2).Write((ushort)pos); // Length
            expectedData = expectedData.Slice(0, pos);

            AssertThat.Equal(data, expectedData);
        }
Example #6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (targeted is Mobile)
                {
                    Mobile       targ     = (Mobile)targeted;
                    BaseCreature creature = targ as BaseCreature;

                    if (m_Creature.Unprovokable || (creature != null && creature.Unprovokable))
                    {
                        from.SendLocalizedMessage(1049446);                           // You have no chance of provoking those creatures.
                    }
                    else if (m_Creature.Map != targ.Map || !m_Creature.InRange(targ, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
                    {
                        from.SendLocalizedMessage(1049450);                           // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
                    }
                    else if (m_Creature != targ)
                    {
                        if (from == targ)
                        {
                            from.SendAsciiMessage("Maybe you should just attack it.");
                            return;
                        }

                        if (from.CanBeHarmful(m_Creature, true) && from.CanBeHarmful(targ, true))
                        {
                            // provoking a guard, or provoking to attack a positive creature is bad
                            if (m_Creature is BaseGuard || m_Creature is BaseShieldGuard || targ is BaseGuard || targ is BaseShieldGuard)
                            {
                                from.SendLocalizedMessage(1049446);                                   // You have no chance of provoking those creatures.
                                Server.Misc.Titles.AlterNotoriety(from, -40);
                                return;
                            }
                            else if (Notoriety.Compute(from, targ) == Notoriety.Innocent)
                            {
                                Misc.Titles.AlterNotoriety(from, -10);
                            }

                            if (!BaseInstrument.CheckMusicianship(from))
                            {
                                from.SendLocalizedMessage(500612);                                   // You play poorly, and there is no effect.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);
                            }
                            else
                            {
                                from.DoHarmful(m_Creature);
                                from.DoHarmful(targ);

                                if (!from.CheckTargetSkill(SkillName.Provocation, targ, 0, 110))             //diff-25.0, diff+25.0 ) )
                                {
                                    from.SendLocalizedMessage(501599);                                       // Your music fails to incite enough anger.
                                    m_Instrument.PlayInstrumentBadly(from);
                                    m_Instrument.ConsumeUse(from);
                                }
                                else
                                {
                                    from.SendLocalizedMessage(501602);                                       // Your music succeeds, as you start a fight.
                                    m_Instrument.PlayInstrumentWell(from);
                                    m_Instrument.ConsumeUse(from);
                                    m_Creature.Provoke(from, targ, true);
                                }
                            }
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(501593);                           // You can't tell someone to attack themselves!
                    }
                }
            }
Example #7
0
        private ushort GetVarHue(InfoBarVars var)
        {
            float percent;

            switch (var)
            {
            case InfoBarVars.HP:
                percent = World.Player.Hits / (float)World.Player.HitsMax;
                if (percent <= 0.25)
                {
                    return(0x0021);
                }
                else if (percent <= 0.5)
                {
                    return(0x0030);
                }
                else if (percent <= 0.75)
                {
                    return(0x0035);
                }
                else
                {
                    return(0x0481);
                }

            case InfoBarVars.Mana:
                percent = World.Player.Mana / (float)World.Player.ManaMax;
                if (percent <= 0.25)
                {
                    return(0x0021);
                }
                else if (percent <= 0.5)
                {
                    return(0x0030);
                }
                else if (percent <= 0.75)
                {
                    return(0x0035);
                }
                else
                {
                    return(0x0481);
                }

            case InfoBarVars.Stamina:
                percent = World.Player.Stamina / (float)World.Player.StaminaMax;
                if (percent <= 0.25)
                {
                    return(0x0021);
                }
                else if (percent <= 0.5)
                {
                    return(0x0030);
                }
                else if (percent <= 0.75)
                {
                    return(0x0035);
                }
                else
                {
                    return(0x0481);
                }

            case InfoBarVars.Weight:
                percent = World.Player.Weight / (float)World.Player.WeightMax;
                if (percent >= 1)
                {
                    return(0x0021);
                }
                else if (percent >= 0.75)
                {
                    return(0x0030);
                }
                else if (percent >= 0.5)
                {
                    return(0x0035);
                }
                else
                {
                    return(0x0481);
                }

            case InfoBarVars.NameNotoriety:
                return(Notoriety.GetHue(World.Player.NotorietyFlag));

            default:
                return(0x0481);
            }
        }
Example #8
0
 public static bool IsInnocentTo(Mobile from, Mobile to)
 {
     return(Notoriety.Compute(from, to) == Notoriety.Innocent);
 }
Example #9
0
 public static HueData GetNotorietyData(Notoriety n)
 {
     if ((n >= Notoriety.Innocent) && (n <= Notoriety.Vendor))
     {
         return m_HueData[World.CharData.NotorietyHues[((int) n) - 1]];
     }
     return new HueData();
 }
Example #10
0
 public static IHue GetNotoriety(Notoriety n, bool full)
 {
     if ((n >= Notoriety.Innocent) && (n <= Notoriety.Vendor))
     {
         int index = ((int) n) - 1;
         int num2 = full ? 1 : 0;
         IHue hue = m_NotorietyHues[index, num2];
         if (hue == null)
         {
             hue = m_NotorietyHues[index, num2] = Load(World.CharData.NotorietyHues[index] | (num2 << 15));
         }
         return hue;
     }
     return Default;
 }
Example #11
0
 public static IHue GetNotoriety(Notoriety n)
 {
     return GetNotoriety(n, true);
 }
Example #12
0
 public void OnNotorietyChange(Notoriety n)
 {
 }
        /// <summary>
        /// Klonovani pri deserializaci
        /// </summary>
        /// <param name="not"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="attack"></param>
        /// <param name="defense"></param>
        /// <param name="atribut"></param>
        /// <param name="isInHero"></param>
        /// <returns></returns>
        public Unit Clone(Notoriety not, int x, int y, int attack, int defense, AttributePair atribut,bool isInHero)
        {
            AnimatedSprite sprite = (AnimatedSprite)this.animatedSprite.Clone();
            Unit unitClone = new Unit(this.Name, this.Attack, this.Defense, sprite, x, y, atribut);
            Unit unitClone2 = new Unit(unitClone, not, x, y, this.HitPoints);
            unitClone2.attack = attack;
            unitClone2.defense = defense;
            unitClone2.HitPoints = atribut;
            unitClone2.isInHero = isInHero;

            return unitClone2;
        }
        /// <summary>
        /// Klonovani pro novou jednotku
        /// </summary>
        /// <param name="not"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public Unit Clone(Notoriety not, int x, int y)
        {
            AnimatedSprite sprite = (AnimatedSprite)this.animatedSprite.Clone();
            Unit unitClone = new Unit(this.Name, this.Attack, this.Defense, sprite, x, y, this.HitPoints);
            Unit unitClone2 = new Unit(unitClone, not, x, y, this.HitPoints);

            return unitClone2;
        }
Example #15
0
        public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
        {
            if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player)
            {
                return(true);
            }

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

            if (pmFrom == null && from is BaseCreature bcFrom)
            {
                if (bcFrom.Summoned)
                {
                    pmFrom = bcFrom.SummonMaster as PlayerMobile;
                }
            }

            if (pmTarg == null && target is BaseCreature bcTarg)
            {
                if (bcTarg.Summoned)
                {
                    pmTarg = bcTarg.SummonMaster as PlayerMobile;
                }
            }

            if (pmFrom != null && pmTarg != null)
            {
                if (pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
                {
                    return(true);
                }
            }

            if ((pmFrom != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
            {
                return(false);
            }

            if (from.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) is Engines.ConPVP.SafeZone /* sz && sz.IsDisabled()*/)
            {
                return(false);
            }

            if (target.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) is Engines.ConPVP.SafeZone /* sz && sz.IsDisabled()*/)
            {
                return(false);
            }
            #endregion

            Region region = from.Region;
            //Check first region, if region have different rules, uses this instead of the map
            if (region != null)
            {
                if (!region.Rules.HasFlag(ZoneRules.HarmfulRestrictions))
                {
                    return(true);                    // in region without HarmfulRestrictions, false
                }
            }
            else
            {
                Map map = from.Map;
                if (map != null && !map.Rules.HasFlag(ZoneRules.HarmfulRestrictions))
                {
                    return(true);                    // In felucca, anything goes
                }
            }

            BaseCreature bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile playerMobile && playerMobile.CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true);                // Uncontrolled NPCs are only restricted by the young system
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
            {
                return(true);                // Guild allies or enemies can be harmful
            }
            if (target is BaseCreature creature && (creature.Controlled || (creature.Summoned && from != creature.SummonMaster)))
            {
                return(false);                // Cannot harm other controlled mobiles
            }
            if (target.Player)
            {
                return(false);                // Cannot harm other players
            }
            if (!(target is BaseCreature targetCreature && targetCreature.InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false);                    // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #16
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            ResetHueVector();

            _equipConvData = null;
            _transform     = false;
            AnimationsLoader.Instance.SittingValue = 0;
            FrameInfo.X      = 0;
            FrameInfo.Y      = 0;
            FrameInfo.Width  = 0;
            FrameInfo.Height = 0;

            posY -= 3;
            int drawX = posX + (int)Offset.X;
            int drawY = posY + (int)(Offset.Y - Offset.Z);

            drawX += 22;
            drawY += 22;

            bool hasShadow = !IsDead && !IsHidden && ProfileManager.Current.ShadowsEnabled;

            if (AuraManager.IsEnabled)
            {
                AuraManager.Draw(batcher, drawX, drawY, ProfileManager.Current.PartyAura && World.Party.Contains(this) ? ProfileManager.Current.PartyAuraHue : Notoriety.GetHue(NotorietyFlag));
            }

            bool isHuman    = IsHuman;
            bool isGargoyle = Client.Version >= ClientVersion.CV_7000 && (Graphic == 666 || Graphic == 667 || Graphic == 0x02B7 || Graphic == 0x02B6);

            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                _viewHue    = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                HueVector.Y = 1;
            }
            else if (SelectedObject.HealthbarObject == this)
            {
                _viewHue = Notoriety.GetHue(NotorietyFlag);
            }
            else if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                _viewHue    = Constants.OUT_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect)
            {
                _viewHue    = Constants.DEAD_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (IsHidden)
            {
                _viewHue = 0x038E;
            }
            else
            {
                _viewHue = 0;

                if (IsDead)
                {
                    if (!isHuman)
                    {
                        _viewHue = 0x0386;
                    }
                }
                else if (ProfileManager.Current.HighlightMobilesByFlags)
                {
                    if (IsPoisoned)
                    {
                        _viewHue = ProfileManager.Current.PoisonHue;
                    }

                    if (IsParalyzed)
                    {
                        _viewHue = ProfileManager.Current.ParalyzedHue;
                    }

                    if (NotorietyFlag != NotorietyFlag.Invulnerable && IsYellowHits)
                    {
                        _viewHue = ProfileManager.Current.InvulnerableHue;
                    }
                }
            }


            bool isAttack     = Serial == TargetManager.LastAttack;
            bool isUnderMouse = TargetManager.IsTargeting && SelectedObject.LastObject == this;

            //bool needHpLine = false;

            if (this != World.Player)
            {
                if (isAttack || isUnderMouse)
                {
                    _viewHue = Notoriety.GetHue(NotorietyFlag);
                }

                //if (this == TargetManager.LastTarget)
                //{
                //    UIManager.SetTargetLineGump(this);
                //    //needHpLine = true;
                //}
            }



            ProcessSteps(out byte dir);
            byte layerDir = dir;

            AnimationsLoader.Instance.GetAnimDirection(ref dir, ref IsFlipped);

            ushort graphic   = GetGraphicForAnimation();
            byte   animGroup = GetGroupForAnimation(this, graphic, true);
            sbyte  animIndex = AnimIndex;

            AnimationsLoader.Instance.Direction = dir;
            AnimationsLoader.Instance.AnimGroup = animGroup;

            Item mount = FindItemByLayer(Layer.Mount);

            if (isHuman && mount != null)
            {
                AnimationsLoader.Instance.SittingValue = 0;

                ushort mountGraphic = mount.GetGraphicForAnimation();

                if (mountGraphic != 0xFFFF)
                {
                    if (hasShadow)
                    {
                        DrawInternal(batcher, this, null, drawX, drawY + 10, IsFlipped, animIndex, true, graphic, isHuman, alpha: HueVector.Z);
                        AnimationsLoader.Instance.AnimGroup = GetGroupForAnimation(this, mountGraphic);
                        DrawInternal(batcher, this, mount, drawX, drawY, IsFlipped, animIndex, true, mountGraphic, isHuman, alpha: HueVector.Z);
                    }
                    else
                    {
                        AnimationsLoader.Instance.AnimGroup = GetGroupForAnimation(this, mountGraphic);
                    }

                    drawY += DrawInternal(batcher, this, mount, drawX, drawY, IsFlipped, animIndex, false, mountGraphic, isHuman, isMount: true, alpha: HueVector.Z);
                }
            }
            else
            {
                if ((AnimationsLoader.Instance.SittingValue = IsSitting()) != 0)
                {
                    animGroup = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND;
                    animIndex = 0;

                    ProcessSteps(out dir);
                    AnimationsLoader.Instance.Direction = dir;
                    AnimationsLoader.Instance.FixSittingDirection(ref dir, ref IsFlipped, ref drawX, ref drawY);

                    if (AnimationsLoader.Instance.Direction == 3)
                    {
                        if (IsGargoyle)
                        {
                            drawY    -= 30;
                            animGroup = 42;
                        }
                        else
                        {
                            animGroup = 25;
                        }
                    }
                    else if (IsGargoyle)
                    {
                        animGroup = 42;
                    }
                    else
                    {
                        _transform = true;
                    }
                }
                else if (hasShadow)
                {
                    DrawInternal(batcher, this, null, drawX, drawY, IsFlipped, animIndex, true, graphic, isHuman, alpha: HueVector.Z);
                }
            }

            AnimationsLoader.Instance.AnimGroup = animGroup;


            DrawInternal(batcher, this, null, drawX, drawY, IsFlipped, animIndex, false, graphic, isHuman, alpha: HueVector.Z);

            for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
            {
                Layer layer = LayerOrder.UsedLayers[layerDir, i];

                Item item = FindItemByLayer(layer);

                if (item == null)
                {
                    continue;
                }

                if (IsDead && (layer == Layer.Hair || layer == Layer.Beard))
                {
                    continue;
                }

                if (isHuman)
                {
                    if (IsCovered(this, layer))
                    {
                        continue;
                    }

                    if (item.ItemData.AnimID != 0)
                    {
                        graphic = item.ItemData.AnimID;

                        if (isGargoyle)
                        {
                            if (graphic == 469)
                            {
                                // gargoyle robe
                                graphic = 342;
                            }
                            else if (graphic == 0x03CA)
                            {
                                // gargoyle dead shroud
                                graphic = 0x0223;
                            }
                        }

                        if (AnimationsLoader.Instance.EquipConversions.TryGetValue(Graphic, out Dictionary <ushort, EquipConvData> map))
                        {
                            if (map.TryGetValue(item.ItemData.AnimID, out EquipConvData data))
                            {
                                _equipConvData = data;
                                graphic        = data.Graphic;
                            }
                        }

                        if (AnimationsLoader.Instance.SittingValue == 0 && IsGargoyle && item.ItemData.IsWeapon)
                        {
                            AnimationsLoader.Instance.AnimGroup = GetGroupForAnimation(this, graphic);
                            DrawInternal(batcher, this, item, drawX, drawY, IsFlipped, animIndex, false, graphic, isHuman, false, alpha: HueVector.Z);
                            AnimationsLoader.Instance.AnimGroup = animGroup;
                        }
                        else
                        {
                            DrawInternal(batcher, this, item, drawX, drawY, IsFlipped, animIndex, false, graphic, isHuman, false, alpha: HueVector.Z);
                        }
                    }
                    else
                    {
                        if (item.ItemData.IsLight)
                        {
                            Client.Game.GetScene <GameScene>().AddLight(this, this, drawX, drawY);
                        }
                    }

                    _equipConvData = null;
                }
                else
                {
                    if (item.ItemData.IsLight)
                    {
                        Client.Game.GetScene <GameScene>().AddLight(this, this, drawX, drawY);
                        break;
                    }
                }
            }

            //if (FileManager.Animations.SittingValue != 0)
            //{
            //    ref var sittingData = ref FileManager.Animations.SittingInfos[FileManager.Animations.SittingValue - 1];

            //    if (FileManager.Animations.Direction == 3 && sittingData.DrawBack &&
            //        HasEquipment && Equipment[(int) Layer.Cloak] == null)
            //    {

            //    }
            //}
            //

            FrameInfo.X      = Math.Abs(FrameInfo.X);
            FrameInfo.Y      = Math.Abs(FrameInfo.Y);
            FrameInfo.Width  = FrameInfo.X + FrameInfo.Width;
            FrameInfo.Height = FrameInfo.Y + FrameInfo.Height;

            return(true);
        }
Example #17
0
        public override void Update(double totalMS, double frameMS)
        {
            base.Update(totalMS, frameMS);

            if (IsDisposed)
            {
                return;
            }

            if (Mobile == null || Mobile.IsDisposed)
            {
                Dispose();
                Engine.UI.RemoveTargetLineGump(Mobile);
                return;
            }

            int per = Mobile.HitsMax;

            if (per > 0)
            {
                per = (Mobile.Hits * 100) / per;

                if (per > 100)
                {
                    per = 100;
                }

                if (per < 1)
                {
                    per = 0;
                }
                else
                {
                    per = (34 * per) / 100;
                }
            }

            _hp.Percent = per;

            if (Mobile.IsPoisoned)
            {
                if (_hp.Hue != 63)
                {
                    _hp.Hue = 63;
                }
            }
            else if (Mobile.IsYellowHits)
            {
                if (_hp.Hue != 53)
                {
                    _hp.Hue = 53;
                }
            }
            else if (_hp.Hue != 90)
            {
                _hp.Hue = 90;
            }


            _background.Hue = Notoriety.GetHue(Mobile.NotorietyFlag);;
        }
        public override void OnSingleClick(Mobile from)
        {
            int hue = Notoriety.GetHue(NotorietyHandlers.CorpseNotoriety(from, this));

            from.Send(new AsciiMessage(Serial, ItemID, MessageType.Label, hue, 3, "", "a charred corpse"));
        }
 private static bool IsInnocentTo(Mobile from, Mobile to)
 {
     return(Notoriety.Compute(from, (Mobile)to) == Notoriety.Innocent);
 }
Example #20
0
 public void OnNotorietyChange(Notoriety n)
 {
 }
Example #21
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
            _Body = reader.ReadInt16();
            _X = reader.ReadInt16();
            _Y = reader.ReadInt16();
            _Z = reader.ReadSByte();
            _Direction = (Direction) reader.ReadByte();
            _Hue = reader.ReadUInt16();

            byte flags = reader.ReadByte();

            if ( ( flags & 0x1 ) > 0 )
                _IsFrozen = true;

            if ( ( flags & 0x2 ) > 0 )
                _IsFemale = true;

            if ( ( flags & 0x4 ) > 0 )
                _IsFlying = true;

            if ( ( flags & 0x8 ) > 0 )
                _HasYellowHealthBar = true;

            if ( ( flags & 0x10 ) > 0 )
                _IsIgnoringMobiles = true;

            if ( ( flags & 0x40 ) > 0 )
                _IsInWarMode = true;

            if ( ( flags & 0x80 ) > 0 )
                _IsHidden = true;

            _Notoriety = (Notoriety) reader.ReadByte();
        }
Example #22
0
        public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
        {
            if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player)
            {
                return(true);
            }

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

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

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

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

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

            if (pmFrom != null && pmTarg != null)
            {
                if (pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
                {
                    return(true);
                }
            }

            if ((pmFrom != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
            {
                return(false);
            }

            Engines.ConPVP.SafeZone sz = from.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone;

            if (sz != null /*&& sz.IsDisabled()*/)
            {
                return(false);
            }

            sz = target.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone;

            if (sz != null /*&& sz.IsDisabled()*/)
            {
                return(false);
            }
            #endregion

            Map map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true);                // In felucca, anything goes
            }
            BaseCreature bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true);                // Uncontrolled NPCs are only restricted by the young system
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
            {
                return(true);                // Guild allies or enemies can be harmful
            }
            if (target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)))
            {
                return(false);                // Cannot harm other controlled mobiles
            }
            if (target.Player)
            {
                return(false);                // Cannot harm other players
            }
            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false);                    // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #23
0
        public void TestMobileIncoming(int hairItemId, int hairHue, int facialHairItemId, int facialHairHue)
        {
            var beholder = new Mobile(0x1)
            {
                Name = "Random Mobile 1"
            };

            beholder.DefaultMobileInit();

            var beheld = new Mobile(0x2)
            {
                Name = "Random Mobile 2"
            };

            beheld.DefaultMobileInit();
            beheld.AddItem(
                new Item((Serial)0x1000)
            {
                Layer = Layer.OneHanded
            }
                );

            // Test Dupe
            beheld.AddItem(
                new Item((Serial)0x1001)
            {
                Layer = Layer.OneHanded
            }
                );

            beheld.HairItemID       = hairItemId;
            beheld.HairHue          = hairHue;
            beheld.FacialHairItemID = facialHairItemId;
            beheld.FacialHairHue    = facialHairHue;

            var data = new MobileIncoming(beholder, beheld).Compile();

            Span <bool> layers = stackalloc bool[256];

#if NO_LOCAL_INIT
            layers.Clear();
#endif

            var items = beheld.Items;
            var count = items.Count;

            if (beheld.HairItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHairItemID > 0)
            {
                count++;
            }

            var length = 23 + count * 9; // Max Size

            Span <byte> expectedData = stackalloc byte[length];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x78);
            pos += 2; // Length

            var isSolidHue = beheld.SolidHueOverride >= 0;

            expectedData.Write(ref pos, beheld.Serial);
            expectedData.Write(ref pos, (ushort)beheld.Body);
            expectedData.Write(ref pos, (ushort)beheld.X);
            expectedData.Write(ref pos, (ushort)beheld.Y);
            expectedData.Write(ref pos, (byte)beheld.Z);
            expectedData.Write(ref pos, (byte)beheld.Direction);
            expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.Hue));
            expectedData.Write(ref pos, (byte)beheld.GetPacketFlags());
            expectedData.Write(ref pos, (byte)Notoriety.Compute(beholder, beheld));

            byte layer;

            for (var i = 0; i < items.Count; i++)
            {
                var item = items[i];

                layer = (byte)item.Layer;

                if (!item.Deleted && !layers[layer] && beholder.CanSee(item))
                {
                    layers[layer] = true;

                    expectedData.Write(ref pos, item.Serial);
                    expectedData.Write(ref pos, (ushort)(item.ItemID & 0xFFFF));
                    expectedData.Write(ref pos, layer);
                    expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : item.Hue));
                }
            }

            layer = (byte)Layer.Hair;
            var itemId = beheld.HairItemID & 0xFFFF;

            if (itemId > 0 && !layers[layer])
            {
                expectedData.Write(ref pos, HairInfo.FakeSerial(beheld));
                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.HairHue));
            }

            layer  = (byte)Layer.FacialHair;
            itemId = beheld.FacialHairItemID & 0xFFFF;

            if (itemId > 0 && !layers[layer])
            {
                expectedData.Write(ref pos, FacialHairInfo.FakeSerial(beheld));
                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.FacialHairHue));
            }

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, 0); // Zero serial, terminate list
#else
            pos += 4;
#endif

            expectedData.Slice(1, 2).Write((ushort)pos); // Length
            expectedData = expectedData.Slice(0, pos);

            AssertThat.Equal(data, expectedData);
        }
Example #24
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();
                from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(10.0);

                Item   stolen  = null;
                Item   attempt = null;
                object root    = null;
                bool   ok      = false;
                bool   caught  = false;

                Mobile mobRoot = null;

                if (target is Item)
                {
                    attempt = (Item)target;
                    root    = attempt.RootParent;
                    mobRoot = root as Mobile;
                    stolen  = TryStealItem(attempt, root, 3, ref ok, ref caught);
                }
                else if (target is Mobile)
                {
                    Container pack = ((Mobile)target).Backpack;

                    if (pack != null && pack.Items.Count > 0)
                    {
                        from.SendAsciiMessage("You reach into {0}'s backpack and try to take something...", ((Mobile)target).Name);

                        int randomIndex = Utility.Random(pack.Items.Count);
                        root    = target;
                        mobRoot = root as Mobile;
                        attempt = pack.Items[randomIndex] as Item;
                        if (attempt != null)
                        {
                            stolen = TryStealItem(attempt, root, 1, ref ok, ref caught);
                        }
                    }
                    else
                    {
                        from.SendAsciiMessage("You reach into {0}'s backpack...  But find it's empty.", ((Mobile)target).Name);
                    }
                }
                else
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }

                if (!ok)
                {
                    return;
                }

                if (stolen != null)
                {
                    from.AddToBackpack(stolen);
                    if (mobRoot != null)
                    {
                        Misc.Titles.AlterNotoriety(from, -1, NotoCap.Dishonorable);

                        ArrayList list = m_Table[m_Thief] as ArrayList;
                        if (list == null)
                        {
                            m_Table[m_Thief] = list = new ArrayList(1);
                        }
                        list.Add(mobRoot);
                        new ThiefExpireTimer(mobRoot, m_Thief).Start();
                    }
                }

                if (caught)
                {
                    bool   crime;
                    string fromStr = String.Empty;
                    int    noto    = Notoriety.CanBeAttacked;

                    if (root is Corpse)
                    {
                        crime = ((Corpse)root).IsCriminalAction(m_Thief);
                    }
                    else if (mobRoot != null)
                    {
                        if (m_Saw != null && m_Saw.Count > 0)
                        {
                            crime = Notoriety.Compute(from, mobRoot) == Notoriety.Innocent;
                        }
                        else
                        {
                            crime = false;
                        }

                        fromStr = String.Format(" from {0}", mobRoot.Name);
                    }
                    else
                    {
                        crime = true;
                    }

                    if (crime)
                    {
                        m_Thief.CriminalAction(false);                          // calls guards
                    }
                    else if (noto != Notoriety.Enemy && noto != Notoriety.Ally) // dont go criminal in guild situations
                    {
                        m_Thief.Criminal = true;                                // doesnt call guards
                    }
                    if (m_Saw != null && m_Saw.Count > 0)
                    {
                        string message = null;
                        foreach (Mobile m in m_Saw)
                        {
                            if (m.NetState != null)
                            {
                                if (root is Mobile && m == root)
                                {
                                    StringBuilder sb = new StringBuilder("You notice ");
                                    sb.Append(m_Thief.Name);
                                    sb.Append(" trying to steal ");

                                    if (attempt.Amount > 1)
                                    {
                                        sb.Append("some ");
                                    }
                                    else
                                    {
                                        sb.Append("a ");
                                    }

                                    if (attempt is BaseItem)
                                    {
                                        ((BaseItem)attempt).AppendClickName(sb);
                                    }
                                    else if (attempt.Name != null && attempt.Name != "")
                                    {
                                        sb.Append(attempt.Name);
                                    }
                                    else
                                    {
                                        sb.Append(attempt.ItemData.Name);
                                    }

                                    sb.Append(" from you!");
                                    m.SendAsciiMessage(sb.ToString());
                                }
                                else
                                {
                                    if (message == null)
                                    {
                                        if (stolen != null)
                                        {
                                            attempt = stolen;
                                        }
                                        if (attempt != null)
                                        {
                                            StringBuilder sb = new StringBuilder("You notice ");
                                            sb.Append(m_Thief.Name);
                                            sb.Append(" trying to steal ");

                                            if (attempt.Amount > 1)
                                            {
                                                sb.Append("some ");
                                            }
                                            else
                                            {
                                                sb.Append("a ");
                                            }

                                            if (attempt is BaseItem)
                                            {
                                                ((BaseItem)attempt).AppendClickName(sb);
                                            }
                                            else if (attempt.Name != null && attempt.Name != "")
                                            {
                                                sb.Append(attempt.Name);
                                            }
                                            else
                                            {
                                                sb.Append(attempt.ItemData.Name);
                                            }

                                            sb.Append(fromStr);
                                            sb.Append('!');
                                            message = sb.ToString();
                                        }
                                        else
                                        {
                                            message = String.Format("You notice {0} trying to something steal something{1}!", m_Thief.Name, fromStr);
                                        }
                                    }

                                    m.SendAsciiMessage(message);
                                }
                            }
                            else if (m is BaseCreature)
                            {
                                if (m.Body.IsHuman)
                                {
                                    if (!(m is BaseGuard) && !(m is PlayerVendor))
                                    {
                                        m.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                                    }
                                    if (crime)
                                    {
                                        GuardedRegion reg = m.Region as GuardedRegion;
                                        if (reg != null && !reg.IsDisabled())
                                        {
                                            reg.CallGuards(m.Location);
                                        }
                                    }
                                }

                                if (root == m && Utility.RandomBool())
                                {
                                    BaseCreature bc = (BaseCreature)m;
                                    if (!bc.Controled && (bc.AlwaysMurderer || (bc.AlwaysAttackable && !bc.IsHarmfulCriminal(m_Thief))))
                                    {
                                        bc.Attack(m_Thief);
                                    }
                                }
                            }
                        }                        // foreach m_Saw
                    }
                }
            }
Example #25
0
        public static void EventSink_PlayerDeath(PlayerDeathEventArgs e)
        {
            Mobile m = e.Mobile;

            List <Mobile> killers = new List <Mobile>();
            List <Mobile> toGive  = new List <Mobile>();

            foreach (AggressorInfo ai in m.Aggressors)
            {
                if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported)
                {
                    if (!((PlayerMobile)m).RecentlyReported.Contains(ai.Attacker))
                    {
                        if (!killers.Contains(ai.Attacker))
                        {
                            killers.Add(ai.Attacker);
                            ai.Reported        = true;
                            ai.CanReportMurder = false;
                        }
                    }
                }
                if (ai.Attacker.Player && (DateTime.UtcNow - ai.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker))
                {
                    toGive.Add(ai.Attacker);
                }
            }

            foreach (AggressorInfo ai in m.Aggressed)
            {
                if (ai.Defender.Player && (DateTime.UtcNow - ai.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender))
                {
                    toGive.Add(ai.Defender);
                }
            }

            foreach (Mobile g in toGive)
            {
                int n = Notoriety.Compute(g, m);

                int  theirKarma = m.Karma, ourKarma = g.Karma;
                bool innocent = (n == Notoriety.Innocent);
                bool criminal = (n == Notoriety.Criminal || n == Notoriety.Murderer);

                int fameAward  = m.Fame / 200;
                int karmaAward = 0;

                if (innocent)
                {
                    karmaAward = (ourKarma > -2500 ? -850 : -110 - (m.Karma / 100));
                }
                else if (criminal)
                {
                    karmaAward = 50;
                }

                Titles.AwardFame(g, fameAward, false);
                Titles.AwardKarma(g, karmaAward, true);

                if (killers.Contains(g))
                {
                    EventSink.InvokePlayerMurdered(new PlayerMurderedEventArgs(g, m));
                }
            }

            if (m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild)
            {
                return;
            }

            if (killers.Count > 0)
            {
                new GumpTimer(m, killers).Start();
            }
        }
Example #26
0
 private static bool IsInnocentTo(Mobile from, Mobile to) => Notoriety.Compute(from, to) == Notoriety.Innocent;
Example #27
0
        private void DrawCharacter(UltimaBatcher2D batcher, int posX, int posY)
        {
            _equipConvData = null;
            _transform     = false;
            UOFileManager.Animations.SittingValue = 0;
            FrameInfo.X      = 0;
            FrameInfo.Y      = 0;
            FrameInfo.Width  = 0;
            FrameInfo.Height = 0;

            posY -= 3;
            int drawX = posX + (int)Offset.X;
            int drawY = posY + (int)(Offset.Y - Offset.Z);

            drawX += 22;
            drawY += 22;

            bool hasShadow = !IsDead && !IsHidden && ProfileManager.Current.ShadowsEnabled;

            if (AuraManager.IsEnabled)
            {
                AuraManager.Draw(batcher, drawX, drawY, ProfileManager.Current.PartyAura && World.Party.Contains(this) ? ProfileManager.Current.PartyAuraHue : (ushort)Notoriety.GetHue(NotorietyFlag));
            }

            bool isHuman = IsHuman;


            if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                _viewHue    = 0x0023;
                HueVector.Y = 1;
            }
            else if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                _viewHue    = Constants.OUT_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect)
            {
                _viewHue    = Constants.DEAD_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (IsHidden)
            {
                _viewHue = 0x038E;
            }
            else if (SelectedObject.HealthbarObject == this)
            {
                _viewHue = Notoriety.GetHue(NotorietyFlag);
            }
            else
            {
                _viewHue = 0;

                if (IsDead)
                {
                    if (!isHuman)
                    {
                        _viewHue = 0x0386;
                    }
                }
                else if (ProfileManager.Current.HighlightMobilesByFlags)
                {
                    if (IsPoisoned)
                    {
                        _viewHue = ProfileManager.Current.PoisonHue;
                    }

                    if (IsParalyzed)
                    {
                        _viewHue = ProfileManager.Current.ParalyzedHue;
                    }

                    if (NotorietyFlag != NotorietyFlag.Invulnerable && IsYellowHits)
                    {
                        _viewHue = ProfileManager.Current.InvulnerableHue;
                    }
                }
            }


            bool isAttack     = Serial == TargetManager.LastAttack;
            bool isUnderMouse = SelectedObject.LastObject == this && TargetManager.IsTargeting;

            //bool needHpLine = false;

            if (this != World.Player)
            {
                if (isAttack || isUnderMouse)
                {
                    _viewHue = Notoriety.GetHue(NotorietyFlag);
                }

                if (this == TargetManager.LastTarget)
                {
                    UIManager.SetTargetLineGump(this);
                    //needHpLine = true;
                }
            }


            bool mirror = false;

            ProcessSteps(out byte dir);

            UOFileManager.Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped = mirror;

            ushort graphic   = GetGraphicForAnimation();
            byte   animGroup = GetGroupForAnimation(this, graphic, true);
            sbyte  animIndex = AnimIndex;

            UOFileManager.Animations.Direction = dir;
            UOFileManager.Animations.AnimGroup = animGroup;

            Item mount = HasEquipment ? Equipment[(int)Layer.Mount] : null;

            if (isHuman && mount != null)
            {
                UOFileManager.Animations.SittingValue = 0;

                ushort mountGraphic = mount.GetGraphicForAnimation();

                if (mountGraphic != 0xFFFF)
                {
                    if (hasShadow)
                    {
                        DrawInternal(batcher, this, null, drawX, drawY + 10, mirror, ref animIndex, true, graphic, isHuman);
                        UOFileManager.Animations.AnimGroup = GetGroupForAnimation(this, mountGraphic);
                        DrawInternal(batcher, this, mount, drawX, drawY, mirror, ref animIndex, true, mountGraphic, isHuman);
                    }
                    else
                    {
                        UOFileManager.Animations.AnimGroup = GetGroupForAnimation(this, mountGraphic);
                    }

                    drawY += DrawInternal(batcher, this, mount, drawX, drawY, mirror, ref animIndex, false, mountGraphic, isHuman, isMount: true);
                }
            }
            else
            {
                if ((UOFileManager.Animations.SittingValue = IsSitting()) != 0)
                {
                    animGroup = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND;
                    animIndex = 0;

                    ProcessSteps(out dir);
                    UOFileManager.Animations.Direction = dir;
                    UOFileManager.Animations.FixSittingDirection(ref dir, ref mirror, ref drawX, ref drawY);

                    if (UOFileManager.Animations.Direction == 3)
                    {
                        animGroup = 25;
                    }
                    else
                    {
                        _transform = true;
                    }
                }
                else if (hasShadow)
                {
                    DrawInternal(batcher, this, null, drawX, drawY, mirror, ref animIndex, true, graphic, isHuman);
                }
            }

            UOFileManager.Animations.AnimGroup = animGroup;

            DrawInternal(batcher, this, null, drawX, drawY, mirror, ref animIndex, false, graphic, isHuman);

            if (HasEquipment)
            {
                var equip = Equipment;
                for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
                {
                    Layer layer = LayerOrder.UsedLayers[dir, i];

                    Item item = equip[(int)layer];

                    if (item == null)
                    {
                        continue;
                    }

                    if (IsDead && (layer == Layer.Hair || layer == Layer.Beard))
                    {
                        continue;
                    }

                    if (isHuman)
                    {
                        if (IsCovered(this, layer))
                        {
                            continue;
                        }

                        if (item.ItemData.AnimID != 0)
                        {
                            graphic = item.ItemData.AnimID;

                            if (UOFileManager.Animations.EquipConversions.TryGetValue(Graphic, out Dictionary <ushort, EquipConvData> map))
                            {
                                if (map.TryGetValue(item.ItemData.AnimID, out EquipConvData data))
                                {
                                    _equipConvData = data;
                                    graphic        = data.Graphic;
                                }
                            }

                            DrawInternal(batcher, this, item, drawX, drawY, mirror, ref animIndex, false, graphic, isHuman, false);
                        }
                        else
                        {
                            if (item.ItemData.IsLight)
                            {
                                CUOEnviroment.Client.GetScene <GameScene>().AddLight(this, this, drawX, drawY);
                            }
                        }

                        _equipConvData = null;
                    }
                    else
                    {
                        if (item.ItemData.IsLight)
                        {
                            CUOEnviroment.Client.GetScene <GameScene>().AddLight(this, this, drawX, drawY);
                            break;
                        }
                    }
                }
            }
            //if (FileManager.Animations.SittingValue != 0)
            //{
            //    ref var sittingData = ref FileManager.Animations.SittingInfos[FileManager.Animations.SittingValue - 1];

            //    if (FileManager.Animations.Direction == 3 && sittingData.DrawBack &&
            //        HasEquipment && Equipment[(int) Layer.Cloak] == null)
            //    {

            //    }
            //}
            //

            FrameInfo.X      = Math.Abs(FrameInfo.X);
            FrameInfo.Y      = Math.Abs(FrameInfo.Y);
            FrameInfo.Width  = FrameInfo.X + FrameInfo.Width;
            FrameInfo.Height = FrameInfo.Y + FrameInfo.Height;
        }
Example #28
0
 private static bool IsAllyTo(Mobile from, Mobile to) => Notoriety.Compute(from, to) == Notoriety.Ally;
Example #29
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDisposed)
            {
                return(false);
            }

            bool mirror = false;
            byte dir    = (byte)GetDirectionForAnimation();

            FileManager.Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped = mirror;

            if (Graphic == 0)
            {
                return(false);
            }


            /*if (_frames[0].IsSitting)
             * {
             *  int x1 = 0, y1 = 0;
             *  FileManager.Animations.FixSittingDirection(ref dir, ref mirror, ref x1, ref y1);
             * }*/

            FrameInfo = Rectangle.Empty;
            Rectangle rect = Rectangle.Empty;

            Hue hue = 0, targetColor = 0;

            if (Engine.Profile.Current.HighlightMobilesByFlags)
            {
                if (IsPoisoned)
                {
                    hue = 0x0044;
                }

                if (IsParalyzed)
                {
                    hue = 0x014C;
                }

                if (NotorietyFlag != NotorietyFlag.Invulnerable && IsYellowHits)
                {
                    hue = 0x0030;
                }
            }

            bool isAttack     = Serial == World.LastAttack;
            bool isUnderMouse = IsSelected && (TargetManager.IsTargeting || World.Player.InWarMode);
            bool needHpLine   = false;

            if (this != World.Player && (isAttack || isUnderMouse || TargetManager.LastGameObject == Serial))
            {
                targetColor = Notoriety.GetHue(NotorietyFlag);

                if (isAttack || this == TargetManager.LastGameObject)
                {
                    Engine.UI.SetTargetLineGump(this);
                    needHpLine = true;
                }

                if (isAttack || isUnderMouse)
                {
                    hue = targetColor;
                }
            }

            bool drawShadow = !IsDead && !IsHidden;

            DrawBody(batcher, position, objectList, dir, out int drawX, out int drawY, out int drawCenterY, ref rect, ref mirror, hue, drawShadow);

            if (IsHuman)
            {
                DrawEquipment(batcher, position, objectList, dir, ref drawX, ref drawY, ref drawCenterY, ref rect, ref mirror, hue);
            }

            FrameInfo.X      = Math.Abs(rect.X);
            FrameInfo.Y      = Math.Abs(rect.Y);
            FrameInfo.Width  = FrameInfo.X + rect.Width;
            FrameInfo.Height = FrameInfo.Y + rect.Height;


            //if (_edge == null)
            //{
            //    _edge = new Texture2D(batcher.GraphicsDevice, 1, 1);
            //    _edge.SetData(new Color[] { Color.LightBlue });
            //}

            //batcher.DrawRectangle(_edge, GetOnScreenRectangle(), Vector3.Zero);
            Engine.DebugInfo.MobilesRendered++;
            return(true);
        }
Example #30
0
 public static void TargetNoto(Notoriety noto)
 {
     Mobile player = World.Player;
     if (player != null)
     {
         ArrayList dataStore = GetDataStore();
         IEnumerator enumerator = World.Mobiles.Values.GetEnumerator();
         MapPackage cache = Map.GetCache();
         bool flag = (noto != Notoriety.Innocent) && (noto != Notoriety.Ally);
         while (enumerator.MoveNext())
         {
             Mobile current = (Mobile) enumerator.Current;
             if (((current.Visible && (current.Notoriety == noto)) && (!flag || !current.m_IsFriend)) && (!current.Player && player.InSquareRange(current, 12)))
             {
                 if (current.Notoriety == Notoriety.Innocent)
                 {
                     int num = current.X - cache.CellX;
                     int num2 = current.Y - cache.CellY;
                     if (((num >= 0) && (num < Renderer.cellWidth)) && (((num2 >= 0) && (num2 < Renderer.cellHeight)) && cache.landTiles[num, num2].m_Guarded))
                     {
                         continue;
                     }
                 }
                 dataStore.Add(current);
             }
         }
         if (dataStore.Count > 0)
         {
             dataStore.Sort(TargetSorter.Comparer);
             Mobile o = (Mobile) dataStore[0];
             if (m_TargetHandler != null)
             {
                 Target(o);
             }
             else if (World.CharData.QueueTargets)
             {
                 if ((o != null) && (m_TargetQueue != o))
                 {
                     o.AddTextMessage("", "Target queued.", GetFont(3), Hues.Load(0x59), true);
                 }
                 m_TargetQueue = o;
             }
         }
         ReleaseDataStore(dataStore);
     }
 }
Example #31
0
        private void DrawHealthLine(UltimaBatcher2D batcher, Mobile mobile, int x, int y, bool passive)
        {
            if (mobile == null)
            {
                return;
            }

            int per = mobile.HitsMax;

            if (per > 0)
            {
                per = mobile.Hits * 100 / per;

                if (per > 100)
                {
                    per = 100;
                }

                if (per < 1)
                {
                    per = 0;
                }
                else
                {
                    per = 34 * per / 100;
                }
            }

            _vectorHue.X = 0;
            _vectorHue.Y = 0;
            _vectorHue.Z = 0;

            float alpha = passive ? 0.5f : 0.0f;

            ShaderHuesTraslator.GetHueVector(ref _vectorHue, Notoriety.GetHue(mobile.NotorietyFlag), false, alpha);

            batcher.Draw2D(_background_texture,
                           x, y,
                           _background_texture.Width,
                           _background_texture.Height,
                           ref _vectorHue);

            _vectorHue.X = 0;
            _vectorHue.Y = 0;
            _vectorHue.Z = 0;

            ushort hue = 23;

            alpha = passive ? 0.5f : 0.0f;

            ShaderHuesTraslator.GetHueVector(ref _vectorHue, hue, false, alpha);

            batcher.Draw2DTiled(_hp_texture,
                                x, y,
                                BAR_WIDTH,
                                _hp_texture.Height,
                                ref _vectorHue);

            _vectorHue.X = 0;
            _vectorHue.Y = 0;
            _vectorHue.Z = 0;


            if (mobile.IsPoisoned)
            {
                hue = 63;
            }
            else if (mobile.IsYellowHits)
            {
                hue = 53;
            }
            else
            {
                hue = 90;
            }

            ShaderHuesTraslator.GetHueVector(ref _vectorHue, hue, false, alpha);

            batcher.Draw2DTiled(_hp_texture,
                                x, y,
                                per,
                                _hp_texture.Height,
                                ref _vectorHue);
        }
        public static void DoPassiveDetect(Mobile src)
        {
            if (src == null || src.Map == null || src.Location == Point3D.Zero || src.IsStaff())
            {
                return;
            }

            double ss = src.Skills[SkillName.DetectHidden].Value;

            if (ss <= 0)
            {
                return;
            }

            IPooledEnumerable eable = src.Map.GetMobilesInRange(src.Location, 4);

            if (eable == null)
            {
                return;
            }

            foreach (Mobile m in eable)
            {
                if (m == null || m is ShadowKnight)
                {
                    continue;
                }

                int noto = Notoriety.Compute(src, m);

                if (m != src && noto != Notoriety.Innocent && noto != Notoriety.Ally && noto != Notoriety.Invulnerable)
                {
                    double ts = (m.Skills[SkillName.Hiding].Value + m.Skills[SkillName.Stealth].Value) / 2;

                    if (src.Race == Race.Elf)
                    {
                        ss += 20;
                    }

                    if (src.AccessLevel >= m.AccessLevel && Utility.Random(1000) < (ss - ts) + 1)
                    {
                        m.RevealingAction();
                        m.SendLocalizedMessage(500814); // You have been revealed!
                    }
                }
            }

            eable.Free();

            eable = src.Map.GetItemsInRange(src.Location, 8);

            foreach (var item in eable)
            {
                if (item is IRevealableItem && ((IRevealableItem)item).CheckPassiveDetect(src))
                {
                    src.SendLocalizedMessage(1153493); // Your keen senses detect something hidden in the area...
                }
            }

            eable.Free();
        }
        public static bool ValidIndirectTarget(Mobile from, Mobile to)
        {
            if (from == to)
            {
                return(true);
            }

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

            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) && !(to.Region is GameRegion && ((GameRegion)to.Region).AllowHarmful(from, to)))
            {
                return(false);
            }

            BaseCreature tbc = to as BaseCreature;
            BaseCreature fbc = from as BaseCreature;

            if (tbc != null)
            {
                if (tbc.Controlled || tbc.Summoned)
                {
                    if (tbc.ControlMaster == from || tbc.SummonMaster == from)
                    {
                        return(false);
                    }

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

            if (fbc != null)
            {
                if (fbc.Controlled || fbc.Summoned)
                {
                    if (fbc.ControlMaster == to || fbc.SummonMaster == to)
                    {
                        return(false);
                    }

                    p = Party.Get(to);

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

            if (tbc != null && fbc != null && !tbc.Controlled && !fbc.Controlled && !tbc.BardProvoked && !fbc.BardProvoked && tbc.Team == fbc.Team)
            {
                return(false);
            }

            if (tbc != null && !tbc.Controlled && tbc.InitialInnocent)
            {
                return(true);
            }

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

            return(noto != Notoriety.Innocent || from.Kills >= 0);
        }
Example #34
0
        public override void Update(double totalMS, double frameMS)
        {
            base.Update(totalMS, frameMS);

            if (IsDisposed)
            {
                return;
            }

            bool inparty = World.Party.GetPartyMember(_partyMemeberSerial) != null;

            Hue color     = 0;
            Hue textColor = 0x0386;
            Hue hitsColor = 0x0386;

            if (Mobile == null || Mobile.IsDisposed)
            {
                Mobile = World.Mobiles.Get(LocalSerial);

                if (!_outOfRange && Mobile == null)
                {
                    _poisoned   = false;
                    _yellowHits = false;
                    _normalHits = true;

                    _outOfRange = true;

                    if (inparty)
                    {
                        hitsColor = textColor = 912;

                        if (_partyNameLabel.Hue != textColor)
                        {
                            _partyNameLabel.Hue = textColor;
                        }

                        _buttonHeal1.IsVisible = _buttonHeal2.IsVisible = false;

                        _bars[1].IsVisible = false;
                        _bars[2].IsVisible = false;
                    }
                    else
                    {
                        if (_textBox.Hue != textColor)
                        {
                            _textBox.Hue = textColor;
                        }

                        if (_canChangeName)
                        {
                            _textBox.MouseClick -= TextBoxOnMouseClick;
                        }
                    }

                    if (_background.Hue != color)
                    {
                        _background.Hue = color;
                    }

                    if (_hpLineRed.Hue != hitsColor)
                    {
                        _hpLineRed.Hue = hitsColor;

                        if (_manaLineRed != null && _stamLineRed != null)
                        {
                            _manaLineRed.Hue = _stamLineRed.Hue = hitsColor;
                        }
                    }


                    _bars[0].IsVisible = false;
                }
            }

            if (Mobile != null && Mobile.HitsMax > 0)
            {
                if (_outOfRange)
                {
                    _outOfRange = false;

                    if (_name != Mobile.Name && !string.IsNullOrEmpty(Mobile.Name))
                    {
                        _name = Mobile.Name;
                    }

                    hitsColor = 0;
                    color     = Notoriety.GetHue(Mobile.NotorietyFlag);

                    if (Mobile.NotorietyFlag == NotorietyFlag.Criminal || Mobile.NotorietyFlag == NotorietyFlag.Gray)
                    {
                        color = 0;
                    }

                    if (inparty)
                    {
                        textColor = color;
                    }
                    else
                    {
                        _canChangeName = Mobile.IsRenamable;

                        if (_canChangeName)
                        {
                            textColor = 0x000E;

                            _textBox.MouseClick += TextBoxOnMouseClick;
                        }
                    }


                    if (_background.Hue != color)
                    {
                        _background.Hue = color;
                    }

                    if (inparty)
                    {
                        if (_partyNameLabel.Hue != textColor)
                        {
                            _partyNameLabel.Hue = textColor;
                        }

                        _buttonHeal1.IsVisible = _buttonHeal2.IsVisible = true;

                        _bars[1].IsVisible = true;
                        _bars[2].IsVisible = true;
                    }
                    else
                    {
                        if (_textBox.Hue != textColor)
                        {
                            _textBox.Hue = textColor;
                        }

                        if (_textBox.Text != _name)
                        {
                            _textBox.Text = _name;
                        }
                    }

                    if (_hpLineRed.Hue != hitsColor)
                    {
                        _hpLineRed.Hue = hitsColor;

                        if (_manaLineRed != null && _stamLineRed != null)
                        {
                            _manaLineRed.Hue = _stamLineRed.Hue = hitsColor;
                        }
                    }

                    _bars[0].IsVisible = true;
                }



                if (Mobile.IsPoisoned && !_poisoned)
                {
                    if (inparty)
                    {
                        _bars[0].Hue = 63;
                    }
                    else
                    {
                        _bars[0].Graphic = LINE_POISONED;
                    }

                    _poisoned   = true;
                    _normalHits = false;
                }
                else if (Mobile.IsYellowHits && !_yellowHits)
                {
                    if (inparty)
                    {
                        _bars[0].Hue = 353;
                    }
                    else
                    {
                        _bars[0].Graphic = LINE_YELLOWHITS;
                    }
                    _yellowHits = true;
                    _normalHits = false;
                }
                else if (!_normalHits && !Mobile.IsPoisoned && !Mobile.IsYellowHits && (_poisoned || _yellowHits))
                {
                    if (inparty)
                    {
                        _bars[0].Hue = 0;
                    }
                    else
                    {
                        _bars[0].Graphic = LINE_BLUE;
                    }
                    _poisoned   = false;
                    _yellowHits = false;
                    _normalHits = true;
                }

                int hits = CalculatePercents(Mobile.HitsMax, Mobile.Hits, inparty ? 96 : 109);

                if (hits != _oldHits)
                {
                    _bars[0].Percent = hits;
                    _oldHits         = hits;
                }
            }


            if (CanBeSaved)
            {
                if (World.Player.InWarMode != _oldWarMode)
                {
                    _oldWarMode = !_oldWarMode;

                    _background.Graphic = World.Player.InWarMode ? BACKGROUND_WAR : BACKGROUND_NORMAL;
                }

                int mana = CalculatePercents(World.Player.ManaMax, World.Player.Mana, inparty ? 96 : 109);
                int stam = CalculatePercents(World.Player.StaminaMax, World.Player.Stamina, inparty ? 96 : 109);

                if (mana != _oldMana)
                {
                    _bars[1].Percent = mana;
                    _oldMana         = mana;
                }

                if (stam != _oldStam)
                {
                    _bars[2].Percent = stam;
                    _oldStam         = stam;
                }
            }
        }
Example #35
0
 public void OnNotorietyChange(Notoriety n)
 {
     if (this.m_Mobile.Visible)
     {
         this.m_Name.Hue = Hues.GetNotoriety(n);
     }
     else
     {
         this.m_Name.Hue = Hues.Grayscale;
     }
 }
Example #36
0
        private void BuildGump()
        {
            LocalSerial = _partyMemeberSerial;

            CanBeSaved = _partyMemeberSerial == World.Player;

            WantUpdateSize = false;

            if (World.Party.GetPartyMember(_partyMemeberSerial) != null)
            {
                Add(_background = new GumpPic(0, 0, BACKGROUND_NORMAL, 0)
                {
                    IsVisible = false
                });
                Width  = 115;
                Height = 55;

                if (CanBeSaved)
                {
                    Add(_partyNameLabel = new Label("[* SELF *]", false, 0x0386, font: 3)
                    {
                        X = 0, Y = -2
                    });
                }
                else
                {
                    Add(_partyNameLabel = new Label(_name, false, Notoriety.GetHue(Mobile.NotorietyFlag), 150, 3, FontStyle.Fixed)
                    {
                        X = 0, Y = -2
                    });
                }

                Add(_buttonHeal1 = new Button((int)ButtonParty.Heal1, 0x0938, 0x093A, 0x0938)
                {
                    ButtonAction = ButtonAction.Activate, X = 0, Y = 20
                });
                Add(_buttonHeal2 = new Button((int)ButtonParty.Heal2, 0x0939, 0x093A, 0x0939)
                {
                    ButtonAction = ButtonAction.Activate, X = 0, Y = 33
                });

                Add(_hpLineRed   = new GumpPic(18, 20, LINE_RED_PARTY, 0));
                Add(_manaLineRed = new GumpPic(18, 33, LINE_RED_PARTY, 0));
                Add(_stamLineRed = new GumpPic(18, 45, LINE_RED_PARTY, 0));

                Add(_bars[0] = new GumpPicWithWidth(18, 20, LINE_BLUE_PARTY, 0, 96));
                Add(_bars[1] = new GumpPicWithWidth(18, 33, LINE_BLUE_PARTY, 0, 96));
                Add(_bars[2] = new GumpPicWithWidth(18, 45, LINE_BLUE_PARTY, 0, 96));
            }
            else
            {
                if (CanBeSaved)
                {
                    _oldWarMode     = World.Player.InWarMode;
                    Add(_background = new GumpPic(0, 0, _oldWarMode ? BACKGROUND_WAR : BACKGROUND_NORMAL, 0));

                    Width  = _background.Texture.Width;
                    Height = _background.Texture.Height;

                    // add backgrounds
                    Add(_hpLineRed = new GumpPic(34, 12, LINE_RED, 0));
                    Add(new GumpPic(34, 25, LINE_RED, 0));
                    Add(new GumpPic(34, 38, LINE_RED, 0));

                    // add over
                    Add(_bars[0] = new GumpPicWithWidth(34, 12, LINE_BLUE, 0, 0));
                    Add(_bars[1] = new GumpPicWithWidth(34, 25, LINE_BLUE, 0, 0));
                    Add(_bars[2] = new GumpPicWithWidth(34, 38, LINE_BLUE, 0, 0));
                }
                else
                {
                    Hue color     = 0;
                    Hue textColor = 0x0386;
                    Hue hitsColor = 0x0386;

                    if (Mobile != null)
                    {
                        hitsColor = 0;
                        color     = Notoriety.GetHue(Mobile.NotorietyFlag);

                        if (Mobile.NotorietyFlag == NotorietyFlag.Criminal || Mobile.NotorietyFlag == NotorietyFlag.Gray)
                        {
                            color = 0;
                        }

                        if (_canChangeName = Mobile.IsRenamable)
                        {
                            textColor = 0x000E;
                        }
                    }

                    Add(_background = new GumpPic(0, 0, 0x0804, color));
                    Add(_hpLineRed  = new GumpPic(34, 38, LINE_RED, hitsColor));
                    Add(_bars[0]    = new GumpPicWithWidth(34, 38, LINE_BLUE, 0, 0));

                    Width  = _background.Texture.Width;
                    Height = _background.Texture.Height;


                    Add(_textBox = new TextBox(1, width: 150, isunicode: false, hue: textColor)
                    {
                        X                   = 16,
                        Y                   = 14,
                        Width               = 150,
                        IsEditable          = false,
                        AcceptMouseInput    = _canChangeName,
                        AcceptKeyboardInput = _canChangeName,
                        Text                = _name
                    });

                    if (_canChangeName)
                    {
                        _textBox.MouseClick += TextBoxOnMouseClick;
                    }
                }
            }
        }
Example #37
0
        public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
        {
            if (from == null || target == null || from.AccessLevel > AccessLevel.Player ||
                target.AccessLevel > AccessLevel.Player)
            {
                return(true);
            }

            var pmFrom = from as PlayerMobile;
            var pmTarg = target as PlayerMobile;
            var bcTarg = target as BaseCreature;

            if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned)
            {
                pmFrom = bcFrom.SummonMaster as PlayerMobile;
            }

            if (pmTarg == null && bcTarg?.Summoned == true)
            {
                pmTarg = bcTarg.SummonMaster as PlayerMobile;
            }

            if (pmFrom != null && pmTarg != null)
            {
                if (pmFrom.DuelContext != pmTarg.DuelContext &&
                    (pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
                    (pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied ||
                     pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
                    pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true &&
                    pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
                    pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
                {
                    return(false);
                }

                if (pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext)
                {
                    return(true);
                }
            }

            if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true)
            {
                return(false);
            }

            if (from.Region.IsPartOf <SafeZone>() || target.Region.IsPartOf <SafeZone>())
            {
                return(false);
            }

            var map = from.Map;

            if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }

            if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null &&
                                  bc.GetMaster().AccessLevel == AccessLevel.Player))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) &&
                    pmTarg?.CheckYoungProtection(from) == true)
                {
                    return(false);
                }

                return(true); // Uncontrolled NPCs are only restricted by the young system
            }

            var fromGuild   = GetGuildFor(from.Guild as Guild, from);
            var targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null &&
                (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
            {
                return(true); // Guild allies or enemies can be harmful
            }

            if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from)
            {
                return(false); // Cannot harm other controlled mobiles
            }

            if (target.Player)
            {
                return(false); // Cannot harm other players
            }

            return(bcTarg?.InitialInnocent == true || Notoriety.Compute(from, target) != Notoriety.Innocent);
        }
Example #38
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            ResetHueVector();

            int sittigIndex = 0;

            _equipConvData   = null;
            _transform       = false;
            FrameInfo.X      = 0;
            FrameInfo.Y      = 0;
            FrameInfo.Width  = 0;
            FrameInfo.Height = 0;

            posY -= 3;
            int drawX = posX + (int)Offset.X;
            int drawY = posY + (int)(Offset.Y - Offset.Z);

            drawX += 22;
            drawY += 22;

            bool hasShadow = !IsDead && !IsHidden && ProfileManager.CurrentProfile.ShadowsEnabled;

            if (AuraManager.IsEnabled)
            {
                AuraManager.Draw(batcher, drawX, drawY, ProfileManager.CurrentProfile.PartyAura && World.Party.Contains(this) ? ProfileManager.CurrentProfile.PartyAuraHue : Notoriety.GetHue(NotorietyFlag));
            }

            bool isHuman = IsHuman;

            bool isGargoyle = Client.Version >= ClientVersion.CV_7000 && (Graphic == 666 || Graphic == 667 || Graphic == 0x02B7 || Graphic == 0x02B6);

            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                _viewHue    = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                HueVector.Y = 1;
            }
            else if (SelectedObject.HealthbarObject == this)
            {
                _viewHue = Notoriety.GetHue(NotorietyFlag);
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                _viewHue    = Constants.OUT_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                _viewHue    = Constants.DEAD_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (IsHidden)
            {
                _viewHue = 0x038E;
            }
            else
            {
                _viewHue = 0;

                if (IsDead)
                {
                    if (!isHuman)
                    {
                        _viewHue = 0x0386;
                    }
                }
                else if (ProfileManager.CurrentProfile.HighlightMobilesByFlags)
                {
                    if (IsPoisoned)
                    {
                        _viewHue = ProfileManager.CurrentProfile.PoisonHue;
                    }

                    if (IsParalyzed)
                    {
                        _viewHue = ProfileManager.CurrentProfile.ParalyzedHue;
                    }

                    if (NotorietyFlag != NotorietyFlag.Invulnerable && IsYellowHits)
                    {
                        _viewHue = ProfileManager.CurrentProfile.InvulnerableHue;
                    }
                }
            }


            bool isAttack     = Serial == TargetManager.LastAttack;
            bool isUnderMouse = TargetManager.IsTargeting && SelectedObject.LastObject == this;

            if (Serial != World.Player.Serial)
            {
                if (isAttack || isUnderMouse)
                {
                    _viewHue = Notoriety.GetHue(NotorietyFlag);
                }
            }


            ProcessSteps(out byte dir);
            byte layerDir = dir;

            AnimationsLoader.Instance.GetAnimDirection(ref dir, ref IsFlipped);

            ushort graphic   = GetGraphicForAnimation();
            byte   animGroup = GetGroupForAnimation(this, graphic, true);
            sbyte  animIndex = AnimIndex;

            Item mount = FindItemByLayer(Layer.Mount);

            if (isHuman && mount != null)
            {
                ushort mountGraphic   = mount.GetGraphicForAnimation();
                byte   animGroupMount = 0;

                if (mountGraphic != 0xFFFF)
                {
                    if (hasShadow)
                    {
                        DrawInternal
                        (
                            batcher,
                            this,
                            null,
                            drawX,
                            drawY + 10,
                            IsFlipped,
                            animIndex,
                            true,
                            graphic,
                            animGroup,
                            dir,
                            isHuman,
                            alpha: HueVector.Z
                        );

                        animGroupMount = GetGroupForAnimation(this, mountGraphic);

                        DrawInternal
                        (
                            batcher,
                            this,
                            mount,
                            drawX,
                            drawY,
                            IsFlipped,
                            animIndex,
                            true,
                            mountGraphic,
                            animGroupMount,
                            dir,
                            isHuman,
                            alpha: HueVector.Z
                        );
                    }
                    else
                    {
                        animGroupMount = GetGroupForAnimation(this, mountGraphic);
                    }

                    drawY += DrawInternal
                             (
                        batcher,
                        this,
                        mount,
                        drawX,
                        drawY,
                        IsFlipped,
                        animIndex,
                        false,
                        mountGraphic,
                        animGroupMount,
                        dir,
                        isHuman,
                        isMount: true,
                        alpha: HueVector.Z
                             );
                }
            }
            else
            {
                if ((sittigIndex = IsSitting()) != 0)
                {
                    animGroup = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND;
                    animIndex = 0;

                    ProcessSteps(out dir);

                    AnimationsLoader.Instance.FixSittingDirection
                    (
                        ref dir,
                        ref IsFlipped,
                        ref drawX,
                        ref drawY,
                        sittigIndex
                    );

                    drawY += SIT_OFFSET_Y;

                    if (dir == 3)
                    {
                        if (IsGargoyle)
                        {
                            drawY    -= 30 - SIT_OFFSET_Y;
                            animGroup = 42;
                        }
                        else
                        {
                            animGroup = 25;
                        }
                    }
                    else if (IsGargoyle)
                    {
                        animGroup = 42;
                    }
                    else
                    {
                        _transform = true;
                    }
                }
                else if (hasShadow)
                {
                    DrawInternal
                    (
                        batcher,
                        this,
                        null,
                        drawX,
                        drawY,
                        IsFlipped,
                        animIndex,
                        true,
                        graphic,
                        animGroup,
                        dir,
                        isHuman,
                        alpha: HueVector.Z
                    );
                }
            }

            DrawInternal
            (
                batcher,
                this,
                null,
                drawX,
                drawY,
                IsFlipped,
                animIndex,
                false,
                graphic,
                animGroup,
                dir,
                isHuman,
                alpha: HueVector.Z,
                forceUOP: isGargoyle
            );

            if (!IsEmpty)
            {
                for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
                {
                    Layer layer = LayerOrder.UsedLayers[layerDir, i];

                    Item item = FindItemByLayer(layer);

                    if (item == null)
                    {
                        continue;
                    }

                    if (IsDead && (layer == Layer.Hair || layer == Layer.Beard))
                    {
                        continue;
                    }

                    if (isHuman)
                    {
                        if (IsCovered(this, layer))
                        {
                            continue;
                        }

                        if (item.ItemData.AnimID != 0)
                        {
                            graphic = item.ItemData.AnimID;

                            if (isGargoyle)
                            {
                                switch (graphic)
                                {
                                // gargoyle robe
                                case 0x01D5:
                                    graphic = 0x0156;

                                    break;

                                // gargoyle dead shroud
                                case 0x03CA:
                                    graphic = 0x0223;

                                    break;

                                // gargoyle spellbook
                                case 0x03D8:
                                    graphic = 329;

                                    break;

                                // gargoyle necrobook
                                case 0x0372:
                                    graphic = 330;

                                    break;

                                // gargoyle chivalry book
                                case 0x0374:
                                    graphic = 328;

                                    break;

                                // gargoyle bushido book
                                case 0x036F:
                                    graphic = 327;

                                    break;

                                // gargoyle ninjitsu book
                                case 0x036E:
                                    graphic = 328;

                                    break;

                                // gargoyle masteries book
                                case 0x0426:
                                    graphic = 0x042B;

                                    break;


                                    // gargoyle mysticism book seems ok. Mha!
                                }
                            }


                            if (AnimationsLoader.Instance.EquipConversions.TryGetValue(Graphic, out Dictionary <ushort, EquipConvData> map))
                            {
                                if (map.TryGetValue(item.ItemData.AnimID, out EquipConvData data))
                                {
                                    _equipConvData = data;
                                    graphic        = data.Graphic;
                                }
                            }

                            // Seems like all Gargoyle equipment has the 'IsWeapon' flag
                            if (sittigIndex == 0 && IsGargoyle /*&& item.ItemData.IsWeapon*/)
                            {
                                DrawInternal
                                (
                                    batcher,
                                    this,
                                    item,
                                    drawX,
                                    drawY,
                                    IsFlipped,
                                    animIndex,
                                    false,
                                    graphic,
                                    GetGroupForAnimation(this, graphic, true),
                                    dir,
                                    isHuman,
                                    true,
                                    alpha: HueVector.Z,
                                    forceUOP: true
                                );
                            }
                            else
                            {
                                DrawInternal
                                (
                                    batcher,
                                    this,
                                    item,
                                    drawX,
                                    drawY,
                                    IsFlipped,
                                    animIndex,  //item.AnimIndex,
                                    false,
                                    graphic,
                                    animGroup,
                                    dir,
                                    isHuman,
                                    false,
                                    alpha: HueVector.Z
                                );
                            }
                        }
                        else
                        {
                            if (item.ItemData.IsLight)
                            {
                                Client.Game.GetScene <GameScene>().AddLight(this, this, drawX, drawY);
                            }
                        }

                        _equipConvData = null;
                    }
                    else
                    {
                        if (item.ItemData.IsLight)
                        {
                            Client.Game.GetScene <GameScene>().AddLight(this, this, drawX, drawY);

                            /*DrawInternal
                             * (
                             *  batcher,
                             *  this,
                             *  item,
                             *  drawX,
                             *  drawY,
                             *  IsFlipped,
                             *  animIndex,
                             *  false,
                             *  graphic,
                             *  animGroup,
                             *  dir,
                             *  isHuman,
                             *  false,
                             *  alpha: HueVector.Z
                             * );
                             */
                            //break;
                        }
                    }
                }
            }


            //if (FileManager.Animations.SittingValue != 0)
            //{
            //    ref var sittingData = ref FileManager.Animations.SittingInfos[FileManager.Animations.SittingValue - 1];

            //    if (FileManager.Animations.Direction == 3 && sittingData.DrawBack &&
            //        HasEquipment && Equipment[(int) Layer.Cloak] == null)
            //    {

            //    }
            //}
            //

            FrameInfo.X      = Math.Abs(FrameInfo.X);
            FrameInfo.Y      = Math.Abs(FrameInfo.Y);
            FrameInfo.Width  = FrameInfo.X + FrameInfo.Width;
            FrameInfo.Height = FrameInfo.Y + FrameInfo.Height;

            return(true);
        }
 private static bool IsAllyTo(Mobile from, Mobile to)
 {
     return(Notoriety.Compute(from, (Mobile)to) == Notoriety.Ally);
 }
Example #40
0
        public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable)
        {
            Mobile target = damageable as Mobile;

            if (from == null || target == null || from.IsStaff() || target.IsStaff())
            {
                return(true);
            }

            #region Mondain's Legacy
            if (target is Gregorio)
            {
                if (Gregorio.IsMurderer(from))
                {
                    return(true);
                }

                from.SendLocalizedMessage(1075456); // You are not allowed to damage this NPC unless your on the Guilty Quest
                return(false);
            }
            #endregion

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

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

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

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

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

            if (pmFrom != null && pmTarg != null)
            {
                if (pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
                {
                    return(false);
                }

                if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
                {
                    return(true);
                }
            }

            if ((pmFrom != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
            {
                return(false);
            }

            Engines.ConPVP.SafeZone sz = from.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone;

            if (sz != null /*&& sz.IsDisabled()*/)
            {
                return(false);
            }

            sz = target.Region.GetRegion(typeof(Engines.ConPVP.SafeZone)) as Engines.ConPVP.SafeZone;

            if (sz != null /*&& sz.IsDisabled()*/)
            {
                return(false);
            }
            #endregion

            Map map = from.Map;

            if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
            {
                return(true); // In felucca, anything goes
            }
            // Summons should follow the same rules as their masters
            if (from is BaseCreature && ((BaseCreature)from).Summoned && ((BaseCreature)from).SummonMaster != null)
            {
                from = ((BaseCreature)from).SummonMaster;
            }

            if (target is BaseCreature && ((BaseCreature)target).Summoned && ((BaseCreature)target).SummonMaster != null)
            {
                target = ((BaseCreature)target).SummonMaster;
            }

            BaseCreature bc = from as BaseCreature;

            if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer()))
            {
                if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection(from))
                {
                    return(false);
                }

                return(true); // Uncontrolled NPCs are only restricted by the young system
            }

            if (XmlPoints.AreChallengers(from, target))
            {
                return(true);
            }

            Guild fromGuild   = GetGuildFor(from.Guild as Guild, from);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
            {
                return(true); // Guild allies or enemies can be harmful
            }
            if (target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)))
            {
                return(false); // Cannot harm other controlled mobiles
            }
            if (target.Player)
            {
                return(false); // Cannot harm other players
            }
            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (Notoriety.Compute(from, target) == Notoriety.Innocent)
                {
                    return(false); // Cannot harm innocent mobiles
                }
            }

            return(true);
        }
Example #41
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Serial = reader.ReadUInt32();
            _Body = reader.ReadInt16();
            _X = reader.ReadInt16();
            _Y = reader.ReadInt16();
            _Z = reader.ReadSByte();
            _Direction = (Direction) reader.ReadByte();
            _Hue = reader.ReadUInt16();

            byte flags = reader.ReadByte();

            if ( ( flags & 0x1 ) > 0 )
                _IsFrozen = true;

            if ( ( flags & 0x2 ) > 0 )
                _IsFemale = true;

            if ( ( flags & 0x4 ) > 0 )
                _IsFlying = true;

            if ( ( flags & 0x8 ) > 0 )
                _HasYellowHealthBar = true;

            if ( ( flags & 0x10 ) > 0 )
                _IsIgnoringMobiles = true;

            if ( ( flags & 0x40 ) > 0 )
                _IsInWarMode = true;

            if ( ( flags & 0x80 ) > 0 )
                _IsHidden = true;

            _Notoriety = (Notoriety) reader.ReadByte();

            // Items
            _Items = new List<MobileItem>();

            uint serial = 0;

            while ( ( serial = reader.ReadUInt32() ) != 0 )
                _Items.Add( new MobileItem( serial, reader ) );
        }
Example #42
0
 public void OnNotorietyChange(Notoriety n)
 {
     if (!this.m_Player)
     {
         base.Hue = Hues.GetNotoriety(n);
     }
 }