From edefa27a48e2b5e7c82e74ca0e924172181fb098 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 12 Jan 2014 23:23:36 +0000 Subject: Detaching improvements * Players now search for an area around themselves to teleport to when detaching from something --- src/Entities/Player.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index bc92790aa..cdedb0c5a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1884,3 +1884,29 @@ void cPlayer::ApplyFoodExhaustionFromMovement() + +void cPlayer::Detach() +{ + super::Detach(); + int PosX = (int)floor(GetPosX()); + int PosY = (int)floor(GetPosY()); + int PosZ = (int)floor(GetPosZ()); + + // Search for a position within an area to teleport player after detachment + // Position must be solid land, and occupied by a nonsolid block + // If nothing found, player remains where they are + for (int x = PosX - 2; x <= (PosX + 2); ++x) + { + for (int y = PosY; y <= (PosY + 3); ++y) + { + for (int z = PosZ - 2; z <= (PosZ + 2); ++z) + { + if (!g_BlockIsSolid[m_World->GetBlock(x, y, z)] && g_BlockIsSolid[m_World->GetBlock(x, y - 1, z)]) + { + TeleportToCoords(x, y, z); + return; + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3 From e3b839b69ff74323f6eccba999dc4635f3520fc9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 14 Jan 2014 18:16:13 +0000 Subject: Yes newline at end of file :D --- src/Entities/Player.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index cdedb0c5a..fa6422389 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1909,4 +1909,8 @@ void cPlayer::Detach() } } } -} \ No newline at end of file +} + + + + -- cgit v1.2.3