The Settlers 4 - modding forum

Playable dark tribe and more :)

You are not logged in.

#1 2018-03-15 01:51:24

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

[RELEASE/DISCUSSION] I need your help (LUA TABLES!!!)

Hey, my name is Mario and I've been a follower of Settlers since I was young. I am still deeply attached to the game that has brought joy to me, in which I want to expand that joy to anyone else.

Just a few days ago, I found out how to add custom scripts into a .map without using /Scripts folder. If I successfully finish one map, I will explain how I can do it unless somebody already knows and wishes to share [sred]).

I just now dumped the whole lua table of the game (I hope it's all tables) and I wish that people continue adding function parameters to all the functions that have been dumped (ignoring anything else now). To follow my process please consider looking at my github profile https://github.com/MuffinMario/Siedler- … eferenzen/
if you go to /custom there lies all my written files (Conditions,etc. is from 2015, the other 2 from today) Most of it is in German as I was too lazy to write the most stuff in another language at that time [dblpt]) The dumper also contains english documentation

The dumped file contains tables in design like this (simple table)


Magic = {
    SPELL_SPECIAL = 7
    SPELL_DEFENSE = 4
    SPELL_ATTACK = 5
    SPELL_SOLDIER = 6
    SPELL_DIVINE_PRESENT = 0
    SPELL_CONVERT_GOOD = 1
    SPELL_TERRAIN = 3
    SPELL_FOOD = 2
    DbgPrt = function
    DecreaseMana = function
    IncreaseMana = function
    CurrentManaAmount = function
    CastSpell = function
}

I want you to add function parameters to these functions, I'll show you an example:

The syntax would be:
    FunctionName = function(paramType1,paramType2,...) -> returnType

Magic = {
    ...
    CurrentManaAmount = function
    ...
}

will then look like


Magic = {
    ...
    CurrentManaAmount = function(n_party) -> n_amount
    ...
}

Lua 3.2.1 (Settlers IV Lua version) contains the following types (we only need these five): userdata<T>,table,number,string,function

numbers: n_
strings:   s_
tables:    t_
userdata: u<T>_ ( T = userdata name, you can think of something if you don't know; probably not used anyway)
function:  f_

CONSTANTS: Tablename.ENUM

I'll show you an enum example:


Vehicles= {
    ...
    AmountInArea= function(n_party,Vehicles.ENUM,n_x,n_y,n_amount) -> n_bool
    ...
}

if there are no params or no return type use this syntax:
    FunctionName = function() -> nil

Game = {
    ...
    Time = function() -> n_time
    DefaultPlayerLostCheck = functoin(n_party) -> nil
    ...
}




But while that is one request I have; that you fill out the dumping table (custom/LUA_S4_TABLES.txt) with information from other scripts you can see on my github; I also want you to tell me what outside of the tables Buildings,Events,AI,Vehicles,Game,Settlers,Goods,dbg,Effects,Vars,Magic and Sounds there are, because I think that's not everything


Let's hope at least somebody reads this  [dblpt]peace[dblpt]



-Mario

Offline

#2 2018-04-03 20:43:53

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

Re: [RELEASE/DISCUSSION] I need your help (LUA TABLES!!!)

Your github is definitely lacking a bunch of mission scripts, but I was able to apply the method described to extract one.

I'm not too big on programming - I can read code and modify existing stuff, but I couldn't do something new from scratch.
Still, I'm interested in finding out how this game works under the hood. I used to think that the difficulty setting actually does very little, but now I see that even the campaign-scripts takes it into consideration.

Some of the comments inside the scripts are in german, but luckily, that's my first language.
I'd be happy to assist, but I don't quite see how.

Offline

#3 2018-04-13 20:04:43

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

Re: [RELEASE/DISCUSSION] I need your help (LUA TABLES!!!)

It's been a while since I've posted this. It's easy adding in scripts via the S4Editor, the way I found it was pretty much the thing that took me a while. I've worked with 3.2.1 Lua now for a while. I can say I can probably do most of the things in this game now. But surely not everything. Mostly the fact that the functions have unknown parameters. Of course I could just... decompile the code but I don't think it's worth the efford. Even less on the dbg and Debug table.
I've also uploaded a few maps including scripts inside the .map file on siedler-mapsource the past month. Helping is quite difficult if you don't know LUA to begin with [dblpt]P I doubt I need a lot of help anymore. Feel free to use all the information inside the /custom/ folder.
I'm currently more interested in how the game encrypts its files. I think I've found the function that does the job but I need more testing. Sadly the function is one hella huge and it takes a bit of time.

Offline

#4 2018-04-13 23:27:22

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

Re: [RELEASE/DISCUSSION] I need your help (LUA TABLES!!!)

While tinkering with the mission scripts, I noticed that some of the scripts you posted are different from the ones I get when I extract them, even with the same mission and (supposedly, according to the script itself) the same version.
In one case (dark08), there were some additional lines which caused a syntax error - ironically, those lines didn't actually do anything.
In the other (dark09), some coordinates were different, as if your version of the map had a different size than mine. This caused some confusion when I copied parts of the script you uploaded to undo some of the changes I made.

Still, I was able to fix an issue I always had with the dark09 script.

I love how people keep saying that adding scripts via the editor is easy, but nobody ever explains how it's done. I know it's possible since I've seen custom maps do it (integrating the script into the map file, rather than having a separate .txt file), but I've never found an explanation as to how it's done.

What files are you trying to decrypt?

Last edited by UltimateSpinDash (2018-04-13 23:33:58)

Offline

#5 2018-04-26 00:16:31

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

Re: [RELEASE/DISCUSSION] I need your help (LUA TABLES!!!)

I'm still planning to do a little tool that does the work. Meanwhile all I can say is that 0x0047512C is a 65534 byte long utf-8 string which gets called if 0x0047512C != nullptr

I noticed there is nothing to decrypt. If I see it correctly, the files are just compressed and changed a little. Not worth my time right now though.

The reason you get different scripts may be because these scripts come from an older version. I've said that most of the scripts taken from game memory inside the github project are not of my heritage.

Last edited by MuffinMario (2018-04-26 00:20:03)

Offline

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

Board footer

Powered by FluxBB
Modified by Visman