public bool UseTrockHandler(int trockID, Packet inPacket) { bool used = false; byte action = inPacket.ReadByte(); ItemConstants.TrockType type = ItemConstants.TrockType.Regular; switch (trockID) { case (int)ItemConstants.UsableCashItems.TeleportRock: type = ItemConstants.TrockType.Regular; break; case (int)ItemConstants.UsableCashItems.VIPTeleportRock: type = ItemConstants.TrockType.VIP; break; default: throw new ArgumentOutOfRangeException(); } int destinationMapID = -1; ItemConstants.TrockResult result = ItemConstants.TrockResult.Success; if (action == (int)ItemConstants.TrockUseAction.TeleportToPresetMap) { int mapID = inPacket.ReadInt(); if (!Contains(mapID)) { result = ItemConstants.TrockResult.CannotGo; } destinationMapID = mapID; } else if (action == (int)ItemConstants.TrockUseAction.TeleportToIGN) { string targetName = inPacket.ReadString(); Character target = TrockParent.GetCharacterByName(targetName); if (target == null) { result = ItemConstants.TrockResult.DifficultToLocate; } else { destinationMapID = target.Map.MapleID; } } int ticks = inPacket.ReadInt(); if (destinationMapID != -1) { Map originMap = TrockParent.Map; Map destinationMap = DataProvider.Maps[destinationMapID]; if (destinationMap.FieldLimit == (int)MapConstants.FieldLimit.CannotUseVIPTrock) { result = ItemConstants.TrockResult.CannotGo; } else if (originMap.FieldLimit == (int)MapConstants.FieldLimit.CannotUseVIPTrock) { result = ItemConstants.TrockResult.CannotGo; } else if (originMap.MapleID == destinationMap.MapleID) { result = ItemConstants.TrockResult.AlreadyThere; } /*else if (false) // TODO: Continent check. * { * result = ItemConstants.TrockResult.CannotGo; * }*/ } if (result == ItemConstants.TrockResult.Success) { TrockParent.SendChangeMapRequest(destinationMapID); used = true; } else { TrockParent.Client.Send(CharacterTrocksPackets.TrockTransferResult(result, type)); } return(used); }
public void UpdateTrockHandler(Packet inPacket) { ItemConstants.TrockMapAction action = (ItemConstants.TrockMapAction)inPacket.ReadByte(); ItemConstants.TrockType type = (ItemConstants.TrockType)inPacket.ReadByte(); switch (action) { case ItemConstants.TrockMapAction.RemoveMapTrock: { int mapID = inPacket.ReadInt(); switch (type) { case ItemConstants.TrockType.Regular: if (!RegularTrocks.Contains(mapID)) { return; } VIPTrocks.Remove(mapID); break; case ItemConstants.TrockType.VIP: if (!VIPTrocks.Contains(mapID)) { return; } VIPTrocks.Remove(mapID); break; default: throw new ArgumentOutOfRangeException(); } } break; case ItemConstants.TrockMapAction.AddMapTrock: { int mapID = TrockParent.Map.MapleID; if (TrockParent.Map.FieldLimit != (int)MapConstants.FieldLimit.CannotUseVIPTrock) { switch (type) { case ItemConstants.TrockType.Regular: if (RegularTrocks.Contains(mapID)) { return; } RegularTrocks.Add(mapID); break; case ItemConstants.TrockType.VIP: if (VIPTrocks.Contains(mapID)) { return; } VIPTrocks.Add(mapID); break; default: throw new ArgumentOutOfRangeException(); } } else { Character.Notify(TrockParent, "[TrockHandler] This map cannot be added to teleport rock!"); } } break; default: throw new ArgumentOutOfRangeException(); } TrockParent.Client.Send(CharacterTrocksPackets.TrockInventoryUpdate(action, type)); }