Shard 0.4/dev
Moderators: hoijui, Moderators
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Is the builder immobile by a chance? With default Shard spothandler.lua immobile builders might get stuck trying to build extractors out of their build range. Mobile units should not have this problem.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Nope, I'm unaware of how the APIs for reading from the VFS work in the C++ API, I'm not sure if there are C++ Wrappers, there are definitely C APIs deep down for it
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Nope, it is fully mobile.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Is it possible to find out which team owns a unit?
Why I need that: game:GetFriendlies() returns not only my own units, but also those of allies, but I sometimes need only a list of my own units.
Why I need that: game:GetFriendlies() returns not only my own units, but also those of allies, but I sometimes need only a list of my own units.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Use GetUnits instead
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Shard on github should contain SWIG wrappers for std::vector<int> adn std::vector<float> later today.
Creation in lua would take the form:
floats should behave as any other list of items in lua, I'm guessing table.insert should suffice
There's also vectorInt but I'm not using that anywhere at the moment.
I've also added IsBeingBuilt to the unit object.
You'll also find it useful to know that there si a Team method on the unit object returning the current units team as an integer.
Another note, It appears that due to a rather fantasticaly dumb mistake, the Repair method actually calls the Attack engine function. This is now fixed on github
Creation in lua would take the form:
Code: Select all
local floats = api.new_vectorFloat();
There's also vectorInt but I'm not using that anywhere at the moment.
I've also added IsBeingBuilt to the unit object.
You'll also find it useful to know that there si a Team method on the unit object returning the current units team as an integer.
Another note, It appears that due to a rather fantasticaly dumb mistake, the Repair method actually calls the Attack engine function. This is now fixed on github
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
A MaximumHeight and MinimumHeight have been added to the map object
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
api.lua does not mention unit:Team(), so I had no idea it exists (and it really does, I just tested).
Now I wonder what else might be there, but undocumented.
Now I wonder what else might be there, but undocumented.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
api/lua is being updated
Also added:
Also added:
- Unit engine objects now have a Wait command, taking 1 parameter ( a timeout value )
- MaximumHeight and MinimumHeight methods have been added to the map object
- A Unit move failed event has been added to the C++ component, though I need to add a function to the lua AI object to accept the new event
- It seems my assumption that the Build command returned success/failure when called was not actually correct, I will need to investigate this further to catch a failure.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
come to thread to ask question, see question answered, leave. Excellent serviceapi.lua does not mention unit:Team(), so I had no idea it exists (and it really does, I just tested).
On a side note: why is my random not random in a selfmade module while it works in taskqueues?
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Probably related to return value of Build() not being a success/failure: I've noticed a few cases of AI builders getting 'stuck': they stand there doing nothing, they don't have any active orders (selecting them in spectator view doesn't show anything), but TaskQueueBehaviour:UnitIdle() isn't called for them.
This seem to happen for example if a mobile builder is ordered to build a geo plant, but there are no geo spots on the map (not 100% sure on that). Immobile builders also get this problem, but with those any build order can cause that, not just geos.
I've implemented a sort of watchdog timer in taskqueuebehaviour.lua that forces the que to progress if current task is not finished in some amount of frames, but that's far from optimal as the unit is still wasting a lot of time before watchdog triggers (can't make it shorter because then long build projects will get abandoned). But I was able to get some statistics on the problem that way (which unit got stuck on which build order).
This problem can also be caused by behaviours sometimes not receiving UnitIdle() events for some reason (since I've noticed a very similar problem with units under control of my self-made behaviour unrelated to taskqueues), but I can't say for sure if that is the case.
This seem to happen for example if a mobile builder is ordered to build a geo plant, but there are no geo spots on the map (not 100% sure on that). Immobile builders also get this problem, but with those any build order can cause that, not just geos.
I've implemented a sort of watchdog timer in taskqueuebehaviour.lua that forces the que to progress if current task is not finished in some amount of frames, but that's far from optimal as the unit is still wasting a lot of time before watchdog triggers (can't make it shorter because then long build projects will get abandoned). But I was able to get some statistics on the problem that way (which unit got stuck on which build order).
This problem can also be caused by behaviours sometimes not receiving UnitIdle() events for some reason (since I've noticed a very similar problem with units under control of my self-made behaviour unrelated to taskqueues), but I can't say for sure if that is the case.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Before I continue, let me note that this is the 20,000th post, and I am now the first person to reach this milestone on the forums. I expect Smoth will follow within the next month or two
It seems in the API when the build order returns an unexpected value for whatever reason, an exception is thrown. Sometimes the build order is never issued and a false response is returned because the C+ portion tried to find a build location and none was found.
Anyways it's expected when the build order times out or fails that unit idle will be issued. The timeout is extremely high though.
Also if the unit gets stuck a movefailed event si fired by the engine, but this was never handled previously. The next version ( or current if you're grabbing it from buildbot ) does handle this event however, and by default uses it to then call UnitIdle.
As a sidenote, you could leave taskqueuebehaviour as is, and override it in the same way taskqueuebehaviour overrides behaviour, and behaviour overrides etc etc That way you need only implement the bits that are different, and the original taskqueuebehaviour is preserved as are your changes
It seems in the API when the build order returns an unexpected value for whatever reason, an exception is thrown. Sometimes the build order is never issued and a false response is returned because the C+ portion tried to find a build location and none was found.
Anyways it's expected when the build order times out or fails that unit idle will be issued. The timeout is extremely high though.
Also if the unit gets stuck a movefailed event si fired by the engine, but this was never handled previously. The next version ( or current if you're grabbing it from buildbot ) does handle this event however, and by default uses it to then call UnitIdle.
As a sidenote, you could leave taskqueuebehaviour as is, and override it in the same way taskqueuebehaviour overrides behaviour, and behaviour overrides etc etc That way you need only implement the bits that are different, and the original taskqueuebehaviour is preserved as are your changes
- Attachments
-
- 20000.PNG
- (22.55 KiB) Downloaded 4 times
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Here is what I'm working on: link. There are more changes to taskqueuebehaviour now than just watchdog. I've added 'cleanup' command which makes the unit reclaim stuff around, and probably a couple more things.
I'm pleased to report that Shard performs quite well at NOTA now, but there is still room for improvement.
I suspect builders can get 'extra' UnitIdle events somehow, although quite rarely. Sometimes (no more than about 5% of the time) freshly started building are abandoned and new ones started, just like the taskque was forced to progress by UnitIdle() right after starting new project. This is rare enough however to not affect the game much.
I'm pleased to report that Shard performs quite well at NOTA now, but there is still room for improvement.
I suspect builders can get 'extra' UnitIdle events somehow, although quite rarely. Sometimes (no more than about 5% of the time) freshly started building are abandoned and new ones started, just like the taskque was forced to progress by UnitIdle() right after starting new project. This is rare enough however to not affect the game much.
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Is there any chance this might be caused by your idle timer? Are you using the buildbot builds?
Of note the engine also passes an event for when a player issues a command to an AI unit, I may add that in
Of note the engine also passes an event for when a player issues a command to an AI unit, I may add that in
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
I'm currently using the build from spring 91, not buildbot.
AI units seem to receive UnitIdle() after player command just fine, do you mean some special event for that case?
AI units seem to receive UnitIdle() after player command just fine, do you mean some special event for that case?
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
No I mean you mentioned you had a timer based system to try and catch idle units and give them orders by setting progress = true
You can try with the buildbot builds if you're too impatient to wait for v92 =p
You can try with the buildbot builds if you're too impatient to wait for v92 =p
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Is it possible to set building facing in Shard? I haven't found how to do that, and it can be quite important to have factories face the right way (else units take more time to leave them which leads to lower output).
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
No but it can be arranged for a future update
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
created a wiki-page:
http://springrts.com/wiki/AI:Shard
it currently contains...uhm... nothing, but maybe that can be extended in the future. also i placed some links to the page... maybe we can add a small howto make an own ai/behaviour with it.
Imo writing some Lua-Code for Shard is currently the most efficient way to get a working ai because it needs no build environment / tools to compile. A plain text-editor is enough. :)
http://springrts.com/wiki/AI:Shard
it currently contains...uhm... nothing, but maybe that can be extended in the future. also i placed some links to the page... maybe we can add a small howto make an own ai/behaviour with it.
Imo writing some Lua-Code for Shard is currently the most efficient way to get a working ai because it needs no build environment / tools to compile. A plain text-editor is enough. :)
Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey
Thanks, I've tweaked the page a little bit, I should create a page for it and a README on tomjn.com
I should also probably tag the releases on github so that every Shard release doesn't show as 'dev' in the installer packages
I should also probably tag the releases on github so that every Shard release doesn't show as 'dev' in the installer packages