3.2 JS API Wishlist :)

For AI and campaign script related discussions and questions
User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: 3.2 JS API Wishlist :)

Post by Shadow Wolf TJC » 13 Feb 2013, 02:34

Although I was originally thinking that an AI designer could use pickStructLocation() twice to return two different position objects for the same structure rotated differently (with one not rotated, and the other rotated 90 degrees), and then pick whichever position is closest to the desired location, adding a direction parameter to the position object that pickStructLocation() returns may work better.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: 3.2 JS API Wishlist :)

Post by aubergine » 13 Feb 2013, 16:37

It would be nice if we could say which way we want the building facing - eg. to make all buildings face nearest enemy or the player start position, etc.

So perhaps an optional direction param on pickStructLocation() to indicate the preferred direction and, as Per suggests, pickStructLocation() returns an additional .direction property in it's position object indicating what direction the building should be built in.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: 3.2 JS API Wishlist :)

Post by Shadow Wolf TJC » 14 Feb 2013, 05:42

Could we add a .target property for droid objects, so that we could find out which object they're ordered to attack or protect, or where they're ordered to move or build at (in the form of a position object)? Also, could we add a .construct property to droids to find out what they're ordered to build at said target location (that could return null if absent, or if no such build order is given)?

By the way, while I'm willing to bet that we can't change existing object properties directly, are we allowed to give game objects (such as droid, structure, feature, player, or position objects) custom properties, like, say, the aforementioned .target and .construct properties?
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: 3.2 JS API Wishlist :)

Post by aubergine » 14 Feb 2013, 08:42

+1 for .target property

For construct droids, could the .target not be a fake structure object? We can see from their order that they are going to construct something, and then look at .target fake struct obj to see what/where they are constructing.

@Shadow: You can add any properties you want to the game objects, but they will be transient and only exist so long as you have a reference to that specific instance of the game object. The properties won't be stored by the JS API, so next time you do an enumDroid() for example, you'll get vanilla objects back. It's better to just build arrays or hashmaps to keep track of additional properties.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: 3.2 JS API Wishlist :)

Post by aubergine » 19 Feb 2013, 17:20

enumGroup() -- allow a sensor/command droid as argument

There is currently no way to ask WZ which droids are assigned to a command or sensor droid.

If enumGroup() could take a command/sensor droid as it's parameter and return a list of droids attached to that droid, it would be most useful.

Code: Select all

var list = enumGroup( < groupID | object > );
The object could also be a sensor structure, eg. if arty droids have been assigned to a stationary CB tower, or VTOLs to a strike tower, etc.

This would not apply to transporters, as their 'cargo' is not on the battle field, hence the separate approach to dealing with cargo (already implemented in 3.2).
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: 3.2 JS API Wishlist :)

Post by Shadow Wolf TJC » 21 Feb 2013, 20:56

Say, could eventAttacked() be changed to trigger whenever ANY player's units or structures come under attack? I know that we'd then have to specify who the attacked object's controller is, but it would allow me to add in some code to rules.js that could inform the player when an ally's units or structures come under attack.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: 3.2 JS API Wishlist :)

Post by aubergine » 21 Feb 2013, 20:59

Use hackChangeMe() to set the player ID to -1 for your script, then events should receive notifications from all players not just the player the script was originally associated with.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: 3.2 JS API Wishlist :)

Post by Shadow Wolf TJC » 21 Feb 2013, 22:35

What is hackChangeMe()? It's currently not documented on your wiki. Is it only available on version 3.2?
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: 3.2 JS API Wishlist :)

Post by Per » 21 Feb 2013, 22:52

Shadow Wolf TJC wrote:What is hackChangeMe()? It's currently not documented on your wiki. Is it only available on version 3.2?
Not to disparage the excellent wiki, but you know there is an official doc for the javascript API, right? It is documented there. :lecture:
http://buildbot.wz2100.net/files/javasc ... cript.html

(And yes, it is 3.2 only.)

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: 3.2 JS API Wishlist :)

Post by aubergine » 22 Feb 2013, 00:56

I wasn't sure how long the hackChangeMe() function is going to be around for so not documented that one yet. Always refer to the official docs linked by Per if in doubt.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: 3.2 JS API Wishlist :)

Post by Shadow Wolf TJC » 22 Feb 2013, 18:38

Per wrote:
Shadow Wolf TJC wrote:What is hackChangeMe()? It's currently not documented on your wiki. Is it only available on version 3.2?
Not to disparage the excellent wiki, but you know there is an official doc for the javascript API, right? It is documented there. :lecture:
http://buildbot.wz2100.net/files/javasc ... cript.html

(And yes, it is 3.2 only.)
I was never aware that such a thing existed. Thanks.

Edit: Perhaps droid objects, and maybe structure objects as well, could be given a new .target property, which is the object (either a game object or a position object) that the droid or structure is supposed to perform its order on (such as attack this, repair this, move to this position, etc.). Note that this isn't necessarily the same as what its weapons are currently targeting (since droids could be shooting nearby enemies while they're ordered to move or scout to a particular position).
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: 3.2 JS API Wishlist :)

Post by Duha » 28 Feb 2013, 13:11

Is it possible to add some code coverage for javascript?
http://addons.wz2100.net/ developer

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: 3.2 JS API Wishlist :)

Post by NoQ » 01 May 2013, 10:08

Hmm. We're still not having API to support "Allow Alliances" mode. That is, to make an AI offer alliance, break alliance, or detect an alliance offer from other player.

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: 3.2 JS API Wishlist :)

Post by Per » 01 May 2013, 11:17

Duha wrote:Is it possible to add some code coverage for javascript?
Since we have zero unit tests for the javascript code, surely it would be easy to calculate a 0% code coverage for it? (Or am I misunderstanding the question?)
NoQ wrote:Hmm. We're still not having API to support "Allow Alliances" mode. That is, to make an AI offer alliance, break alliance, or detect an alliance offer from other player.
I think that is pretty much a waste of time. You cannot have dynamic alliances without diplomacy, and if there is anything an AI useless at, then it is diplomacy. I spent a lot of time trying to write a good diplomacy AI for another game once... It will either be abused horribly by players or it will be annoyingly paranoid. Either way it won't be fun.

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: 3.2 JS API Wishlist :)

Post by NoQ » 01 May 2013, 12:39

It will either be abused horribly by players or it will be annoyingly paranoid.
Hmm. I'd report if i come up with any "better than nothing" pseudo code.

Post Reply