PDA

View Full Version : Fast Random Numbers..



Blackfoot
March 12th, 2019, 03:12
So.. the dice in FG are cool and all.. but is there a way to generate an instant random number to resolve a question in the middle of a script without having to call out for a roll and wait for the result to come back?

Here's what I'm trying to do...
In Champions/HERO System.. any sort of power can have an activation roll.. often times this is used to simulate armor that only works 'some' of the time...
What I'd like to do is be able to make an damage roll against a target and have an effect that gives the target defense with an activation... the activation gets checked and the damage gets applied as normal with or without the extra defense.. with a roll this is going to slow this whole process down and make it a lot more complicated.. if I can just generate an instant random number... then I can ask the question.. get the answer.. spit out a message saying what happened.. and move on.

Hopefully this explanation makes sense.

Moon Wizard
March 12th, 2019, 03:42
There’s a math.random function in Lua to do that. This is how rerolls are handled in 5E ruleset.

Alternately, you could chain rolls if you really wanted the dice simulation (sort of like saves in 5E ruleset); but you would need to maintain state information in the roll structure somehow.

Regards,
JPG

Blackfoot
March 13th, 2019, 07:24
There’s a math.random function in Lua to do that. This is how rerolls are handled in 5E ruleset.

Alternately, you could chain rolls if you really wanted the dice simulation (sort of like saves in 5E ruleset); but you would need to maintain state information in the roll structure somehow.

Regards,
JPG

That worked.. well.. almost.
I ended up creating an extra IF check to include the ACTivation roll.. like this:
IF:ACT(14);rPD:10;rED:10 (this effect allows for resistant physical defense or energy defense to work on a 14 or less)
.. but the IF check gets checked every time any sort effect call is made not just when the specific effect is triggered.. so it works for setting up a random chance that the effect works.. but.. I can't see a way to report it whenever it occurs.. except by passing the results of the check on to the back end and that requires a lot of additional code all over the place. Still.. it does work.
Thanks a lot. :)

Paul Pratt
March 14th, 2019, 05:56
Blackfoot,

In the 40kMultiset I have a similar situation with hit rolls and force fields. Any hit roll needs to check if the target has a force field and therefore a straight chance to miss. I use an effect built into the ruleset such as "REFRACTOR", that comes with a built in 30% chance to miss. When the attack proceeds through the script in manager_attack.lua, I grab the attack result, check if it is a hit, and then check for the miss chance. The miss chance is a separate roll at the end of the chain. It's similar to the auto saves in the D&D rules.

It would be some coding, but I think you should be able to grab the damage result, check for the effect, check if it should be applied, mod the results, and pass that result on. I wish I knew HERO system better, but the basis is so similar. If you are in the mood to code, then check out the 5E saves for sure and maybe the 40K Multiset manager_attack.lua around lines 744-747 and then again at 767-789. The miss chance effects are in manager_actor2.lua around lines 567.


Hope it helps.

Blackfoot
March 14th, 2019, 06:40
While some activation rolls could apply to defenses... others could apply to other things.. pretty much anything... so I was trying to make it more generic by creating an option have it apply to any effect .. and it is .. it just doesn't do all the things I wanted it to do.
But thanks for the suggestion.