mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
AI chooses the closest deposit to build an extractor
This commit is contained in:
@@ -55,14 +55,15 @@ function Player:buildExtractor()
|
||||
self:selectUnits({engineer})
|
||||
|
||||
deposits = self:getResourceDeposits()
|
||||
depPos = nil
|
||||
if #deposits == 0 then return false end
|
||||
|
||||
if #deposits > 0 then
|
||||
depPos = deposits[1]:getPos()
|
||||
end
|
||||
depPos = deposits[1]:getPos()
|
||||
spawnPoint = self:getSpawnPoint()
|
||||
|
||||
if depPos == nil then
|
||||
return false
|
||||
for i = 1, #deposits do
|
||||
if deposits[i]:getPos():getDistanceFrom(spawnPoint) < depPos:getDistanceFrom(spawnPoint) then
|
||||
depPos = deposits[i]:getPos()
|
||||
end
|
||||
end
|
||||
|
||||
extractor = GameObjectFactory.createUnit(self, UnitId.EXTRACTOR, depPos, Quaternion:new(1, 0, 0, 0), 0)
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace battleship{
|
||||
"y", &Vector3::y,
|
||||
"z", &Vector3::z,
|
||||
"norm", &Vector3::norm,
|
||||
"getDistanceFrom", &Vector3::getDistanceFrom,
|
||||
"add", [](Vector3 v1, Vector3 v2){return v1 + v2;},
|
||||
"subtr", [](Vector3 v1, Vector3 v2){return v1 - v2;},
|
||||
"mult", [](Vector3 v1, float s){return v1 * s;},
|
||||
|
||||
Reference in New Issue
Block a user