private static void DropItem(Character chr, byte inventory, short slot, short quantity)
        {
            if (chr.AssertForHack(chr.Room != null, "Trying to drop item while in a 'room'"))
            {
                NoChange(chr);
                return;
            }

            // Remove items from slot, taking stars if possible
            var drop = chr.Inventory.TakeItemAmountFromSlot(inventory, slot, quantity, true);

            if (drop == null)
            {
                // Item not found or quantity not enough
                NoChange(chr);
                return;
            }

            bool droppedFromEquips = Constants.isEquip(drop.ItemID) && slot < 0;

            ItemTransfer.ItemDropped(chr.ID, chr.MapID, drop.ItemID, drop.Amount, "", drop);

            chr.Field.DropPool.Create(Reward.Create(drop), chr.ID, 0, DropType.Normal, chr.ID, new Pos(chr.Position), chr.Position.X, 0, false, (short)(chr.Field.DropPool.DropEverlasting ? drop.InventorySlot : 0), false, true);

            if (droppedFromEquips)
            {
                MapPacket.SendAvatarModified(chr, MapPacket.AvatarModFlag.Equips);
            }
        }
示例#2
0
        public static void HandleChat(Character chr, Packet packet)
        {
            string what = packet.ReadString();

            if (chr.IsGM == false && CheatInspector.CheckTextSpam(what))
            {
                log.Error("Disconnecting player for chat spam");
                chr.Player.Socket.Disconnect();
                return;
            }

            if (//!MainCommandHandler.HandleCommand(chr, new CommandHandling.CommandArgs(what)) &&
                !CommandHandling.HandleChat(chr, what))
            {
                if (ShowMuteMessage(chr))
                {
                    log.Info("[MUTED] " + chr.Name + ": " + what);
                    return;
                }
                log.Info(chr.Name + ": " + what);
                if (chr.Field.ChatEnabled)
                {
                    MapPacket.SendChatMessage(chr, what);
                }
            }
            else
            {
                commandLog.Info(chr.Name + ": " + what);
            }
        }
        private static void Unequip(Character chr, BaseItem equip, short slotTo)
        {
            byte  inventory = Constants.getInventory(equip.ItemID);
            short slotFrom  = equip.InventorySlot;

            BaseItem swap = chr.Inventory.GetItem(inventory, slotTo);

            if (swap == null && !chr.Inventory.HasSlotsFreeForItem(equip.ItemID, 1, false))  // Client checks this for us, but in case of PE
            {
                NoChange(chr);
                return;
            }

            if (swap != null && slotFrom < 0)
            {
                HandleEquip(chr, swap, equip, slotTo, slotFrom);
                return;
            }

            chr.Inventory.SetItem(inventory, slotFrom, swap);
            chr.Inventory.SetItem(inventory, slotTo, equip);

            SwitchSlots(chr, slotFrom, slotTo, inventory);
            MapPacket.SendAvatarModified(chr, MapPacket.AvatarModFlag.Equips);
        }
示例#4
0
        public void TryRemoveDoor(int ownerCharId)
        {
            if (Doors.ContainsKey(ownerCharId))
            {
                var door = Doors[ownerCharId];
                Doors.Remove(ownerCharId);

                Field.SendPacket(MapPacket.RemoveDoor(door, 0));

                DataProvider.Maps[Field.ReturnMap].DoorPool.DoorsLeadingHere.Remove(ownerCharId);

                //in case owner is in town when it dies
                if (door.OwnerPartyId == 0)
                {
                    var owner = Server.Instance.GetCharacter(ownerCharId);
                    if (owner != null && owner.Field.ID == Field.ReturnMap)
                    {
                        MapPacket.RemovePortal(owner);
                        owner.DoorMapId = Constants.InvalidMap;
                    }
                }
                else
                {
                    Server.Instance.CenterConnection.PartyDoorRemoved(ownerCharId);
                }
            }
        }
示例#5
0
 public void SetSkin(byte id)
 {
     _characterLog.Info(new StatChangeLogRecord {
         value = id, type = "skin", add = false
     });
     Skin = id;
     CharacterStatsPacket.SendStatChange(this, (byte)CharacterStatsPacket.StatFlags.Skin, id);
     MapPacket.SendAvatarModified(this, MapPacket.AvatarModFlag.Skin);
 }
        private static void Equip(Character chr, BaseItem from, BaseItem to, short slotFrom, short slotTo)
        {
            byte inventory = Constants.getInventory(from.ItemID);

            chr.Inventory.SetItem(inventory, slotFrom, to);
            chr.Inventory.SetItem(inventory, slotTo, from);
            SwitchSlots(chr, slotFrom, slotTo, inventory);
            MapPacket.SendAvatarModified(chr, MapPacket.AvatarModFlag.Equips);
        }
示例#7
0
 public void SetFace(int id)
 {
     _characterLog.Info(new StatChangeLogRecord {
         value = id, type = "face", add = false
     });
     Face = id;
     CharacterStatsPacket.SendStatChange(this, (int)CharacterStatsPacket.StatFlags.Eyes, id);
     MapPacket.SendAvatarModified(this, MapPacket.AvatarModFlag.Face);
 }
示例#8
0
 public void SetHair(int id)
 {
     _characterLog.Info(new StatChangeLogRecord {
         value = id, type = "hair", add = false
     });
     Hair = id;
     CharacterStatsPacket.SendStatChange(this, (int)CharacterStatsPacket.StatFlags.Hair, id);
     MapPacket.SendAvatarModified(this, MapPacket.AvatarModFlag.Equips);//Because hair is a equip I guess
 }
示例#9
0
        public void OnChangeChannel(Character character, Packet packet)
        {
            if (character.Field.DisableChangeChannel)
            {
                MapPacket.BlockedMessage(character, MapPacket.PortalBlockedMessage.CannotGoToThatPlace);
                return;
            }

            var channel = packet.ReadByte();

            DoChangeChannelReq(channel);
        }
        public void UpdateChocoCount(bool sendPacket = true)
        {
            int prevChocoCount = ChocoCount;

            ChocoCount   = Items[Constants.getInventory(Constants.Items.Choco) - 1].Count(x => x?.ItemID == Constants.Items.Choco);
            ActiveItemID = ChocoCount > 0 ? Constants.Items.Choco : 0;

            if (sendPacket && prevChocoCount != ChocoCount)
            {
                MapPacket.SendAvatarModified(Character, MapPacket.AvatarModFlag.ItemEffects);
            }
        }
示例#11
0
        public void SetLevel(byte value)
        {
            _characterLog.Info(new StatChangeLogRecord {
                value = value, type = "level", add = false
            });
            PrimaryStats.Level = value;
            CharacterStatsPacket.SendStatChange(this, (uint)CharacterStatsPacket.StatFlags.Level, value);
            MapPacket.SendPlayerLevelupAnim(this);

            this.FlushDamageLog();
            Server.Instance.CenterConnection.UpdatePlayerJobLevel(this);
        }
示例#12
0
        private void FinishChangeMap(Map prevMap, Map newMap)
        {
            TryActivateHide();
            MapPacket.SendChangeMap(this);

            if (newMap.PQPortalOpen == true)
            {
                MapPacket.PortalEffect(Field, 2, "gate");
            }
            newMap.AddPlayer(this);
            Summons.MigrateSummons(prevMap, newMap);
            Server.Instance.CenterConnection.PlayerUpdateMap(this);
            PartyHPUpdate();
        }
示例#13
0
        public void OnEnterCashShop(Character character)
        {
            if (character.Field.DisableGoToCashShop)
            {
                MapPacket.BlockedMessage(character, MapPacket.PortalBlockedMessage.CannotGoToThatPlace);
                return;
            }

            Server.Instance.CenterConnection.RequestCharacterConnectToWorld(
                Player.SessionHash,
                character.ID,
                Server.Instance.WorldID,
                50,
                character
                );
        }
示例#14
0
        private static void StopSkill(Character chr, int skillid)
        {
            if (chr.PrimaryStats.HasBuff(skillid) == false)
            {
                return;
            }

            chr.PrimaryStats.RemoveByReference(skillid);
            if (skillid == Constants.Rogue.Skills.DarkSight)
            {
                // Are we debuffing twice here?
                MapPacket.CancelSkillEffect(chr, skillid); //?
                MapPacket.SendPlayerSkillAnim(chr, skillid, 1);
                MapPacket.SendPlayerDebuffed(chr, BuffValueTypes.DarkSight);
            }
        }
示例#15
0
        public void FinalizeDebuff(BuffValueTypes removed, bool sendPacket = true)
        {
            if (removed == 0)
            {
                return;
            }
            Trace.WriteLine($"Removed buffs {removed}");

            Character.FlushDamageLog();

            if (!sendPacket)
            {
                return;
            }
            BuffPacket.ResetTempStats(Character, removed);
            MapPacket.SendPlayerDebuffed(Character, removed);
        }
示例#16
0
        public void FinalizeBuff(BuffValueTypes added, short delay, bool sendPacket = true)
        {
            if (added == 0)
            {
                return;
            }
            Trace.WriteLine($"Added buffs {added}");

            Character.FlushDamageLog();

            if (!sendPacket)
            {
                return;
            }
            BuffPacket.SetTempStats(Character, added, delay);
            MapPacket.SendPlayerBuffed(Character, added, delay);
        }
示例#17
0
        public void SendPQSign(Character chr, bool clear)
        {
            string Sound;
            string Message;

            if (clear)
            {
                Sound   = "Party1/Clear";
                Message = "quest/party/clear";
            }
            else
            {
                Sound   = "Party1/Failed";
                Message = "quest/party/wrong_kor";
            }
            MapPacket.PQMessages(chr, 4, Sound);
            MapPacket.PQMessages(chr, 3, Message);
        }
示例#18
0
        public void ShowAllDoorsTo(Character f****r)
        {
            foreach (var d in Doors.Values)
            {
                f****r.SendPacket(MapPacket.ShowDoor(d, 1));
            }

            foreach (var d in DoorsLeadingHere.Values)
            {
                if (d.OwnerId == f****r.ID)
                {
                    if (f****r.PartyID != 0)
                    {
                        continue;
                    }
                    d.OwnerPartyId = 0; // Update portal just to be sure
                    MapPacket.SpawnPortal(f****r, Field.ReturnMap, Field.ReturnMap, d.X, d.Y);
                }
            }
        }
示例#19
0
        private static void ChangeSlot(Character chr, BaseItem from, BaseItem to, short slotFrom, short slotTo)
        {
            if (to != null)
            {
                if (
                    Constants.isStackable(to.ItemID) &&
                    to.ItemID == from.ItemID &&
                    // Do not allow cashitem stacking
                    to.CashId == 0 &&
                    from.CashId == 0
                    )
                {
                    StackItems(chr, from, to, slotFrom, slotTo);
                    return;
                }
            }
            byte inventory = Constants.getInventory(@from.ItemID);

            chr.Inventory.SetItem(inventory, slotFrom, to);
            chr.Inventory.SetItem(inventory, slotTo, from);

            SwitchSlots(chr, slotFrom, slotTo, inventory);
            MapPacket.SendAvatarModified(chr, MapPacket.AvatarModFlag.Equips);
        }