Go Back   EQEmulator Home > EQEmulator Forums > Support > Spell Support

Spell Support Broken Spells? Want them Fixed? Request it here.

Reply
 
Thread Tools Display Modes
  #1  
Old 10-15-2008, 06:13 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I figured out what the problem was. There is just too much stuff being done with chancetohit at the point that the defense bonuses are calculated to actually set it with a percentage. I set the spell bonus check to do a percentage on the final value of chancetohit.

In attack.cpp remove this line:

Code:
	bonus = defender->spellbonuses.AvoidMeleeChance + defender->itembonuses.AvoidMeleeChance;
And replace it with the line in RED here:
Code:
	//subtract off avoidance by the defender
	bonus = defender->itembonuses.AvoidMeleeChance;
	if(bonus > 0) {
		chancetohit -= (bonus) / 10; //
		mlog(COMBAT__TOHIT, "Applied avoidance chance %.2f/10, yeilding %.2f", bonus, chancetohit);
	}
And then, right above this section at the end of Mob::CheckHitChance:
Code:
	mlog(COMBAT__TOHIT, "Final hit chance: %.2f%%. Hit roll %.2f", chancetohit, tohit_roll);
	
	return(tohit_roll <= chancetohit);
Add the Lines in red:
Code:
	//Reduce final chancetohit by % based on spell bonuses
	bonus = (100 - (defender->spellbonuses.AvoidMeleeChance / 10)) / 100;
	if(bonus > 0) {
		chancetohit *= (bonus);
	}

	mlog(COMBAT__TOHIT, "Final hit chance: %.2f%%. Hit roll %.2f", chancetohit, tohit_roll);
	
	return(tohit_roll <= chancetohit);
I tested this and it looks to work great. Everything works the same as before, accept now spell bonuses that are supposed to reduce hit chance are now factored into the final hit chance as a percentage.

Really, the code that AndMetal posted would probably work great as well if it was just moved to the end of Mob::CheckHitChance instead of being done in the middle of it. Doing it in the middle as a percentage really throws off the rest of the calculations.

I have no idea why "case SE_AvoidMeleeChance:" and "case SE_ProcChance:" are multiplying the spell values by 10, but if there is no other use for them, I think we could remove that multiplier and then remove the "/ 10" from the related code in Mob::CheckHitChance. No reason to do unneeded math 2 times!
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 10-15-2008 at 02:19 PM..
Reply With Quote
  #2  
Old 10-16-2008, 01:43 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by trevius View Post
I have no idea why "case SE_AvoidMeleeChance:" and "case SE_ProcChance:" are multiplying the spell values by 10, but if there is no other use for them, I think we could remove that multiplier and then remove the "/ 10" from the related code in Mob::CheckHitChance. No reason to do unneeded math 2 times!
If I had to guess, I would say it's because we're working with integers, not floats, so there's a fudge factor that we have to deal with: C++ rounds down when storing as an integer. As a result, it's better to work with larger numbers w/o decimals being rounded off, then dividing later where not as much is rounded off. Example:

Avoidance = 1 (from items)
Avoid Melee Chance = 21 (from spells)

The way is/was originally, it would end up being 1 + (20 * 10), so a bonus 211. Then we divide by 10, so 21.1, which gets rounded to 21 (this is our percentage to mitigate).

Using the new code, we would first calculate 1 / 10, which is .1, which rounds to 0. Later, we calculate (100 - (211 / 10)) / 100 which ends up being 0.789, which technically, because it's rounded, ends up providing no bonus, so nothing happens.

That's the main reason I calculated the bonus first, without dividing, then did the "conversion" to a percentage ((100 - bonus) / 100) in the chancetohit calculations, because it won't round until after it stores the result back to chancetohit.

I think what we might want to do is make bonus a float, and that should take care of most of these rounding issues, especially if you have less than 10 Avoidance (although we might have to do some casting for everything to work as expected). Since we're not talking rocket science, we shouldn't need to worry about using a double instead of a float.

However, we're still running into a much larger issue: mitigation isn't a reduction in the chance to land a hit, it's a reduction in the amount of damage done. Unfortunately, if we change it right now, everyone who has +mitigation is going to be hit a lot more often, but for less damage, which will probably mean retuning a lot of content.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #3  
Old 10-16-2008, 06:13 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I changed the way evasive type effects are calculated to be like all other melee effects. Multiplicative not additive.
Reply With Quote
  #4  
Old 10-16-2008, 06:55 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I think that is the way that they should be done. But I also think that may throw off the current combat system considerably. I was mainly just wanting to figure out how to fix the evasive disc without messing with everything else. I imagine with that change, we would probably have to rewrite alot of the chancetohit code to get things more in line with what they should be.

Though, making them multipliers instead of adding them will probably fix miss rates being so high in the high end stuff for NPCs. It also means a pretty major overhaul on all high end encounters to balance them again. I don't think NPCs get any avoidance bonuses like players, so it probably means players will still miss alot.

I will give it a try and see how it feels.

Looked at the code and I think it is missing a dividing factor of 10 for the bonus. 100 avoidance from items should only reduce hit rate by 10%. Also, since spell avoidance is multiplied by 10, Evasive Discipline would be 500. So, I think you can just add the 0 in red below to correct it:

Code:
	//subtract off avoidance by the defender
	bonus = defender->spellbonuses.AvoidMeleeChance + defender->itembonuses.AvoidMeleeChance;
	if(bonus > 0) {
		chancetohit -= ((bonus * chancetohit) / 1000);
		mlog(COMBAT__TOHIT, "Applied avoidance chance %.2f/10, yeilding %.2f", bonus, chancetohit);
	}
I will give this a try maybe tomorrow night. I really need to get a test server running so my players don't suffer while I am testing
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 10-16-2008 at 04:16 PM..
Reply With Quote
Reply

Thread Tools
Display Modes

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 Jump

   

All times are GMT -4. The time now is 02:25 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3