{"action":"created","comment":{"url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments/76679747","id":76679747,"diff_hunk":"@@ -915,35 +915,121 @@ void PathGenerator::ReducePathLenghtByDist(float dist)\n     if (_pathPoints.size() < 2) // path building failure\n         return;\n \n-    uint32 i = _pathPoints.size();\n-    G3D::Vector3 nextVec = _pathPoints[--i];\n-    while (i > 0)\n+    /*\n+    evolution of idx:\n+     x---->x---->x---->X\n+     0     1     2     3\n+                idx   idx+1\n+          idx  idx+1\n+    idx  idx+1\n+    ---------------------------\n+    diffVec when idx==1 in example above:\n+            ---->\n+    */\n+    int idx = _pathPoints.size() - 2;\n+    float totalLengthSoFar = 0.0f;\n+    G3D::Vector3 diffVec;\n+    for ( ; idx >= 0; idx--)\n     {\n-        G3D::Vector3 currVec = _pathPoints[--i];\n-        G3D::Vector3 diffVec = (nextVec - currVec);\n-        float len = diffVec.length();\n-        if (len > dist)\n-        {\n-            float step = dist / len;\n-            // same as nextVec\n-            _pathPoints[i + 1] -= diffVec * step;\n-            _sourceUnit->UpdateAllowedPositionZ(_pathPoints[i + 1].x, _pathPoints[i + 1].y, _pathPoints[i + 1].z);\n-            _pathPoints.resize(i + 2);\n+        diffVec = _pathPoints[idx + 1] - _pathPoints[idx];\n+        totalLengthSoFar += diffVec.length();\n+        if (totalLengthSoFar >= dist)\n             break;\n+    }\n+\n+    if (totalLengthSoFar > dist)\n+    {\n+        float delta = totalLengthSoFar - dist;\n+        G3D::Vector3 newFinalPoint = _pathPoints[idx] + diffVec.unit() * delta;\n+        _sourceUnit->UpdateAllowedPositionZ(newFinalPoint.x, newFinalPoint.y, newFinalPoint.z);\n+\n+        /*\n+        3 potential problems could have occured up until this point:\n+        1) the \"actual end position\" (closest position to the target found by the PathGen) could be not exactly on the target.\n+        Which means the distance from the target to the last point of the path BEFORE THE CUT could be > 0\n+        and add into that the cutted distance and this can result in the target being further away than dist to the \n+        path's end position AFTER CUT.\n+        2) AFTER THE CUT, the Z of the new last point is normalized \n+        (to make sure our point is on the ground in case non flying/swimming unit).\n+        This means the distance from the target to the path's last point AFTER CUT can be higher than dist.\n+        3) The path's last point AFTER CUT can be out of LoS from the target.\n+\n+        We need to make sure that in ANY case: \n+        a) the last point after cut is at MAX at \"dist\" yards from the target + marginal error factor (0.5f)","path":"src/server/game/Movement/PathGenerator.cpp","position":66,"original_position":66,"commit_id":"7fdf9bd2eda70b6b139560e4c2182d635147c66d","original_commit_id":"7fdf9bd2eda70b6b139560e4c2182d635147c66d","user":{"login":"chaodhib","id":6612710,"avatar_url":"https://avatars.githubusercontent.com/u/6612710?v=3","gravatar_id":"","url":"https://api.github.com/users/chaodhib","html_url":"https://github.com/chaodhib","followers_url":"https://api.github.com/users/chaodhib/followers","following_url":"https://api.github.com/users/chaodhib/following{/other_user}","gists_url":"https://api.github.com/users/chaodhib/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodhib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodhib/subscriptions","organizations_url":"https://api.github.com/users/chaodhib/orgs","repos_url":"https://api.github.com/users/chaodhib/repos","events_url":"https://api.github.com/users/chaodhib/events{/privacy}","received_events_url":"https://api.github.com/users/chaodhib/received_events","type":"User","site_admin":false},"body":"this method should not be called when dealing with such path. my mistake if it's the case right now.","created_at":"2016-08-29T20:23:03Z","updated_at":"2016-08-29T20:23:03Z","html_url":"https://github.com/TrinityCore/TrinityCore/pull/17850#discussion_r76679747","pull_request_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850","_links":{"self":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments/76679747"},"html":{"href":"https://github.com/TrinityCore/TrinityCore/pull/17850#discussion_r76679747"},"pull_request":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850"}}},"pull_request":{"url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850","id":82416999,"html_url":"https://github.com/TrinityCore/TrinityCore/pull/17850","diff_url":"https://github.com/TrinityCore/TrinityCore/pull/17850.diff","patch_url":"https://github.com/TrinityCore/TrinityCore/pull/17850.patch","issue_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/17850","number":17850,"state":"open","locked":false,"title":"[WIP] Core/Movement: Targeted MoveGen Improvements","user":{"login":"chaodhib","id":6612710,"avatar_url":"https://avatars.githubusercontent.com/u/6612710?v=3","gravatar_id":"","url":"https://api.github.com/users/chaodhib","html_url":"https://github.com/chaodhib","followers_url":"https://api.github.com/users/chaodhib/followers","following_url":"https://api.github.com/users/chaodhib/following{/other_user}","gists_url":"https://api.github.com/users/chaodhib/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodhib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodhib/subscriptions","organizations_url":"https://api.github.com/users/chaodhib/orgs","repos_url":"https://api.github.com/users/chaodhib/repos","events_url":"https://api.github.com/users/chaodhib/events{/privacy}","received_events_url":"https://api.github.com/users/chaodhib/received_events","type":"User","site_admin":false},"body":"# Work in progress PR\r\n\r\n## **Planned changes:**\r\nMajor changes:\r\n- Changing how the way the destination point of each NPC path is determined. Up until now, each time a creature had to move, first a destination point was computed. And only then a path leading to that point was generated. Now it's the other way around. The destination point is actually deduced from the path itself. We first generate a path to the target's location and then remove from the path a certain length: the distance at which the npc should stand.\r\n\r\nIn the only commit yet, this is already implemented but only for MoveChase. Also, ReducePathLenghtByDist needs to be improved in order to make sure that after that method call, the last point of the path is always in LoS of the target & at the right distance.\r\n\r\nMinor changes:\r\n-  From sniff analysis, I found that the standard distance at which NPCs stand after chasing another unit is 'Chaser->CombatReach + Target->CombatReach' instead of 'Chaser->CombatReach + Target->CombatReach + 0.5'.\r\n- From sniff analysis, I believe pets follow their masters at a 3 constant yard distance.\r\n-  Planning to remove the third parameter of MoveChase (the angle).\r\n\r\n**Target branch(es):** 3.3.5\r\n\r\n**Issues addressed:** Should fix quite a lot of issues related to NPC movements\r\n\r\n**Tests performed:** WIP. Build and tested IG for what I have so far.\r\n","created_at":"2016-08-23T18:31:34Z","updated_at":"2016-08-29T20:23:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38a285321fdff98950a73b47170080772d41f490","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850/commits","review_comments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850/comments","review_comment_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/17850/comments","statuses_url":"https://api.github.com/repos/TrinityCore/TrinityCore/statuses/7fdf9bd2eda70b6b139560e4c2182d635147c66d","head":{"label":"chaodhib:targeted_movegen_improvements","ref":"targeted_movegen_improvements","sha":"7fdf9bd2eda70b6b139560e4c2182d635147c66d","user":{"login":"chaodhib","id":6612710,"avatar_url":"https://avatars.githubusercontent.com/u/6612710?v=3","gravatar_id":"","url":"https://api.github.com/users/chaodhib","html_url":"https://github.com/chaodhib","followers_url":"https://api.github.com/users/chaodhib/followers","following_url":"https://api.github.com/users/chaodhib/following{/other_user}","gists_url":"https://api.github.com/users/chaodhib/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodhib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodhib/subscriptions","organizations_url":"https://api.github.com/users/chaodhib/orgs","repos_url":"https://api.github.com/users/chaodhib/repos","events_url":"https://api.github.com/users/chaodhib/events{/privacy}","received_events_url":"https://api.github.com/users/chaodhib/received_events","type":"User","site_admin":false},"repo":{"id":32586040,"name":"TrinityCore","full_name":"chaodhib/TrinityCore","owner":{"login":"chaodhib","id":6612710,"avatar_url":"https://avatars.githubusercontent.com/u/6612710?v=3","gravatar_id":"","url":"https://api.github.com/users/chaodhib","html_url":"https://github.com/chaodhib","followers_url":"https://api.github.com/users/chaodhib/followers","following_url":"https://api.github.com/users/chaodhib/following{/other_user}","gists_url":"https://api.github.com/users/chaodhib/gists{/gist_id}","starred_url":"https://api.github.com/users/chaodhib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaodhib/subscriptions","organizations_url":"https://api.github.com/users/chaodhib/orgs","repos_url":"https://api.github.com/users/chaodhib/repos","events_url":"https://api.github.com/users/chaodhib/events{/privacy}","received_events_url":"https://api.github.com/users/chaodhib/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chaodhib/TrinityCore","description":"TrinityCore Open Source MMO Framework","fork":true,"url":"https://api.github.com/repos/chaodhib/TrinityCore","forks_url":"https://api.github.com/repos/chaodhib/TrinityCore/forks","keys_url":"https://api.github.com/repos/chaodhib/TrinityCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chaodhib/TrinityCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chaodhib/TrinityCore/teams","hooks_url":"https://api.github.com/repos/chaodhib/TrinityCore/hooks","issue_events_url":"https://api.github.com/repos/chaodhib/TrinityCore/issues/events{/number}","events_url":"https://api.github.com/repos/chaodhib/TrinityCore/events","assignees_url":"https://api.github.com/repos/chaodhib/TrinityCore/assignees{/user}","branches_url":"https://api.github.com/repos/chaodhib/TrinityCore/branches{/branch}","tags_url":"https://api.github.com/repos/chaodhib/TrinityCore/tags","blobs_url":"https://api.github.com/repos/chaodhib/TrinityCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chaodhib/TrinityCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chaodhib/TrinityCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/chaodhib/TrinityCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chaodhib/TrinityCore/statuses/{sha}","languages_url":"https://api.github.com/repos/chaodhib/TrinityCore/languages","stargazers_url":"https://api.github.com/repos/chaodhib/TrinityCore/stargazers","contributors_url":"https://api.github.com/repos/chaodhib/TrinityCore/contributors","subscribers_url":"https://api.github.com/repos/chaodhib/TrinityCore/subscribers","subscription_url":"https://api.github.com/repos/chaodhib/TrinityCore/subscription","commits_url":"https://api.github.com/repos/chaodhib/TrinityCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/chaodhib/TrinityCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/chaodhib/TrinityCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/chaodhib/TrinityCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/chaodhib/TrinityCore/contents/{+path}","compare_url":"https://api.github.com/repos/chaodhib/TrinityCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chaodhib/TrinityCore/merges","archive_url":"https://api.github.com/repos/chaodhib/TrinityCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chaodhib/TrinityCore/downloads","issues_url":"https://api.github.com/repos/chaodhib/TrinityCore/issues{/number}","pulls_url":"https://api.github.com/repos/chaodhib/TrinityCore/pulls{/number}","milestones_url":"https://api.github.com/repos/chaodhib/TrinityCore/milestones{/number}","notifications_url":"https://api.github.com/repos/chaodhib/TrinityCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chaodhib/TrinityCore/labels{/name}","releases_url":"https://api.github.com/repos/chaodhib/TrinityCore/releases{/id}","deployments_url":"https://api.github.com/repos/chaodhib/TrinityCore/deployments","created_at":"2015-03-20T13:44:30Z","updated_at":"2016-02-05T23:16:05Z","pushed_at":"2016-08-28T16:58:05Z","git_url":"git://github.com/chaodhib/TrinityCore.git","ssh_url":"git@github.com:chaodhib/TrinityCore.git","clone_url":"https://github.com/chaodhib/TrinityCore.git","svn_url":"https://github.com/chaodhib/TrinityCore","homepage":"http://www.trinitycore.org","size":294709,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"3.3.5"}},"base":{"label":"TrinityCore:3.3.5","ref":"3.3.5","sha":"5615645b6bd3dc432ed60897b727cdc7f6962c22","user":{"login":"TrinityCore","id":539602,"avatar_url":"https://avatars.githubusercontent.com/u/539602?v=3","gravatar_id":"","url":"https://api.github.com/users/TrinityCore","html_url":"https://github.com/TrinityCore","followers_url":"https://api.github.com/users/TrinityCore/followers","following_url":"https://api.github.com/users/TrinityCore/following{/other_user}","gists_url":"https://api.github.com/users/TrinityCore/gists{/gist_id}","starred_url":"https://api.github.com/users/TrinityCore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrinityCore/subscriptions","organizations_url":"https://api.github.com/users/TrinityCore/orgs","repos_url":"https://api.github.com/users/TrinityCore/repos","events_url":"https://api.github.com/users/TrinityCore/events{/privacy}","received_events_url":"https://api.github.com/users/TrinityCore/received_events","type":"Organization","site_admin":false},"repo":{"id":1204412,"name":"TrinityCore","full_name":"TrinityCore/TrinityCore","owner":{"login":"TrinityCore","id":539602,"avatar_url":"https://avatars.githubusercontent.com/u/539602?v=3","gravatar_id":"","url":"https://api.github.com/users/TrinityCore","html_url":"https://github.com/TrinityCore","followers_url":"https://api.github.com/users/TrinityCore/followers","following_url":"https://api.github.com/users/TrinityCore/following{/other_user}","gists_url":"https://api.github.com/users/TrinityCore/gists{/gist_id}","starred_url":"https://api.github.com/users/TrinityCore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrinityCore/subscriptions","organizations_url":"https://api.github.com/users/TrinityCore/orgs","repos_url":"https://api.github.com/users/TrinityCore/repos","events_url":"https://api.github.com/users/TrinityCore/events{/privacy}","received_events_url":"https://api.github.com/users/TrinityCore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TrinityCore/TrinityCore","description":"TrinityCore Open Source MMO Framework","fork":false,"url":"https://api.github.com/repos/TrinityCore/TrinityCore","forks_url":"https://api.github.com/repos/TrinityCore/TrinityCore/forks","keys_url":"https://api.github.com/repos/TrinityCore/TrinityCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TrinityCore/TrinityCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TrinityCore/TrinityCore/teams","hooks_url":"https://api.github.com/repos/TrinityCore/TrinityCore/hooks","issue_events_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/events{/number}","events_url":"https://api.github.com/repos/TrinityCore/TrinityCore/events","assignees_url":"https://api.github.com/repos/TrinityCore/TrinityCore/assignees{/user}","branches_url":"https://api.github.com/repos/TrinityCore/TrinityCore/branches{/branch}","tags_url":"https://api.github.com/repos/TrinityCore/TrinityCore/tags","blobs_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TrinityCore/TrinityCore/statuses/{sha}","languages_url":"https://api.github.com/repos/TrinityCore/TrinityCore/languages","stargazers_url":"https://api.github.com/repos/TrinityCore/TrinityCore/stargazers","contributors_url":"https://api.github.com/repos/TrinityCore/TrinityCore/contributors","subscribers_url":"https://api.github.com/repos/TrinityCore/TrinityCore/subscribers","subscription_url":"https://api.github.com/repos/TrinityCore/TrinityCore/subscription","commits_url":"https://api.github.com/repos/TrinityCore/TrinityCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/TrinityCore/TrinityCore/contents/{+path}","compare_url":"https://api.github.com/repos/TrinityCore/TrinityCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TrinityCore/TrinityCore/merges","archive_url":"https://api.github.com/repos/TrinityCore/TrinityCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TrinityCore/TrinityCore/downloads","issues_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues{/number}","pulls_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls{/number}","milestones_url":"https://api.github.com/repos/TrinityCore/TrinityCore/milestones{/number}","notifications_url":"https://api.github.com/repos/TrinityCore/TrinityCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TrinityCore/TrinityCore/labels{/name}","releases_url":"https://api.github.com/repos/TrinityCore/TrinityCore/releases{/id}","deployments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/deployments","created_at":"2010-12-28T23:40:07Z","updated_at":"2016-08-29T05:19:59Z","pushed_at":"2016-08-29T20:13:47Z","git_url":"git://github.com/TrinityCore/TrinityCore.git","ssh_url":"git@github.com:TrinityCore/TrinityCore.git","clone_url":"https://github.com/TrinityCore/TrinityCore.git","svn_url":"https://github.com/TrinityCore/TrinityCore","homepage":"http://www.trinitycore.org","size":793213,"stargazers_count":3445,"watchers_count":3445,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3532,"mirror_url":null,"open_issues_count":1305,"forks":3532,"open_issues":1305,"watchers":3445,"default_branch":"6.x"}},"_links":{"self":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850"},"html":{"href":"https://github.com/TrinityCore/TrinityCore/pull/17850"},"issue":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/17850"},"comments":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/17850/comments"},"review_comments":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850/comments"},"review_comment":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/17850/commits"},"statuses":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/statuses/7fdf9bd2eda70b6b139560e4c2182d635147c66d"}}}}
{"actor":{"display_login":"chaodhib"}}