public void HandleTeleportMap(WorldClient client, GMTeleportMapPacket packet) { if (!_gameSession.IsAdmin) { return; } if (!_gameWorld.AvailableMapIds.Contains(packet.MapId)) { _packetFactory.SendGmCommandError(client, PacketType.GM_TELEPORT_MAP); return; } float x = 100; float y = 100; float z = 100; var spawn = _mapLoader.LoadMapConfiguration(packet.MapId).Spawns.FirstOrDefault(s => ((int)s.Faction == 1 && _countryProvider.Country == CountryType.Light) || ((int)s.Faction == 2 && _countryProvider.Country == CountryType.Dark)); if (spawn != null) { x = spawn.Area.LowerLimit.X; y = spawn.Area.LowerLimit.Y; z = spawn.Area.LowerLimit.Z; } _packetFactory.SendGmCommandSuccess(client); _teleportationManager.Teleport(packet.MapId, x, y, z, true); }
public void Handle(WorldClient client, RebirthPacket packet) { var rebirthType = (RebirthType)packet.RebirthType; // TODO: implement other rebith types. (ushort MapId, float X, float Y, float Z)rebirthCoordinate = (0, 0, 0, 0); // Usual rebirth. if (rebirthType == RebirthType.KillSoul) { rebirthCoordinate = _mapProvider.Map.GetRebirthMap(_gameWorld.Players[_gameSession.CharId]); } // Rebirth with rune. Will rebirth at the same place. if (rebirthType == RebirthType.KillSoulByItem) { var rune = _inventoryManager.InventoryItems.Values.FirstOrDefault(x => x.Special == SpecialEffect.ResurrectionRune); if (rune != null) { _inventoryManager.TryUseItem(rune.Bag, rune.Slot, skillApplyingItemEffect: true); rebirthCoordinate.MapId = _mapProvider.Map.Id; rebirthCoordinate.X = _movementManager.PosX; rebirthCoordinate.Y = _movementManager.PosY; rebirthCoordinate.Z = _movementManager.PosZ; // Add untouchable buff for 6 secs. _definitionsPreloder.Skills.TryGetValue((199, 2), out var dbSkill); _buffsManager.AddBuff(new Skill(dbSkill, 0, 0), null); } else { rebirthCoordinate = _mapProvider.Map.GetRebirthMap(_gameWorld.Players[_gameSession.CharId]); } } if (_mapProvider.Map.Id != rebirthCoordinate.MapId) { _teleportationManager.Teleport(rebirthCoordinate.MapId, rebirthCoordinate.X, rebirthCoordinate.Y, rebirthCoordinate.Z); } else { _movementManager.PosX = rebirthCoordinate.X; _movementManager.PosY = rebirthCoordinate.Y; _movementManager.PosZ = rebirthCoordinate.Z; } _healthManager.Rebirth(); }
public void Handle(WorldClient client, PartySummonAnswerPacket packet) { if (!_partyManager.HasParty || _partyManager.Party.SummonRequest is null) { return; } var summoner = _gameWorld.Players[_partyManager.Party.SummonRequest.OwnerId]; if (summoner is null) { return; } _partyManager.SetSummonAnswer(!packet.IsDeclined); if (!packet.IsDeclined) { _teleportationManager.Teleport(summoner.Map.Id, summoner.PosX, summoner.PosY, summoner.PosZ); } _packetFactory.SendSummonAnswer(summoner.GameSession.Client, _gameSession.CharId, packet.IsDeclined); }
public void HandleNpcTeleport(WorldClient client, CharacterTeleportViaNpcPacket packet) { var npc = _mapProvider.Map.GetNPC(_gameWorld.Players[_gameSession.CharId].CellId, packet.NpcId); if (npc is null) { _logger.LogWarning("Character {Id} is trying to get non-existing npc via teleport packet.", _gameSession.CharId); return; } if (!npc.ContainsGate(packet.GateId)) { _logger.LogWarning("NPC type {type} type id {typeId} doesn't contain teleport gate {gateId}. Check it out!", npc.Type, npc.TypeId, packet.GateId); return; } if (_mapProvider.Map is GuildHouseMap) { if (!_guildManager.HasGuild) { _packetFactory.SendGuildHouseActionError(client, GuildHouseActionError.LowRank, 30); return; } var allowed = _guildManager.CanUseNpc(npc.Type, npc.TypeId, out var requiredRank); if (!allowed) { _packetFactory.SendGuildHouseActionError(client, GuildHouseActionError.LowRank, requiredRank); return; } allowed = _guildManager.HasNpcLevel(npc.Type, npc.TypeId); if (!allowed) { _packetFactory.SendGuildHouseActionError(client, GuildHouseActionError.LowLevel, 0); return; } } var gate = npc.Gates[packet.GateId]; if (_inventoryManager.Gold < gate.Cost) { _packetFactory.SendTeleportViaNpc(client, NpcTeleportNotAllowedReason.NotEnoughMoney, _inventoryManager.Gold); return; } var mapConfig = _mapLoader.LoadMapConfiguration((ushort)gate.MapId); if (mapConfig is null) { _packetFactory.SendTeleportViaNpc(client, NpcTeleportNotAllowedReason.MapCapacityIsFull, _inventoryManager.Gold); return; } // TODO: there should be somewhere player's level check. But I can not find it in gate config. _inventoryManager.Gold = (uint)(_inventoryManager.Gold - gate.Cost); _packetFactory.SendTeleportViaNpc(client, NpcTeleportNotAllowedReason.Success, _inventoryManager.Gold); _teleportationManager.Teleport((ushort)gate.MapId, gate.Position.X, gate.Position.Y, gate.Position.Z); }