## Random Numbers within a Combat System

—Personal Intro—
Any help with the following is highly appreciated. I've been playing around with Squiffy for about two weeks now and fallen in love with it. My level of knowledge is -- I've heard about JS. This is my first post, apologies if I'm posting in the wrong place. Please don't eat me alive.

—The Project—
I'm working on a "high fantasy" gamebook that's high fantasy in the same way the manga/anime Trigun is a western. The story revolves around a bard in a world where bards are basically paparazzi. My aim is to get an action loop that's a little like the original Assassin's Creed.

—The Problem—
The combat system I've developed operates on two opposing score ranges. Strength between 1 and x, where 15 >x>1. And speed where 15>speed>x. So strength might be the range 1 — 10, and speed would therefore be 11 — 15.

I need to be able to generate a random number, "n" between 1 and 20 (including both 1 and 20), and then sort that number into one of three categories: 1) n falls within the range I'm testing; 2) n falls within the opposing range; or 3) n falls between 16 and 20 (including 16 and 20). After that I need to be able to adjust two scores -- stamina and damage -- based on the categorization of the roll.

Any help will be appreciated. Thanks in advance.
-GP

Random:
My advice is to use mrangel's Squiffy version:

``````@set random:n=1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20
``````

If you use javascript, there are several options. (This is a link to a Squiffy forum entry that does a good job explaining javascript random options.)

Once you've got your random numbers, you can control what they do to other varibles with Squiffy `{if` statements.

``````{if n>15:{@stamina+=2}}
``````

Translation: If n is greater that 15, increase stamina two points.

``````{if n>0:{if n<4:{@damage+=1}}}
``````

Translation: If n is between 1 and three, increase damage one point.

I don't understand this: "where 15 >x>1. And speed where 15>speed>x"

@IFforClassroom This is great! Thank you so much, I think this is all I need.

The whole "where 15 >x>1. And speed where 15>speed>x" should have read "where 15 >x>1. And speed where 15>(15 – x)>x". It was maybe a clumsy way of trying to say this:

If strength is the range 1 to 8, then speed is the range 9 to 15. So, on a strength roll does n fall between 1 and 8, or 9 and 15, or 16 and 20?

But you've more than helped me even through the ponderous verbiage. Much appreciated.

Keep in mind, the use of `>` and `<`symbols is a little buggy in Squiffy sometimes.
`>=` and `<=` are less buggy, so that's what I usually use.

This topic is now closed. Topics are closed after 60 days of inactivity.

Quest
Squiffy
ActiveLit

Documentation
Blog
GitHub

Forums