Page 1 of 1

Tech level and limiter scripts to JS

PostPosted: 06 Dec 2017, 19:18
by Berserk Cyborg
Doing even more WZScript to Javascript conversions. So now I have the tech level enablers and the limiter screen script working. The latter of which seems to need everything globally or it don't work. There was also a bunch of non-existent research in the tech files so I went and removed the unavailable ones

It does have a silent assert when loading a save because it can not find multilim.js. So I pose an interesting question: would it be possible to skip saving and loading a certain script?

Current work.

Re: Tech level and limiter scripts to JS

PostPosted: 06 Dec 2017, 21:08
by Per
Nice work.

There is hackDoNotSave(var name) to not save a particular global variable, but no way to prevent an entire script context from being saved.

Anything you load through the WRF / resource system will get its own script context, which will be saved and require some special handling for load. This is usually a bad idea, I think. Wouldn't it be easier to just include() some of this code from rules.js?

When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?

Re: Tech level and limiter scripts to JS

PostPosted: 06 Dec 2017, 23:52
by Berserk Cyborg
Per wrote:Anything you load through the WRF / resource system will get its own script context, which will be saved and require some special handling for load. This is usually a bad idea, I think. Wouldn't it be easier to just include() some of this code from rules.js?
Maybe even better: Now I make it so the research is granted within eventGameInit() by adding a JS function called getMultiTechLevel() and moving the research definitions into camTechEnabler.js which is included with rules.js.

Per wrote:When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?
That would make the most sense. Instead, the one and only purpose of those scripts were to set the structure limits of some structure. Using setStructureLimits() on player zero. All that magic starts in startLimitScreen() in multilimit.cpp.

Re: Tech level and limiter scripts to JS

PostPosted: 10 Dec 2017, 19:10
by Berserk Cyborg
Here is the tech level conversion. I'll leave this here for a quick review to spot any potential problems.

Edit: Now in d31f6a2c704ada8f46957a34279af78deafdeec7.

Re: Tech level and limiter scripts to JS

PostPosted: 12 Dec 2017, 02:59
by Per
Berserk Cyborg wrote:
Per wrote:When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?
That would make the most sense. Instead, the one and only purpose of those scripts were to set the structure limits of some structure. Using setStructureLimits() on player zero. All that magic starts in startLimitScreen() in multilimit.cpp.

Ok, see my attempt to fix this in https://github.com/perim/warzone2100/co ... fbc9794fd6

This patch simplifies the code quite a bit, and allows us to set a default limit that is different from the maximum. I'm not sure if and how limits are used in campaign / tutorial, though.

Re: Tech level and limiter scripts to JS

PostPosted: 12 Dec 2017, 03:01
by Per
Berserk Cyborg wrote:Here is the tech level conversion. I'll leave this here for a quick review to spot any potential problems.

Edit: Now in d31f6a2c704ada8f46957a34279af78deafdeec7.

Looks good to me.

Re: Tech level and limiter scripts to JS

PostPosted: 12 Dec 2017, 03:37
by Berserk Cyborg
Per wrote:Ok, see my attempt to fix this in https://github.com/perim/warzone2100/co ... fbc9794fd6

This patch simplifies the code quite a bit, and allows us to set a default limit that is different from the maximum. I'm not sure if and how limits are used in campaign / tutorial, though.

Don't need data/mp/multiplay/script/multilim.slo in Potfiles.in anymore. Other than that looks good.

Campaign's rule.js calls setStructureLimits on eventStartLevel (should be the same amounts as multiplayer). Tutorial basically sets the max limits to 1 for the standard buildings in its eventStartLevel.