Dice Type Based on Skill

Simulated dice for role playing games
Taharka
Posts: 10
Joined: Sat Mar 27, 2010 1:40 pm
IQ Test: Orange

Dice Type Based on Skill

Post by Taharka » Sat Mar 27, 2010 1:49 pm

Forgive this possibly easy and already answered (I looked, I really did!) question.
I'm playing a Savage Worlds system game, and depending on your skill level, you roll a certain dice type. So if you have one point in the skill, you roll a d4, 2 and you roll a d6, etc.
I'm trying to add a formula to the character sheet so that when you tap the skill, it rolls the appropriate dice type. Either I'm going about it the wrong way, or my syntax is wrong, but I can't get it to work. I'm trying to do it with if - then statements, but if I put

Code: Select all

if @SKILL["level'] = 1 then
   1d+4 \/ 1d+6
end
if @SKILL["level"] = 2 then
  1d+6 \/ 1d+6
end
It never gets past the level 1 roll. If I go with an elseif (instead of end, if), then it rolls every dice combination I put.
Is there a better way to go about this? Perhaps I'm not defining or storing the skill level correctly. Any help would be much appreciated.

Taharka
Posts: 10
Joined: Sat Mar 27, 2010 1:40 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Taharka » Sat Mar 27, 2010 1:50 pm

To add a little bit of info, my skill levels are entered in the character sheet xml as

Code: Select all

<variable id="SKILLS" kind="list" records="skills" title="Skills" height="24">
<string>Name=Guts|Level=0</string>
<string>Name=Healing|Level=0</string>
</variable>
And then the actual skill level is edited in the program.

Then the roll is:

Code: Select all

<list id="Skillsskills" records="skills" height="24" title="Skills" variable="SKILLS">
    <select>
	<formula>
	if @SKILL["level"] = 1 then
		1d+4 \/ 1d+6
	elseif @SKILL["level"] = 2 then
		1d+6 \/ 1d+6
	elseif @SKILL["level"] = 3 then
		1d+8 \/ 1d+6
	elseif @SKILL["level"] = 4 then
		1d+10 \/ 1d+6
	elseif @SKILL["level"] = 5 then
		1d+12 \/ 1d+6
	end
	</formula>
    </select>
</list>
I suspect that I'm not calling the skill level correctly.

gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

Re: Dice Type Based on Skill

Post by gandreas » Sun Mar 28, 2010 10:53 am

First, check out the "What to Roll" article in The Dicenomicon Spellbook (easily access from the help section) to explain why your first attempt rolls boatloads of dice.

One way to approach this problem ("stepped die pools") is to use :next: to compose a roll programmatically and transparently chain to it:

Code: Select all

@1 <- (4,6,8,10,12)[ @SKILL["level"] ].
@2 <- (6,6,6,6,6)[ @SKILL["level"] ].
:next:("", "1d+" - @1 - " \/ 1d+" - @2).
":next:"
(this example has the second die be variable as well - you could just code in 1d+6 into the string literal).

Taharka
Posts: 10
Joined: Sat Mar 27, 2010 1:40 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Taharka » Mon Mar 29, 2010 5:41 pm

Ok... now I'm really confused. I replaced

Code: Select all

	<formula>
	if @SKILL["level"] = 1 then
		1d+4 \/ 1d+6
	elseif @SKILL["level"] = 2 then
		1d+6 \/ 1d+6
	elseif @SKILL["level"] = 3 then
		1d+8 \/ 1d+6
	elseif @SKILL["level"] = 4 then
		1d+10 \/ 1d+6
	elseif @SKILL["level"] = 5 then
		1d+12 \/ 1d+6
	end
	</formula>
With your example

Code: Select all

    
<formula>
@1 <- (4,6,8,10,12)[ @SKILL["level"] ].
    @2 <- (6,6,6,6,6)[ @SKILL["level"] ].
    :next:("", "1d+" - @1 - " \/ 1d+" - @2).
    ":next:"
</formula>
And my ability to set the level of my skills disappeared. I didn't make any other changes, but in the character sheet, there are no longer any circles next to the stat/skill.
If I undo the edit, put it back to my version, then the skill circles comes back. What did I do?

gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

Re: Dice Type Based on Skill

Post by gandreas » Mon Mar 29, 2010 5:58 pm

You have been cursed with the curse of XML.

Using "<-" confuses XML, since the "<" needs to be escaped. As a result, the XML gets confused - if you are running OS X, you can use xmllint to check that for you.

What you really want is to use the LEFTWARDS ARROW (u2190) which you can access in several ways, such as by an input method that allows directly typing in unicode values (which I believe exist under Windows), selection it from the Special Characters panel under OS X (select "All Characters" from the view popup menu, under "Symbols", select "Arrows", and pick the leftwards arrow, or by copying and pasting this: ←

Alternately, you need to escape the "<-" in XML by saying "<-", or use a CDATA section (which is always ugly).

Needless to say, when I first did this, I really wasn't concerned with stuffing formulas into XML...

Taharka
Posts: 10
Joined: Sat Mar 27, 2010 1:40 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Taharka » Mon Mar 29, 2010 6:10 pm

Wonderful! Thank you, that returned my circles. Now next problem... When I click on a skill, it rolls 2d8, no mater what.
Looking at the history, it says:

Code: Select all

@1 ← (4, 6, 8, 10, 12)[@SKILLS["level"]].
@2 ← (6, 6, 6, 6, 6)[@SKILLS["level"]].
:next:("", "1d+" - @1 - "\/ 1d+" - @2).
":next:"; = :next:
d+0 \/ d+0; = 16
Is this because earlier in the xml, I defined the skills as thus:

Code: Select all

<variable id="SKILLS" kind="list" records="skills" title="Skills" height="24">
<string>Name=Guts|Level=0</string>
<string>Name=Healing|Level=0</string>
</variable>
So basically the roll is thinking that each skill is level 0 (why it picks a d8 to roll is beyond me)?

gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

Re: Dice Type Based on Skill

Post by gandreas » Mon Mar 29, 2010 7:24 pm

The problem is that @SKILLS is a list (a list of strings which are structured as a record). @SKILLS["level"] won't do the trick - you need to find the appropriate @SKILLS entry.

If we take a look at a sample (WoD "Mental Skills" entries):

Code: Select all

<list id="mentalskills" records="skills" height="24" title="Mental Skills" variable="MENTALSKILLS">
    <select>
	<formula>@SKILL ← @MENTALSKILLS[#1]. 
	@TITLE ← "\=18="+@SKILL["Name"].
	:next:(@TITLE,"Skill Roll",@SKILL["Name"], @SKILL["Level"], #2, #3, -3).
	":next:"
	</formula>
	<name eval="expr">(@MENTALSKILLS[#1])["Name"] + “Test”</name>
	<parameter name="Stat" style="enum" enums="Int, Wit, Res" default="Int"/>
	<parameter name="Modifiers" style="signed"/>
    </select>
</list>
we see that we can use @MENTALSKILLS[#1] gives us the appropriate entry from the @MENTALSKILLS list (when the user selects the item, #1 contains the index of the item selected - this is also used to get the correct skill name into the list).

Cgeist7
Posts: 9
Joined: Sun May 30, 2010 5:31 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Cgeist7 » Tue Jun 08, 2010 10:45 pm

Hey there,

I am really trying to figure the program out, but am having a difficult time. Will you be posting the Savage Worlds character sheet and roll macros on the shared servers?

Thanks!

CG7

Taharka
Posts: 10
Joined: Sat Mar 27, 2010 1:40 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Taharka » Thu Jun 10, 2010 1:13 pm

So sorry! I haven't been checking this forum since I figured it out. Here's my character sheet for Savage Worlds. This is specifically for Deadlands, but I think it'll work for most Savage Worlds games. I'm now embarking on making a comprehensive 3.5 D&D sheet...
http://www.2shared.com/document/HMiji7eY/Deadlands.html

Taharka
Posts: 10
Joined: Sat Mar 27, 2010 1:40 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Taharka » Thu Jun 10, 2010 1:33 pm

Then for my other rolls, I use favorite rolls. I have
Unskilled, d+4 - 2 v Rd+6 - 2
Damage, d+8 + d+6
Raise Damage, d+8 + d+6 + d+6

At some point, I'll edit the sheet to include a place to add damage to weapons, so you can just click on the weapon name to roll damage.

Cgeist7
Posts: 9
Joined: Sun May 30, 2010 5:31 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Cgeist7 » Thu Jun 10, 2010 3:01 pm

Thanks, Taharka!

This might be a stupid question, but how to I bring the web stuff and formulas into Dicenomicon without having to input them all separately? Are there instructions somewhere?

Cheers!

CG7

Cgeist7
Posts: 9
Joined: Sun May 30, 2010 5:31 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Cgeist7 » Thu Jun 10, 2010 10:08 pm

Okay, not quite the dummy I appear to be, I used the Web-based editor to upload the character sheet. Unfortunately, the stats don't show up and all it rolls for any skill is:

1d+0 V 1d+0

Somethings tells me I've missed something along the way...

Thoughts?

CG7

Cgeist7
Posts: 9
Joined: Sun May 30, 2010 5:31 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Cgeist7 » Thu Jun 10, 2010 10:28 pm

Okay, not quite the dummy I appear to be, I used the Web-based editor to upload the character sheet. Unfortunately, the stats don't show up and all it rolls for any skill is:

1d+0 V 1d+0

Somethings tells me I've missed something along the way... Taharka, is this something you might have corrected on your sheet after you set the upload? It seems like your multiple d8 rolls.

Thoughts?

CG7

jazzman
Honored
Posts: 63
Joined: Mon May 31, 2010 1:13 am
IQ Test: Orange

Re: Dice Type Based on Skill

Post by jazzman » Fri Jun 11, 2010 1:12 pm

I changed the Formula code in the xml file to following and it seems to work.

Code: Select all

<formula>
@SKILL ← @SKILLS[#1].
    @1 ← (4,6,8,10,12)[ @SKILL["Level"] ].
    @2 ← (6,6,6,6,6)[ @SKILL["Level"] ].
    :next:("", "1d+" + @1 + " \/ 1d+" + @2).
    ":next:"
</formula>

Cgeist7
Posts: 9
Joined: Sun May 30, 2010 5:31 pm
IQ Test: Orange

Re: Dice Type Based on Skill

Post by Cgeist7 » Fri Jun 11, 2010 5:48 pm

Okay - I have tried to change the file, but I am still getting the d+0 V d+0.

I am really sorry for this, but if anyone could fix the file so that I can just upload it, it would be great. Balls.

CG7

Post Reply