User Name:


Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Google

Members: 0
Guests: 8
Newest Member
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Spell dice forumlas ret...
Forum Rules | Mark all | Recent Posts

[Bug] Spell dice forumlas return incorrect results when parsed
< Newer Topic :: Older Topic > AFKMud 1.75

Pages:<< prev 1 next >>
Post is unread #1 Sep 8, 2005, 4:12 pm   Last edited Nov 13, 2005, 11:04 am by Samson
Go to the top of the page
Go to the bottom of the page

Black Hand
JoinedJan 1, 2002

Bug: Spell dice forumlas return incorrect results when parsed. Damage caps do not work.
Discovered in: AFKMud 1.75
Danger: Medium - Returns values outside expected ranges, making some spells far too powerful.
Found by: Too many people to count
Fixed by: Remcon


magic.c, rd_parse

    * get rid of brackets if they surround the entire expresion 
   if( ( *pexp == '(' ) && !index( pexp + 1, '(' ) && pexp[strlen( pexp ) - 1] == ')' )
      pexp[strlen( pexp ) - 1] = '\0';

Change to:
    * get rid of brackets if they surround the entire expresion
   if( ( *pexp == '(' ) && pexp[strlen( pexp ) - 1] == ')' )
      pexp[strlen( pexp ) - 1] = '\0';

At the root of a number of problems in spell/skill dice formulas is the rd_parse function. What it does is take a spell formula, parse the variables, and return a value within the range specified by that formula. Something similar to this:

ld6+(l/2) { 500

A seemingly simple formula, it takes the caster's level, rolls it as that many 6 sided dice. The value of that is then added to half of the caster's level. The left brace indicates this formula wants a cap, and the cap is set to 500, so the most this spell should do in damage is 500 points. The bug in rd_parse would outright ignore any caps, minimums or maximums, so this spell in reality could have become quite devastating and thus provide a huge advantage to the classes that could cast it. Once fixed, the formula does need to be rewritten in proper syntax to acheive the desired result, and should now look like:

(ld6+(l/2)) { 500

Notice that the expression on the left side of the brace is entirely surrounded in parentheses. If this is not done then the cap would only apply to the expression closest to it on the right of an operator, such as +, -, * or /

This bug has been long-standing, very persistant, and dozens of coders have attempted in some way or another to fix it. Often with comically large 100-200+ line rewrites of various portions and whole new wrapper functions around those. Our own coding staff on Alsherok spent months trying to fix this, and it became so frustrating we began jokingly referring to it as "The function whose name shall not be spoken". It was basically treated as evil incarnate. A cancer upon the code. It has quite a history behind it. How ironic that the fix for it would literally be a single line, and only a portion of that single line.
Pages:<< prev 1 next >>