Lone Wolf Development Forums Having trouble using the ROUND function.
 User Name Remember Me? Password
 Register FAQ Members List Search Today's Posts Mark Forums Read

 Notices 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

 Thread Tools Display Modes
Senior Member

Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 127

December 4th, 2017, 01:12 PM
Im writing an eval script that grants a 5 bonus to base speed. This ability scales with level. The first 5 bonus is granted at 1st level, and then again at every 4 class levels (i.e. 4th, 8th, 12th, etc.)
The script I first came up with was:

field[abValue].value += round(field[xTotalLev].value / 4, 0, -1) + 5

It worked for 1st level (changed 30 speed to 35 speed), but at 4th level the speed became 36. So I changed the script to:

field[abValue].value += round(field[xTotalLev].value / 4, 0, -1) * 5

This worked at all levels except 1st.

Then I thought What if I round up instead of down?:
field[abValue].value += round(field[xTotalLev].value / 4, 0, 1) + 5

This resulted in a +6 movement speed at 1st level.

field[abValue].value += round(field[xTotalLev].value / 4, 0, 1) * 5

This resulted in a 5 increase at 1st level, but no increase at 4th.

What is the magic formula to make this work?
Thanks^7
#1
Senior Member
Lone Wolf Staff

Join Date: May 2005
Posts: 12,396

December 4th, 2017, 01:48 PM
At 1st level, level/4 = 0, but you want to add +5 at 1st level, so you want to add 1 to the total you're calculating, and then multiply it.

Code:
`field[abValue].value += (round(field[xTotalLev].value / 4, 0, -1) + 1) * 5`
#2
Bob G
Senior Member

Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 127

December 4th, 2017, 09:10 PM
Quote:
 Originally Posted by Mathias At 1st level, level/4 = 0, but you want to add +5 at 1st level, so you want to add 1 to the total you're calculating, and then multiply it. Code: `field[abValue].value += (round(field[xTotalLev].value / 4, 0, -1) + 1) * 5`
Yes! That made it work. You guys must work on this a lot
#3
Senior Member

Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 127

December 7th, 2017, 10:31 PM
Another Round function challenge for you all: Ability that grants +1 to perception skill at 3rd level, and gains an additional +1 at 7th, 11th, 15th and 19th levels.

field[abValue].value += round(field[xTotalLev].value-2 / 4, 0, -1) + 1

~Apply bonus to Perception skill
hero.child[skPercep].field[Bonus].value += field[abValue].value

Somehow, the bonus at 3rd level delivers a result of +3. I am baffled as to how it arrived at that result. Any ideas?
#4
Senior Member

Join Date: Mar 2013
Location: Greater London, UK
Posts: 1,794

December 8th, 2017, 12:51 AM
Well, I suspect it is doing 3 - 2 / 4; so that becomes 3 - 0.

You need the field...value - 2 in parentheses so that the minus gets done before the divide.

BODMAS

Farling

Author of the Realm Works Import (http://forums.wolflair.com/showthread.php?t=58156) and Output tools (http://forums.wolflair.com/showthread.php?t=59981)
#5
EightBitz
Senior Member

Join Date: May 2013
Posts: 1,344

December 8th, 2017, 04:13 AM
Quote:
 Originally Posted by Bob G Another Round function challenge for you all: Ability that grants +1 to perception skill at 3rd level, and gains an additional +1 at 7th, 11th, 15th and 19th levels. field[abValue].value += round(field[xTotalLev].value-2 / 4, 0, -1) + 1 ~Apply bonus to Perception skill hero.child[skPercep].field[Bonus].value += field[abValue].value Somehow, the bonus at 3rd level delivers a result of +3. I am baffled as to how it arrived at that result. Any ideas?
I would also put the value you want to round in a variable first. Then round the variable. I've found that to eliminate a lot of issues.

Code:
```var bonus as number
var roundbonus as number

bonus = field[xTotalLev].value-2
roundbonus = round(bonus/4,0,-1) + 1

field[abValue].value += roundbonus

~Apply bonus to Perception skill
hero.child[skPercep].field[Bonus].value += field[abValue].value```
It's a few more lines, but it makes things more readable.
#6

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Lone Wolf Development Web Site Announcements Realm Works Forums     Realm Works Discussion         Realm Works in Action         Realm Works Feature Requests     Realm Works in Action     Realm Works Feature Requests Hero Lab Online Forums     Hero Lab Online Discussion     HLO - Pathfinder Playtest     HLO - Starfinder Hero Lab Forums     HL - Pathfinder Roleplaying Game     HL - D&D 5th Edition SRD     HL - Shadowrun     HL - Mutants & Masterminds     HL - d20 System     HL - World of Darkness     HL - Call of Cthulhu     HL - 4th Edition     HL - Savage Worlds     HL - Cortex System     HL - Authoring Kit     HL - User Projects     HL - Alternity (user-created)     Hero Lab Discussion Army Builder Forums     Army Builder Army Builder Data Files     Babylon 5: A Call to Arms     Battlefleet Gothic     Blood Bowl     Black Powder, Bolt Action, Hail Caesar, Judge Dredd, and Pike & Shotte     Confrontation - English     Kings of War (2nd Edition)     Lord of the Rings (Tabletop)     Mordheim     Necromunda     Starship Troopers     Star Wars: X-Wing and Armada Miniatures Game     The 9th Age     Warhammer Ancient Battles     Warhammer 40,000     Warhammer Fantasy 8th Ed.     Warhammer Historical: The Great War     Warhammer Fantasy 3rd Ed.     Warlord     Warmachine & Hordes     Warmaster Card Vault Forums     Card Vault Card Vault Data Files     MLB Showdown     Lord of the Rings CCG     .hack//ENEMY     Vs. System     Yu-Gi-Oh!     D&D Miniatures

All times are GMT -8. The time now is 04:39 AM.

 -- Default Style -- Majestic Contact Us - Lone Wolf Development Forums - Archive - Top