Page 13 of 13

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

PostPosted: 21 Feb 2017, 06:12
by Berserk Cyborg
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.

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

PostPosted: 21 Feb 2017, 10:37
by NoQ
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.

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

PostPosted: 25 Feb 2017, 00:20
by Berserk Cyborg
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.

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

PostPosted: 13 Mar 2017, 05:26
by vexed
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!

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

PostPosted: 14 Mar 2017, 20:04
by NoQ
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.

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

PostPosted: 15 Mar 2017, 14:37
by NoQ
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.

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

PostPosted: 16 Mar 2017, 00:19
by Per
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?

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

PostPosted: 16 Mar 2017, 10:31
by NoQ
Yep, right, we could just put __camOriginalEvents and __camPreHookEvent() into a self-calling closure :stressed:

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

PostPosted: 23 Mar 2017, 22:20
by Berserk Cyborg
@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.

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

PostPosted: 24 Mar 2017, 15:01
by NoQ
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.

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

PostPosted: 24 Mar 2017, 20:06
by Per
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.

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

PostPosted: 25 Mar 2017, 23:15
by Per
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.)

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

PostPosted: 01 Apr 2017, 22:51
by Berserk Cyborg
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.

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

PostPosted: 18 Apr 2017, 20:24
by Berserk Cyborg
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.