Javascript API documentation
Re: Javascript API documentation
Awesome, thanks Per!
Do you have any examples of using that bind() function you mentioned above? I noted in the API docs that the feature is still under construction - what params does it pass to the bound function?
Do you have any examples of using that bind() function you mentioned above? I noted in the API docs that the feature is still under construction - what params does it pass to the bound function?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: Javascript API documentation
The bind function itself is: bind(function, object[, player]). If player is omitted, it is set to the value of 'me'.
The bound function (ie the function parameter to bind) is called with object as its only parameter.
The bound function (ie the function parameter to bind) is called with object as its only parameter.
Re: Javascript API documentation
I think it's that last param that still confuses me - the docs say:
[quote]A third, optional player parameter may be passed, which may be used for filtering, depending on the ob ject type.[quote]
But I'm not sure why I would want to filter the object (eg. a droid) I bind to? Or is it filtering on who destroys it? Is there a way to say "don't filter" (eg. pass in -1 or something)?
[quote]A third, optional player parameter may be passed, which may be used for filtering, depending on the ob ject type.[quote]
But I'm not sure why I would want to filter the object (eg. a droid) I bind to? Or is it filtering on who destroys it? Is there a way to say "don't filter" (eg. pass in -1 or something)?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: Javascript API documentation
Ignore the third parameter. It currently does nothing.
-
- Trained
- Posts: 103
- Joined: 06 Feb 2009, 04:02
Re: Javascript API documentation
ambitious, fascinating, worthwhile. hope you work it out.aubergine wrote: ......
Future plans include (mostly reliant on what features are added to the JS API):
* Ability to interact with human allies via in-game messages / beacons - similar to DyDo AI
* Ability to adapt (+/-) to enemy capabilities (in single player skirmishes) to provide a more balanced game
* Ability to create multi-player groups (between allied AI players) - eg. each AI ally contributing some VTOLs to a group and then one ally taking control of the entire group (even though it doesn't own all units in it)
* Ability to coordinate multi-AI attacks on a target, with target optionally defined by human player
* Ability to create 'survivor' trucks which hide in ally bases - if the AI main bases get destroyed, its survivor trucks give it a chance to rebuild somewhere safer or as a last resort donate it's remaining power/droids to an ally......
can see those connections. makes you think what if. you're also whistling Dixie in yank country, i see. lol. at least for now.Rman Virgil wrote: ....
The particulars of HOW it will accomplish that ALSO point to, and will demonstrate the viability of, a development direction for MP GPMs that will advance depth and breath of tactical game play like nothing else has done heretofore since 1999.
What I'm refering to in the last statement is the cognitive task ease of advanced maneuver (along with its associated situational awareness). And this is how I define "Advanced Maneuver": effective, simultaneous, command and control of at least 3 combat groups from coordinated, multiple vectors and varying velocities. (To translate from the A.I. context to MP capabilties would also require UI changes.)
I don't see anything else that has the definitive power to
"....propell WZ 2100 into the front ranks, finally, of elite RTSs while still maintaining its unique identity."
Re: Javascript API documentation
I've added the ability to add scripts to challenges now. This is documented in the latest version of the javascript API documentation, which I have attached below. (Also fixed several accumulated bugs in the challenge code.)
Re: Javascript API documentation
This API just keeps getting more awesome! Great work Per!
droid.droidType = DROID_ECM: I wasn't aware there were electronic counter measure turrets in the game - what are they?
droid.experience: if not set, ie. droid hasn't killed anything, will it be <null> or <undefined> or <0>? Also "this value is not set" - do you mean "this value is read-only"?
Scavengers: From what I understand, player[0..9] = human/AI players. How do I, for example, find out who the scavenger players are and iterate through their droids, structures, etc?
... must be quoted, otherwise the function will be inlined: Is the issue with inlining that the function won't see the global variables, etc? If so, I assume I can work round that problem using a JS enclosure (assuming the JS engine in WZ is fairly ECMA-262 compliant)?
componentAvailable(): What is a component? Is it like a research item or something else?
enum<Whatever>(): Is there any way to say "get me a list of <whatever> for a map region within x1,y1,x2,y2"? I can create a JS function to iterate through a list and filter out any items outside a given region, but it seems wasteful to have to iterate through what could be quite a big list just to get stuff in a specific region. Similar to how groupAddArea() must have to get a list of all my droids in that area - I assume there's already some code floating around to get a list of certain things in a given area?
pickStructLocation(): I assume this checks to see if the droid can reach that location (if not, please let me know). Would it be possible to ignore that check if droid == null? Reason: At some point I want to get my AI to create cyborg transports and then send an engineer to an otherwise inaccessible place and build something - so I'd want to know if the thing I could build could be built there (ie. is there enough flat land for it), then fly a cyborg engineer in, then build it, then fly the cyborg engineer out.
setStructureLimits(): Any chance of a getStructureLimits() function? If structure type omitted, return a list of all structures and their associated limits, otherwise return limit for specified structure.
centreView(x, y): Any chance an optional "player" param can be added to this (defaults to current player). Reason: At some point I want my AI to be able to warn human player about something, or show them something on the map. Sequence would be: AI messages human via in-game chat, then human replies with "show me", then AI centers human players' view on that point. [Note: Not really that important a feature, but would be cool to experiment with]
add/removeReticuleButton(): What is a reticule button?
droidFromId(): Would it be possible to get structFromId() and featureFromId() - or possibly better: objFromId(any_object)? Reason: I want to persist some links to specific buildings, features, etc., as part of my AI's "mission" list - as I can't store complex objects, I'd need to have a separate global var with a basic array/object containing just primitive types like id's (numbers) and strings, and when game loaded have some way of converting those id's back to actual in-game objects.
droid.droidType = DROID_ECM: I wasn't aware there were electronic counter measure turrets in the game - what are they?
droid.experience: if not set, ie. droid hasn't killed anything, will it be <null> or <undefined> or <0>? Also "this value is not set" - do you mean "this value is read-only"?
Scavengers: From what I understand, player[0..9] = human/AI players. How do I, for example, find out who the scavenger players are and iterate through their droids, structures, etc?
... must be quoted, otherwise the function will be inlined: Is the issue with inlining that the function won't see the global variables, etc? If so, I assume I can work round that problem using a JS enclosure (assuming the JS engine in WZ is fairly ECMA-262 compliant)?
componentAvailable(): What is a component? Is it like a research item or something else?
enum<Whatever>(): Is there any way to say "get me a list of <whatever> for a map region within x1,y1,x2,y2"? I can create a JS function to iterate through a list and filter out any items outside a given region, but it seems wasteful to have to iterate through what could be quite a big list just to get stuff in a specific region. Similar to how groupAddArea() must have to get a list of all my droids in that area - I assume there's already some code floating around to get a list of certain things in a given area?
pickStructLocation(): I assume this checks to see if the droid can reach that location (if not, please let me know). Would it be possible to ignore that check if droid == null? Reason: At some point I want to get my AI to create cyborg transports and then send an engineer to an otherwise inaccessible place and build something - so I'd want to know if the thing I could build could be built there (ie. is there enough flat land for it), then fly a cyborg engineer in, then build it, then fly the cyborg engineer out.
setStructureLimits(): Any chance of a getStructureLimits() function? If structure type omitted, return a list of all structures and their associated limits, otherwise return limit for specified structure.
centreView(x, y): Any chance an optional "player" param can be added to this (defaults to current player). Reason: At some point I want my AI to be able to warn human player about something, or show them something on the map. Sequence would be: AI messages human via in-game chat, then human replies with "show me", then AI centers human players' view on that point. [Note: Not really that important a feature, but would be cool to experiment with]
add/removeReticuleButton(): What is a reticule button?
droidFromId(): Would it be possible to get structFromId() and featureFromId() - or possibly better: objFromId(any_object)? Reason: I want to persist some links to specific buildings, features, etc., as part of my AI's "mission" list - as I can't store complex objects, I'd need to have a separate global var with a basic array/object containing just primitive types like id's (numbers) and strings, and when game loaded have some way of converting those id's back to actual in-game objects.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: Javascript API documentation
I wasn't aware there were electronic counter measure turrets in the game - what are they?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
- Inactive
- Posts: 1695
- Joined: 01 Sep 2006, 19:17
Re: Javascript API documentation
The six buttons bottom left for research, building (F1-F6) etc., the tutorial enables only those needed to proceed.aubergine wrote:add/removeReticuleButton(): What is a reticule button?
We want information... information... information.
Re: Javascript API documentation
If it has not killed anything, it will be zero.aubergine wrote: droid.experience: if not set, ie. droid hasn't killed anything, will it be <null> or <undefined> or <0>? Also "this value is not set" - do you mean "this value is read-only"?
If I write that "this value is not set" in some cases, I mean that the value may be undefined. Check if it is defined before using, unless you know that you use it in the correct cases where it always is defined.
Not sure what you are trying to do. If you want to control the scavenger, change the scavenger script. (See doc.)aubergine wrote: Scavengers: From what I understand, player[0..9] = human/AI players. How do I, for example, find out who the scavenger players are and iterate through their droids, structures, etc?
I'm do not know what happens under the hood when function parameters are not quoted, but things tend not to work the way you'd expect them to.aubergine wrote: ... must be quoted, otherwise the function will be inlined: Is the issue with inlining that the function won't see the global variables, etc? If so, I assume I can work round that problem using a JS enclosure (assuming the JS engine in WZ is fairly ECMA-262 compliant)?
A component is what droids are made up of.aubergine wrote: componentAvailable(): What is a component? Is it like a research item or something else?
It is on the list of things to look into.aubergine wrote: enum<Whatever>(): Is there any way to say "get me a list of <whatever> for a map region within x1,y1,x2,y2"? I can create a JS function to iterate through a list and filter out any items outside a given region, but it seems wasteful to have to iterate through what could be quite a big list just to get stuff in a specific region. Similar to how groupAddArea() must have to get a list of all my droids in that area - I assume there's already some code floating around to get a list of certain things in a given area?
It checks if the droid can get there. You cannot pass in a null droid.aubergine wrote: pickStructLocation(): I assume this checks to see if the droid can reach that location (if not, please let me know). Would it be possible to ignore that check if droid == null? Reason: At some point I want to get my AI to create cyborg transports and then send an engineer to an otherwise inaccessible place and build something - so I'd want to know if the thing I could build could be built there (ie. is there enough flat land for it), then fly a cyborg engineer in, then build it, then fly the cyborg engineer out.
Adding structure limits info is on my TODO list.aubergine wrote: setStructureLimits(): Any chance of a getStructureLimits() function? If structure type omitted, return a list of all structures and their associated limits, otherwise return limit for specified structure.
You can hack around this limitation by adding stuff to the rules script (rules.js). But currently there is no support for parsing chat messages yet.aubergine wrote: centreView(x, y): Any chance an optional "player" param can be added to this (defaults to current player). Reason: At some point I want my AI to be able to warn human player about something, or show them something on the map. Sequence would be: AI messages human via in-game chat, then human replies with "show me", then AI centers human players' view on that point. [Note: Not really that important a feature, but would be cool to experiment with]
Calling it droidFromId was a mistake, as it is not limited to droids. I've renamed it for objFromId() now.aubergine wrote: droidFromId(): Would it be possible to get structFromId() and featureFromId() - or possibly better: objFromId(any_object)? Reason: I want to persist some links to specific buildings, features, etc., as part of my AI's "mission" list - as I can't store complex objects, I'd need to have a separate global var with a basic array/object containing just primitive types like id's (numbers) and strings, and when game loaded have some way of converting those id's back to actual in-game objects.
I really need to find a nicer to implement AI object memory than this, though.
Re: Javascript API documentation
Well, I'll prolly be writing a javascript class / helper that will make persistence layer a bit more friendly from the JS end of things, then that could just be included by anyone that wants to persist game objects as part of their JS objects and then restore then after a saved game is loaded?Per wrote:I really need to find a nicer to implement AI object memory than this, though.
Regarding ECM, I thought CB towers were just there to detect incoming artillery, calculate where it came from based on trajectory, and then enable player artillery/droids to fire back or attack it? While testing my AI in cheat mode recently, I noticed a new "Radar Jammer" tower which looks like the CB tower - is that a planned new feature or am I getting horribly mixed up?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: Javascript API documentation
I do not think a persistence framework based on objFromId is a good idea, long term. It is a very slow lookup. And if you are asking people to include a helper layer to code anything of use, you have basically admitted that your own API layer is crap. And I do not want the javascript API to be crap
ECM suport exists in the code, but is not enabled yet by default. You can enable it with cheats and play with it.
ECM suport exists in the code, but is not enabled yet by default. You can enable it with cheats and play with it.
Re: Javascript API documentation
How do i find out wether a VTOL droid is fully recharged?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: Javascript API documentation
Or better (IMHO) - how charged is it as a percentage. Eg. I don't want to keep telling my VTOL group to attack stuff if they have to return to a VTOL pad for restocking.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
Re: Javascript API documentation
I'm also still looking for a way to implement a function similar to numBuildSameBuilding() from Nexus AI. For this, i need to know not just the truck.order, but also something similar to truck.orderx and truck.ordery.
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam