Bit of confusion with the new Java AI
Posted: 29 Dec 2011, 15:19
Recently, I had a bit of free time and thought of porting my old Java AI (it was never released) to the new interface. After a bit of fiddling, I managed to have it compile again and have it run.
Now I still seem to have some odd problems with it.
1) Building structures [SOLVED]
At the start of the game, I have my commander create a number of buildings. Once he finishes building one structure, I give him a new build order. I only give him build orders, no movement or otherwise. However, it seems that with the new AI, after he has finished building, he returns back to where he was when the order was given, meaning he's always returning to his spawn location whenever he builds something, and then doubling back for a new build order.
Old code:
Code that makes him work somewhat better, but still broken (he needs to travel outside of the build place every time):
timeout is 10000, and opts are -1.
So I'm mostly curious what caused the change, and how can I have the old behavior (only build orders were necessary) back?
2) Building units [SOLVED]
It does not work. I have a vehplant which is supposed to be building jeffys, flashes and construction vehicles, but it seems to simply be ignoring the commands (and I have confirmed that the vehplant is finished and can build those unitdefs, it used to work fine before).
This is code that I have tried so far:
I've also tried the timeout factor (15 in examples above) to be 10000 with no effect. Also it may be worth noting that I get kind of errors after a while (not soon after the vehplant is built and units should be being built). I tried looking at how the interface and wrappers work, but it all seems solid - no idea on what's causing the problem, and I'm getting no errors, which is the worst part.
3) Missing command-ID constants
Usually, I'd have units work with commands, and as soon as it finished something, and caused unitIdle to trigger, I'd look at what it's completed (by commandTypeId) and then based on that send it off to do other things. While it's still possible to do that, it seems the files that had commands with their type-ids, are gone, so one would have to write down type-ids himself (42 is moving, 35 is building and so on) instead of using an enumeration like
.
Sure, nothing is stopping me from creating those enums myself, but I would've hoped they existed in the generated Java interface/wrappers (maybe they do already?), instead of forcing me to have an open C/C++ .h file where those are written (took me some time to find, and I'm not new to spring).
Now I still seem to have some odd problems with it.
1) Building structures [SOLVED]
At the start of the game, I have my commander create a number of buildings. Once he finishes building one structure, I give him a new build order. I only give him build orders, no movement or otherwise. However, it seems that with the new AI, after he has finished building, he returns back to where he was when the order was given, meaning he's always returning to his spawn location whenever he builds something, and then doubling back for a new build order.
Old code:
Code: Select all
builder.build(unitDef, position, facing, opts, timeout);
Code: Select all
builder.moveTo(position, opts, timeout);
builder.build(unitDef, position, facing, opts, timeout);
So I'm mostly curious what caused the change, and how can I have the old behavior (only build orders were necessary) back?
2) Building units [SOLVED]
It does not work. I have a vehplant which is supposed to be building jeffys, flashes and construction vehicles, but it seems to simply be ignoring the commands (and I have confirmed that the vehplant is finished and can build those unitdefs, it used to work fine before).
This is code that I have tried so far:
Code: Select all
builder.build(unitDef, new AIFloat3(), facing, opts, 15);
Code: Select all
builder.build(unitDef, new AIFloat3(0, 0, 0), facing, opts, 15);
Code: Select all
builder.build(unitDef, builder.getPos(), facing, opts, 15);
Code: Select all
builder.build(unitDef, null, facing, opts, 15); //crashes
Code: Select all
[f=0026298] Warning: Waiting packet limit was reached for gajop AI #1 [packets dropped]
3) Missing command-ID constants
Usually, I'd have units work with commands, and as soon as it finished something, and caused unitIdle to trigger, I'd look at what it's completed (by commandTypeId) and then based on that send it off to do other things. While it's still possible to do that, it seems the files that had commands with their type-ids, are gone, so one would have to write down type-ids himself (42 is moving, 35 is building and so on)
Code: Select all
if (35 == commandTopicId) {...
Code: Select all
if (BuildCommand.id == commandTopicId) {...
Sure, nothing is stopping me from creating those enums myself, but I would've hoped they existed in the generated Java interface/wrappers (maybe they do already?), instead of forcing me to have an open C/C++ .h file where those are written (took me some time to find, and I'm not new to spring).