• 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

If-Then-Else Conditional statements

GodPole

Well-known member
I'm trying to set up an automatic adjustment condition related to the Haste spell and hitting a snag when trying to set the new speed.

The way the spell is written, if the target's speed is <30, then the new speed is 2x the old speed.
If the target's speed is 30 or higher, the new speed is 30 + the old speed.

I am trying to use the following script to take care of this:

doneif (state.isoutput <> 0)
doneif (field[pIsOn].value = 0)

hero.child[Attack].field[ModCirc].value = hero.child[Attack].field[ModCirc].value + 1
#applybonus[tACDodge, hero.child[ArmorClass], 1]
#applybonus[vMisc, hero.child[vRef], 1]

if (hero.child[Speed].field[tSpeed].value > 29) then
hero.child[Speed].field[BonEnhance].value = maximum(hero.child[Speed].field[BonEnhance].value, 30)
endif

if (hero.child[Speed].field[tSpeed].value < 30) then
hero.child[Speed].field[BonEnhance].value = maximum(hero.child[Speed].field[BonEnhance].value, hero.child[Speed].field[tSpeedMod].value)
endif


However, no matter what the base speed of the hero is, it always adds 30.
I have been using the floating debug screens to make sure that I am referencing the right fields but no matter how I write this, is is still only applying the +30 conditional and not the 2x conditional. I can understand if my calculations in the <30 scenario are written wrong and thus the hero would receive no bonus, but it ALWAYS reads the >29 conditional as true...which is wrong.

Any ideas on what is going on here?
Thanks!
 
Phase and priority?

For your >29 scenario, you can reduce the typing with this:

Code:
#applybonus[BonEnhance, hero.child[Speed], 30]

Also, for flow control, I'd recommend:

Code:
if ( >= 30) then
  ~>= 30 scenario
else
  ~< 30 scenario
  endif

Oh, and in terms of bonus stacking, the attack bonus in the haste spell isn't assigned a type, so use Bonus rather than ModCirc, and dodge bonuses stack, so use simple addition for those (a dodge field hasn't been added to the ref save, so you'll have to use a generic bonus in that case):

Code:
hero.child[Attack].field[Bonus].value += 1
hero.child[ArmorClass].field[tACDodge].value += 1
hero.child[vRef].field[Bonus].value += 1

That attack bonus needs to be assigned relatively early in order to be incorporated into all the other attack fields, so I'd recommend splitting the script into two - the first, at PreLevel/10000 or so, for the attack/AC/Ref bonuses, the second, at Final/9000 or so, for the speed.
 
Last edited:
I thought of a better way to handle the speed - you want to add in your speed again, but not add more than 30:

Phase: Final, Priority: 9900

Code:
var bonusspeed as number
bonusspeed = minimum(hero.child[Speed].field[tSpeed].value, 30)
#applybonus[BonEnhance, hero.child[Speed], bonusspeed]
For swim, fly, climb, burrow (in the same speed script):

Code:
~start by calculating the swim speed
#value[xSwim] = maximum(#value[xSwim], hero.childfound[xSwim].tagmax[Value.?])
~then add 30 (or the current value)
#value[xSwim] += maximum(30, #value[xSwim])
Duplicate that for xFly, xClimb and xBurrow
 
Phase and priority?
Oh, and in terms of bonus stacking, the attack bonus in the haste spell isn't assigned a type, so use Bonus rather than ModCirc, and dodge bonuses don't stack, so use simple addition for those (a dodge field hasn't been added to the ref save, so you'll have to use a generic bonus in that case):

Dodge bonuses do stack though

From the D20 srd
http://www.d20srd.org/srd/theBasics.htm#dodgeBonus

Dodge Bonus

A dodge bonus improves Armor Class (and sometimes Reflex saves) resulting from physical skill at avoiding blows and other ill effects. Dodge bonuses are never granted by spells or magic items. Any situation or effect (except wearing armor) that negates a character's Dexterity bonus also negates any dodge bonuses the character may have. Dodge bonuses stack with all other bonuses to AC, even other dodge bonuses. Dodge bonuses apply against touch attacks.
 
Last edited:
Oops, I said "don't" rather than "do" - the rest of my explanation is correct for stacking bonuses - simple addition, rather than the #applybonus[] macro.
 
Back
Top