aliens

Author Topic: Modding this  (Read 6410 times)

Offline Cerazor

  • Captain
  • ***
  • Posts: 61
    • View Profile
Modding this
« on: June 23, 2016, 07:39:10 am »
Hello. I want to get into modding and scripting and I was wondering how if this game is a good place to start learning. I've edited a Paradox save game file before but I doubt thats anything close to this.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Modding this
« Reply #1 on: June 23, 2016, 08:57:25 am »
Hello. I want to get into modding and scripting and I was wondering how if this game is a good place to start learning. I've edited a Paradox save game file before but I doubt thats anything close to this.

I recently noticed when looking at Stellaris files that some of them are written with YAML, which is the same as Openxcom. So it could be more familiar to you than you'd think.
I've modded a few games too and in my opinion Openxcom is a really easy one to mod. I suggest you start with analysing some simple mod and altering it. Use the nightly version rather than milestone for more modding capabilities. You will also need this reference. The rest is details. :)

Offline Kadmos

  • Squaddie
  • *
  • Posts: 1
    • View Profile
Re: Modding this
« Reply #2 on: June 23, 2016, 11:10:03 am »
May I also ask a "noob" question?

Do I have to directly edit the ruleset files (for example "alienDeployments") or can I somehow create a file that overwrites some values of a default ruleset file?

For example: If I want to change the size (length and width) of battlescape maps can I create a file with just "type", "width" and "length":

- type: x
    width: 80
    length: 80

- type: y
    width: 80
    length: 80

etc.

If yes; where do I place and how do I load such a file?

Thank you!

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Modding this
« Reply #3 on: June 23, 2016, 11:28:39 am »
May I also ask a "noob" question?

Do I have to directly edit the ruleset files (for example "alienDeployments") or can I somehow create a file that overwrites some values of a default ruleset file?

You can edit the original files, but it's a poor option for a number of reasons, for example your changes will disappear whenever you update the game.

The correct way is to create a new .rul file, which is just a YAML file (editable with any text editor which encodes in Unicode, which is almost any). The file only contains the changes and additions. Mods that don't add any new resources (like graphics) are just a text file. See for example my Alien Melee Stat mod which changes the Melee stat for aliens.

For example: If I want to change the size (length and width) of battlescape maps can I create a file with just "type", "width" and "length":

- type: x
    width: 80
    length: 80

- type: y
    width: 80
    length: 80

etc.

Yes, in short. The actual formatting is a bit different, but you're on the right track.
For more information check the Ruleset Reference I linked. And primarily try to find a mod which does something similar and inspect it. If you have questions, ask.

If yes; where do I place and how do I load such a file?

Have you ever used mods? I expect so; otherwise I don't think you'd want to make your own. So just place your new mod like any other mod, in the user/mods folder.

Thank you!

You're welcome!

Offline Cerazor

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Modding this
« Reply #4 on: June 23, 2016, 03:33:11 pm »
I recently noticed when looking at Stellaris files that some of them are written with YAML, which is the same as Openxcom. So it could be more familiar to you than you'd think.
I've modded a few games too and in my opinion Openxcom is a really easy one to mod. I suggest you start with analysing some simple mod and altering it. Use the nightly version rather than milestone for more modding capabilities. You will also need this reference. The rest is details. :)

Funny how that was my initial plan to find a simple mod, look at it and then see how the system works.

So whats  the Ruleset for anyway?
« Last Edit: June 23, 2016, 03:35:39 pm by Cerazor »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Modding this
« Reply #5 on: June 23, 2016, 03:51:33 pm »
Funny how that was my initial plan to find a simple mod, look at it and then see how the system works.

Good thing you can do this. My first mod (made together with Dioxine) was before modding became popular on the internet, so we had to decipher everything ourselves. And neither of us is a programmer.
BTW, this mod was for Civilization: Call to Power, it's called Forever Future and it's still pretty wicked. ;)

So whats  the Ruleset for anyway?

Well... That's your mod. Everything except graphics and sound, because these obviously require separate files. Not sure if this answers your question...

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Modding this
« Reply #6 on: June 23, 2016, 04:32:24 pm »
The more pedantic answer is that the Ruleset files are the data that the openxcom executable reads for all of the objects in the game - items, craft, base facilities, alien geoscape behavior, where to find graphics and sound files, ufopaedia entries, etc.  They provide for a more user-friendly way to change anything that isn't baked directly into the program itself.  If you look at the (path-to-openxcom)/data/Ruleset/Xcom1Ruleset.rul file (or I think it's split into multiple files in standard/xcom1 for the nightly version), you can find most everything that makes X-COM, X-COM, and therefore change practically anything you like.  Adding a mod is basically creating an addendum to this Ruleset file, whether it's changing the size of a map, to deleting everything and building a new game from the ground up.  There are a few things you can't change unless you re-write the source code, like the alien battlescape AI.

For the example of changing the map size, the executable reads the data from a Ruleset file under the heading 'alienDeployments:' for the size of maps generated when you assault a UFO.  Here's the bit for a small scout map:

Code: [Select]
alienDeployments:
  - type: STR_SMALL_SCOUT
    data:
      - alienRank: 5
        lowQty: 1
        highQty: 1
        dQty: 0
        percentageOutsideUfo: 50
        itemSets:
          -
            - STR_PLASMA_PISTOL
            - STR_PLASMA_PISTOL_CLIP
            - STR_PLASMA_PISTOL_CLIP
            - STR_MIND_PROBE
          -
            - STR_PLASMA_RIFLE
            - STR_PLASMA_RIFLE_CLIP
            - STR_PLASMA_RIFLE_CLIP
            - STR_MIND_PROBE
          -
            - STR_HEAVY_PLASMA
            - STR_HEAVY_PLASMA_CLIP
            - STR_MIND_PROBE
    width: 40
    length: 40
    height: 4

In your modded ruleset file, you only need to include what you're changing - here, the width and length of the map.  So an example of that change might look like:

Code: [Select]
alienDeployments:
  - type: STR_SMALL_SCOUT
    width: 80
    length: 80
« Last Edit: June 23, 2016, 04:41:30 pm by ohartenstein23 »

Offline Cerazor

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Modding this
« Reply #7 on: June 23, 2016, 05:24:20 pm »
I was looking in Aliens Pickup Dropped Items. I'm slightly confused about the grenade. How does setting it to 6 make the alien not want to pick the grenade back up? Is anything under a certain digit e.g. 6, something that the AI wont pick up after dropping and 7-10 items that are so desirable that they will just pick it up as quickly as possible.

(Sorry its 12PM now and I just got hit with a wave of drowzyness so I'm going to read all of the Ruleset tomorrow)


Good thing you can do this. My first mod (made together with Dioxine) was before modding became popular on the internet, so we had to decipher everything ourselves. And neither of us is a programmer.
BTW, this mod was for Civilization: Call to Power, it's called Forever Future and it's still pretty wicked. ;

Shameless Self Promotion!  ;D
BTW, I don't think I have that game you very helpful, helpful man.

The more pedantic answer is that the Ruleset files are the data that the openxcom executable reads for all of the objects in the game - items, craft, base facilities, alien geoscape behavior, where to find graphics and sound files, ufopaedia entries, etc.  They provide for a more user-friendly way to change anything that isn't baked directly into the program itself.  If you look at the (path-to-openxcom)/data/Ruleset/Xcom1Ruleset.rul file (or I think it's split into multiple files in standard/xcom1 for the nightly version), you can find most everything that makes X-COM, X-COM, and therefore change practically anything you like.  Adding a mod is basically creating an addendum to this Ruleset file, whether it's changing the size of a map, to deleting everything and building a new game from the ground up.  There are a few things you can't change unless you re-write the source code, like the alien battlescape AI.

For the example of changing the map size, the executable reads the data from a Ruleset file under the heading 'alienDeployments:' for the size of maps generated when you assault a UFO.  Here's the bit for a small scout map:

Code: [Select]
alienDeployments:
  - type: STR_SMALL_SCOUT
    data:
      - alienRank: 5
        lowQty: 1
        highQty: 1
        dQty: 0
        percentageOutsideUfo: 50
        itemSets:
          -
            - STR_PLASMA_PISTOL
            - STR_PLASMA_PISTOL_CLIP
            - STR_PLASMA_PISTOL_CLIP
            - STR_MIND_PROBE
          -
            - STR_PLASMA_RIFLE
            - STR_PLASMA_RIFLE_CLIP
            - STR_PLASMA_RIFLE_CLIP
            - STR_MIND_PROBE
          -
            - STR_HEAVY_PLASMA
            - STR_HEAVY_PLASMA_CLIP
            - STR_MIND_PROBE
    width: 40
    length: 40
    height: 4

In your modded ruleset file, you only need to include what you're changing - here, the width and length of the map.  So an example of that change might look like:

Code: [Select]
alienDeployments:
  - type: STR_SMALL_SCOUT
    width: 80
    length: 80

Thanks you also very helpful man. I'm going to have to take a look at more of those .rul files.

I thought I deleted me asking what the Ruleset was though...  :-[ Now I'm embarrassed cause I made myself look dumb. But thanks for providing examples of the cyntax and formatting. "baked firectly into the program itself" I take it changing the xcom game code is hard?

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Modding this
« Reply #8 on: June 23, 2016, 05:47:13 pm »
In the reference Solarius linked in his first post, items with an attraction: value above 5 will be picked up by the aliens if they don't have a weapon - I don't know specifics of how it works, but I'm guessing as you increase the value, the more likely it becomes the item will be picked up.

Changing the code isn't particularly hard if you know C++, as long as you're either just using the new executable yourself or willing to distribute a compiled version of your new executable with any mod you release that uses it - like OpenXcom Extended and XPiratez.  There are plenty of things you can do with just Ruleset editing, rewriting source codes is for when you hit the limit; once you're more comfortable with modding and want to do something that you can't do in the Nightly versions, you should check out the Extended branch for features you may want to use.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Modding this
« Reply #9 on: June 23, 2016, 08:43:16 pm »
Thanks for the elaboration, Ohartenstein. I was on lunch break and couldn't really write a more thoroughful explanation, so kudos for doing it.

Now, there's one more important advice. Check out this link https://openxcom.org/irc-channel/
This is the IRC channel where openxcom devs often hang around. They are quite helpful, especially with coding. You can try going there if you want an immediate answer or just want to kill some time chatting.

Offline Cerazor

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Modding this
« Reply #10 on: June 24, 2016, 04:54:58 am »
Will do! :)