Example #1
0
        public void OnUseDye(SagaMap.Packets.Client.GetUseDye p)
        {
            Item newitem = null;
            byte dyeslot = p.GetDyeSlot();
            Item useddye = this.Char.Inventory[dyeslot];

            if (p.GetContainer() == CONTAINER_TYPE.EQUIP)
            {
                newitem = this.Char.inv.EquipList[p.GetSlot()];
            }
            else if (p.GetContainer() == CONTAINER_TYPE.INVENTORY)
            {
                newitem = this.Char.Inventory[(byte)p.GetSlot()];
            }
            Packets.Server.UseDyeingItem packet = new SagaMap.Packets.Server.UseDyeingItem();
            if (newitem != null)
            {
                packet.SetError((byte)Global.GENERAL_ERRORS.NO_ERROR);
                //Change the colour of the equip
                //Item dyes 4101 - 4106
                newitem.Dye = (byte)(useddye.id - 4101);
                Console.WriteLine("New colour: " + newitem.Dye + " for item: " + newitem.id + " used dye: " + useddye.id);
            }
            else
            {
                packet.SetError((byte)Global.GENERAL_ERRORS.INV_ITEM_NOT_FOUND);
            }
            packet.SetItemID(useddye.id);
            packet.SetContainer(p.GetContainer());
            packet.SetEquipment(p.GetSlot());
            this.netIO.SendPacket(packet, this.SessionID);
            this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_EQUIP, new Map.ChangeEquipArgs((EQUIP_SLOT)newitem.index, newitem.id), this.Char, true);
            this.map.RemoveItemFromActorPC(this.Char, useddye.id, 1, ITEM_UPDATE_REASON.OTHER);
            //As a test, try sending 0x0302 with the new info
            //TODO: proper packet updates
            this.Char.e.OnActorAppears(this.Char);
        }
Example #2
0
 private void ProcessTest3(MapClient client, string args)
 {
     string[] arg = args.Split('|');
     int itemID;
     Item nItem;
     try { itemID = int.Parse(arg[0]); }
     catch (Exception) { itemID = 1; }
     try
     {
         nItem = new Item(itemID);
     }
     catch (Exception)
     {
         client.SendMessage(_MasterName, "cannot create item with ID " + itemID);
         return;
     }
     Packets.Server.UseDyeingItem packet = new SagaMap.Packets.Server.UseDyeingItem();
     packet.SetError((byte)Global.GENERAL_ERRORS.NO_ERROR);
     packet.SetItemID(nItem.id);
     packet.SetContainer((CONTAINER_TYPE)byte.Parse(arg[1]));
     packet.SetEquipment((EQUIP_SLOT)byte.Parse(arg[2]));
     client.netIO.SendPacket(packet, client.SessionID);
     Item item = client.Char.inv.EquipList[EQUIP_SLOT.BACK];
     client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_EQUIP, new Map.ChangeEquipArgs((EQUIP_SLOT)item.index, item.id), client.Char, true);
 }
Example #3
0
        public void OnUseDye(SagaMap.Packets.Client.GetUseDye p)
        {
            Item newitem = null;
            byte dyeslot = p.GetDyeSlot();
            Item useddye = this.Char.Inventory[dyeslot];

            if (p.GetContainer() == CONTAINER_TYPE.EQUIP)
            {
                newitem = this.Char.inv.EquipList[p.GetSlot()];
            }
            else if (p.GetContainer() == CONTAINER_TYPE.INVENTORY)
            {
                newitem = this.Char.Inventory[(byte)p.GetSlot()];
            }
            Packets.Server.UseDyeingItem packet = new SagaMap.Packets.Server.UseDyeingItem();
            if (newitem != null)
            {
                packet.SetError((byte)Global.GENERAL_ERRORS.NO_ERROR);
                //Change the colour of the equip
                //Item dyes 4101 - 4106
                newitem.Dye = (byte)(useddye.id - 4101);
                Console.WriteLine("New colour: " + newitem.Dye + " for item: " + newitem.id + " used dye: " + useddye.id);
            }
            else
            {
                packet.SetError((byte)Global.GENERAL_ERRORS.INV_ITEM_NOT_FOUND);
            }
            packet.SetItemID(useddye.id);
            packet.SetContainer(p.GetContainer());
            packet.SetEquipment(p.GetSlot());
            this.netIO.SendPacket(packet, this.SessionID);
            this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_EQUIP, new Map.ChangeEquipArgs((EQUIP_SLOT)newitem.index, newitem.id), this.Char, true);
            this.map.RemoveItemFromActorPC(this.Char, useddye.id, 1, ITEM_UPDATE_REASON.OTHER);
            //As a test, try sending 0x0302 with the new info
            //TODO: proper packet updates
            this.Char.e.OnActorAppears(this.Char);
        }