Javascript API documentation

For AI and campaign script related discussions and questions
User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 01 May 2013, 15:48

We have a new alliancesType constant, which is ALLIANCES_UNSHARED; it describes a new game mode that is similar to ALLIANCES_TEAMS but research is no longer shared or transfered between allies.

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: Javascript API documentation

Post by Shadow Wolf TJC » 03 May 2013, 05:05

aubergine wrote:rules.js uses alliancesType for victory conditions - so things like Enhanced SitRep Mod and Contingency Mod might be affected, but it should be trivial to make them adapt to the change. Speaking of which, what exactly is the change - been frantic IRL recently and not been keeping up with the qtscript changes...
It's OK. Development of Contingency is currently focusing on the more stable 3.1 versions. It hasn't been ported to 3.2 yet, and from the looks of things, I may have to wait for 3.2 to stabilize before porting it over.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 18 May 2013, 08:44

23da1f18915bd0e7c811672fffb3f39944ab5669 probably wasn't a good idea :oops: i was sure i was fixing a typo, and then i thought that 3.1 users need to be able to read the docs too :oops:

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

Re: Javascript API documentation

Post by Per » 18 May 2013, 11:42

NoQ wrote:23da1f18915bd0e7c811672fffb3f39944ab5669 probably wasn't a good idea :oops: i was sure i was fixing a typo, and then i thought that 3.1 users need to be able to read the docs too :oops:
There will probably be more people learning the scripting stuff and the docs when 3.2 is released :)

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

Re: Javascript API documentation

Post by Per » 18 May 2013, 11:43

Two new scripting functions added to support temporary vision (like the scanner sweep in starcraft 2):

addSpotter(x, y, player, range, type, expiry) -- Add an invisible viewer at a given position for given player that shows map in given range. type is zero for vision reveal, or one for radar reveal. The difference is that a radar reveal can be obstructed by ECM jammers. expiry, if non-zero, is the game time at which the spotter shall automatically be removed. The function returns a unique ID that can be used to remove the spotter with removeSpotter.

removeSpotter(id) -- Remove a spotter given its unique ID.

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: Javascript API documentation

Post by Shadow Wolf TJC » 18 May 2013, 12:00

Neat, though is there going to be a way for modders to create their own custom support powers or superweapons? Perhaps an eventStructureActivated() function would be needed whenever a support power or superweapon (including a LasSat Command Post) is activated? I'd imagine that the source code would also need to be modified to allow modders to create additional support/superweapon structures, each with their own powers or weapons (such as a massive EMP blast).
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

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

Re: Javascript API documentation

Post by Per » 18 May 2013, 12:47

Shadow Wolf TJC wrote:Neat, though is there going to be a way for modders to create their own custom support powers or superweapons?
Yes. I'm working toward it. :)

User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 20 May 2013, 06:15

:?: 9ac0e6ae4c87b877982564dfc479b3cb61dc24ab <=== does it mean i need to re-lecture the AIs on how to produce cyborgs? Should be quite possible, just asking.

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

Re: Javascript API documentation

Post by Per » 20 May 2013, 08:29

NoQ wrote::?: 9ac0e6ae4c87b877982564dfc479b3cb61dc24ab <=== does it mean i need to re-lecture the AIs on how to produce cyborgs? Should be quite possible, just asking.
Hmm. Yes. I did not think of that. No way around it, though.

User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 20 May 2013, 13:39

:hmm: Maybe we can make aliases for items in ini files?

User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 20 May 2013, 19:56

Something like

Code: Select all

[CybRotMgGrd]
aliasFor = CyborgLightBody
and add one more add-on to the wzconfig wrapper :hmm:

User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: Javascript API documentation

Post by Duha » 20 May 2013, 20:20

NoQ wrote:Something like

Code: Select all

[CybRotMgGrd]
aliasFor = CyborgLightBody
and add one more add-on to the wzconfig wrapper :hmm:
May be you need just js object

Code: Select all

var aliases  = {'CybRotMgGrd': 'CyborgLightBody'}
You can generate template from python.
http://addons.wz2100.net/ developer

User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 20 May 2013, 20:24

I think maintaining aliases in ini files is easier than maintaining a complicated separate js file that overrides multiple API functions. I'd also surely go with js if i need to make my scripts work on both versions, but the idea is mostly about the base game: since we aim at "scripts never break", i thought it would be a useful way of keeping AIs sane after balance changes that involve adding or removing stuff.

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

Re: Javascript API documentation

Post by Per » 20 May 2013, 20:44

Wouldn't it be easier to just pass in a list of bodies to buildDroid(), with CybRotMgGrd etc as the first, and CyborgLightBody / CyborgHeavyBody as the second?

I believe it will just spit out a warning if it is given a body that does not exist, then select the next one in the list...

User avatar
NoQ
Special
Special
Posts: 6189
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Javascript API documentation

Post by NoQ » 20 May 2013, 21:03

I repeat, I have no problem with fixing my scripts. I'm having problems with the fact that they need to be fixed every time things like that happen.

Post Reply