Some questions on JS API

For AI and campaign script related discussions and questions
Post Reply
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Some questions on JS API

Post by aubergine » 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?
"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: Some questions on JS API

Post by aubergine » 25 Jan 2012, 18:11

Oh, and... (just spotted these lurking in an obscure bit of my "blocker" list)

7. Recycling droids

How do I recycle a droid? Is an event called when a droid is recycled?

If I have done a bind() to get notified when an enemy droid/structure is destroyed, will bind() trigger if it's recycled/demolished?

8. Droid secondary orders

How do I get/set droid secondary orders (the things you get when right-clicking a droid) or factory default orders (things you get when right-clicking a factory)?

For example, attack mode: hold, return-fire, fire-at-will
"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: 3776
Joined: 03 Aug 2006, 19:39

Re: Some questions on JS API

Post by Per » 25 Jan 2012, 19:53

IDs are unique and never reused. The .name property is not translated, and is not a name that the user ever sees. (Think of it as a unique string key.) AI players currently cannot pick up oil drums or artefacts (this is supposedly a feature). Bind will trigger on recycle and demolish.

The rest is simply not implemented yet.

User avatar
lav_coyote25
Professional
Professional
Posts: 3434
Joined: 08 Aug 2006, 23:18

Re: Some questions on JS API

Post by lav_coyote25 » 25 Jan 2012, 23:52

so why cant the AI pick up oil drums. they are players , arent they? :hmm:

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

Re: Some questions on JS API

Post by Per » 26 Jan 2012, 00:04

Don't know. Always been this way.

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

Re: Some questions on JS API

Post by aubergine » 26 Jan 2012, 00:23

I see there's a DORDER_RECOVER in orderdef.h - would exposing that to JS API allow AI players to pick up stuff?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Safety0ff
Trained
Trained
Posts: 397
Joined: 18 Jul 2009, 23:23

Re: Some questions on JS API

Post by Safety0ff » 26 Jan 2012, 00:34

There's also this, but it's probably best to keep it to intentional pick-ups.

Post Reply