d20 open ended but uses new die if result of 20... can you h

Simulated dice for role playing games
Post Reply
mediro
Posts: 4
Joined: Mon Mar 11, 2013 12:25 pm
IQ Test: Orange

d20 open ended but uses new die if result of 20... can you h

Post by mediro » Tue Mar 12, 2013 1:39 pm

For new Hackmaster, there is a die roll I wasn't to implement ...

If you get a 20, you then use an open ended d6 from that point on until no longer get a 6... Here is some pseudo code...

Total = dieroll20

If total > 19 then

Do

Total = total + open ended die roll 6

While die roll 6 > 5

End if

Notes:

Does the code accept a standard computer language?

I used the do while concept because I want it to do the loop at least one time

Posted with gandreas software's Web

Tektat04
Honored
Posts: 109
Joined: Mon Sep 15, 2008 12:55 pm

Re: d20 open ended but uses new die if result of 20... can y

Post by Tektat04 » Tue Mar 12, 2013 7:24 pm

Try this:

@1 ← d20 . if @1 = 20 then @1 + d+6 else @1 end

mediro
Posts: 4
Joined: Mon Mar 11, 2013 12:25 pm
IQ Test: Orange

Re: d20 open ended but uses new die if result of 20... can y

Post by mediro » Tue Mar 12, 2013 11:03 pm

Tektat04 wrote:Try this:

@1 ← d20 . if @1 = 20 then @1 + d+6 else @1 end

So far, your suggestion looks like it working! I got a 20 and it rolled a 6 sided die and calculated correctly... I just have not as yet got a follow up 6 on the d6... But looks great so far...

Thanks!!

Do you mind breaking down the code for me so I can understand what the code means? If you have time. This will help me better understand how to code dice rolls... I would REALLY appreciate it.

Actually, I think I might have it... The one thing I'm not sure of is what the period after the d20 is for.

Thanks!

Rrelkon
Posts: 16
Joined: Tue Aug 02, 2011 10:30 am
IQ Test: Orange

Re: d20 open ended but uses new die if result of 20... can y

Post by Rrelkon » Wed Mar 13, 2013 4:47 am

The dot operator separates the two instructions (only the result of the last one is shown on the screen).

Tektat04
Honored
Posts: 109
Joined: Mon Sep 15, 2008 12:55 pm

Re: d20 open ended but uses new die if result of 20... can y

Post by Tektat04 » Wed Mar 13, 2013 7:31 pm

Here the logic.

@1 ← d20 .

Defines a variable called @1. The period at the end is to close off that line of code. In Dicenomicon anything to the left of the period is acted on but not displayed as a result. In dicenomicon both the local and global variable are preceded by the symbol @. I could easily had substituted @1 with @roll.

if @1 = 20 then @1 + d+6 else @1 end

The logic statement goes as follows if variable @1 equals 20 then display the sum of variable @1 and an opened ended d6. Otherwise display variable @1.

RhodeKille
Posts: 1
Joined: Tue Aug 13, 2013 9:49 am
IQ Test: Orange

Re: d20 open ended but uses new die if result of 20... can y

Post by RhodeKille » Tue Aug 13, 2013 9:55 am

That's close, and got me most of the way there, but the first d6 is at -1 as well (since it's the first "penetration" die). The correct formula is:

@1 ← d20 . if @1 = 20 then @1 - 1 + d.+6 else @1 end

BTW - I'm new to the app, but so far I'm loving it. Great job, folks!

Post Reply