Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Trying to make a basic combat system.

So I'm making an RPG type game. I want a basic combat system that subtracts an amount of health from the character based on whether they hit or miss the enemy.

Right now I have:

(set: $health to 30)
Your health is $health

I want the health variable to be lowered during combat, but I don't know how.

Comments

  • We need to know which story format and version of the story format you're using.

    There are several examples of turn based combat systems for Twine floating around out there, and in general, there isn't any shortcut or premade system in Twine for making one, and with good reason: there's just too many potential options and desires to account for.

    This means you'll have to build it yourself, which seems daunting, but in all honesty, is very doable. I suggest you plan your system from the player perspective and try to break it down into its smallest parts, and then work on putting those parts together.

    The code it sounds like you're asking for might look something like this:
    (set: $attack to (either: 'hit', 'miss'))
    <!-- or whatever -->
    
    (if: $attack is 'miss')[
        You missed. The enemy hits you. 
        (set: $health to it - $enemyattack)
    ](else:) [
        You hit the enemy. 
        (set: $enemyhealth to it - $playerdamage)
    ]
    

    This is far from enough for even a simple combat system, though. You'll probably need to check the health of each participant at the top of every passage or something, and use a (goto:) to send the player to either a game over or the victory screen.

    You'll also need links for the user and some sort of output or visuals to track the status of the combatants. You may need a targeting system of some kind if their can be multiple opponents, and you'll need some system for defining and 'loading' enemies so that you aren't rewriting the system for every battle.

    It'll be a lot of work even for a simple system, and you absolutely should ask for help here or at the q&a when you need it, but it's probably best if you read up on the documentation and work on it yourself, and then come back with precise, answerable questions.
Sign In or Register to comment.