public void ProcessMoveRequest(Connection client, CharacterPositionClass mtp) { // Check to see if we hit any npcs foreach (NPC npc in _npcs.Values) { if (npc.CellIndex == mtp.CellIndex) { // Hit this npc - Check distance Vector target = Utils.DecodeCellIndex(_mapID, mtp.CellIndex); Vector start = Utils.DecodeCellIndex(_mapID, client.Character.CellIndex); Vector toTarget = target - start; double distSquared = toTarget.LengthSquared; if (distSquared > 13) { // Out of range, just move there client.SendPacket(new PlayerMovePacket(mtp.CellIndex, client.Character.MoveSpeed)); } else { // Talk to NPC npc.DoDialog(client); } // no matter what, we are done here return; } } // Check to see if we hit monsters // Check to see if we hit other players // Just move client.SendPacket(new PlayerMovePacket(mtp.CellIndex, client.Character.MoveSpeed)); }
public void UpdatePlayerPosition(Connection client, CharacterPositionClass cpc) { client.Character.CellIndex = cpc.CellIndex; // Inform other clients ObserveMovementPacket omp = new ObserveMovementPacket(client.Character.WorldID, cpc.CellIndex, client.Character.MoveSpeed); foreach (Connection c in _players.Values) { if (c.AccountID != client.AccountID) { // Send move update c.SendPacket(omp); } } }