WatchNon-threaded

Forums » Newbie Central » Read Thread

Don't know your Pages from your Links? Stuck in the editor? Find some expert help here.

Variable D6

3 months ago

Is there any way to make the computer do a dice roll like 1D6 but have it replace 1 with a variable? The would really cut down on scripting time if there is.

Variable D6

3 months ago
You can try multiplying 1D6 (or whatever) by 1D6, or by any other already set variable, if that's what you mean.

Look for the article The Basics of Scripting, I think that gives examples of division and multiplication syntax.

Variable D6

2 months ago
What you could do instead is have x number of die roll every page, then just grab their values if needed.
%DIE1 := 1D6
%DIE2 := 1D6
%DIE3 := 1D6
%DIE4 := 1D6
%DIE5 := 1D6

Add more if you ever need more than that many dice rolls, then just grab the values as you need them. Not the most efficient way, but easier than determining where to actually roll dice every time.

Variable D6

2 months ago
I was wondering if I can implement a way to add dice rolls, so for instance,

a 10 sided dice to act as percentages on the players attack.

a 1 would be 10% of attack
a 2 would be 20%
3 would be 30%
and so on.

is this an easily doable thing?

Variable D6

2 months ago
Yep.

%PERCENT := 1D100
%DAMAGE := 0
IF %PERCENT < 76 THEN %DAMAGE := %ATTDMG * 100 / 200
IF %PERCENT < 51 THEN %DAMAGE := %ATTDMG
IF %PERCENT < 26 THEN %DAMAGE := %ATTDMG * 2

25% Miss
25% Half Damage
25% Regular Damage
25% Double Damage

Variable D6

2 months ago
%PERCENT := 1D100
%PLYRATK := 0
IF %PERCENT < 1 THEN %PLYRATK := %PLYRATK * 20 / 200
IF %PERCENT < 11 THEN %PLYRATK := %PLYRATK * 40 / 200
IF %PERCENT < 21 THEN %PLYRATK := %PLYRATK * 60 / 200
IF %PERCENT < 31 THEN %PLYRATK := %PLYRATK * 80 / 200
IF %PERCENT < 41 THEN %PLYRATK := %PLYRATK * 100 / 200
IF %PERCENT < 51 THEN %PLYRATK := %PLYRATK * 120 / 200
IF %PERCENT < 61 THEN %PLYRATK := %PLYRATK * 140 / 200
IF %PERCENT < 71 THEN %PLYRATK := %PLYRATK * 160 / 200
IF %PERCENT < 81 THEN %PLYRATK := %PLYRATK * 180 / 200
IF %PERCENT < 91 THEN %PLYRATK := %PLYRATK * 200 / 200
IF %PERCENT < 99 THEN %PLYRATK := %PLYRATK * 2

This is what I've used, any reason why it would drop the attack to 0 and never change?
I have added this script to the page link where the attack happens, if that helps.

PLYRATK is the variable is use for damage

Variable D6

2 months ago
Zero times any of those numbers is still zero.

Variable D6

2 months ago
to be more specific, PLYRATK is set to 0.

This means that PLRRATK * any percentage/number would result in 0 as well.

Variable D6

2 months ago
%PERCENT := 1D100
%PLYRATK := %PLYRATK
IF %PERCENT < 1 THEN %PLYRATK := %PLYRATK * 20 / 200
IF %PERCENT < 11 THEN %PLYRATK := %PLYRATK * 40 / 200
IF %PERCENT < 21 THEN %PLYRATK := %PLYRATK * 60 / 200
IF %PERCENT < 31 THEN %PLYRATK := %PLYRATK * 80 / 200
IF %PERCENT < 41 THEN %PLYRATK := %PLYRATK * 100 / 200
IF %PERCENT < 51 THEN %PLYRATK := %PLYRATK * 120 / 200
IF %PERCENT < 61 THEN %PLYRATK := %PLYRATK * 140 / 200
IF %PERCENT < 71 THEN %PLYRATK := %PLYRATK * 160 / 200
IF %PERCENT < 81 THEN %PLYRATK := %PLYRATK * 180 / 200
IF %PERCENT < 91 THEN %PLYRATK := %PLYRATK * 200 / 200
IF %PERCENT < 99 THEN %PLYRATK := %PLYRATK * 2

So this would now be correct?

Variable D6

2 months ago
PLYRATK is presumably already set to something, there's no point in matching it to itself so you don't need that line at all.

The rest is probably quickest just to test yourself.

Variable D6

2 months ago
Its set to 10 but then a variable change and script changes change the value

It doesnt seem to work as I thought it would to be honest

Variable D6

2 months ago
So if I'm getting this right, you're trying to get a damage value from the player attack stat?

Maybe you need to make a new variable for the damage output and leave the attack value constant.

Variable D6

2 months ago
Wouldnt I need the damage output and and attack value to be the same?

As the damage that would be dealt, is the attack value.

Variable D6

2 months ago
BZ's example used both.

Variable D6

2 months ago
oh is that a choice? as in 100 or 200

Variable D6

2 months ago
I mean it depends on what you trying to do. But if you can't explain why you're using 200 and before that were multiplying things by zero, I'm guessing you aren't actually doing any of the math on this stuff so really who knows what you end up with.

Variable D6

2 months ago
What I am try to achieve is,

1 x 12 diced dice.

Each face represents a percentage.

rolling a 1 would mean that you miss the attack
rolling a 2 would mean that you attack with 10% of the current attack variable (PLYRATK)
rolling a 3 would mean that you attack with 20% of the current attack variable (PLYRATK)
rolling a 4 would mean that you attack with 30% of the current attack variable (PLYRATK)
rolling a 5 would mean that you attack with 40% of the current attack variable (PLYRATK)
rolling a 6 would mean that you attack with 50% of the current attack variable (PLYRATK)
rolling a 7 would mean that you attack with 60% of the current attack variable (PLYRATK)
rolling a 8 would mean that you attack with 70% of the current attack variable (PLYRATK)
rolling a 9 would mean that you attack with 80% of the current attack variable (PLYRATK)
rolling a 10 would mean that you attack with 90% of the current attack variable (PLYRATK)
rolling a 11 would mean that you attack with 100% of the current attack variable (PLYRATK)
rolling a 12 would mean that you attack with double of the current attack variable (PLYRATK)

So I would assume based on what youve told me I would need something like this:-

%PERCENT := 1D100
%PLYRATK := 0
IF %PERCENT > 99 THEN %PLYRATK := %PLYRATK * 2
IF %PERCENT > 91 THEN %PLYRATK := %PLYRATK * 100 / 100
IF %PERCENT > 81 THEN %PLYRATK := %PLYRATK * 90 / 100
IF %PERCENT > 71 THEN %PLYRATK := %PLYRATK * 80 / 100
IF %PERCENT > 61 THEN %PLYRATK := %PLYRATK * 70 / 100
IF %PERCENT > 51 THEN %PLYRATK := %PLYRATK * 60 / 100
IF %PERCENT > 41 THEN %PLYRATK := %PLYRATK * 50 / 100
IF %PERCENT > 31 THEN %PLYRATK := %PLYRATK * 40 / 100
IF %PERCENT > 21 THEN %PLYRATK := %PLYRATK * 30 / 100
IF %PERCENT > 11 THEN %PLYRATK := %PLYRATK * 20 / 100
IF %PERCENT > 1 THEN %PLYRATK := %PLYRATK * 10 / 100

Variable D6

2 months ago
Oh. Well then I think you're making this needlessly complicated.

%DAMAGE := %1D12
%PLYRATK := (base value)

IF %DAMAGE = 1
THEN
%PLYRATK := 0

IF %DAMAGE = 2
THEN
%PLYRATK := (math to make it 10%)

IF %DAMAGE = 3
THEN
%PLYRATK := (math to make it 20%)


Change the math as needed to get the results you want. I don't think anyone is going to be doing that part for you as it's not a scripting thing, percentages are just normal math.

You'll also of course need to subtract the final result from the hitpoints of whatever it is he player is fighting, which I don't see any indication of at all in your examples here

Variable D6

2 months ago
Oh, so i've been looking at this wrong the whole time. I will work on this and get back to you.

I can also worth out the percentages, I wasnt wanting someone to work it out for me I just wanted to know what the formula would so to speak

Thank you Mizal

Variable D6

2 months ago
...and you're right back to multiplying things by zero, and I'm not sure you understood the other thing I just said.

IF %PERCENT > 1 THEN %PLYRATK := %PLYRATK * 10 / 100

Let's pretend you hadn't nullified every script by setting PLYRATK to zero. This would then be the last thing it's going to be looking at, and so the only thing it will use. Why did you change them all to greater than?

Variable D6

2 months ago
I was trying to make it so if its greater than 1 then it would deal 10% of the PLYRATK value in damage

Variable D6

2 months ago
The results of 1D100 are always going to be either 1 or something greater than 1. You're telling it to do either 10% or zero damage no matter what you roll.

Look at the order of the numbers in Berka's example again.

And stop multiplying things by zero and expecting the result to be higher than that somehow. Numbers don't work that way.

Variable D6

2 months ago
You know what I did read that earlier on 'How to use Random Variables' page but didnt implemetn it. I am stupid you know this so bare with me whilst I learn :)

Variable D6

2 months ago
Okay but if you can't understand why this is a problem:

%PLYRATK := 0
IF %PERCENT > 99 THEN %PLYRATK := %PLYRATK * 2

You need to back way waaay up, all the way to second grade math class. And give the rest of this stuff a break until you get that far.

Variable D6

2 months ago
I'm pretty sure this was explained already but here I go regardless.
You have one too many outputs than your inputs, because setting %PLYRATK to 0 doesn't do anything but nullify all the following percentages. First set %PERCENT := 1D100 to %PERCENT := 1D102

Then, I'd just start with IF %PERCENT = 1 THEN %PLYRATK := %PLYRATK * 0
It'd make your attack miss regardless of what your base attack is.

Then set IF %PERCENT > 1 THEN %PLYRATK := %PLYRATK * 10 / 100

Then go up in increments at 10% until you reach IF %PERCENT > 91 THEN %PLYRATK := %PLYRATK * 100 / 100

Make your final attack bracket as IF %PERCENT > 101 THEN %PLYRATK := %PLYRATK * 2

I also can't remember scripting well enough to specify the tiers so the smaller brackets don't multiply the higher brackets (because 75 is great than 21, 31, 41 etc), fyi. Hope that helps if you wanted to keep your general script.

Variable D6

2 months ago
*greater

Variable D6

2 months ago
it does help thank you for that, I know I'm annoying askng all these questions but its teaching me alot

Variable D6

2 months ago
%PERCENT := 1D102
IF %PERCENT = 1 THEN %PLYRATK := %PLYRATK * 0
IF %PERCENT > 1 THEN %PLYRATK := %PLYRATK * 10 / 100
IF %PERCENT > 11 THEN %PLYRATK := %PLYRATK * 20 / 100
IF %PERCENT > 21 THEN %PLYRATK := %PLYRATK * 30 / 100
IF %PERCENT > 31 THEN %PLYRATK := %PLYRATK * 40 / 100
IF %PERCENT > 41 THEN %PLYRATK := %PLYRATK * 50 / 100
IF %PERCENT > 51 THEN %PLYRATK := %PLYRATK * 60 / 100
IF %PERCENT > 61 THEN %PLYRATK := %PLYRATK * 70 / 100
IF %PERCENT > 71 THEN %PLYRATK := %PLYRATK * 80 / 100
IF %PERCENT > 81 THEN %PLYRATK := %PLYRATK * 90 / 100
IF %PERCENT > 91 THEN %PLYRATK := %PLYRATK * 100 / 100
IF %PERCENT > 101 THEN %PLYRATK := %PLYRATK * 2

I am doing it the way I have been advised to and it's still hitting 0's

Variable D6

2 months ago
....what is %PLYRATK set to?

Variable D6

2 months ago
the variable itself is set to 1, then a page variable change adds 10 to the value (this is done by selecting a class) so thats 11 and then another page variable change adds a further 5 to it (this is done by equiping some starter equipment) which makes a total of 16.

Variable D6

2 months ago
You really do need to have two variables to track this, rather than 1. If you only use 1, then you change it every time you run the script.

For example:

Say you already set the value of %PLYRATK to 16 -- then ran this -- (Note, they system will round to nearest whole number)

%PERCENT := 1D102
IF %PERCENT = 1 THEN %PLYRATK := %PLYRATK * 0 -- %PLYRATK is Zero
IF %PERCENT > 1 THEN %PLYRATK := %PLYRATK * 10 / 100 -- %PLYRATK is 2
IF %PERCENT > 11 THEN %PLYRATK := %PLYRATK * 20 / 100 -- %PLYRATK is 3
IF %PERCENT > 21 THEN %PLYRATK := %PLYRATK * 30 / 100 -- %PLYRATK is 5
IF %PERCENT > 31 THEN %PLYRATK := %PLYRATK * 40 / 100 -- %PLYRATK is 6
IF %PERCENT > 41 THEN %PLYRATK := %PLYRATK * 50 / 100 -- %PLYRATK is 8
IF %PERCENT > 51 THEN %PLYRATK := %PLYRATK * 60 / 100 -- %PLYRATK is 10
IF %PERCENT > 61 THEN %PLYRATK := %PLYRATK * 70 / 100 -- %PLYRATK is 11
IF %PERCENT > 71 THEN %PLYRATK := %PLYRATK * 80 / 100 -- %PLYRATK is 13
IF %PERCENT > 81 THEN %PLYRATK := %PLYRATK * 90 / 100 -- %PLYRATK is 14
IF %PERCENT > 91 THEN %PLYRATK := %PLYRATK * 100 / 100 -- %PLYRATK is 16
IF %PERCENT > 101 THEN %PLYRATK := %PLYRATK * 2 -- %PLYRATK is 32

The very next time you ran it, %PLYRATK is going to have an unknown value of zero to 32. Most likely however, it will be a value less than 16 and would continue to decrease closer to zero each time you ran the script.

A second variable changes this and keeps %PLYRATK set to 16 unless you specifically choose to alter it at some other point. For example, use %ATTACK, %DAMAGE, or the like. Example:

%PERCENT := 1D102
IF %PERCENT = 1 THEN %ATTACK := 0
IF %PERCENT > 1 THEN %ATTACK := %PLYRATK * 10 / 100
IF %PERCENT > 11 THEN %ATTACK := %PLYRATK * 20 / 100
IF %PERCENT > 21 THEN %ATTACK := %PLYRATK * 30 / 100
IF %PERCENT > 31 THEN %ATTACK := %PLYRATK * 40 / 100
IF %PERCENT > 41 THEN %ATTACK := %PLYRATK * 50 / 100
IF %PERCENT > 51 THEN %ATTACK := %PLYRATK * 60 / 100
IF %PERCENT > 61 THEN %ATTACK := %PLYRATK * 70 / 100
IF %PERCENT > 71 THEN %ATTACK := %PLYRATK * 80 / 100
IF %PERCENT > 81 THEN %ATTACK := %PLYRATK * 90 / 100
IF %PERCENT > 91 THEN %ATTACK := %PLYRATK
IF %PERCENT > 101 THEN %ATTACK := %PLYRATK * 2

Variable D6

2 months ago
You guys all use such weirdly complex logic lol.

%BASE := 10
%ROLL := 1D121 - 1
%ATTACKP := %ROLL * 10 / 100

IF %ATTACKP > 10 THEN %DAMAGE := %BASE * 2
ELSE %DAMAGE := %BASE * %ATTACKP/10

Just use this. %DAMAGE is you final attack variable. I guess if you wanted to keep reducing damage each time you could set base to damage to begin with (this would mean you'd speedrun to 0 damage very fast though)

Variable D6

2 months ago
My aim isnt to get it to reduce the damage to 0 and stay at 0 but ill try that and see if it works.

Variable D6

2 months ago
Oh and look at the way you have the numbers arranged versus how Berka did it.

IF %PERCENT < 99 THEN %PLYRATK := %PLYRATK * 2
Is the last thing it evaluates in your version. So all results are going to be the same because they're all less than 99.

Maybe you should just use his example and not alter it so much since y'know I'm pretty sure he has a fair idea of what he's talking about when it comes to scripting.

Variable D6

2 months ago
Berkas example was brilliant, it has helped me understand quite a bit I just thought I could change it to what it slightly but I don't think I can.

Would you recommend swapping them round then? So the higher value is first?

Variable D6

2 months ago
Why are you dividing everything by 200 instead of 100?

Variable D6

2 months ago
I don't know lol, ill change it and try it again

Also, based on what i have made it it doesnt look like it can miss either

Variable D6

2 months ago

Have you tried deleting then remaking the storygame? I've heard that helps sometimes

Variable D6

2 months ago
yes i did that once and made progress actually

Variable D6

2 months ago
What about this?

%DICE := 1D6 (or X)
IF %DICE = 1 THEN %DAMAGE := 1D6
IF %DICE = 2 THEN %DAMAGE := 2D6
IF %DICE = 3 THEN %DAMAGE := 3D6
IF %DICE = 4 THEN %DAMAGE := 4D6
IF %DICE = 5 THEN %DAMAGE := 5D6
IF %DICE = 6 THEN %DAMAGE := 6D6

Variable D6

2 months ago
I do believe there is an issue though with rolling multiple D's. Rather than actually rolling 2D6 for example, it will roll 1D6 and multiply by 2 (meaning you cannot get any odd numbers in that particular roll).

Killa can probably verify if this really is the case though. If it matters to you to have the full range of numbers, then you would want to use this instead of 2D6 etc : 1D6 + 1D6

Variable D6

2 months ago
@Nightwatch can probably take a quick look and find out, but I do remember this coming up in a thread before.

Variable D6

2 months ago
Yeah, reason I suggested the multiple different dice is because I remembered hearing about that specific bug. I can't recall who brought it up last (probably Brad).

Variable D6

2 months ago
Are the Zombie guy and 7thContinent the same person?

Variable D6

2 months ago
nah

Variable D6

2 months ago
Anyway, this has been painful to watch. @The7thContinent fear not, I'm going to fix this problem. 1) First, got to My Stuff >> Storygame and locate the story. 2) Take a shard of glass about four inches long and draw it swiftly five or six times across your reproductive organs. 3) Click 'delete game'. 4) Take a couple aspirin if you like.

Variable D6

2 months ago
cringe