What the hell is a ruleset anyways?

As a lot of you might have heard, I’ve been working on these mythical things called the rulesets again, but nobody actually seems to have a clear idea of what they’re for. So time for some history.

When I first started OpenXcom, one of the issues I ran into was how to structure all that valuable game logic. Should I just write it all up? Extract it from GEOSCAPE.EXE? Hardcode it in? Load it dynamically? All of it looking like a lot of work.

Then I thought of how the community loves tweaking. Things like XcomUtil and Ufo Extender are really popular by just letting you tweak little things like changing the starting base layout, giving Skyrangers a weapon pod, making Laser weapons more useful, etc. And there’s all those “game modes” people come up with to change things up. It’d be great if I could accomodate all of that easily. So I came up with rulesets.

OpenXcom uses rulesets to define all the game elements. There is a base UFO Ruleset that defines all the countries, crafts, weapons, base facilities, items, aliens, armors, UFOs, etc, etc. Something like this:


---
countries:
- type: STR_AUSTRALIA
fundingMin: 280
fundingMax: 560
labelLon: 2.35619
labelLat: 0.436332
- type: STR_BRAZIL
fundingMin: 300
fundingMax: 600
labelLon: 5.32325
labelLat: 0.0872665
- ...
facilities:
- type: STR_GENERAL_STORES
spriteShape: 1
spriteFacility: 24
lift: false
hyper: false
mind: false
grav: false
size: 1
buildCost: 150000
buildTime: 10
monthlyCost: 5000
storage: 50
- ...
crafts:
- type: STR_SKYRANGER
sprite: 0
fuelMax: 1500
damageMax: 150
speedMax: 760
accel: 2
weapons: 0
soldiers: 14
hwps: 3
cost: 500000
repair: 1
refuel: 50
range: 600
time: 72
score: 200
- ...
...

 

So if you want to tweak something, you just edit it and modify a value or two. But boy, that’d become a real pain to maintain, having to make your own versions of that big old file just to tweak a value or two. So I decided to make them modular, so that you can combine various rulesets as you please, and they only need to have the things that change. So if you wanted to make a super Interceptor that could detect everything and fly really fast, you’d just need this:

---
crafts:
- type: STR_INTERCEPTOR
speedMax: 99999
range: 99999

 

Or a Super Stingray launcher that would fire a million missiles a second:

---
craftWeapons:
- type: STR_STINGRAY
reloadCautious: 1
reloadStandard: 1
reloadAggressive: 1

 

Or a Super Pistol that would nuke the whole map:

---
items:
- type: STR_PISTOL_CLIP
power: 999999
damageType: DT_HE

 

And if you combined it all, you’d get something like this:

6 thoughts on “What the hell is a ruleset anyways?

  1. ufofan

    awesome project – looking great! I’m a gitnub, but had a quick glance at code to add a quick fix sound control key.

    In Game::run() a quick action hack like FPS to increase/decrease volume by 10% on a key down (eg. F1/F2 up/down music, F3/F4 up/down sound). I’d submit a patch but I’m a gitnub and your forum password requirements got the better of me.

    Again, great work on the project!

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.