Javascript API documentation

For AI and campaign script related discussions and questions
cybersphinx
Inactive
Inactive
Posts: 1695
Joined: 01 Sep 2006, 19:17

Re: Javascript API documentation

Post by cybersphinx »

Made the buildbot generate the current javascript docs of master (which should cover 3.1 as well).
One page: http://buildbot.wz2100.net/files/javasc ... cript.html
Multi page table of contents: http://buildbot.wz2100.net/files/javasc ... index.html
We want information... information... information.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Javascript API documentation

Post by aubergine »

@cybersphinx - AWESOME WIN! Great work!

When referencing things like structures.txt, rules.js, scavfact.js, features.txt, is there any way they could be hyperlinked to github so we can view those online too? Would be much easier than having to trawl through base.wz and mp.wz looking for them (as I'm never quite sure where some of those files exist).
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Javascript API documentation

Post by Per »

Added:
* chat(target, message), for sending chat messages. chat may be ALL_PLAYERS or ALLIES or a specific player number
* orderDroid(droid, order), with new orders DORDER_STOP, DORDER_HOLD, DORDER_RTR, DORDER_RTB
* DORDER_FIRESUPPORT
* DORDER_REARM, and it may be used both with orderDroid() and orderDroidObj()
* enumGateways(), gives array of objects with x1, y1, x2, y2 properties
* .hasIndirect property for droids, if any weapons are indirect (eg artillery)

Fixed .armed and .range properties. The .group and .armed properties are now null instead of undefined if not applicable.

All of this is for 3.2 only at the moment.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

sending chat messages
All right, but we also need to receive chat messages! (:
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Javascript API documentation

Post by aubergine »

Woot! Great to see more stuff being added :D

enumGateways()? What are gateways?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

What are gateways?
Gateways are special invisible marks on the map that hint AIs to build hardpoints on them. They are painted by the map maker (of course, some map makers are lazy enough to paint them). Each gateway is a line segment of adjacent map tiles. Nexus AI fills the whole line with best hardpoints available, except two middle tiles (any two middle tiles in case gateway has odd length); i guess any AI should do the same. Picture.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

In order to build hardpoints on gateways, i'd like to be able to find out if a certain tile of a gateway is already occupied by a (friendly) structure. So that not to block things. Of course, i could make this check manually (cycle through all structures, guess its dimensions based on stattype and/or name, etc.), but it's a lot of pain.

That is, i'd like to have something like isBuildable(x,y) that will return true iff the tile (x,y) is passable (neither cliff nor water) and not occupied by any building or feature (tiles near a research center are considered to be occupied, but tiles near factory aren't).
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Javascript API documentation

Post by aubergine »

I'd like a whatsAt(x,y) function that returns:

* terrain type
* z-index
* continent
* any droids/structures/features at that point
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Javascript API documentation

Post by Per »

NoQ wrote:All right, but we also need to receive chat messages! (:
Right. Added eventChat(from, to, message) for receiving chat messages. I think it will handle network messages, as in the case of non-host players being allied to an AI and wanting to message it, but this has not been properly tested yet. (No, this is not trivial. The message code is FUBAR.)
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

Excellent! Beacons is the thing i want the most now.

Also, in the latest git, whatever AI said is displayed as if the host said this (displayed as NoQ: ...) (it was a skirmish game) (eventChat also thinks that me == NoQ) (this wasn't there some time ago when eventChat wasn't present)
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Javascript API documentation

Post by aubergine »

Ability for AI to place beacons as well - that would be v. useful as it would allow AIs to indicate to allies locations on the map.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

I'd like to have DORDER_OBSERVE, so that i could use mobile sensors to pick targets for long-range artillery. Neither DORDER_ATTACK nor DORDER_SCOUT seem to do the job.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Javascript API documentation

Post by aubergine »

Can't you just pass the numeric id of that order in to orderDroidObj?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

Didn't try yet; just though that to ask is better than to hack (:
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ »

I think it's a good idea to 1. make this thread sticky and 2. separate wzscript discussions into a subforum (:
Post Reply