aliens

Author Topic: [Experimental] Modular rulesets  (Read 15333 times)

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
[Experimental] Modular rulesets
« on: October 17, 2012, 07:22:32 pm »
Since there's been a lot of modding talk lately, I figured I'd post about this feature here first, since it's still experimental and you guys are probably best fit to try it out and let me know how it works before I let it out into the wild. :) You can use the Git Builds (and eventually 0.4.5) to try it out.

Anyways, one of the first stepping stones in the big road to full moddability are "modular rulesets". What does this mean? Well currently, if you wanna make your own mod for OpenXcom, you have to make your own modded version of the fuckin' huge Xcom1Ruleset to distribute with it. Then you have to bitch everytime it changes and you have to update your mod, bitch everytime you wanna change your mod and find yourself editing a fuckin' huge file, and gawd forbid you wanna use multiple mods because you'll have to merge them all yourself into some new frakenstein version of Xcom1Ruleset (and bitch a lot). :o

Well in 0.4.5, modular rulesets put an end to all that! The principle is that each mod ruleset should only contain what it mods, not the whole picture. For example, taking this example, you could make a XcomutilInterceptor.rul with just this:
Code: [Select]
crafts:
  - type: STR_INTERCEPTOR
    soldiers: 6
    vehicles: 1
    battlescapeTerrainData:
      name: INTERC
      mapDataSets:
        - BLANKS
        - PLANE
      mapBlocks:
        - name: INTERC
          width: 10
          length: 10

That's it! No more need to lug around the entire Xcom1Ruleset around! Any updates won't affect your mod, and you have a much more manageable file to take care of. But wait, how do I put it into OpenXcom? Well there's a new "rulesets" section in your options.cfg, you just have to add it there:
Code: [Select]
rulesets:
  - Xcom1Ruleset
  - XcomutilInterceptor

And voilá! Your mod is now in effect. No muss, no fuss. OpenXcom will load all the rulesets specified one by one, combining them all in runtime for you, so in the end you get the all the mods running together. :) Note that order matters! Xcom1Ruleset must come first as it's the "base ruleset", otherwise it'll end up overriding any rulesets that come before it.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #1 on: October 17, 2012, 08:07:52 pm »
Great feature. What with changing existing objects, if you want to, let's say, change the building cost of a laboratory to 800000, you make a file with just:
facilities:
  - type: STR_LABORATORY
    buildCost: 800000

Will that work?
Never mind, it works :p
« Last Edit: October 17, 2012, 08:13:58 pm by Daiky »

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: [Experimental] Modular rulesets
« Reply #2 on: October 17, 2012, 09:23:28 pm »
oh, that is VERY nice. I'll have to find some time to play around with that. adding new weapons, for example. that should be possible, right? I just have to define them in a ruleset file.


...all we need now is loading graphics from .png files... and loading files from .zip archives, so we can put all relevant files into one .zip archive and load them from there :) :) :)

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #3 on: October 17, 2012, 09:43:45 pm »
Great feature. What with changing existing objects, if you want to, let's say, change the building cost of a laboratory to 800000, you make a file with just:
facilities:
  - type: STR_LABORATORY
    buildCost: 800000

Will that work?
Never mind, it works :p
Yeah, the way it works is that when loading rulesets, OpenXcom simply keeps loading new info on top of the old one, instead of "starting from scratch", and it checks the IDs to see if it's a new entry or an update to an existing one, so in the end you get everything combined cleanly (assuming there's no conflicts between mods :P).

Technically this has been supported from the start, it just took the (oh so painful) removal of the hardcoded XcomRuleset.cpp to get it going.

oh, that is VERY nice. I'll have to find some time to play around with that. adding new weapons, for example. that should be possible, right? I just have to define them in a ruleset file.


...all we need now is loading graphics from .png files... and loading files from .zip archives, so we can put all relevant files into one .zip archive and load them from there :) :) :)
Patience. ;)

Offline MKSheppard

  • Colonel
  • ****
  • Posts: 249
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #4 on: October 18, 2012, 11:58:22 pm »
Would it be possible to combine this with the UFOPedia entry as well? e.g. you can add the following string at the end of your definition:

Code: [Select]
STR_INTERCEPTOR_UFOPEDIA
COMBAT AIRCRAFT WITH HYDROGEN TURBORAMJET ENGINES AND SPECIALLY SHIELDED ELECTRONIC SYSTEMS.  THE BEST AVAILABLE EARTH BASED TECHNOLOGY.

It would replace the stock text?

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #5 on: October 19, 2012, 01:32:59 am »
There are plans to eventually bring Languages, Resources and Rulesets all under one optimum moddability banner. Again, patience. I'd really like to hear about people trying out this feature and finding any issues first. :P

Offline luke83

  • Commander
  • *****
  • Posts: 1558
    • View Profile
    • openxcommods
Re: [Experimental] Modular rulesets
« Reply #6 on: October 19, 2012, 09:06:03 am »
OK , i have tested this function with a separate" Dawn City" Ruleset , everything appears to work except this map set has a few issues in Openxcom , i want to test it a few times in the original before i start blaming Daiky as it may be something to do with how its made.
 That being said , its a really nice set and i am tempted to spend a few nights tweaking it to my own tasts
« Last Edit: October 19, 2012, 02:28:38 pm by luke83 »

Offline MKSheppard

  • Colonel
  • ****
  • Posts: 249
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #7 on: October 20, 2012, 05:14:50 pm »
Luke83, that picture is... :o ;D

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #8 on: October 20, 2012, 09:55:25 pm »
... sweet!  8) 8)

Offline luke83

  • Commander
  • *****
  • Posts: 1558
    • View Profile
    • openxcommods
Re: [Experimental] Modular rulesets
« Reply #9 on: October 21, 2012, 04:58:40 am »
Yep there was a few issues in the Mapset - but the code to add doesn't seem to be the issue ( well at this moment i dont think its the new code causing the issues).

--- posts merged ---

Had me scratching my head as to what was goign on until i loaded my CF terror maps back into game , Supsuper , it appears this is Mixing my Defualt URBAN set ( in this case its Hobbes DAWN MAP) with my additional " modular" set instead of replacing it , i think the screen shot shows it rather well.

The result is rather interesting to look at :)
« Last Edit: February 07, 2016, 11:29:48 am by Solarius Scorch »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #10 on: October 21, 2012, 01:56:13 pm »
Could you post the rulesets (and related files) you used for me to test it out?

Offline luke83

  • Commander
  • *****
  • Posts: 1558
    • View Profile
    • openxcommods
Re: [Experimental] Modular rulesets
« Reply #11 on: October 21, 2012, 02:21:42 pm »
As requested , i think its everything you will need.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #12 on: November 05, 2012, 01:51:45 am »
Ok this should be fixed now.

Offline luke83

  • Commander
  • *****
  • Posts: 1558
    • View Profile
    • openxcommods
Re: [Experimental] Modular rulesets
« Reply #13 on: November 18, 2012, 06:43:12 am »
Just trying this again and i got this error, i have double checked all my game files , i THINK there all correct so maybe someone can tell me the normal cause of this Error message?

 Also is there a LOG in Openxcom yet?



Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: [Experimental] Modular rulesets
« Reply #14 on: November 18, 2012, 05:21:56 pm »
Thats an STL vector out of bounds access getting caught in a debug build by debug only error checks in the STL

some code is trying to access element N of a vector of less than N+1 elements in length.