i tested something and noticed that suddenly the builders stop building after some time. The find a good build pos and call giveorder, but then nothing happens.
This happens:
When they can't reach the build pos. (sometimes with UnitMoveFailed() and sometimes without)
When they are to close to a building.
After some time other builder also stop building.(without reason=
Can somebody help? Is there a solution?
problems with giveorder()
Moderators: hoijui, Moderators
First off
Check the return value isnt -1, if so its a failed order
Give the order a timeout value so even if it cant or wont be carried out untiIdle will still be caleld after teh tiemout period and the order canceled.
Wehn an order is finished, UnitIdle sint always called. Just because your unit has finished what it's doign and then stop doesnt mean there's soemthgin wrong with your code, it's an engine problem. Run checks itnermittently to see if con untis are doing what they're meant to eb doing, or if they've finished and you've not been told.
NTAI runs a check ocne a second to see if there are any con units that are idle with no commands queued or CMD_STOP comamnds, but are supposed to ahve ahd UnitIdle() called, then ti kicks them abck into actions. Doesnt work as well as I'd like it to tho since units still stall, not as much tho...
Check the return value isnt -1, if so its a failed order
Give the order a timeout value so even if it cant or wont be carried out untiIdle will still be caleld after teh tiemout period and the order canceled.
Wehn an order is finished, UnitIdle sint always called. Just because your unit has finished what it's doign and then stop doesnt mean there's soemthgin wrong with your code, it's an engine problem. Run checks itnermittently to see if con untis are doing what they're meant to eb doing, or if they've finished and you've not been told.
NTAI runs a check ocne a second to see if there are any con units that are idle with no commands queued or CMD_STOP comamnds, but are supposed to ahve ahd UnitIdle() called, then ti kicks them abck into actions. Doesnt work as well as I'd like it to tho since units still stall, not as much tho...
return value is 0.
my code:
The problem is not that UnitIdle is never called. The problem is that it is called every update. The unit builds something and next update it builds again, and again!
The best part is that this problem only occurs if i change something in my metal class!?!
my code:
Code: Select all
if(mAICallback->GetCurrentUnitCommands(i->first)->empty() == true)
{
// build
...
}
The best part is that this problem only occurs if i change something in my metal class!?!
There's a delay between the GIveOrder() command and the GetCurrentUnitCommands() call being populated.
I tried to use this method as well, but I found that my unit was getting somewhere between 10-30 commands before GetCurrentUnitCommands() was populated. Don't know why. Now I just keep an internal bool array of UnitIdle, and update it when I get unit idle calls.
I tried to use this method as well, but I found that my unit was getting somewhere between 10-30 commands before GetCurrentUnitCommands() was populated. Don't know why. Now I just keep an internal bool array of UnitIdle, and update it when I get unit idle calls.
When I started fof ym check routine for NTAI I found that my commander never built solars, because ti would always cancel tis order, move out a bit then try again because ti was standing on the solars eventual footprint. But ym loop saw this and gave the commander a new task so the solar order was never executed.
I sovled it by making the loop increment a counter for that unit if it was doing nothing and decrementing if ti was, and if that counter reached a threshold it was kicked back into life again, and the counter was set back to zero.
I sovled it by making the loop increment a counter for that unit if it was doing nothing and decrementing if ti was, and if that counter reached a threshold it was kicked back into life again, and the counter was set back to zero.
GiveOrder simply puts a message onto the networking message queue, this is send to the server queue (even if the local host is also the server), and the server sends it to the client.. if there is a lag between AI host and server, this gets even worse. Anyway, it's something you should really consider when creating a task system. For this reason JCAI also mirrors all tasks internally...I tried to use this method as well, but I found that my unit was getting somewhere between 10-30 commands before GetCurrentUnitCommands() was populated. Don't know why. Now I just keep an internal bool array of UnitIdle, and update it when I get unit idle calls.
it is really strange. what happens:
a builder builds something
it is finished
unitidle()
update
GetCurrentUnitCommands() == empty
giveorder()
unitidle()
update
GetCurrentUnitCommands() == empty
giveorder()
unitidle()
update
GetCurrentUnitCommands() == empty
giveorder()
....
i tested the old MyAI_0_0_4 version and the same happened! Yesterday I tested it hours and never happened something like this!
Sometimes the error occurs because of failed movement. This can be solved.
hmm... WTF!!!!!!!!!
It seems like it only happens with absolute annihilation and building ARMLAB!
strange!?!
need more testing!
a builder builds something
it is finished
unitidle()
update
GetCurrentUnitCommands() == empty
giveorder()
unitidle()
update
GetCurrentUnitCommands() == empty
giveorder()
unitidle()
update
GetCurrentUnitCommands() == empty
giveorder()
....
i tested the old MyAI_0_0_4 version and the same happened! Yesterday I tested it hours and never happened something like this!
Sometimes the error occurs because of failed movement. This can be solved.
hmm... WTF!!!!!!!!!
It seems like it only happens with absolute annihilation and building ARMLAB!
strange!?!
need more testing!
My latest incarnation of my build algorithm behaves just as oddly.
It's told to execute the first task in its list for an idle unit. If the return value is -1 it executes the next task and so on.
As a result ym commander in NTAI refuses to build mexes till it's finished building a laoda factories and solars and gotten halfway through its build tree, it just skips over the entries.
It's told to execute the first task in its list for an idle unit. If the return value is -1 it executes the next task and so on.
As a result ym commander in NTAI refuses to build mexes till it's finished building a laoda factories and solars and gotten halfway through its build tree, it just skips over the entries.