Esempio n. 1
0
        public void Send()
        {
            MsgSuperFlag pMsg = new MsgSuperFlag
            {
                Durability   = m_pItem.Durability,
                ItemIdentity = m_pItem.Identity
            };

            for (int i = 0; i < m_pLocations.Count; i++)
            {
                pMsg.AddLocation((uint)i, m_pLocations[i].RecordMapId, m_pLocations[i].RecordMapX,
                                 m_pLocations[i].RecordMapY, m_pLocations[i].Name);
            }
            m_pOwner.Send(pMsg);
        }
        public static void HandleSuperFlag(Character pUser, MsgSuperFlag pMsg)
        {
            switch (pMsg.Action)
            {
            case 1:     // save location
            {
                if (pUser.Map.IsDynamicMap())
                {
                    return;
                }
                if (pUser.Map.IsRecordDisable())
                {
                    return;
                }
                if (pUser.Map.IsPkField())
                {
                    return;
                }
                if (pUser.Map.IsBoothEnable())
                {
                    return;
                }
                if (pUser.Map.IsFamilyMap() || pUser.Map.IsSynMap())
                {
                    return;
                }
                if (pUser.Map.IsPrisionMap())
                {
                    return;
                }
                if (pUser.Map.Identity == 2055 || pUser.Map.Identity == 2056)
                {
                    return;
                }
                Item item;
                if (pUser.Inventory.Items.TryGetValue(pMsg.ItemIdentity, out item))
                {
                    if (pMsg.CarryIdentity > 0 || item.CarryCount >= Carry.MAX_RECORDS)
                    {
                        item.UpdateLocation((int)pMsg.CarryIdentity);
                    }
                    else
                    {
                        if (item.CarryCount >= Carry.MAX_RECORDS)
                        {
                            return;
                        }
                        item.SaveLocation();
                    }
                }
                break;
            }

            case 2:     // change name
            {
                if (pMsg.Name.Length <= 0 || !CheckName(pMsg.Name))
                {
                    return;
                }
                string name = pMsg.Name.Length > 32 ? pMsg.Name.Substring(0, 32) : pMsg.Name;
                Item   item;
                if (pUser.Inventory.Items.TryGetValue(pMsg.ItemIdentity, out item))
                {
                    item.CarrySetName(name, (int)pMsg.CarryIdentity);
                }
                break;
            }

            case 3:     // goto location
            {
                if (pUser.Map.IsPrisionMap())
                {
                    return;
                }
                if (pUser.IsInsideQualifier)
                {
                    return;
                }
                Item item;
                if (pUser.Inventory.Items.TryGetValue(pMsg.ItemIdentity, out item))
                {
                    DbCarry carry;
                    if (!item.GetTeleport(pMsg.CarryIdentity, out carry))
                    {
                        return;
                    }
                    Map map;
                    if (!ServerKernel.Maps.TryGetValue(carry.RecordMapId, out map))
                    {
                        return;
                    }

                    if (map.IsDynamicMap())
                    {
                        return;
                    }
                    if (map.IsRecordDisable())
                    {
                        return;
                    }
                    if (map.IsPkField())
                    {
                        return;
                    }
                    if (map.IsBoothEnable())
                    {
                        return;
                    }
                    if (map.IsFamilyMap() || map.IsSynMap())
                    {
                        return;
                    }
                    if (map.IsPrisionMap())
                    {
                        return;
                    }
                    if (item.Durability <= 0)
                    {
                        return;
                    }
                    item.Durability -= 1;
                    item.SendCarry();
                    pUser.ChangeMap(carry.RecordMapX, carry.RecordMapY, carry.RecordMapId);
                }
                break;
            }

            case 4:     // refill
            {
                Item item;
                if (pUser.Inventory.Items.TryGetValue(pMsg.ItemIdentity, out item))
                {
                    int nCost = Math.Max(1, item.MaximumDurability - item.Durability) / 2;
                    if (!pUser.ReduceEmoney(nCost, true))
                    {
                        return;
                    }
                    item.Durability = item.MaximumDurability;
                    item.SendCarry();
                }
                break;
            }
            }
        }