The official --=jscam=-- thread

For AI and campaign script related discussions and questions

Re: The official --=jscam=-- thread

Postby Berserk Cyborg » 21 Feb 2017, 06:12

Is there a way to force a droid to a certain position even with enemies nearby? I tried orderDroidLoc() with dorder_move but it acts the same as dorder_scout when player units are nearby.
Berserk Cyborg
Code contributor
Code contributor
 
Posts: 302
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Postby NoQ » 21 Feb 2017, 10:37

I tried orderDroidLoc() with dorder_move but it acts the same as dorder_scout when player units are nearby.

NullBot uses DORDER_MOVE all the time when retreating from combat and it works. As far as i remember, on the first level of the campaign you also have scavengers retreating after few of them are dead; you may fail to notice this effect because they die too quickly anyway, but i tested it carefully(c) and it worked.
User avatar
NoQ
Special
Special
 
Posts: 6090
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The official --=jscam=-- thread

Postby Berserk Cyborg » 25 Feb 2017, 00:20

Yeah... I failed to notice that group management makes units scout and it was overriding my commands. Adding some extra conditions for vtol units did what I needed. I will be able to test and improve the campaign vtol related stuff fully once I finish cam2-c since it is the first mission with vtol rearming pads. That said cam2-2 is completed and works like it should again.
Berserk Cyborg
Code contributor
Code contributor
 
Posts: 302
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Postby vexed » 13 Mar 2017, 05:26

Those people that have downloaded this, please give us your input!

If you have any issues, comments or questions, please don't hesitate to ask!

Thanks!
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
User avatar
vexed
Inactive
Inactive
 
Posts: 2411
Joined: 27 Jul 2010, 02:07

Re: The official --=jscam=-- thread

Postby NoQ » 14 Mar 2017, 20:04

Hmm, the hook system is all broken. I've no idea how or why it worked before.

On game load from a saved game, first the global scope of libcampaign is executed, and hooks are properly installed and original event handlers are stored for future use, then saved script state from the savegame data is poured over, replacing all original events with improperly (de)serialized handlers that existed before the save. Because we cannot serialize javascript functions at all, of course it all breaks.

Is it possible that we used to load savegame data before executing the script's global scope, but a last-minute change in load order has broken everything? Unlikely, but i have no other explanation, because i'm sure it worked, i had saves for all levels and no errors whatsoever.

Anyway, i suggest we move all hook calls from global scope to a function, say __camResetHooks(), implement eventGameInit() and eventGameLoaded() to call it (directly, not as hooks!) in libcampaign, and say in documentation that we forbid user level scripts from defining eventGameInit() or eventGameLoaded() (because it's already defined in the library).

An alternative trick would be to move poorly serializable data out of the way in eventGameSaving() and put it back in eventGameSaved(), but that's tricky.
User avatar
NoQ
Special
Special
 
Posts: 6090
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The official --=jscam=-- thread

Postby NoQ » 15 Mar 2017, 14:37

Also, we could make a native API function like excludeFromSavedGames(string), which would avoid mentioning or serializing the global variable with the given name in save files. The list of such variables itself should be saved. Such function could also be used to decrease savegame size.
User avatar
NoQ
Special
Special
 
Posts: 6090
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The official --=jscam=-- thread

Postby Per » 16 Mar 2017, 00:19

Implementing such a function would be trivially simple, because we already maintain such an exclusion list internally. But wouldn't it be better to have a prefix (or private object) you could give globals to avoid them being saved?
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
 
Posts: 3625
Joined: 03 Aug 2006, 19:39

Re: The official --=jscam=-- thread

Postby NoQ » 16 Mar 2017, 10:31

Yep, right, we could just put __camOriginalEvents and __camPreHookEvent() into a self-calling closure :stressed:
User avatar
NoQ
Special
Special
 
Posts: 6090
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The official --=jscam=-- thread

Postby Berserk Cyborg » 23 Mar 2017, 22:20

@Per can you add an optional player argument to findResearch() and make donateObject() accept structures?

I am currently testing 2-5/s and 2-d/s (will start working on cam2-6/s next). Beta campaign is roughly half converted now.
Berserk Cyborg
Code contributor
Code contributor
 
Posts: 302
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Postby NoQ » 24 Mar 2017, 15:01

Berserk Cyborg wrote:make donateObject() accept structures

A bit tricky here because we shouldn't allow skirmish AIs to donate structures to players.
Of course, this should be done as anti-cheat check, not on API level.
User avatar
NoQ
Special
Special
 
Posts: 6090
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The official --=jscam=-- thread

Postby Per » 24 Mar 2017, 20:06

NoQ wrote:
Berserk Cyborg wrote:make donateObject() accept structures

A bit tricky here because we shouldn't allow skirmish AIs to donate structures to players.
Of course, this should be done as anti-cheat check, not on API level.

We have lots of functions that it would be cheating for a skirmish AI to use. Just... don't :-)

I'll have a look at the code. It should be easy to add as an optional parameter.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
 
Posts: 3625
Joined: 03 Aug 2006, 19:39

Re: The official --=jscam=-- thread

Postby Per » 25 Mar 2017, 23:15

Added:

findResearch() now has an optional second parameter that gives the player to search for. (I did not test this.)
donateObject() can now take a structure as well. It will ignore transfers that would take a player beyond building limits. (I did test this. Seems to work.)
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
 
Posts: 3625
Joined: 03 Aug 2006, 19:39

Re: The official --=jscam=-- thread

Postby Berserk Cyborg » 01 Apr 2017, 22:51

Per wrote:findResearch() now has an optional second parameter that gives the player to search for. (I did not test this.)
Tested and it works.

Finished up 2-6(s). I have moved the extra victory condition callback into its own function so that it can be used in something other than the standard victory (nothing seems to break from what I can tell). And updated the off-world victory code to support extra win conditions also. So I will start with 2-7(s) now.
Berserk Cyborg
Code contributor
Code contributor
 
Posts: 302
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Postby Berserk Cyborg » 18 Apr 2017, 20:24

I will finish off 2-8(s) and the last Beta mission since I am done with 2-7 now. Not quite sure what I will do about the transporter for the Beta escape mission, but it seems like a good challenge.

I have been working on a fix for an ancient research related bug for the campaign (research not granted correctly). This involved reworking the three campaign tech trees into one and using findResearch() to complete all the required research up to the passed in item. Currently, if an enemy gets vehicle-metals-07, they actually only have the benefits of one defense upgrade and not any of the previous upgrades. Similar issues affect the player upon campaign transition as well. Because of this I must convert 3-a to test everything properly.
Berserk Cyborg
Code contributor
Code contributor
 
Posts: 302
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Postby Berserk Cyborg » 01 May 2017, 20:25

Missions 2-7/2-8/2-B have been completed. Additionally, I fixed 1-1s "let me win" not letting a player to skip through the power module part by cheating. And made minor fixes for the campaign library.

I am at the last Beta mission. Are droids saved in some list somewhere when the transporter exits the map (would multiple transport loads in the same mission just remove previous ones)? If not, I would have to copy the components/experience and create a copy of the droid upon entering 3-a. From there I guess I would destroy all remaining droids on map when the timer is zero and then play the last video sequence. Also the Collective transporter could drop of scouts (cyborgs/weaker tanks) at their LZ which is unused in the WZ Script version. Should I enable this?
Berserk Cyborg
Code contributor
Code contributor
 
Posts: 302
Joined: 26 Sep 2016, 19:56

PreviousNext

Return to Scripting