Writing a basic combat extension for inform 7

I’ve decided that I would like to write a very basic combat extension for I7 that I wish to use for a short game that I have an idea for.

The extension will be based on simple die rolls for a handful of stats like initiative (to determine who attacks first), dexterity (to determine how accurate a strike is e.g. A miss or a critical hit etc.

As a novice I7 author, what would be a good place to start in terms of implimenting this? I figure I should start by implementing the most basic stats first and gradually add things one at a time.

I’ve looked into Kerkerkruip’s source code a bit but its pretty enormous and far more in depth that I wish to implement in my game idea.

Has anyone here had much luck creating or editing an existing extension to serve as a simple dice based combat system for a game using I7.

At the most basic level I would like to have the following flow of combat as the basic building blocks from which to build upon:

  1. Player encounters and enemy.
    -both roll for initiative.
    -highest roll begins combat.
  2. Player/Enemy rolls for damage (random number between 1 and max damage)
  3. Receiving character rolls for defence (random number between 1 and max defence)
  4. Damage roll minus defence roll = Damage inflicted.

With the limited knowledge I have of inform, my guess is I will first need to create definitions for each of the variables such as Damage, Defence, Hit Points, Damage inflicted etc. then create ‘if’ statements to allow the definitions to have meaning?

I have been referencing ‘Lanista 2’ from: 7.5. Combat and Death, however have been having some trouble trying to get the code thats written as an example to work in a fresh I7 project. After removing all commented sections I continuosly get errors regarding improper use of colons and indentations etc. I was hoping to find a very simple, short example of some combat based code to experiment with so I could use it as a base to then build something that I can use for my own game that fits my own purposes.

I apologise for the meandering form that this post has become, I do realise that combat within text based games is extremely uncommon and is probably not the best thing for a beginner to start with, however I have become quite fixated on the idea of creating a simple and engaging combat system for a text based game.

Any advice, references, example code etc. would be really really appreciated and helpful as I currently feel like I’ve done as much searching as I can to still only find a handful of games and I think some fresh eyes might help point me in the right direction.

Thanks!

P.S. I’m not sure if I should be writing this as an extension or simply within the source code to begin with? My guess is that once I have a working and viable source code I can trim out the relevant sections as my ‘combat extension’?

2 Likes

I’m not sure if I should be writing this as an extension or simply within the source code to begin with? My guess is that once I have a working and viable source code I can trim out the relevant sections as my ‘combat extension’?

That sounds like the right approach to me; splitting out an extension first seems like extra hassle, especially when you’re still just trying things out.

I have been referencing ‘Lanista 2’

Also looks like a good place to start! Though Lanista 1 is of course even simpler, and covers the basics that it sounds like you’ll need. (Player stats, random numbers.)

After removing all commented sections I continuosly get errors regarding improper use of colons and indentations etc.

Sounds like you may need to fix the indentation. In particular, Inform 7 typically requires tabs for indentation, but I think some of the online documentation is rendered with spaces. Annoying but not too hard to fix hopefully!

1 Like

Ah thanks! That makes sense about the indentations. I’ll have another look later on when I can get back on my laptop. Lanista seems like a reasonable place to start building off so I’ll try and get the lanista 2 example working correctly and then try and add or change things to suit my needs a bit better.

Cheers

2 Likes

Here are two games with published source code to look toward as examples:

1 Like

Thanks for this, I had already looked at Kerkerkruip in some detail but the overwhelming scale is a bit hard to wade through when you’re only wanting to filter out a few stats and mechanics. On the other hand while I had briefly played Reliques, I was not very taken with it’s combat so I didn’t really think to look at the source code. Having done so now it looks like it could be modified and adjusted to suit a lot of different game styles. The way it shows how dice are defined etc is quite informative so I will be sure to reference this in future.

I need to look into tables as I’m sure that tables would be the beat way to handle various weapons etc with different stats.

1 Like

I’ve decided at this point in time to create the battle system and bug test it with physical dice and referencing spreadsheets until I feel it is at a standard I am happy with and simultaneously will become my project and simply have place holder enemies which will engage in combat however die with a single command with all battling taking place with pen, paper and dice.

It really does seem like this sub genre has not had a lot of love at all which is a bit of shame considering how engaging kerkerkruip’s mechanics are. Personally I find roguelikes aren’t as enjoyable as a more curated game with more structure etc. but I would love to see a more fleshed out rpg with the mechanics of kerkerkruip and an engaging story etc.

I hope this thread remains an open discussion for all things relating to battle mechanics in I7 as it seems that there are quite a few other threads that have never gone far and probably died out due to a lack of interest.

Its a shame a more ‘vanilla’ and stripped down version of ‘attack’ hasn’t made its way into the inform 7 official extensions as I feel this could really encourage a lot of creativity from new authors.

1 Like

I knew there was one I was forgetting: Armed by David Ratliff (written for a previous version of Inform 7; it wouldn’t compile with the modern version without changes).

I think this hasn’t happened 'cause what you’re abstracting how and at what level of granularity stands to be so wildly different between any two conceptions (he says someone who has learned a bazillion RPG combat systems). Also, once you know Inform, it’s fairly straightforward to write such a thing – the harder part is designing the combat system, not the coding – so people haven’t had much incentive to not just start from scratch.

1 Like

You’re absolutely right. It’s the whole reason I figured I had to write my own to suit my needs in the first place. I guess when I refer to ‘vanilla’, I was more meaning the fundamental basic things a combat system would likely have such as health, weapons with variable damage, enemies which engage in combat etc, but either way you would end up having to alter most of the code. Unlike other extensions which handle much more common and general concepts which suit most people’s needs.

At this point I’m just trying to find as many examples as possible to read so I can get a feel for how I should go about writing my own code.

I’m definitely a beginner so even a basic system is quite an undertaking for me at this stage in my learning. I think Ill continue to experiment with the building blocks for building a system within i7, but flesh it out and playtest using pen and paper as to not waste a lot of time on rewriting code every time I wish to improve the system.

2 Likes