Javascript API documentation
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
I'm still scratching my chin over the annotation stuff. Do you have any examples of how it would be used?
Is the primary use so when we construct a droid we can store what propulsion, body and turrets it's using? If so that would be better done by having an annotation param on buildDroid(), or, much better, properties for propulsion, body and turrets (array so as to handle dragon bodies) that get set automatically for all droids.
Having those standard properties for droids would make AI adaption, droid recycling, and a whole bunch of other stuff much easier. Exposing the droid's creation time (can't remember the C++ property that defines that but saw it somewhere on my travels through the WZ source code) would be useful as well in terms of finding out how old a droid is (not sure what would happen for droids placed by map makers though?
Also, can I put in another request for getting some extra properties on playerData objects - player type (PLAYER_HUMAN, PLAYER_SCAV, PLAYER_AI, PLAYER_NONE) and if possible player name?
Is the primary use so when we construct a droid we can store what propulsion, body and turrets it's using? If so that would be better done by having an annotation param on buildDroid(), or, much better, properties for propulsion, body and turrets (array so as to handle dragon bodies) that get set automatically for all droids.
Having those standard properties for droids would make AI adaption, droid recycling, and a whole bunch of other stuff much easier. Exposing the droid's creation time (can't remember the C++ property that defines that but saw it somewhere on my travels through the WZ source code) would be useful as well in terms of finding out how old a droid is (not sure what would happen for droids placed by map makers though?
Also, can I put in another request for getting some extra properties on playerData objects - player type (PLAYER_HUMAN, PLAYER_SCAV, PLAYER_AI, PLAYER_NONE) and if possible player name?
"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
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
How many groups an AI is allowed to have? Is it limited to 0..9 as it is for a human player?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
Those are two different kinds of groups. There is no limit (in practice).NoQ wrote:How many groups an AI is allowed to have? Is it limited to 0..9 as it is for a human player?
-
Artofeel
- Greenhorn
- Posts: 7
- Joined: 10 Feb 2012, 15:32
- Location: Russia
Re: Javascript API documentation
since it's already have, no? Or the old AI wzscript does not work on a new JS AI engine?aubergine wrote:or, much better, properties for propulsion, body and turrets (array so as to handle dragon bodies) that get set automatically for all droids.
- * droid.x
* droid.y
* droid.z
* droid.id - unique ID number
* droid.player - player ID
* droid.type - one of OBJ_DROID, OBJ_STRUCTURE, OBJ_FEATURE
* droid.health - %age number of body points left
* droid.clusterID - the cluster the object is a member of
* droid.target - target of the object (in case of a multi-turret object returns target of the default weapon)
* droid.order - current order of the droid
* droid.orderx - target location of the droid order
* droid.ordery - target location of the droid order
* droid.action - current action of the droid
* droid.body - the BODY of the droid
* droid.propulsion - the PROPULSION of the droid
* droid.weapon - the WEAPON of the droid
* droid.selected - holds TRUE if droid is currently selected
* droid.group - the GROUP droid belongs to
Also droid.target only work with weapon, it would be great if it worked with sensor\repair\etc turrets
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
Lots of those properties are missing from the droid objects in the JS API:
https://warzone.atlassian.net/wiki/disp ... oid+object
Items missing are:
* droid.clusterID - the cluster the object is a member of
* droid.target - target of the object (in case of a multi-turret object returns target of the default weapon)
* droid.orderx - target location of the droid order
* droid.ordery - target location of the droid order
* droid.body - the BODY of the droid
* droid.propulsion - the PROPULSION of the droid
* droid.weapon - the WEAPON of the droid
https://warzone.atlassian.net/wiki/disp ... oid+object
Items missing are:
* droid.clusterID - the cluster the object is a member of
* droid.target - target of the object (in case of a multi-turret object returns target of the default weapon)
* droid.orderx - target location of the droid order
* droid.ordery - target location of the droid order
* droid.body - the BODY of the droid
* droid.propulsion - the PROPULSION of the droid
* droid.weapon - the WEAPON of the droid
Last edited by aubergine on 12 Mar 2012, 18:16, edited 2 times in total.
"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
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
They're separate. You use either one or another, not "one over another". The functions and object properties have to be re-implemented, and they aren't yet (:Or the old AI wzscript does not work on a new JS AI engine?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
Added .born field to all game objects, which is the game time at which the object came into the world. A game time of 2 means it was added to the map on start. Added .body and .propulsion string fields to droids. This is their body and propulsion components. The turret/weapon component is much more complicated to add, and I think some cleaning up in that code/data is warranted before finalizing any API for that.
-
Emdek
- Regular

- Posts: 1329
- Joined: 24 Jan 2010, 13:14
- Location: Poland
Re: Javascript API documentation
For turret / weapon it should be probably simple array (I like turrets more, since it is more generic), and there could be concept of weapon handles for future use (like where the weapon / turret is mounted), as properties of turret object (it could maybe also have type property, as I think that we already can have sensor in weapon on Dragon, or we can't?).
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
I think the weapon/turret handles should be defined on the body, but that's for future ponderance. I'm already taking that approach with my concept of JS game objects / mutators, but won't be ready to show much results for quite some time.
If you put a sensor on Dragon, it won't let you have a weapon in the other slot
Anyone know what the body ID is for Super Transporter and also the two cyborg bodies? Found answer in body.ini
If you put a sensor on Dragon, it won't let you have a weapon in the other slot
Anyone know what the body ID is for Super Transporter and also the two cyborg bodies? Found answer in body.ini
Last edited by aubergine on 14 Mar 2012, 22:52, edited 1 time in total.
"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
-
Emdek
- Regular

- Posts: 1329
- Joined: 24 Jan 2010, 13:14
- Location: Poland
Re: Javascript API documentation
aubergine, well, now, but think about future. 
Also I'm including place for structures with multiple mount points (consistent API), I want it to be future proof and flexible enough.
Also I'm including place for structures with multiple mount points (consistent API), I want it to be future proof and flexible enough.
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
@Emdek ditto! Once I've got some more done on my latest JS project, I'll post the results in the mutator wiki and you can take a look and see if we're thinking along the same lines.
"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
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
Droid object docs updated: https://warzone.atlassian.net/wiki/disp ... oid+object 
Wherever possible I try and update that wiki with the latest information, even when new features aren't currently released. If you see anything I've missed, please post a comment on the associated wiki page (it should allow anon comments, or you can sign-up via the login link at top-right) -- I get instant notifications when comments are posted and will do everything I can to update docs quickly.
Wherever possible I try and update that wiki with the latest information, even when new features aren't currently released. If you see anything I've missed, please post a comment on the associated wiki page (it should allow anon comments, or you can sign-up via the login link at top-right) -- I get instant notifications when comments are posted and will do everything I can to update docs quickly.
"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
-
Emdek
- Regular

- Posts: 1329
- Joined: 24 Jan 2010, 13:14
- Location: Poland
Re: Javascript API documentation
Yes, that is best approach, as generating from backlog can be painful. 
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
-
milo christiansen
- Regular

- Posts: 749
- Joined: 02 Jun 2009, 21:23
- Location: Perrinton Michigan
Re: Javascript API documentation
I think this is a complete list of all the functions needed before cam 4 can be ported. Not a lot to say except some are probably optional and I may have missed one or two 
You do not have the required permissions to view the files attached to this post.
In general, if you see glowing, pulsating things in the game, you should click on them.
- Demigod Game Ganual
- Demigod Game Ganual
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
Added functions setAssemblyPoint(struct, x, y), addFeature(x, y, name), setAlliance(player1, player2, value), and removeObject(obj[, bool special effect]) to 3.2. Deprecated removeStructure(struct).
Milo, concerning your list, I made a check run down of how I think it is currently met:
structButNoWallsInArea --> not needed
killStructsInArea --> not needed, use removeObject(xx, true)
numDroidsInArea --> not needed
droidInArea --> not needed
flushConsoleMessages --> not needed?
numStructsInArea --> not needed
createAlliance --> use setAlliance(p1, p2, bool)
breakAlliance --> not needed, see above
destroyFeature --> not needed, see removeObject(xx)
vanishUnit --> not needed, see removeObject(xx)
getDroidCount --> not needed
addFeature --> addFeature added
setAssemblyPoint --> setAssemblyPoint added
For the area functions, you can use enumRange() to iterate over objects instead.
TODO
removeMessage and addMessage
I still hope to implement a sane version of addMessage, but if this is preventing anyone from working on a javascript-based campaign, I can quickly implement the same hacky addMessage that wzscript has as a stopgap measure.
Milo, concerning your list, I made a check run down of how I think it is currently met:
structButNoWallsInArea --> not needed
killStructsInArea --> not needed, use removeObject(xx, true)
numDroidsInArea --> not needed
droidInArea --> not needed
flushConsoleMessages --> not needed?
numStructsInArea --> not needed
createAlliance --> use setAlliance(p1, p2, bool)
breakAlliance --> not needed, see above
destroyFeature --> not needed, see removeObject(xx)
vanishUnit --> not needed, see removeObject(xx)
getDroidCount --> not needed
addFeature --> addFeature added
setAssemblyPoint --> setAssemblyPoint added
For the area functions, you can use enumRange() to iterate over objects instead.
TODO
removeMessage and addMessage
I still hope to implement a sane version of addMessage, but if this is preventing anyone from working on a javascript-based campaign, I can quickly implement the same hacky addMessage that wzscript has as a stopgap measure.