#2876: AI Script: buildDerrick + closestOil + droidCanReach + Map Sk-Concrete
(8P)
= Error
-------------------------------------------------+-------------------------
Reporter: wzdude | Owner: Per
Type: bug | Status: new
Priority: normal | Milestone:
Component: Engine: Scripting / AI | unspecified
Keywords: buildDerrick closestOil | Version:
droidCanReach AI | unspecified
Blocked By: | Operating System: All
| /Non-Specific
| Blocking:
-------------------------------------------------+-------------------------
buildDerrick() uses closest_oil(). This fkt. is looking for the closest
oil resource no matter if any contruction droid can reach it. For map Sk-
Concrete (with 8 Players) this is fatal, because there are oil resources
located at islands and if no contruction droid was build with hover (as it
is always the case) any AI gets stuck here. Free oil resources little bit
further away will be completely ignored.
I found a solution that worked for me:
1. removed droidCanReach()-check from buildDerrick()
2. replaced closestOil() fkt. with this one:
function FEATURE closestOil(int _x, int _y, bool _bAvoidThreat)
{
local FEATURE _oil, _closestOil;
local int _bestDist, _newDist;
local DROID _droid;
_closestOil = NULLOBJECT;
initIterateGroup(buildGroup);
_droid = iterateGroup(buildGroup);
while (_droid != NULLOBJECT)
{
_bestDist = distBetweenTwoPoints(0, 0, (mapWidth * TILE),
(mapHeight * TILE));
initGetFeature(oilRes, -1, me);
_oil = getFeatureB(me);
while (_oil != NULLOBJECT)
{
_newDist = distBetweenTwoPoints(_x, _y, _oil.x,
_oil.y);
if (_newDist < _bestDist and droidCanReach(_droid,
_oil.x, _oil.y))
{
if ( !(_bAvoidThreat && threatInRange(me,
_oil.x, _oil.y, OIL_THREAT_RANGE, FALSE)) )
{
_bestDist = _newDist;
_closestOil = _oil;
}
}
_oil = getFeatureB(me);
}
if (_closestOil != NULLOBJECT)
{
return _closestOil;
}
_droid = iterateGroup(buildGroup);
}
return _closestOil;
}
--
Ticket URL: <http://developer.wz2100.net/ticket/2876>
Warzone 2100 Trac <http://developer.wz2100.net/>
The Warzone 2100 Project
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev