Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

[Bug] Lua : FindClearSpaceForUnit & SetHullRadius

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Bug] Lua : FindClearSpaceForUnit & SetHullRadius

    There is an issue when FindClearSpaceForUnit is used on a unit with its SetHullRadius set.

    - The unit will get stuck inside the gridnav. Unless you click at its feet to move.
    - If the SetHullRadius(32) and runs around a gridnav it will teleport to the edge of the map. https://gfycat.com/PointedVariableDiamondbackrattlesnake#
    (No longer happens but the unit gets stuck at the corner of the gridnav instead)
    - When walking around a blocked gridnav the unit will get stuck on the corners and fail to walk to its destination.

    I have provided a gfy as demonstration. https://gfycat.com/SeparateMisguidedLamprey

    An addition gfy to demonstrate walking around blocked gridnavs https://gfycat.com/DescriptiveDescriptiveCusimanse

    This is a sample of the code being used to move the hero.

    Code:
    hero:SetHullRadius(33) -- This happens when the hero is initiated, It is also set to 33 as 32 teleports to the edge of the map when the unit runs around a blocked gridnav.
    
    ...
    
    caster:Stop()
    FindClearSpaceForUnit(caster, v, true)
    Last edited by anth92; 08-14-2015, 05:22 PM.

  • #2
    It would be nice if this could get a higher priority in regards to being fixed.

    SetHullRadius has broken and unreliable pathfinding on larger than default hulls.

    Sheep Tag : http://steamcommunity.com/sharedfile.../?id=435131884 (Privately listed) cannot be released without it.
    Last edited by anth92; 08-17-2015, 11:18 PM.

    Comment


    • #3
      Hey I implemented my own FindClearSpace function since I had the same problem as you.

      Here's the code.

      Its decently documented, there's quite a few places throughout the repo where I use it.

      Comment


      • #4
        Originally posted by butthurt View Post
        Hey I implemented my own FindClearSpace function since I had the same problem as you.

        Here's the code.

        Its decently documented, there's quite a few places throughout the repo where I use it.
        This is a good workaround for FindClearSpaceForUnit with a custom hull size but there is still the issue with pathfinding using a custom hull size.

        Comment


        • #5
          I made this since butthurt's function did not fulfil my needs.

          Hopefully in the near future valve fixes this mess.

          Code:
          --[[ Find a clear space for a unit based on gridnav, for a hull size bigger than 1x1 but smaller than 2x2. (Used to replace FindClearSpaceForUnit)
          	Author: a_dizzle
          	Date: 06.01.2016 
          	unit 		: The handle of the unit you are moving.
          	vTargetPos	: The target Vector you want to move this unit too.
          
          	returns boolean: true if a clear space has been found, false if it hasn't (this will not move the unit)
          ]]
          function FindBigSpaceForUnit( unit, vTargetPos )
          	local newPos = nil
          	local checkSpace = {}
          	checkSpace[1] = Vector( -64, 64, 0 )
          	checkSpace[2] = Vector( 0, 64, 0 )
          	checkSpace[3] = Vector( 64, 64, 0 )
          	checkSpace[4] = Vector( -64, 0, 0 )
          	checkSpace[5] = Vector( 0, 0, 0 )
          	checkSpace[6] = Vector( 64, 0, 0 )
          	checkSpace[7] = Vector( -64, -64, 0 )
          	checkSpace[8] = Vector( 0, -64, 0 )
          	checkSpace[9] = Vector( 64, -64, 0 )
          	local goodSpace = {}
          	local vAlignedPos = Vector(SnapToGrid32(vTargetPos[1]), SnapToGrid32(vTargetPos[2]), vTargetPos[3])
          	DebugDrawCircle(vAlignedPos, Vector(0,255,255), 1, 32, true, 5)
          	DebugDrawCircle(vTargetPos, Vector(0,255,0), 1, 32, true, 5)
          	-- Check for valid spaces
          	for i,v in ipairs(checkSpace) do
          		local validSpace = true
          		if GridNav:IsBlocked(v + vAlignedPos) or GridNav:IsTraversable(v + vAlignedPos) == false then
          			validSpace = false
          			DebugDrawCircle(v + vAlignedPos, Vector(255,0,0), 1, 16, true, 5)
          		else
          			DebugDrawCircle(v + vAlignedPos, Vector(0,255,0), 1, 16, true, 5)
          		end
          		goodSpace[i] = validSpace
          	end
          
          	-- Case 1: All Clear
          	local case1 = true
          	for i,v in ipairs(goodSpace) do
          		if not v then
          			case1 = false
          		end
          	end
          	if case1 then
          		newPos = vAlignedPos
          		print("Case 1")
          	end
          
          	-- Case 2: Corner Clear
          	if newPos == nil then
          		local cornerClear = {}
          		cornerClear[1] = false
          		cornerClear[2] = false
          		cornerClear[3] = false
          		cornerClear[4] = false
          		if goodSpace[1] == true and goodSpace[2] == true and goodSpace[4] == true and goodSpace[5] == true then
          			cornerClear[1] = true
          		end
          		if goodSpace[2] == true and goodSpace[3] == true and goodSpace[5] == true and goodSpace[6] == true then
          			cornerClear[2] = true
          		end
          		if goodSpace[4] == true and goodSpace[5] == true and goodSpace[7] == true and goodSpace[8] == true then
          			cornerClear[3] = true
          		end
          		if goodSpace[5] == true and goodSpace[6] == true and goodSpace[8] == true and goodSpace[9] == true then
          			cornerClear[4] = true
          		end
          
          		print(cornerClear[1],cornerClear[2],cornerClear[3],cornerClear[4])
          		-- Pick Spot
          		if cornerClear[1] and not cornerClear[2] and not cornerClear[3] and not cornerClear[4] then
          			print("1")
          			newPos = vAlignedPos + Vector( -32, 32, 0)
          		elseif cornerClear[2] and not cornerClear[1] and not cornerClear[3] and not cornerClear[4] then
          			print("2")
          			newPos = vAlignedPos + Vector( 32, 32, 0)
          		elseif cornerClear[3] and not cornerClear[1] and not cornerClear[2] and not cornerClear[4] then
          			print("3")
          			newPos = vAlignedPos + Vector( -32, -32, 0)
          		elseif cornerClear[4] and not cornerClear[1] and not cornerClear[2] and not cornerClear[3] then
          			print("4")
          			newPos = vAlignedPos + Vector( 32, -32, 0)
          		elseif cornerClear[1] and cornerClear[2] and not cornerClear[3] and not cornerClear[4] then
          			print("5")
          			newPos = vAlignedPos + Vector( 0, 32, 0)
          		elseif cornerClear[3] and cornerClear[4] and not cornerClear[1] and not cornerClear[2] then
          			print("6")
          			newPos = vAlignedPos + Vector( 0, -32, 0)
          		elseif cornerClear[2] and cornerClear[4] and not cornerClear[1] and not cornerClear[3] then
          			print("7")
          			newPos = vAlignedPos + Vector( 32, 0, 0)
          		elseif cornerClear[1] and cornerClear[3] and not cornerClear[2] and not cornerClear[4] then
          			print("8")
          			newPos = vAlignedPos + Vector( -32, 0, 0)
          		elseif cornerClear[1] and (cornerClear[2] or cornerClear[3] or cornerClear[4]) then
          			print("9")
          			newPos = vAlignedPos + Vector( -32, 32, 0)
          		elseif cornerClear[2] and (cornerClear[1] or cornerClear[3] or cornerClear[4]) then
          			print("10")
          			newPos = vAlignedPos + Vector( 32, 32, 0)
          		elseif cornerClear[3] and (cornerClear[1] or cornerClear[2] or cornerClear[4]) then
          			print("11")
          			newPos = vAlignedPos + Vector( -32, -32, 0)
          		elseif cornerClear[4] and (cornerClear[1] or cornerClear[2] or cornerClear[3]) then
          			print("12")
          			newPos = vAlignedPos + Vector( 32, -32, 0)
          		end
          		if newPos ~= nil then
          			print("Case 2")
          		end
          	end
          
          	-- Case Default: No Space
          	if newPos == nil then
          		newPos = vTargetPos
          		print("Case Default")
          		return false
          	end
          	DebugDrawCircle(newPos, Vector(255,255,0), 1, 8, true, 5)
          	FindClearSpaceForUnit( unit, newPos, true )
          	return true
          end

          Comment


          • #6
            And this one still doesn't fix troubles with pf, isn't it?

            Comment


            • #7
              Originally posted by 6opoDuJIo View Post
              And this one still doesn't fix troubles with pf, isn't it?
              It does not fix path finding sadly.

              Comment

              Working...
              X