Non-fixed damage system


I’m curious about ways to create abilities, attacks, and typical game systems that do damage amounts in certain ranges, but not fixed damage.

For example, if you have a basic attack skill, that does between 1 and 10 damage, a spell that does between 1 and 15 damage, and a healing spell that heals between 1 and 10 damage, is there a way of implementing something like a more traditional party turn-based system with a skill tree?

What have you tried? There’s a *rand command that can be used to generate random numbers. Are you using that?

I’m not entirely sure how that works. I know there are some issues where .rand gets rerolled upon going to the stats screen and am not sure of the best way to implement it that doesn’t make it possible for people to just reroll at an obvious time and always minmax for maximum damage.

Use a page break, then rand, then another page break, then the actual text of whatever you were trying to do. That way, by the time the results of rand are shown to the user, the actual rolling of the dice is already on the previous page.

Easy d10 system might go like this:

*comment here we set up up the variables we need. These can either be created at the beginning of a 
*comment chapter using *temp, in text also using *temp (not recommended) or in your startup file using
*comment the *create command - it depends if you are going to be using them in multiple chapters or just one.
*temp damage 0
*temp enemy_wounds 10
*temp d10_rollA 0
*temp d10_rollB 0
*temp damage_bonus 2

*comment here we use the *rand command to roll a number between 1 and 10 for our two d10s. It is 
*comment important that this is done before either a *page_break or *choice else. If rolls are on the same page as
*comment results then rolls can be remade until the desired result is ontained by flicking back and fourth from the stats screen - a well known choicescript bug.
*rand d10_rollA 1 10
*rand d10_rollB 1 10

*comment the player chooses an action.
    #Shoot a fireball
        *comment a variable called "damage" is used to concatenate dice rolls so it can be used to modify 
        *comment the "enemy_wounds" variable. this is not strictly necessary but it makes things a lot easier if you are 
        *comment doing more complex calculations as per the 2nd and 3rd actions.
        *set damage d10_rollA
        *comment the damage done is displayed using ${damage}
        You do ${damage} damage
        *comment enemy wounds are modified, reducing them by the value of the damage
        *set enemy_wounds - damage
        *goto round2 
    #Shoot a fireball +
        *set damage (d10_rollA + damage_bonus)
        You do ${damage} damage
        *set enemy_wounds - damage
        *goto round2 
    #shoot a MEGA fireball
        *set damage ((d10_rollA + d10_rollB)  + damage_bonus)
        You do ${damage} damage
        *set enemy_wounds - damage
        *goto round2 

*label round2
*comment here we have a check to see if the enemy is dead, sending you to the victory label, else continuing to round 2
*if enemy_wounds <= 0
    *goto victory
    The nasty monster sizes you up and swings its club at you!
    *comment and so on and on

*label victory
You win, woo

It can get a lot more complex than this, but learning the basics will allow you to do a lot of what you want to do, though it requires a lot of coding!

1 Like

Okay, thank you. So far, this makes sense. I just have one further question for you: after the round 2 label, you have the check to check the enemy health. Is there any reason this couldn’t be done with a gosub at the bottom of the file? It seems like since that would have to be checked after every round of combat in every fight, it would be easier to do that as a subroutine rather than checking it manually every time.

Yeah, you can subroutine as much as you can - anything that’s repeatable - i learnt the hard way that it makes things a lot easier.

I now try to subroutine all my random rolls, though I store them in seperate files so I can access them from any chapter, rather than *gosub which would require storing them at the bottom of a file, so I can just do:

*gosub_scene dice_rolls

at the beginning of each round and that rolls all the different *rand dice for my game

You can also use subroutines for your different spells so you could:

*gosub_scene spells fireball

which would call a subroutine which would go to your “spells” page, find the “fireball” *label, rattle off the calculations it finds there then head back to your main file. The advantage to this is you can keep all these spells/actions/whatever in one place and would only have to make one change to change the damage of a fireball across the whole game

1 further semi-related question: Suppose you want to have a series of barks, random lines any 1 of 3 characters might say before their turn.

I assume you’d *create character1_bark “”
character2_bark “”
and character3_bark “”
then a line variable that can be any of the strings,
and character bark line

But what I’m not sure of is how you’d set the line to be a random 1 of several possible lines.

I know that war for the west essentially does something kind of like this.

*create barkroll_char1 0

then *rand barkroll_char1 1 20
then just a bunch of *ifs with if barkroll=1, line, barkroll=2 line… etc. and doing the same for all the other characters?

Have you looked into Multireplace? The documentation here. I’ll admit I haven’t worked with them in awhile (so I’d definitely check the documentation if no one else steps in) but I think they might work, depending on the number of barks you’re working with.

*create bark1 0
*create bark2 0
*create bark3 0

*label start

*rand bark1 0 2
*rand bark2 0 2
*rand bark3 0 2

*comment this should give you three bark options

*comment To avoid that stat_screen bug
Char1 says @{bark1 "Bark text 0" | "Bark text 1" | "Bark text 2"}

Char2 says "@{bark2 "Bark text 0" | "Bark text 1" | "Bark text 2"}

1 Like

@Alice-chan thank you so much. I’ve been playing with this all day and making little modifications. This works beautifully and I deeply appreciate your help.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.