The Settlers 4 - modding forum

Playable dark tribe and more :)

You are not logged in.

#1 2018-04-13 13:47:21

UltimateSpinDash
Member
Registered: 2018-04-03
Posts: 18
Windows 7Firefox 59.0

Modifying mission scripts

After learning how to extract mission scripts and that the game checks for the presence of certain config files upon launch, I had a hunch that it may also check if there is a copy of a mission script in the scripts folder when launching a given mission.

To test this, I planned on taking a mission that uses a timer, and modify that timer.
The good news is, my hunch was correct in that the game does check if there is a script with the name of the mission in the scripts folder.
The bad news is that if there is a script (even an unaltered original), the game will simply default to standard rules. In the case of the mission with the timer, this resulted in me winning the mission after 20 seconds, because while there is an AI enemy present, it doesn't actually have a settlement, instead appearing in the form of warships that appear at set locations and travel on set routes.
I tested this again with an unaltered copy of the AddOns Trojan mission 09, which, among other things, has the unique property that you don't share your allies' vision. The result was again that no script was applied at all, so I could see my allies, but the actual objective would not be completeable.

Now, there are a few rather bad scripts (Dark09 comes to mind, as defeated AI's keep spawning ships, which clutter the edges of the map) that I'd love to try and optimize. But apparently, it won't be that easy.
Does anyone here have experience with altering campaign scripts and actually applying them to that campaign? Why does having a copy of the script cause the map to launch without one? Is this some kind of trap code to prevent tampering? I can't imagine that BlueByte would've bothered to do something like this.

Added later 9 h 33 min 31 s:
After some additional tests, I found the problem.

If there is a syntax error in the script (even if it should be an unaltered copy of the original), the game simply won't load it.
While tinkering, I also noticed how the script for the same mission was slightly different when I extracted it vs. the copy on the github MuffinMario created. In one case (despite supposedly being the same version, even according to the script itself), there were a few extra lines that don't even appear to have an effect (which may be why one version didn't have them - they were unnecessary), in the other, some coordinates were different.

After several hours of tinkering and testing, I was able to modify the Dark09 script so defeated AIs no longer spawn new ships. I'm not sure if I'm confident to release it without further testing, though.

Offline

#2 2018-04-17 17:02:55

UltimateSpinDash
Member
Registered: 2018-04-03
Posts: 18
Windows 7Firefox 59.0

Re: Modifying mission scripts

Aaand I hit another snag.

While the above approach works for campaign maps, it apparently doesn't work for standalone maps (the ones made by BlueByte, that is). I can extract the script, but I can't get the map to load a modified version of it instead.

So far I tested this with two maps, Cordoba (the one I'm actually trying to modify) and Eleven Towers (tested it with that one as well. That map is really script-heavy).

Offline

#3 2018-04-26 00:22:35

MuffinMario
Member
Registered: 2018-03-15
Posts: 4
WindowsFirefox 59.0

Re: Modifying mission scripts

everything inside /custom was made from scratch from me. I'd recommend using the S4_LUA_TABLE file (or something like that i forgot the name) since it has a lot of functions with parameters and return values (ignoring the obvious getter functions)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman