Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function harrold:_selectEnemyToEngage(_v)
- local v = _v
- local score = 0
- local scoutScore = 0
- local posX, posY = nil, nil
- local targetID = nil
- for i,j in ipairs(unit:_returnTable()) do
- local un = j
- if j.team ~= unit:_returnTurn() then
- local bool, threat, bid = self:isEnemyNearOneOfOurBuildings(j)
- local moveScore = 0
- local path, length = pather:getPath(v.x, v.y, un.x, un.y)
- local bunitScore = self:scoreUnit(v)
- local targUnScore = self:scoreUnit(un)
- if path ~= nil then
- local modifier = 0
- if bool == true then
- local extraMode = 0
- if bid ~= nil then
- local bld = building:_returnBuildingTable()[bid]
- -- get my own distance to the
- local distCheck = math.dist(v.x, v.y, bld.x, bld.y)
- if distCheck < v.range then
- extraMode = 18 - distCheck*2
- end
- if length < 4 then
- extraMode = extraMode + 500
- end
- end
- if threat == 1 then
- if j.tp == 1 or j.tp == 2 then
- modifier = 225 + extraMode
- else
- modifier = 125 + extraMode
- end
- else
- modifier = 20
- end
- end
- local freeSpotModifier = 0
- local mcX, mcY = self:findFreeSpot(j.x, j.y, v.attack_range)
- if mcX ~= nil and mcy ~= nil then
- freeSpotModifier = - 200
- else
- freeSpotModifier = 40
- end
- moveScore = moveScore + (30 - length) + modifier + (20 ) + freeSpotModifier
- if moveScore > score then
- posX, posY = un.x, un.y
- score = moveScore
- targetID = i
- end
- else
- --print("NIL FUCKERE")
- end
- end
- end
- v.goal_x = posX
- v.goal_y = posY
- v.rival = i
- if v.goal_x == nil and v.goal_y == nil then
- --print("FIND FREE LOCATION")
- v.goal_x, v.goal_y = self:_findFreeLocation(v)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement