Some questions on JS API
Posted: 25 Jan 2012, 18:07
I've been trying to read the C++ code in an attempt to not ask so many stupid questions, however I'm really not familiar with C++ so there are some things I'm still unsure about with regards to the JS API and game objects...
1. Object IDs
Are object IDs unique across all objects in the game, or specific to a single player, or specific to a type of object (structure, droid, etc)?
If an object (droid, etc) gets destroyed, will it's object ID ever be re-used?
2. Features
How do I know which features are destroyable? I'd like to instruct my droids to destroy any destroyable features near the base at the start of the game to make more room for buildings.
3. Defence structures
Currently all defence structures are grouped under a .stattype == DEFENCE. How do I know, for example, which structures are hellstorm emplacement vs. bombard pit or anything else?
I was wondering if using the .name property would be enough, but I'm worried it might change depending on localisation settings.
I want to know the specific type of structure because:
* I want to work out what it cost to build - I want my AI to make certain decisions based on economics
* I want to know what the defence structure is capable of - eg. can it shoot down my VTOLs, can it fire missiles at my troops, etc?
* I want to be able to work out if it's become outclassed due to research by me or an enemy
4. Droids
How do I work out what propulsion, body and weapon a droid has?
Again, I was thinking of using the .name property but when creating droids both humans and AIs alike (eg. see nullbot by NoQ) tend to have custom names for their templates.
There's several reasons I want to know this info:
* What did it cost to build the droid?
* What are the droid's capabilities? - both in terms of firepower and propulsion (eg. can it travel on water?)
I know I can work out if a droid is using VTOL propulsion using the isVTOL() function, but other propulsions are generally opaque. For example, there doesn't seem to be any way to distinguish between Heavy and Cyborg transports (both are .droidType == DROID_TRANSPORTER), or cyborg and track/halftrack/hover/wheeled trucks (they are all DROID_CONSTRUCT).
I like the way .droidType works currently, but it would be great if there were .propulsion, .body and .turret1, .turret2 properties on droid objects.
5. Nexus tower/turret
How do I know when a droid has been assimilated by a Nexus tower/turret? It would be useful to have an event:
eventAssimilated(victim, attacker)
Where 'victim' is the droid pre-assimilation (ie. victim.player = original owner) and 'attacker' is the tower or droid that assimilated it (ie. attacker.player = which player assimilated it).
The event would need to trigger when I assimilate something, or when an enemy assimilates something I owned.
Also, I believe it's possible to "assimilate" technology from factories, etc. (I've never seen/tried it but seem to remember it mentioned somewhere). How is that handled and relayed to an AI script?
6. Picking stuff up
How do I make my AI instruct it's droids to pick up oil drums and artefacts?
Do I get an eventResearched() when picking up artefacts?
1. Object IDs
Are object IDs unique across all objects in the game, or specific to a single player, or specific to a type of object (structure, droid, etc)?
If an object (droid, etc) gets destroyed, will it's object ID ever be re-used?
2. Features
How do I know which features are destroyable? I'd like to instruct my droids to destroy any destroyable features near the base at the start of the game to make more room for buildings.
3. Defence structures
Currently all defence structures are grouped under a .stattype == DEFENCE. How do I know, for example, which structures are hellstorm emplacement vs. bombard pit or anything else?
I was wondering if using the .name property would be enough, but I'm worried it might change depending on localisation settings.
I want to know the specific type of structure because:
* I want to work out what it cost to build - I want my AI to make certain decisions based on economics
* I want to know what the defence structure is capable of - eg. can it shoot down my VTOLs, can it fire missiles at my troops, etc?
* I want to be able to work out if it's become outclassed due to research by me or an enemy
4. Droids
How do I work out what propulsion, body and weapon a droid has?
Again, I was thinking of using the .name property but when creating droids both humans and AIs alike (eg. see nullbot by NoQ) tend to have custom names for their templates.
There's several reasons I want to know this info:
* What did it cost to build the droid?
* What are the droid's capabilities? - both in terms of firepower and propulsion (eg. can it travel on water?)
I know I can work out if a droid is using VTOL propulsion using the isVTOL() function, but other propulsions are generally opaque. For example, there doesn't seem to be any way to distinguish between Heavy and Cyborg transports (both are .droidType == DROID_TRANSPORTER), or cyborg and track/halftrack/hover/wheeled trucks (they are all DROID_CONSTRUCT).
I like the way .droidType works currently, but it would be great if there were .propulsion, .body and .turret1, .turret2 properties on droid objects.
5. Nexus tower/turret
How do I know when a droid has been assimilated by a Nexus tower/turret? It would be useful to have an event:
eventAssimilated(victim, attacker)
Where 'victim' is the droid pre-assimilation (ie. victim.player = original owner) and 'attacker' is the tower or droid that assimilated it (ie. attacker.player = which player assimilated it).
The event would need to trigger when I assimilate something, or when an enemy assimilates something I owned.
Also, I believe it's possible to "assimilate" technology from factories, etc. (I've never seen/tried it but seem to remember it mentioned somewhere). How is that handled and relayed to an AI script?
6. Picking stuff up
How do I make my AI instruct it's droids to pick up oil drums and artefacts?
Do I get an eventResearched() when picking up artefacts?