Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Dice roller question (http://forums.wolflair.com/showthread.php?t=16617)

Protector152 January 30th, 2012 01:01 AM

Dice roller question
 
hi, I'm making a data file for Dark Heresy and have run into a _Potential_ challenge. I need to call the dice roller multiple times throughout the character generation process. A List seems to be in order.
i need to roll a

D5 for Wounds.
D10 for Fate
D100 for Divination

and in the future will need 2D10 for characteristic generation (this will only happen AFTER i get the data files in a workable form)

i am assuming that you can call the function from outside the Tac-con, my question is whether you can change what type of dice it rolls on the fly and if so, how?

Thanks for any help,

Regards,

Protector152

Mathias January 30th, 2012 07:16 AM

Let the user enter the results of those rolls, rather than generating the rolls yourself - many people will prefer to roll physical dice for character generation - those who don't can use the dice roller themselves.

Protector152 January 30th, 2012 09:36 PM

I'll implement that as an option. However the group i play with doesn't know much about rolling up characters and we play over the net, hence i want to have the option of semi-/hidden rolls to speed up the process.

Mathias January 30th, 2012 11:04 PM

There aren't any good ways to lock down random number generation in the code, and prevent the user from rolling it again - or prevent the program from rolling it again just because you changed something else and your lockdown code wasn't perfect.

Protector152 January 31st, 2012 03:58 AM

tags can do a lot of things, however most of the stuff i "need" to randomize, (other then starting money, and stat generation) will not be needed until start of play. I appreciate that you want to make this whole process easier for me.

I still want to know how to call the dice roller from within the code, change the type of dice it's rolling on the fly and keep the user from interfering with the process unless they have chosen to roll a semi-random character/use real dice.

Mathias January 31st, 2012 08:19 AM

There is no way to call the diceroller.

The only way to get a random number is to call a random number function - which means that every time you run that script, you will get a new random number.

ikvsabre October 28th, 2017 09:02 PM

Quote:

Originally Posted by Mathias (Post 71932)
There is no way to call the diceroller.

The only way to get a random number is to call a random number function - which means that every time you run that script, you will get a new random number.

If you called the script from a button, and then disabled the button after the roll, wouldn't that prevent the player from re-rolling?

Aaron November 7th, 2017 03:19 PM

You can call it from an action script and then store it in a persistant user field with each button press. Here is an example of a button we use in PF.

Code:


    <portal
      id="actRoll"
      style="actBig">
      <action
        action="trigger">
        <trigger><![CDATA[
          ~make sure we're rolling a valid number of dice
          var iserror as number
          if (herofield[tSCRNumDce].value < 1) then
            iserror = 1
            endif
          if (herofield[tSCRDceSiz].value < 1) then
            iserror = 1
            endif
          if (herofield[tSCRMult].value < 0) then
            iserror = 1
            endif
          if (herofield[tSCROver].value > 0) then
            iserror = 0
            endif

          if (iserror <> 0) then
            notify "Sorry, no starting cash roll has been specified for this class."
            done
            endif

          ~for each die, generate a random number and add it to the total
          var i as number
          var basecoin as number
          for i = 1 to herofield[tSCRNumDce].value
            basecoin += random(herofield[tSCRDceSiz].value) + 1
            next
          basecoin *= herofield[tSCRMult].value
          basecoin += herofield[tSCRBonus].value

          if (herofield[tSCROver].value <> 0) then
            basecoin = herofield[tSCROver].value
            endif

          ~update the starting cash
          ~first reset the existing fields.
          herofield[tStartCP].value = 0
          herofield[tStartSP].value = 0
          herofield[tStartGP].value = 0
          herofield[tStartPP].value = 0

          herofield[tStartCn1].value = 0
          herofield[tStartCn2].value = 0
          herofield[tStartCn3].value = 0
          herofield[tStartCn4].value = 0

          ~ Depending on which slot we have chosen, the base coin differs
          if (hero.childfound[Currency].field[curBaseSlt].value = 8) then
            herofield[tStartCn4].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 7) then
            herofield[tStartCn3].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 6) then
            herofield[tStartCn2].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 5) then
            herofield[tStartCn1].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 4) then
            herofield[tStartPP].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 3) then
            herofield[tStartGP].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 2) then
            herofield[tStartSP].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 1) then
            herofield[tStartCP].value = basecoin
            endif
          ]]></trigger>

        <buttontext><![CDATA[
          ~it's only a "roll" if we don't have a fixed override value for our cash
          if (herofield[tSCROver].value <> 0) then
            @text = "Set Cash"
          else
            @text = "Roll"
            endif
          ]]></buttontext>
        </action>
      </portal>



All times are GMT -8. The time now is 05:25 PM.

Powered by vBulletin® - Copyright ©2000 - 2019, vBulletin Solutions, Inc.
wolflair.com copyright 1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.