• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Math help, pulling number of bon spls from high ability scores.

TobyFox2002

Well-known member
I am in need of a bit of math assistance. I am trying to create a script that calculates the number of spells gained from high ability score (pathfinder core rulebook p 17). I have a number of methods I have tried the past few days and it has gone well except the numbers never seem to add up correctly.

I've tried the cBonusSpl procedure, but it never output useful numbers. Every level of bonus spells came back as 0 (zero). So I abandoned that and am attempting to do it manually.

I tried to do it manually using a for loop, failed, so now I am doing each level of spell individually, which is making for some interesting spaghetti code. I don't need help with the code, per se. Just.. um... the math as it relates to the code.

Everything after debug "Bonus spells awarded for level 2: " & bonSplAtr2, can be ignored. It is not part of the question. It is part of the item I am trying to code. I think I have that in hand. (It is an item that doubles spells, excluding spells from high ability scores). No I cannot use the Hero.Wizardry Tags. But I looked at the code used to create them and that's how I got this far.

Final/15000
Code:
      ~ If not equiped, Get out Now!
      doneif (field[gIsEquip].value = 0)

      ~ If no selection, Get out Now!
      doneif (field[usrChosen1].ischosen = 0)

      var v_level as number
      var v_spells as number
      var v_bonus as number
 ~ bonus spells from attribute, calculated for each level.
      var bonSplAtr1 as number
      var bonSplAtr2 as number
      var bonSplAtr3 as number
      
      v_bonus = field[usrChosen1].chosen.field[cSplAttBon].value
~ call cBonusSpl doesnt do anything, couldn't get the function call to
~ actually do anything useful.
      call cBonusSpl
~ First Level Bonus Spells
    if (hero.tagis[source.HouBonus0] + 1 <> 0) then
      	bonSplAtr1 = v_bonus - 1 + 1
	bonSplAtr1 = round(bonSplAtr1 / 4, 0, 1) 
	bonSplAtr1 = maximum(bonSplAtr1, 0)
        else
            bonSplAtr1 = 0
    endif
~ Second Level Bonus Spells
    if (hero.tagis[source.HouBonus0] + 2 <> 0) then
      	bonSplAtr2 = v_bonus - 2 + 1
	bonSplAtr2 = round(bonSplAtr2 / 4, 0, 1)
	bonSplAtr2 = maximum(bonSplAtr2, 0)
        else
            bonSplAtr2 = 0
    endif
    debug "Bonus spells awarded for level 1: " & bonSplAtr1
    debug "Bonus spells awarded for level 2: " & bonSplAtr2
    
    debug "Name of the Chosen: " & field[usrChosen1].chosen.field[name].text
    debug "Spell Attr Bonus: " & field[usrChosen1].chosen.field[cSplAttBon].value
    debug "Max Spell Level: " &  field[usrChosen1].chosen.field[cSplMaxLvl].value

      for v_level = field[usrChosen1].chosen.field[cSplMinLvl].value to field[usrChosen1].chosen.field[cSplMaxLvl].value

    field[usrChosen1].chosen.field[cMemMax].arrayvalue[v_level] = field[usrChosen1].chosen.field[cMemMax].arrayvalue[v_level] * 2

    field[usrChosen1].chosen.field[cCastMax].arrayvalue[v_level] = field[usrChosen1].chosen.field[cCastMax].arrayvalue[v_level] * 2
     next
 
Back
Top