Page 1 of 1

defending gateways

Posted: 03 Mar 2010, 17:57
by DylanDog
I was wondering if someone can explain how the standard warzone AI is able to build defences on gateways points without using the function:

getNearestGateway() to become aware of the gateways positions.

This would be nice to know.

Re: defending gateways

Posted: 03 Mar 2010, 19:46
by Per
By calling skDefenseLocation() and skDefenseLocationB().

Re: defending gateways

Posted: 03 Mar 2010, 22:57
by DylanDog
Per wrote:By calling skDefenseLocation() and skDefenseLocationB().
skDefenseLocation() is not used.

How does skDefenseLocationB() works? from the AI manual (referred to skDefenseLocation() ):

Code: Select all

bool skDefenseLocation (ref int x, ref int y, STRUCTURESTAT defenceStat, STRUCTURESTAT wallstat, DROID unit, int player)
    Given a starting x and y, make unit unit belonging to player build either a defenceStat or a row of wallStat. Returns modified x and ys. 
Does this mean that the nearest gateway to x,y coord is the first one to be fortified?
What happens when all gateways are fortified?
Valid gateways are within which range of x,y?

Re: defending gateways

Posted: 03 Mar 2010, 23:37
by Per
Yes, the nearest gateway is fortified, and the passed in droid is given a linebuild order to construct the entire gateway in one order. It is a rather ugly hack, and it is full of bugs. I fixed some of the bugs in trunk while testing semperfi, but more bugs remain (if gateway goes into map border then gateway building is cancelled, it doesn't usually understand that a gateway is already built, etc). When all gateways are fortified, it returns false and does nothing. There is no range limitation, so droids can be sent on quite a journey in odd cases.

The difference between the two versions is that the B version will skip gateways unless it can preserve at least two empty tiles in the middle of the gateway for traffic. Probably any use of the non-B version is a bug.

If you have your own gateway building code, I am sure it is better than this.

Re: defending gateways

Posted: 04 Mar 2010, 14:51
by DylanDog
Per wrote: If you have your own gateway building code, I am sure it is better than this.
thanks for the clarification.
Yes I am using my code but it is also using skDefenseLocationB(), I pass to that function up to three gateways coordinates (I check for the number of def buildings built in that range before pasing that coordinates to that function).