Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function harrold:scoreBuildingBasedOnProximity(_v)
- local v = _v
- local score = 0
- local posX = nil
- local posY = nil
- --Game:updatePathfinding( )
- for i,j in ipairs(building:_returnBuildingTable()) do
- local bld = j
- --if j.point > 0 then --not our team
- if bld.team ~= unit:_returnTurn() and unit:isLocEmpty(bld.x, bld.y) == nil and bld.x ~= v.x and bld.y ~= v.y then
- local path, length = pather:getPath(v.x, v.y, bld.x, bld.y)
- if path ~= nil then -- make sure there's a path to that building
- local bool = false
- for k, l in ipairs(unit:_returnTable() ) do
- if l.tp == 1 or l.tp == 2 and l.team == v.team then
- local distCheck = math.dist(l.x, l.y, bld.x, bld.y)
- if length < 2 then
- bool = true
- end
- end
- end
- local moveScore = 0
- local modifier = 0
- if bool == true then
- modifier = 8
- end
- moveScore = moveScore + (9 - bld._type*2) + (30 - length) - modifier -- more focus on buildings that create units
- if moveScore > score then
- posX = bld.x
- posY = bld.y
- score = moveScore
- end
- else
- --print("VX: "..v.x.." | VY: "..v.y.." BX: "..bld.x.." BY: "..bld.y.."")
- --print("NIL NIL NIL IN SCORE BUILDING")
- end
- end
- end
- -- now we add our final positions to a list. This way, we'll make sure we didn't target the building before
- v.goal_x = posX
- v.goal_y = posY
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement