Esempio n. 1
0
        public override void Select(int x, int y)
        {
            if (!SerialHelper.IsValid(Serial) /*&& IsMulti*/ && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                return;
            }

            if (SelectedObject.Object == this)
            {
                return;
            }

            if (IsCorpse)
            {
                if (Texture.Contains(x, y))
                {
                    SelectedObject.Object = this;
                }
            }
            else
            {
                if (SelectedObject.IsPointInStatic(Texture, x - Bounds.X, y - Bounds.Y))
                {
                    SelectedObject.Object = this;
                }
            }
        }
Esempio n. 2
0
        public DragEffect(uint src, uint trg, int xSource, int ySource, int zSource, int xTarget, int yTarget, int zTarget, ushort graphic, ushort hue)
        {
            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(xSource, ySource, zSource);
            }


            Entity target = World.Get(trg);

            if (SerialHelper.IsValid(trg) && target != null)
            {
                SetTarget(target);
            }
            else
            {
                SetTarget(xTarget, yTarget, zTarget);
            }

            AlphaHue = 255;
            Hue      = hue;
            Graphic  = graphic;
            Load();
        }
Esempio n. 3
0
        public void RequestServerPartyGuildInfo(bool force = false)
        {
            if (!force && !Enabled)
            {
                return;
            }

            if (World.InGame && _lastPacketSend < Time.Ticks)
            {
                _lastPacketSend = Time.Ticks + (uint)(_lastPacketRecv < Time.Ticks ? 2000 : 250);

                NetClient.Socket.Send(new PQueryGuildPosition());

                if (World.Party != null && World.Party.Leader != 0)
                {
                    foreach (var e in World.Party.Members)
                    {
                        if (e != null && SerialHelper.IsValid(e.Serial))
                        {
                            var mob = World.Mobiles.Get(e.Serial);

                            if (mob == null || mob.Distance > World.ClientViewRange)
                            {
                                NetClient.Socket.Send(new PQueryPartyPosition());
                                break;
                            }
                        }
                    }
                }
            }
        }
        private void CloseItemGumps(Item item)
        {
            if (item != null)
            {
                var gump = UIManager.GetGump <Gump>(item);

                if (gump != null)
                {
                    if (gump.GumpType == GUMP_TYPE.GT_SPELLBUTTON)
                    {
                        return;
                    }

                    gump.Dispose();
                }

                if (SerialHelper.IsValid(item.Container))
                {
                    for (var i = item.Items; i != null; i = i.Next)
                    {
                        Item it = (Item)i;
                        CloseItemGumps(it);
                    }
                }
            }
        }
Esempio n. 5
0
        private void CloseItemGumps(Item item)
        {
            if (item != null)
            {
                var gump = UIManager.GetGump <Gump>(item);

                if (gump != null)
                {
                    if (gump.GumpType == GUMP_TYPE.GT_SPELLBUTTON)
                    {
                        return;
                    }

                    gump.Dispose();
                }

                if (SerialHelper.IsValid(item.Container))
                {
                    foreach (Item i in item.Items)
                    {
                        CloseItemGumps(i);
                    }
                }
            }
        }
Esempio n. 6
0
        private string ReadProperties(uint serial, out string htmltext)
        {
            bool hasStartColor = false;

            string result = null;

            htmltext = string.Empty;

            if (SerialHelper.IsValid(serial) && World.OPL.TryGetNameAndData(serial, out string name, out string data))
            {
                ValueStringBuilder sbHTML = new ValueStringBuilder();
                {
                    ValueStringBuilder sb = new ValueStringBuilder();
                    {
                        if (!string.IsNullOrEmpty(name))
                        {
                            if (SerialHelper.IsItem(serial))
                            {
                                sbHTML.Append("<basefont color=\"yellow\">");
                                hasStartColor = true;
                            }
                            else
                            {
                                Mobile mob = World.Mobiles.Get(serial);

                                if (mob != null)
                                {
                                    sbHTML.Append(Notoriety.GetHTMLHue(mob.NotorietyFlag));
                                    hasStartColor = true;
                                }
                            }

                            sb.Append(name);
                            sbHTML.Append(name);

                            if (hasStartColor)
                            {
                                sbHTML.Append("<basefont color=\"#FFFFFFFF\">");
                            }
                        }

                        if (!string.IsNullOrEmpty(data))
                        {
                            sb.Append('\n');
                            sb.Append(data);
                            sbHTML.Append('\n');
                            sbHTML.Append(data);
                        }

                        htmltext = sbHTML.ToString();
                        result   = sb.ToString();

                        sb.Dispose();
                        sbHTML.Dispose();
                    }
                }
            }
            return(string.IsNullOrEmpty(result) ? null : result);
        }
            public GumpPicEquipment(uint serial, int x, int y, ushort graphic, ushort hue, Layer layer) : base(x, y, graphic, hue)
            {
                LocalSerial = serial;
                CanMove     = false;
                _layer      = layer;

                if (SerialHelper.IsValid(serial) && World.InGame)
                {
                    SetTooltip(serial);
                }
            }
Esempio n. 8
0
        private string ReadProperties(uint serial, out string htmltext)
        {
            _sb.Clear();
            _sbHTML.Clear();

            bool hasStartColor = false;

            if (SerialHelper.IsValid(serial) &&
                World.OPL.TryGetNameAndData(serial, out string name, out string data))
            {
                if (!string.IsNullOrEmpty(name))
                {
                    if (SerialHelper.IsItem(serial))
                    {
                        _sbHTML.Append("<basefont color=\"yellow\">");
                        hasStartColor = true;
                    }
                    else
                    {
                        Mobile mob = World.Mobiles.Get(serial);

                        if (mob != null)
                        {
                            _sbHTML.Append(Notoriety.GetHTMLHue(mob.NotorietyFlag));
                            hasStartColor = true;
                        }
                    }

                    _sb.Append(name);
                    _sbHTML.Append(name);

                    if (hasStartColor)
                    {
                        _sbHTML.Append("<basefont color=\"#FFFFFFFF\">");
                    }
                }


                if (!string.IsNullOrEmpty(data))
                {
                    string s = $"\n{data}";
                    _sb.Append(s);
                    _sbHTML.Append(s);
                }
            }


            htmltext = _sbHTML.ToString();
            string result = _sb.ToString();

            return(string.IsNullOrEmpty(result) ? null : result);
        }
Esempio n. 9
0
        public MovingEffect
        (
            uint src,
            uint trg,
            int xSource,
            int ySource,
            int zSource,
            int xTarget,
            int yTarget,
            int zTarget,
            ushort graphic,
            ushort hue,
            bool fixedDir,
            byte speed
        ) : this(graphic, hue)
        {
            FixedDir = fixedDir;

            if (speed > 20)
            {
                speed = (byte)(speed - 20);
            }

            MovingDelay   = (byte)(20 - speed);
            _lastMoveTime = Time.Ticks;

            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);

                //Offset.X = source.FrameInfo.Right;
                //Offset.Y = source.FrameInfo.Bottom;
            }
            else
            {
                SetSource(xSource, ySource, zSource);
            }


            Entity target = World.Get(trg);

            if (SerialHelper.IsValid(trg) && target != null)
            {
                SetTarget(target);
            }
            else
            {
                SetTarget(xTarget, yTarget, zTarget);
            }
        }
Esempio n. 10
0
        public AnimatedItemEffect(uint sourceSerial, int sourceX, int sourceY, int sourceZ, ushort graphic, ushort hue, int duration, int speed) : this(graphic, hue, duration, speed)
        {
            Entity source = World.Get(sourceSerial);

            if (source != null && SerialHelper.IsValid(sourceSerial))
            {
                SetSource(source);
            }
            else
            {
                SetSource(sourceX, sourceY, sourceZ);
            }
        }
        public LightningEffect(uint src, int x, int y, int z, ushort hue) : this(hue)
        {
            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(x, y, z);
            }
        }
Esempio n. 12
0
        public MovingEffect
        (
            uint src,
            uint trg,
            int xSource,
            int ySource,
            int zSource,
            int xTarget,
            int yTarget,
            int zTarget,
            ushort graphic,
            ushort hue,
            bool fixedDir,
            byte speed
        ) : this(graphic, hue)
        {
            FixedDir = fixedDir;

            if (speed > 20)
            {
                speed = (byte)(speed - 20);
            }

            MovingDelay = (byte)(20 - speed);

            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(xSource, ySource, zSource);
            }


            Entity target = World.Get(trg);

            if (SerialHelper.IsValid(trg) && target != null)
            {
                SetTarget(target);
            }
            else
            {
                SetTarget(xTarget, yTarget, zTarget);
            }


            Calculate(true);
        }
        public MovingEffect
        (
            EffectManager manager,
            uint src,
            uint trg,
            int xSource,
            int ySource,
            int zSource,
            int xTarget,
            int yTarget,
            int zTarget,
            ushort graphic,
            ushort hue,
            bool fixedDir,
            int duration,
            byte speed
        ) : base(manager, graphic, hue, duration, speed)
        {
            FixedDir = fixedDir;

            // we override interval time with speed
            IntervalInMs = speed;
            //_lastMoveTime = Time.Ticks + IntervalInMs;

            // moving effects want a +22 to the X
            Offset.X += 22;

            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(xSource, ySource, zSource);
            }


            Entity target = World.Get(trg);

            if (SerialHelper.IsValid(trg) && target != null)
            {
                SetTarget(target);
            }
            else
            {
                SetTarget(xTarget, yTarget, zTarget);
            }
        }
Esempio n. 14
0
        public PPartyMessage(string text, uint serial) : base(0xBF)
        {
            WriteUShort(0x06);

            if (SerialHelper.IsValid(serial))
            {
                WriteByte(0x03);
                WriteUInt(serial);
            }
            else
            {
                WriteByte(0x04);
            }

            WriteUnicode(text);
        }
        public LightningEffect(EffectManager manager, uint src, int x, int y, int z, ushort hue)
            : base(manager, 0x4E20, hue, 400, 0)
        {
            IsEnabled = true;
            AnimIndex = 0;

            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(x, y, z);
            }
        }
Esempio n. 16
0
        public MovingEffect
        (
            uint src,
            uint trg,
            int xSource,
            int ySource,
            int zSource,
            int xTarget,
            int yTarget,
            int zTarget,
            ushort graphic,
            ushort hue,
            bool fixedDir,
            byte speed
        ) : this(graphic, hue, speed)
        {
            FixedDir = fixedDir;

            // we override interval time with speed
            IntervalInMs  = speed;
            _lastMoveTime = Time.Ticks + IntervalInMs;

            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(xSource, ySource, zSource);
            }


            Entity target = World.Get(trg);

            if (SerialHelper.IsValid(trg) && target != null)
            {
                SetTarget(target);
            }
            else
            {
                SetTarget(xTarget, yTarget, zTarget);
            }
        }
Esempio n. 17
0
        public DragEffect
        (
            EffectManager manager,
            uint src,
            uint trg,
            int xSource,
            int ySource,
            int zSource,
            int xTarget,
            int yTarget,
            int zTarget,
            ushort graphic,
            ushort hue,
            int duration,
            byte speed
        )
            : base(manager, graphic, hue, duration, speed)
        {
            Entity source = World.Get(src);

            if (SerialHelper.IsValid(src) && source != null)
            {
                SetSource(source);
            }
            else
            {
                SetSource(xSource, ySource, zSource);
            }


            Entity target = World.Get(trg);

            if (SerialHelper.IsValid(trg) && target != null)
            {
                SetTarget(target);
            }
            else
            {
                SetTarget(xTarget, yTarget, zTarget);
            }

            Hue     = hue;
            Graphic = graphic;
        }
Esempio n. 18
0
        public void RequestServerPartyGuildInfo(bool force = false)
        {
            if (!force && !Enabled)
            {
                return;
            }

            if (World.InGame && _lastPacketSend < Time.Ticks)
            {
                _lastPacketSend = Time.Ticks + 250;

                //if (!force && !_can_send)
                //{
                //    return;
                //}

                NetClient.Socket.Send_QueryGuildPosition();

                if (World.Party != null && World.Party.Leader != 0)
                {
                    foreach (PartyMember e in World.Party.Members)
                    {
                        if (e != null && SerialHelper.IsValid(e.Serial))
                        {
                            Mobile mob = World.Mobiles.Get(e.Serial);

                            if (mob == null || mob.Distance > World.ClientViewRange)
                            {
                                NetClient.Socket.Send_QueryPartyPosition();

                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 19
0
        public FixedEffect
        (
            EffectManager manager,
            uint sourceSerial,
            int sourceX,
            int sourceY,
            int sourceZ,
            ushort graphic,
            ushort hue,
            int duration,
            byte speed
        ) : this(manager, graphic, hue, duration, speed)
        {
            Entity source = World.Get(sourceSerial);

            if (source != null && SerialHelper.IsValid(sourceSerial))
            {
                SetSource(source);
            }
            else
            {
                SetSource(sourceX, sourceY, sourceZ);
            }
        }
Esempio n. 20
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(_serial) && World.OPL.TryGetRevision(_serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(_serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true);
            }
            else if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    FontsLoader.Instance.SetUseHTML(true);
                    FontsLoader.Instance.RecalculateWidthByInfo = true;

                    int width = FontsLoader.Instance.GetWidthUnicode(1, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode(1, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;

                    FontsLoader.Instance.RecalculateWidthByInfo = false;
                    FontsLoader.Instance.SetUseHTML(false);
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Text = _textHTML;
            }

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8))
            {
                x = Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8);
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8))
            {
                y = Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8);
            }

            Vector3 hue = Vector3.Zero;

            ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true);

            batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);

            return(_renderedText.Draw(batcher, x + 3, y));
        }
Esempio n. 21
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, float depth)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            //Engine.DebugInfo.ItemsRendered++;
            Vector3 hueVec;

            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);

            float alpha = AlphaHue / 255f;

            if (IsCorpse)
            {
                hueVec = ShaderHueTranslator.GetHueVector(0, false, alpha);
                return(DrawCorpse(batcher, posX, posY - 3, hueVec, depth));
            }


            ushort hue     = Hue;
            ushort graphic = DisplayedGraphic;
            bool   partial = ItemData.IsPartialHue;

            if (OnGround)
            {
                if (ItemData.IsAnimated)
                {
                    if (ProfileManager.CurrentProfile.FieldsType == 2)
                    {
                        if (StaticFilters.IsFireField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0020;
                        }
                        else if (StaticFilters.IsParalyzeField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0058;
                        }
                        else if (StaticFilters.IsEnergyField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0070;
                        }
                        else if (StaticFilters.IsPoisonField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0044;
                        }
                        else if (StaticFilters.IsWallOfStone(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x038A;
                        }
                    }
                }

                if (ItemData.IsContainer && SelectedObject.SelectedContainer == this)
                {
                    hue     = 0x0035;
                    partial = false;
                }
            }

            if (ProfileManager.CurrentProfile.HighlightGameObjects && ReferenceEquals(SelectedObject.LastObject, this))
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue = Constants.OUT_RANGE_COLOR;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue = Constants.DEAD_RANGE_COLOR;
            }
            else
            {
                if (!IsLocked && !IsMulti && ReferenceEquals(SelectedObject.LastObject, this))
                {
                    // TODO: check why i put this.
                    //isPartial = ItemData.Weight == 0xFF;
                    hue = 0x0035;
                }
                else if (IsHidden)
                {
                    hue = 0x038E;
                }
            }

            hueVec = ShaderHueTranslator.GetHueVector(hue, partial, alpha);

            if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable)
            {
                DrawStaticAnimated
                (
                    batcher,
                    graphic,
                    posX - 5,
                    posY - 5,
                    hueVec,
                    false,
                    depth
                );
            }

            if (ItemData.IsLight || graphic >= 0x3E02 && graphic <= 0x3E0B || graphic >= 0x3914 && graphic <= 0x3929)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                hueVec.Z = 0.5f;
            }

            DrawStaticAnimated
            (
                batcher,
                graphic,
                posX,
                posY,
                hueVec,
                false,
                depth
            );

            return(true);
        }
Esempio n. 22
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(Serial) && World.OPL.TryGetRevision(Serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(Serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }


            byte   font  = 1;
            float  alpha = 0.3f;
            ushort hue   = 0xFFFF;
            float  zoom  = 1;

            if (ProfileManager.CurrentProfile != null)
            {
                font  = ProfileManager.CurrentProfile.TooltipFont;
                alpha = 1f - ProfileManager.CurrentProfile.TooltipBackgroundOpacity / 100f;

                if (float.IsNaN(alpha))
                {
                    alpha = 1f;
                }

                hue  = ProfileManager.CurrentProfile.TooltipTextHue;
                zoom = ProfileManager.CurrentProfile.TooltipDisplayZoom / 100f;
            }

            FontsLoader.Instance.SetUseHTML(true);
            FontsLoader.Instance.RecalculateWidthByInfo = true;

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create
                                (
                    null,
                    font: font,
                    isunicode: true,
                    style: FontStyle.BlackBorder,
                    cell: 5,
                    isHTML: true,
                    align: TEXT_ALIGN_TYPE.TS_CENTER,
                    recalculateWidthByInfo: true,
                    hue: hue
                                );
            }

            if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    int width = FontsLoader.Instance.GetWidthUnicode(font, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode
                            (
                        font,
                        Text,
                        width,
                        TEXT_ALIGN_TYPE.TS_CENTER,
                        (ushort)FontStyle.BlackBorder
                            );

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Font = font;
                _renderedText.Hue  = hue;
                _renderedText.Text = _textHTML;
            }

            FontsLoader.Instance.RecalculateWidthByInfo = false;
            FontsLoader.Instance.SetUseHTML(false);

            if (_renderedText.Texture == null)
            {
                return(false);
            }

            int z_width  = _renderedText.Width + 8;
            int z_height = _renderedText.Height + 8;

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - z_width)
            {
                x = Client.Game.Window.ClientBounds.Width - z_width;
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - z_height)
            {
                y = Client.Game.Window.ClientBounds.Height - z_height;
            }


            Vector3 hue_vec = Vector3.Zero;

            ShaderHueTranslator.GetHueVector(ref hue_vec, 0, false, alpha);

            batcher.Draw2D
            (
                SolidColorTextureCache.GetTexture(Color.Black),
                x - 4,
                y - 2,
                z_width * zoom,
                z_height * zoom,
                ref hue_vec
            );

            batcher.DrawRectangle
            (
                SolidColorTextureCache.GetTexture(Color.Gray),
                x - 4,
                y - 2,
                (int)(z_width * zoom),
                (int)(z_height * zoom),
                ref hue_vec
            );

            hue_vec.X = 0;
            hue_vec.Y = 0;
            hue_vec.Z = 0;

            return(batcher.Draw2D
                   (
                       _renderedText.Texture,
                       x + 3,
                       y + 3,
                       z_width * zoom,
                       z_height * zoom,
                       0,
                       0,
                       z_width,
                       z_height,
                       ref hue_vec
                   ));
        }
Esempio n. 23
0
        public void ParsePacket(ref PacketBufferReader p)
        {
            byte code         = p.ReadByte();
            bool partyGiga487 = false;
            bool add          = false;
            byte count        = 0;

            switch (code)
            {
            case 1:
                add = true;

                if (!partyGiga487)
                {
                    goto case 2;     //giga487, trovo molto confuso questa parte di codice, la riscrivo.
                }
                else
                {
                    count = p.ReadByte();

                    if (count <= 1)
                    {
                    }

                    for (int i = 0; i < count; i++)
                    {
                        uint serial = p.ReadUInt();
                        //InsertPartyElement(serial, wme.Name); //inserisce l'elemento del party libero
                        Members[i] = new PartyMember(serial);
                    }
                }



                break;

            case 2:
                count = p.ReadByte();

                if (count <= 1)     //se ho 2 elementi e ne rimuovo uno
                {
                    Leader  = 0;
                    Inviter = 0;

                    for (int i = 0; i < PARTY_SIZE; i++)
                    {
                        if (Members[i] == null || Members[i].Serial == 0)
                        {
                            break;
                        }

                        BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(Members[i].Serial);


                        if (gump != null)
                        {
                            if (code == 2)
                            {
                                Members[i].Serial = 0;
                            }

                            gump.RequestUpdateContents();
                        }
                    }

                    Clear();

                    UIManager.GetGump <PartyGump>()?.RequestUpdateContents();

                    break;
                }

                Clear();

                uint to_remove = 0xFFFF_FFFF;

                if (!add)
                {
                    to_remove = p.ReadUInt();

                    UIManager.GetGump <BaseHealthBarGump>(to_remove)?.RequestUpdateContents();
                }

                bool remove_all = !add && to_remove == World.Player;
                int  done       = 0;

                for (int i = 0; i < count; i++)
                {
                    uint serial = p.ReadUInt();
                    bool remove = !add && serial == to_remove;

                    if (remove && serial == to_remove && i == 0)
                    {
                        remove_all = true;
                    }

                    if (!remove && !remove_all)
                    {
                        if (!Contains(serial))
                        {
                            Members[i] = new PartyMember(serial);
                        }

                        done++;
                    }

                    if (i == 0 && !remove && !remove_all)
                    {
                        Leader = serial;
                    }

                    BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(serial);

                    if (gump != null)
                    {
                        gump.RequestUpdateContents();
                    }
                    else
                    {
                        if (serial == World.Player)
                        {
                        }
                    }
                }

                if (done <= 1 && !add)
                {
                    for (int i = 0; i < PARTY_SIZE; i++)
                    {
                        if (Members[i] != null && SerialHelper.IsValid(Members[i].Serial))
                        {
                            uint serial = Members[i].Serial;

                            Members[i] = null;

                            UIManager.GetGump <BaseHealthBarGump>(serial)?.RequestUpdateContents();
                        }
                    }

                    Clear();
                }


                UIManager.GetGump <PartyGump>()?.RequestUpdateContents();
                NetClient.Socket.Send(new PQueryPartyPosition());
                break;

            case 3:
            case 4:     /* questo è il messaggio di chat */
                uint   ser  = p.ReadUInt();
                string name = p.ReadUnicode();

                for (int i = 0; i < PARTY_SIZE; i++)
                {
                    if (Members[i] != null && Members[i].Serial == ser)
                    {
                        MessageManager.HandleMessage
                        (
                            null,
                            name,
                            Members[i].Name,
                            ProfileManager.CurrentProfile.PartyMessageHue,
                            MessageType.Party,
                            3,
                            TextType.GUILD_ALLY
                        );

                        break;
                    }
                }

                break;

            case 7:
                Inviter = p.ReadUInt();

                if (ProfileManager.CurrentProfile.PartyInviteGump)
                {
                    UIManager.Add(new PartyInviteGump(Inviter));
                }

                break;
            }
        }
Esempio n. 24
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            //Engine.DebugInfo.ItemsRendered++;

            ResetHueVector();
            DrawTransparent = false;

            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);

            if (ItemData.IsTranslucent)
            {
                HueVector.Z = 0.5f;
            }

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

            if (IsCorpse)
            {
                return(DrawCorpse(batcher, posX, posY - 3));
            }


            ushort hue     = Hue;
            ushort graphic = DisplayedGraphic;
            bool   partial = ItemData.IsPartialHue;

            if (OnGround)
            {
                if (ItemData.IsAnimated)
                {
                    if (ProfileManager.CurrentProfile.FieldsType == 2)
                    {
                        if (StaticFilters.IsFireField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0020;
                        }
                        else if (StaticFilters.IsParalyzeField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0058;
                        }
                        else if (StaticFilters.IsEnergyField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0070;
                        }
                        else if (StaticFilters.IsPoisonField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0044;
                        }
                        else if (StaticFilters.IsWallOfStone(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x038A;
                        }
                    }
                }

                if (ItemData.IsContainer && SelectedObject.SelectedContainer == this)
                {
                    hue     = 0x0035;
                    partial = false;
                }
            }

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue = Constants.OUT_RANGE_COLOR;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue = Constants.DEAD_RANGE_COLOR;
            }
            else
            {
                if (!IsLocked && !IsMulti && SelectedObject.LastObject == this)
                {
                    // TODO: check why i put this.
                    //isPartial = ItemData.Weight == 0xFF;
                    hue = 0x0035;
                }
                else if (IsHidden)
                {
                    hue = 0x038E;
                }
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, HueVector.Z);

            if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable)
            {
                DrawStaticAnimated(batcher, graphic, posX - 5, posY - 5, ref HueVector, ref DrawTransparent);
            }

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                HueVector.Z = 0.5f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent);

            if (SelectedObject.Object == this || TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                return(false);
            }

            ArtTexture texture = ArtLoader.Instance.GetTexture(graphic);

            if (texture != null)
            {
                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(texture, posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }
Esempio n. 25
0
        public static void DefendParty()
        {
            //
            var healpotion = World.Player.FindItemByGraphic(0x0F0C);

            //
            if (!World.Player.IsDead && World.Player.Exists && World.Player != null && ProfileManager.CurrentProfile != null)
            {
                foreach (Mobile mobile in World.Mobiles)
                {
                    if (World.Mobiles.Get(mobile.Serial).Distance < 12 && mobile.IsHuman && ProfileManager.CurrentProfile != null)
                    {
                        if (mobile.Name.Length == 0 || mobile.Name == null && ProfileManager.CurrentProfile != null)
                        {
                            TimeSpan.FromMilliseconds(125);
                            return;
                        }
                        else
                        {
                            foreach (Mobile mobile1 in World.Mobiles)
                            {
                                if (mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial) && mobile != World.Player && ProfileManager.CurrentProfile != null)
                                {
                                    if (!mobile.IsDead && mobile != null && SerialHelper.IsMobile(mobile.Serial) && ProfileManager.CurrentProfile != null)
                                    {
                                        if (SerialHelper.IsValid(mobile.Serial) && ProfileManager.CurrentProfile != null)
                                        {
                                            if (mobile.Hits < 64 && mobile.Distance < 12 && ProfileManager.CurrentProfile != null)
                                            {
                                                if (TargetManager.IsTargeting)
                                                {
                                                    if (SerialHelper.IsValid(mobile.Serial) && mobile.Distance < 12 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(mobile.Serial);

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                                else if (!TargetManager.IsTargeting)
                                                {
                                                    GameActions.CastSpell(29);

                                                    TimeSpan.FromMilliseconds(375);

                                                    if (!TargetManager.IsTargeting)
                                                    {
                                                        TimeSpan.FromMilliseconds(125);
                                                    }
                                                    else
                                                    {
                                                        continue;
                                                    }

                                                    if (TargetManager.IsTargeting && SerialHelper.IsValid(mobile.Serial) && mobile.Distance < 12 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(mobile.Serial);

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                            else if (World.Player.Hits < 64 && ProfileManager.CurrentProfile != null)
                                            {
                                                if (TargetManager.IsTargeting)
                                                {
                                                    if (!World.Player.IsDead && World.Player.Hits < 64 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(World.Player);

                                                        TimeSpan.FromMilliseconds(125);
                                                        if (healpotion != null && ProfileManager.CurrentProfile != null)
                                                        {
                                                            GameActions.DoubleClick(healpotion);
                                                            GameActions.Print("AD: Heal Potion used");
                                                        }
                                                        else
                                                        {
                                                            GameActions.Print("AD: No Heal Potions.");
                                                        }

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                                else if (!TargetManager.IsTargeting)
                                                {
                                                    GameActions.CastSpell(29);

                                                    TimeSpan.FromMilliseconds(375);

                                                    if (!TargetManager.IsTargeting)
                                                    {
                                                        TimeSpan.FromMilliseconds(125);
                                                    }
                                                    else
                                                    {
                                                        continue;
                                                    }

                                                    if (TargetManager.IsTargeting && !World.Player.IsDead && World.Player.Hits < 64 && ProfileManager.CurrentProfile != null)
                                                    {
                                                        TargetManager.Target(World.Player);

                                                        TimeSpan.FromMilliseconds(125);
                                                        if (healpotion != null && ProfileManager.CurrentProfile != null)
                                                        {
                                                            GameActions.DoubleClickQueued(healpotion);
                                                            GameActions.Print("AD: Heal Potion used");
                                                        }
                                                        else
                                                        {
                                                            GameActions.Print("AD: No Heal Potions.");
                                                        }

                                                        TimeSpan.FromMilliseconds(125);
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        break;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                GameActions.Print("AD: Nothing to do.");
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        continue;
                    }
                    else
                    {
                        GameActions.Print("AD: Nobody near.");
                    }
                }
            }
        }
Esempio n. 26
0
        private void ChatOnMessageReceived(object sender, MessageEventArgs e)
        {
            if (e.Type == MessageType.Command)
            {
                return;
            }

            string name;
            string text;

            ushort hue = e.Hue;

            switch (e.Type)
            {
            case MessageType.Regular:
            case MessageType.Limit3Spell:

                if (e.Parent == null || !SerialHelper.IsValid(e.Parent.Serial))
                {
                    name = ResGeneral.System;
                }
                else
                {
                    name = e.Name;
                }

                text = e.Text;

                break;

            case MessageType.System:
                name = string.IsNullOrEmpty(e.Name) || e.Name.ToLowerInvariant() == "system" ? ResGeneral.System : e.Name;

                text = e.Text;

                break;

            case MessageType.Emote:
                name = e.Name;
                text = $"{e.Text}";

                if (e.Hue == 0)
                {
                    hue = ProfileManager.CurrentProfile.EmoteHue;
                }

                break;

            case MessageType.Label:
                name = ResGeneral.YouSee;
                text = e.Text;

                break;

            case MessageType.Spell:
                name = e.Name;
                text = e.Text;

                break;

            case MessageType.Party:
                text = e.Text;
                name = string.Format(ResGeneral.Party0, e.Name);
                hue  = ProfileManager.CurrentProfile.PartyMessageHue;

                break;

            case MessageType.Alliance:
                text = e.Text;
                name = string.Format(ResGeneral.Alliance0, e.Name);
                hue  = ProfileManager.CurrentProfile.AllyMessageHue;

                break;

            case MessageType.Guild:
                text = e.Text;
                name = string.Format(ResGeneral.Guild0, e.Name);
                hue  = ProfileManager.CurrentProfile.GuildMessageHue;

                break;

            default:
                text = e.Text;
                name = e.Name;
                hue  = e.Hue;

                Log.Warn($"Unhandled text type {e.Type}  -  text: '{e.Text}'");

                break;
            }

            if (!string.IsNullOrEmpty(text))
            {
                World.Journal.Add
                (
                    text,
                    hue,
                    name,
                    e.TextType,
                    e.IsUnicode
                );
            }
        }
Esempio n. 27
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            //Engine.DebugInfo.ItemsRendered++;

            ResetHueVector();


            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);


            if (IsCorpse)
            {
                return(DrawCorpse(batcher, posX, posY - 3));
            }


            ushort hue = Hue;

            if (ProfileManager.Current.FieldsType == 1 && StaticFilters.IsField(Graphic)) // static
            {
                unsafe
                {
                    IntPtr ptr = AnimDataLoader.Instance.GetAddressToAnim(Graphic);

                    if (ptr != IntPtr.Zero)
                    {
                        AnimDataFrame2 *animData = (AnimDataFrame2 *)ptr;

                        if (animData->FrameCount != 0)
                        {
                            _originalGraphic = (ushort)(Graphic + animData->FrameData[animData->FrameCount >> 1]);
                        }
                    }
                }

                _force = false;
            }
            else if (ProfileManager.Current.FieldsType == 2)
            {
                if (StaticFilters.IsFireField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0020;
                }
                else if (StaticFilters.IsParalyzeField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0058;
                }
                else if (StaticFilters.IsEnergyField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0070;
                }
                else if (StaticFilters.IsPoisonField(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x0044;
                }
                else if (StaticFilters.IsWallOfStone(Graphic))
                {
                    _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                    hue = 0x038A;
                }
            }

            if (_originalGraphic != DisplayedGraphic || _force || Texture == null || Texture.IsDisposed)
            {
                if (_originalGraphic == 0)
                {
                    _originalGraphic = DisplayedGraphic;
                }

                Texture       = ArtLoader.Instance.GetTexture(_originalGraphic);
                Bounds.X      = (Texture.Width >> 1) - 22;
                Bounds.Y      = Texture.Height - 44;
                Bounds.Width  = Texture.Width;
                Bounds.Height = Texture.Height;

                _force = false;
            }

            if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                HueVector.X = 0x0023;
                HueVector.Y = 1;
            }
            else if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                HueVector.X = Constants.OUT_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect)
            {
                HueVector.X = Constants.DEAD_RANGE_COLOR;
                HueVector.Y = 1;
            }
            else
            {
                bool isPartial = ItemData.IsPartialHue;

                if (SelectedObject.LastObject == this && !IsLocked && !IsMulti)
                {
                    isPartial = ItemData.Weight == 255;
                    hue       = 0x0035;
                }
                else if (IsHidden)
                {
                    hue = 0x038E;
                }

                ShaderHuesTraslator.GetHueVector(ref HueVector, hue, isPartial, ItemData.IsTranslucent ? .5f : 0);
            }

            if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable)
            {
                base.Draw(batcher, posX - 5, posY - 5);
            }

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>()
                .AddLight(this, this, posX + 22, posY + 22);
            }

            if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                HueVector.Z = 0.5f;
            }

            return(base.Draw(batcher, posX, posY));
        }
Esempio n. 28
0
        public void ParsePacket(Packet p)
        {
            byte code = p.ReadByte();

            bool add = false;

            switch (code)
            {
            case 1:
                add = true;
                goto case 2;

            case 2:
                byte count = p.ReadByte();

                if (count <= 1)
                {
                    Leader  = 0;
                    Inviter = 0;

                    for (int i = 0; i < PARTY_SIZE; i++)
                    {
                        if (Members[i] == null || Members[i].Serial == 0)
                        {
                            break;
                        }

                        BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(Members[i].Serial);


                        if (gump != null)
                        {
                            if (code == 2)
                            {
                                Members[i].Serial = 0;
                            }

                            gump.RequestUpdateContents();
                        }
                    }

                    Clear();
                    UIManager.GetGump <PartyGump>()?.RequestUpdateContents();

                    break;
                }

                Clear();

                uint to_remove = 0xFFFF_FFFF;
                if (!add)
                {
                    to_remove = p.ReadUInt();
                    UIManager.GetGump <BaseHealthBarGump>(to_remove)?.RequestUpdateContents();
                }

                bool remove_all = !add && to_remove == World.Player;
                int  done       = 0;
                for (int i = 0; i < count; i++)
                {
                    uint serial = p.ReadUInt();
                    bool remove = !add && (/*count <= 2 || */ serial == to_remove);

                    if (remove && serial == to_remove && i == 0)
                    {
                        remove_all = true;
                    }

                    if (!remove && !remove_all)
                    {
                        if (!Contains(serial))
                        {
                            Members[i] = new PartyMember(serial);
                        }
                        done++;
                    }

                    if (i == 0 && !remove && !remove_all)
                    {
                        Leader = serial;
                    }

                    BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(serial);

                    if (gump != null)
                    {
                        gump.RequestUpdateContents();
                    }
                    else
                    {
                        if (serial == World.Player)
                        {
                        }
                    }
                }

                if (done <= 1 && !add)
                {
                    for (int i = 0; i < PARTY_SIZE; i++)
                    {
                        if (Members[i] != null && SerialHelper.IsValid(Members[i].Serial))
                        {
                            uint serial = Members[i].Serial;
                            Members[i] = null;

                            UIManager.GetGump <BaseHealthBarGump>(serial)?.RequestUpdateContents();
                        }
                    }

                    Clear();
                }


                UIManager.GetGump <PartyGump>()?.RequestUpdateContents();

                break;

            case 3:
            case 4:
                uint   ser  = p.ReadUInt();
                string name = p.ReadUnicode();

                for (int i = 0; i < PARTY_SIZE; i++)
                {
                    if (Members[i] != null && Members[i].Serial == ser)
                    {
                        MessageManager.HandleMessage(null, name, Members[i].Name, ProfileManager.Current.PartyMessageHue, MessageType.Party, 3, TEXT_TYPE.SYSTEM);

                        break;
                    }
                }

                break;

            case 7:
                Inviter = p.ReadUInt();

                if (ProfileManager.Current.PartyInviteGump)
                {
                    UIManager.Add(new PartyInviteGump(Inviter));
                }
                break;
            }
        }
Esempio n. 29
0
            public ShopItem
            (
                uint serial,
                ushort graphic,
                ushort hue,
                int count,
                uint price,
                string name
            )
            {
                LocalSerial = serial;
                Graphic     = graphic;
                Hue         = hue;
                Price       = price;
                Name        = name;

                ResizePicLine line = new ResizePicLine(0x39)
                {
                    X     = 10,
                    Width = 190
                };

                Add(line);

                int offY = 15;

                string itemName = StringHelper.CapitalizeAllWords(Name);

                if (!SerialHelper.IsValid(serial))
                {
                    return;
                }


                string subname = string.Format(ResGumps.Item0Price1, itemName, Price);

                Add
                (
                    _name = new Label
                            (
                        subname,
                        true,
                        0x219,
                        110,
                        1,
                        FontStyle.None,
                        TEXT_ALIGN_TYPE.TS_LEFT,
                        true
                            )
                {
                    X = 55,
                    Y = offY
                }
                );

                int height = Math.Max(_name.Height, 35) + 10;

                if (SerialHelper.IsItem(serial))
                {
                    height = Math.Max(TileDataLoader.Instance.StaticData[graphic].Height, height);
                }

                Add
                (
                    _amountLabel = new Label
                                   (
                        count.ToString(),
                        true,
                        0x0219,
                        35,
                        1,
                        FontStyle.None,
                        TEXT_ALIGN_TYPE.TS_RIGHT
                                   )
                {
                    X = 168,
                    Y = offY + (height >> 2)
                }
                );

                Width  = 220;
                Height = Math.Max(50, height) + line.Height;

                WantUpdateSize = false;

                if (World.ClientFeatures.TooltipsEnabled)
                {
                    SetTooltip(LocalSerial);
                }

                Amount = count;
            }