Here we stuff all the bugs we've managed to squash/squish/squelch.
dragon slayer
UOX3 Guru
Posts: 776 Joined: Thu Dec 21, 2006 7:37 am
Has thanked:
4 times
Been thanked:
26 times
Post
by dragon slayer » Fri Dec 16, 2011 6:56 pm
This part of the code seems to fail when server loads up.
I looked though it i can't seem to find the error
function CalcSpellDamage( caster, ourTarg, baseDamage, spellResisted ) { baseDamage = RandomNumber( baseDamage / 2 , baseDamage ) ; if ( spellResisted ) baseDamage = baseDamage / 2 ) ; var casterEval = caster.skills .evaluatingintel / 10 ; var targetResist = ourTarg.skills .magicresistance / 10 ; if ( targetResist > casterEval ) baseDamage *= ( ( ( casterEval - targetResist ) / 200 ) + 1 ) ; else baseDamage *= ( ( ( casterEval - targetResist ) / 500 ) + 1 ) ; int i = RandomNumber( 0 , 4 ) ; if ( i <= 2 ) baseDamage = Math .round ( RandomNumber( RandomNumber( basedamage / 2 , baseDamage ) / 2 , baseDamage ) ) ; else if ( i == 3 ) baseDamage = Math .round ( RandomNumber( baseDamage / 2 , baseDamage ) ; else //keep current damage baseDamage = Math .round ( baseDamage ) ; return baseDamage; }
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Sat Dec 17, 2011 1:45 am
Hm. Possibly because I wrote
int i = 0;
while it should have been
var i = 0;
-= Ho Eyo He Hum =-
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Tue Dec 20, 2011 5:47 am
The actual real culprit was the extra parenthesis at the end of the second line here:
Code: Select all
if( spellResisted )
baseDamage = baseDamage / 2[color=red] )[/color];
That parenthesis should not have been there
...while there _should_ have been one at the end of the second line here:
Code: Select all
else if( i == 3 )
baseDamage = Math.round( RandomNumber( baseDamage / 2, baseDamage )[color=red])[/color];
-= Ho Eyo He Hum =-
John
UOX3 Neophyte
Posts: 32 Joined: Thu Sep 15, 2011 7:41 am
Location: Inside Tom's Brain
Has thanked:
0
Been thanked:
0
Post
by John » Tue Dec 20, 2011 4:12 pm
For some reason I had it in my head that when you do:
if( blah )
{
blah
}
In Javascript do you not need to use brackets in code like C++?
Last edited by
John on Thu Jan 09, 2014 6:15 am, edited 1 time in total.
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Tue Dec 20, 2011 7:29 pm
If there is only one follow-up line it's not required to use the brackets in neither Javascript nor C++. Some people swear to using it always and forever though. Depends on what coding style you prefer.
Personally I drop the brackets when there's only one line after an if or else. So:
Code: Select all
if( blah )
blahblah = blergh;
else if( bluh = green )
{
bleh = green;
bluh = blue;
}
else
Nii!;
-= Ho Eyo He Hum =-
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Mon Mar 19, 2012 3:19 pm
The fix for this is now available in UOX3 0.99, and on the CVS.
-= Ho Eyo He Hum =-