widelands / widelands

Widelands is a free, open source real-time strategy game with singleplayer campaigns and a multiplayer mode. The game was inspired by Settlers II™ (© Bluebyte) but has significantly more variety and depth to it.
https://www.widelands.org/
GNU General Public License v2.0
2.01k stars 158 forks source link

Add-on system #3898

Closed Noordfrees closed 3 years ago

Noordfrees commented 4 years ago

Emerged from https://www.widelands.org/forum/topic/4843

Widelands should have an add-on system as it is found in many other games. From inside the game, it should be possible to download new maps, scenarios, starting- and win conditions, immovables, bobs, terrains, wares, workers, buildings, even tribes. And also to upload one's own creations to the server, ideally also from within the game.

This is a pretty big feature. We will need at least:

See also https://github.com/widelands/widelands-metaserver/issues/71

Noordfrees commented 4 years ago

Just in case someone would like a sneak peek at the current state of this feature ;) shot0000 shot0001

gunchleoc commented 4 years ago

The principal idea of addons is that first, the official units are loaded, and directly afterwards, the add-on scripts are run and modify stuff. I'm providing a lua interface for hacking into existing *Descr objects and allowing to change them. Example script: https://github.com/Noordfrees/wl_addons_server/blob/master/addons/frisians-economy-ultra.wad/init.lua

I had a quick look at the format and here are some thoughts on it:

The rest is looking good to me concept wise :)

My branches on the subject:

  1. Tribes Filtering (already up for code review) https://github.com/gunchleoc/widelands/tree/tribes-filtering
  2. Move tribe-specific info out of unit init.lua files https://github.com/gunchleoc/widelands/tree/pluggable-tribes
  3. Move tribe-specific info out of unit helptext.lua files https://github.com/gunchleoc/widelands/tree/pluggable-tribes-helptexts
  4. We might also need to revise my design for attribute loading, but we can do that later
Noordfrees commented 4 years ago

For the first two points, I'd better wait then until the tribes-filtering is merged and then adapt everything to the new specs. (I have little time for reviewing large changes ATM though). Will implement the third point. It is already possible to specify any number of requirements and the game will take care of loading order, but yes it would look cleaner to have a lua array for that. We'll have to keep in mind that the server as well as the game needs to be able to parse the addons.lua though – my minimal pseudoserver implementation will have to impose some restrictions on the file until we have a real add-ons server with a full lua interface. Regarding the fourth and fifth point – then these should be several add-ons which depend on each other. IMHO splitting big stuff into several medium-sized modules is more maintainable. Also, for smaller add-ons it would be overkill to have lots of sub-sub-sub-…-directories when there are just one or two files. Here I'd prefer having one main script per add-on that takes care of including/loading/modifying everything.

gunchleoc commented 4 years ago

I think it would be even safer to wait for https://github.com/gunchleoc/widelands/tree/pluggable-tribes because I got rid of the init.lua file too for the tribes; I had forgotten about that. It contains info for multiple tribes at once, and I want to make everything self-contained.

The helptexts thing won't be a problem as long as you keep your examples small enough that merging/adapting won't take too long. This will already be endless fun for the Amazonians... I guess best leave that one to me then, because I'll be most familiar with the new spec.

Parsing Lua on the server is a good point. We should think about which programming language we want to use and whether it can parse Lua before you spend much time on it and we then maybe reverse our decision.

I also think that smaller add-ons are easier to maintain than bigger ones, but we don't know what type of modder we'll get, and somebody might want to make a full conversion mod or something once everything is moddable.

gunchleoc commented 4 years ago

it would be overkill to have lots of sub-sub-sub-…-directories I didn't express myself very well. I mean we could have something like tribes/init.lua and anything tribe-related in the tribes directory etc. It adds 1 directory level.

I have been thinking a bit more about the server implementation.

Noordfrees commented 4 years ago

Regarding security, I have already implemented a system for that, described here: https://github.com/Noordfrees/widelands/blob/addons/doc/sphinx/source/add-ons.rst#verification So yes manually reviewing them is something we should attempt to do (I don't expect massive usage of this system so the effort should be manageable)

There is also an add-on category "maps" which just adds one or more maps, so we could replace the website's maps section is the long run if we want. Add-ons already have versioning and an upgrade system.

For the server, I can't really comment on that as I have practically no networking experience. I hacked together a simple class that uses the CURL lib to connect to the GitHub repo with the example add-ons and download stuff from there, and I can't even imagine how a more complex approach could look like…

Noordfrees commented 4 years ago

@gunchleoc I have lost the overview a bit – how many branches are left to get merged before I can safely convert the add-ons feature to the new format?

gunchleoc commented 4 years ago

Then there will be a bug fix https://github.com/gunchleoc/widelands/tree/4139-scenario-animations with changes to animation_directory and icon - I don't know if that affects you.

The rest will be getting rid of AI hints, which I think is non-critical for your project.