Javascript API documentation
Re: Javascript API documentation
Yup - having it be LASERSAT or something like that would be good.
Would it be worth merging startPositions and playerData to make them more consistent with other things?
enumPlayers(); // return array of player objects
And a player object would have following properties (similar to base object, extended with some player specific stuff):
.id = (integer) player position on map (eg. 0..10)
.x, .y and .z = x,y,z of start position for player
.type = PLAYER
.playerType = HUMAN || AI || SCAVENGER || EMPTY
.player = (integer) player ID (same as .id I assume?)
.ai = If .playerType == AI then the id of the AI being used (useful for inter-AI comms at a later date)
.difficulty = (only applicable to AI players) EASY || MEDIUM || HARD || INSANE
.colour = colour of player (I assume this is a string? is it localised or i18n keyword?)
.team = team that the player is currently in (is this numeric or char or string?)
.selected = (boolean) true if player[id] == selectedPlayer
.name = (string) name of player, AI, "Scavengers" or undefined as applicable considering .playerType
I think this would improve overall consistency of the API. (: The existing startPositions and playerData could remain as alternate ways of accessing the info.
Also, global array "derrickPositions" - wouldn't this be better named "oilPositions"? (and isn't derrick spelt wrong?)
Would it be worth merging startPositions and playerData to make them more consistent with other things?
enumPlayers(); // return array of player objects
And a player object would have following properties (similar to base object, extended with some player specific stuff):
.id = (integer) player position on map (eg. 0..10)
.x, .y and .z = x,y,z of start position for player
.type = PLAYER
.playerType = HUMAN || AI || SCAVENGER || EMPTY
.player = (integer) player ID (same as .id I assume?)
.ai = If .playerType == AI then the id of the AI being used (useful for inter-AI comms at a later date)
.difficulty = (only applicable to AI players) EASY || MEDIUM || HARD || INSANE
.colour = colour of player (I assume this is a string? is it localised or i18n keyword?)
.team = team that the player is currently in (is this numeric or char or string?)
.selected = (boolean) true if player[id] == selectedPlayer
.name = (string) name of player, AI, "Scavengers" or undefined as applicable considering .playerType
I think this would improve overall consistency of the API. (: The existing startPositions and playerData could remain as alternate ways of accessing the info.
Also, global array "derrickPositions" - wouldn't this be better named "oilPositions"? (and isn't derrick spelt wrong?)
"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
.droidType = DROID_TRANSPORTER: how do I know what sort of transporter (cyborg or heavy)?
How do I get droids to dis/embark a transporter?
How do I get droids to dis/embark a transporter?
"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
eventObjectSeen() - does this get called for starting units as well?
"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
Would it be possible to add a third optional parameter to the queue function so that I can have an array of arguments passed to my queued functions?
Where:
* sFunc = (string) name of function to call
* oObj = (object or primative) an object to pass to the function as first parameter
* bApply = (boolean) if true, and oObj is an array, apply oObj as arguments array to the function
In cases where I want multiple params passed to a queued function, this will avoid the need to create crufty activation objects / closures (which is what I'm currently doing).
Code: Select all
queue(sFunc[, oObj[, bApply]]);
* sFunc = (string) name of function to call
* oObj = (object or primative) an object to pass to the function as first parameter
* bApply = (boolean) if true, and oObj is an array, apply oObj as arguments array to the function
Code: Select all
// pseudo code - I've used JS here as I understand JS better, but
// I'm using it to describe the sort of thing the C++ code would do
// invoke a queued function
if (sFunc in global && global[sFunc] instanceof Function) {
global[sFunc][(bApply && oObj instanceof Array) ? "apply" : "call"](global,oObj);
}
"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
- lav_coyote25
- Professional
- Posts: 3434
- Joined: 08 Aug 2006, 23:18
Re: Javascript API documentation
aubergine wrote:
Also, global array "derrickPositions" - wouldn't this be better named "oilPositions"? (and isn't derrick spelt wrong?)
nope. see : http://en.wikipedia.org/wiki/Derrick
Re: Javascript API documentation
Damn, I need to go fix lots of spelling mistakes in my code - I'd been spelling it "derrik" for some reason *slaps forehead*
"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
- lav_coyote25
- Professional
- Posts: 3434
- Joined: 08 Aug 2006, 23:18
Re: Javascript API documentation
aubergine wrote:Damn, I need to go fix lots of spelling mistakes in my code - I'd been spelling it "derrik" for some reason *slaps forehead*
there is a derrik and it is also usable see: http://www.thinkbabynames.com/meaning/1/Derrik " people's ruler".
Re: Javascript API documentation
If you want to be pedantic, the WZ 'oil derrick' thingie is actually a pump jack, a device for extracting oil. A derrick is used for drilling.
Re: Javascript API documentation
It does not get called for your own units.aubergine wrote:eventObjectSeen() - does this get called for starting units as well?
Re: Javascript API documentation
I've added stattype LASSAT for the laser satellite, DORDER_EMBARK for embarking on a transport, and DORDER_DISEMBARK for getting the transport to unload somewhere.
Re: Javascript API documentation
Possible, certainly. But I am not sure why you'd want to do that. Something tells me you are trying to do something that is not a very good idea...? I suspect that passing lots of data between the C++ side and the Javascript side of things is expensive, at least compared to keeping the data on the Javascript side.aubergine wrote:Would it be possible to add a third optional parameter to the queue function so that I can have an array of arguments passed to my queued functions?
Re: Javascript API documentation
I see it also only includes things that my sensors see - so I assume it won't tell me when allies sensors detect something?Per wrote:It does not get called for your own units.aubergine wrote:eventObjectSeen() - does this get called for starting units as well?
Awesome! Thanks How do I know what sort of transport I'm working with (eg. I don't think I can get tanks on the smaller cyborg transport)?Per wrote:I've added stattype LASSAT for the laser satellite, DORDER_EMBARK for embarking on a transport, and DORDER_DISEMBARK for getting the transport to unload somewhere.
I'm not intending on sending huge objects or anything, I just find my code easier to read if queued functions could have named parameters, rather than having to pick at properties in an object that's passed in as first and only parameter. An arguments object will be created whatever happens, even if there is no object/parameters.Per wrote:Possible, certainly. But I am not sure why you'd want to do that. Something tells me you are trying to do something that is not a very good idea...? I suspect that passing lots of data between the C++ side and the Javascript side of things is expensive, at least compared to keeping the data on the Javascript side.aubergine wrote:Would it be possible to add a third optional parameter to the queue function so that I can have an array of arguments passed to my queued functions?
"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
Added new event eventObjectTransfer(object, from) that is called when objects are transferred between players (eg due to Nexus Link). Also new feature property .damageable that tells whether it can be destroyed or not.
I consider that eventObjectSeen() does not trigger for allies seeing things a bug, but it is not trivially fixed.
I consider that eventObjectSeen() does not trigger for allies seeing things a bug, but it is not trivially fixed.
Re: Javascript API documentation
Awesome! Thanks!Per wrote:Added new event eventObjectTransfer(object, from) that is called when objects are transferred between players (eg due to Nexus Link). Also new feature property .damageable that tells whether it can be destroyed or not.
I can work round this for now with a timer that enums what each ally can see every 10-15 seconds.Per wrote:I consider that eventObjectSeen() does not trigger for allies seeing things a bug, but it is not trivially fixed.
"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
Paradigm shift: i just noticed that in the challenge in question not only player_2 (at position 4) and player_3 (at position 6) are controlled by both AIs simultaneously, but also pink (at position 2) and cyan (at position 7) are not controlled by any AI at all (just remaining idle). So probably just some of the Nexus AIs get applied to a wrong player.NoQ wrote:Also, i tried the challenges with custom AIs again, and i have a feeling that two AIs at once are running for the player for which an external AI is specified.
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam