Having Some Problems With A Dice Mehcanic
Shoal
04 Feb 2006, 16:33Behold, the code I'm working with:
I always get an Amazing success, Failure, or Critical failure. I have a very bad feeling that Quest isn't reading the "+#" in each "if" statement. If it isn't, I have no idea how to proceed except by removing the %difficulty% variable altogether and doing the math manually for every individual roll. Not cool.
Any help would be greatly appreciated. Please keep in mind I'm a newbie at this. Thanks!
script {
set numeric <muscle; 0> ' This and %melee% would normally be defined a long time ago and wouldn't be here.
set numeric <melee; 0>
set numeric <difficulty; 10>
set numeric <roll; $rand(1;20)$>
set numeric <diffResult; %roll% + %muscle% + %melee%>
if ( %diffResult% >= %difficulty% ) and ( %diffResult% < %difficulty% + 4 ) and ( %roll% < 20 ) then msg <Ordinary success.>
if ( %diffResult% >= %difficulty% + 4 ) and ( %diffResult% < %difficulty% + 8 ) and ( %roll% < 20 ) then msg <Good success!>
if ( %diffResult% >= %difficulty% + 8 ) or ( %roll% = 20 ) then msg <Amazing success!>
if ( %diffResult% < %difficulty% ) and ( %roll% > 1 ) then msg <Failure.>
if ( %roll% = 1 ) then msg <Critical failure!>
}
I always get an Amazing success, Failure, or Critical failure. I have a very bad feeling that Quest isn't reading the "+#" in each "if" statement. If it isn't, I have no idea how to proceed except by removing the %difficulty% variable altogether and doing the math manually for every individual roll. Not cool.
Any help would be greatly appreciated. Please keep in mind I'm a newbie at this. Thanks!
paul_one
04 Feb 2006, 21:55You've hit one thing Quest can't do (I think).
You're doing a comparison AND a computation in one thing.
Plus you have 2 computations in one set <> .
Just have this, and it should work:
So remember:
If's are for comparisons only.
Set's are for one computation only.
... I do, eventually, want to create a function where you can pass a string and it'd do a computation and return a value.. And this would allow for many actions to go through.
I need to think about it though.
You're doing a comparison AND a computation in one thing.
Plus you have 2 computations in one set <> .
Just have this, and it should work:
script {
set numeric <muscle; 0>
set numeric <melee; 0>
set numeric <difficulty; 10>
set numeric <roll; $rand(1;20)$>
set numeric <diffResult; %roll% + %muscle%>
set numeric <diffResult; %diffResult% + %melee%>
set numeric <meddiff; %difficulty% + 4>
set numeric <highdiff; %difficulty% + 8>
' Var's set
if ( %diffResult% >= %difficulty% ) and ( %diffResult% < %meddiff% ) and ( %roll% < 20 ) then msg <Ordinary success.>
if ( %diffResult% >= %meddiff% ) and ( %diffResult% < %highdiff% ) and ( %roll% < 20 ) then msg <Good success!>
if ( %diffResult% >= %highdiff% ) or ( %roll% = 20 ) then msg <Amazing success!>
if ( %diffResult% < %difficulty% ) and ( %roll% > 1 ) then msg <Failure.>
if ( %roll% = 1 ) then msg <Critical failure!>
}
So remember:
If's are for comparisons only.
Set's are for one computation only.
... I do, eventually, want to create a function where you can pass a string and it'd do a computation and return a value.. And this would allow for many actions to go through.
I need to think about it though.
Shoal
04 Feb 2006, 22:19Tr0n wrote:You've hit one thing Quest can't do (I think).
You're doing a comparison AND a computation in one thing.
Plus you have 2 computations in one set <> .
Just have this, and it should work:
Thanks! I'm pretty sure I'm reading your code correctly and understanding the logic behind it. I'm terribly new at programming in general, and have never been good at any sort of math. But I gotta say, having finally sat down and put my mind to programming (even if it's only scripting) is intensely rewarding.
I'll try it out. Anyway, except to be hearing from me again soon -- I still have character creation, combat, and dialogue code to write. I promise I'll go as far as I possibly can in each situation before I bother the forum (no one likes to spoon-feed newbies). :)
EDIT:
Okay, here's how I adapted your code (along with some "upgrades" and simplifications to the mechanic in general):
script {
set numeric <nimble; 0>
set numeric <melee; 0>
set numeric <difficulty; 10>
set numeric <amazing; %difficulty% + 6>
set numeric <critical; %difficulty% - 6>
set numeric <roll; $rand(1;20)$>
set numeric <diffResult; %roll% + %nimble%>
set numeric <diffResult; %diffResult% + %melee%>
if ( %diffResult% >= %difficulty% ) and ( %diffResult% < %amazing% ) and ( %roll% < 20 ) then msg <Success.>
if ( %diffResult% >= %amazing% ) or ( %roll% = 20 ) then msg <Amazing success!>
if ( %diffResult% < %difficulty% ) and ( %diffResult% > %critical% ) and ( %roll% > 1 ) then msg <Failure.>
if ( %diffResult% < %critical% ) or ( %roll% = 1 ) then msg <Critical failure!>
}
I didn't realize that you couldn't put %roll% + %nimble& + %melee% all into one variable. Glad you caught me on that when you did, 'cause that would have stumped me for a while if I started tripping over it. :)
paul_one
04 Feb 2006, 22:31Hehe, no - it's perfectly fine.
I think most programming languages would be fine with it - you'd need to add in ()'s obviously.
Quest just doesn't like more than one computation in a set <> command, which just means more lines of code.
I don't know how to really make it so that you can pass a string either - as using {}'s, or [], or <> wouldn't be allowed. /\'s can't be used as / is devide.
Only alternative is to use something like ^ and &, or | and \.
Anyway, post all you wish - just try not to post annoying posts is all
.
You seem to be grasping the basics just fine.
I think most programming languages would be fine with it - you'd need to add in ()'s obviously.
Quest just doesn't like more than one computation in a set <> command, which just means more lines of code.
I don't know how to really make it so that you can pass a string either - as using {}'s, or [], or <> wouldn't be allowed. /\'s can't be used as / is devide.
Only alternative is to use something like ^ and &, or | and \.
Anyway, post all you wish - just try not to post annoying posts is all

You seem to be grasping the basics just fine.
Shoal
04 Feb 2006, 22:47I edited my previous post -- didn't think you'd reply that fast. :)
paul_one
06 Feb 2006, 10:30Ya..
I do get on at some odd times!
... All seems well in fairy-land. With fluffy bunnies running around, and children playing.
I do get on at some odd times!
... All seems well in fairy-land. With fluffy bunnies running around, and children playing.
GabrielConnor
30 Apr 2007, 09:21Sorry for reviving this old topic but Shoal, your game wouldn't have to do anything with TSR's Alternity Game System, would it?