PDA

View Full Version : new to-hit code to test if you wish...


Armanthuz
01-18-2004, 02:23 AM
After reviewing code and what i wrote i thought id redo and clean up a bit and try to explain more.


Heres WHY i did the changes to original code.

1. Original code used factors such as str/dex/agi which is incorrect.
the only thing that effects chance to hit are levels and weapon
skills.

2. Orginal caps on to hit were way to high/low in relation to live

3. Was not weighting weapon skill enough in chance to hit imho.



Basically in eqlive the following is true regarding to-hit values..

1. Level is the single biggest factor in to-hit rolls.
2. Offense skill and Weapon skill are the only other factors figured.
3. Attack buffs do NOT change it, stats do NOT change it

If the code below is terrible please let me know and perhaps i can give the forms outta here to someone that can code better.

2 known problems are

1. Weapon skill is checked off PRIMARY hand for BOTH weapons.
i THINK this is a bug someplace before my code when it calls
calls for weapon skill.

2. I am using educated guessing on the 35 min cap.



I based my work off some of the following links...

http://www.thesteelwarrior.org/forum/showthread.php?s=07953c8a138ff0bf1c80d68074845f07& threadid=3803


http://www.eqbeastlord.com/forums/viewtopic.php?t=10317



And more pages like that in general...



Anyhow here is the code... Line 156 is starting number in attack.cpp



////////////////////////////////////////////////////////
// To hit calcs go here goes here
////////////////////////////////////////////////////////
#ifdef IPC
if (other->IsNPC() && !other->CastToNPC()->IsInteractive()){
#else
if (other->IsNPC()) {
#endif

int8 chancetohit = 0;
int8 otherlevel = this->GetLevel();
int8 mylevel = other->GetLevel();
otherlevel = otherlevel ? otherlevel : 1;
mylevel = mylevel ? mylevel : 1;
int8 leveldif = (mylevel-otherlevel);

// chance to hit from behind the mob with equal levels should be around 60 percent

chancetohit = 60 + leveldif;

// cap the max/min to 73 percent and 35 percent respectively

if (chancetohit >= 73) {
chancetohit = 73;
}
else if (chancetohit <= 35) {
chancetohit = 35;
}


float tohit_roll = ((float)rand()/RAND_MAX)*100;

// Reposte discipline
if (IsClient() && CastToClient()->disc_inuse == 6) {
damage = -3;
return false;
}

if (tohit_roll > chancetohit){
#if EQDEBUG>=5
LogFile->write(EQEMuLog::Debug, "%s::AvoidDamage(%s) NPC missed %f:%f", GetName(), other->GetName(), tohit_roll, chancetohit);
#endif
damage = 0;
return false;
}
}
else if (other->IsNPC()){
int8 chancetohit = 0;
int8 otherlevel = this->GetLevel();
int8 mylevel = other->GetLevel();
otherlevel = otherlevel ? otherlevel : 1;
mylevel = mylevel ? mylevel : 1;
int8 leveldif = (mylevel-otherlevel);

// chance to hit from behind the mob with equal levels should be around 60 percent

chancetohit = 60 + leveldif;

// cap the max/min to 73 percent and 35 percent respectively


if (chancetohit >= 73) {
chancetohit = 73;
}
else if (chancetohit <= 35) {
chancetohit = 35;
}

float tohit_roll = ((float)rand()/RAND_MAX)*100;
if (tohit_roll > chancetohit){

damage = 0;
return false;
}
}
else if (other->IsClient()){


int8 chancetohit = 0;
int8 otherlevel = this->GetLevel();
int8 mylevel = other->GetLevel();
otherlevel = otherlevel ? otherlevel : 1;
mylevel = mylevel ? mylevel : 1;
int16 skillval = ((float)other->CastToClient()->GetSkill(attack_skill));
int16 offval = ((float)other->CastToClient()->GetSkill(OFFENSE));
int16 combo = (skillval + offval);
int16 leveldif = (mylevel-otherlevel);
int16 skilind = (combo/mylevel);

// Given that levels are equal and given that clients skills are maxxed for his/her level
// this will give very close to a 60 percent chance to hit from behind again.
// skillind is basically an index of how skilled for clients level is he/she.
// this should reflect live behavior in ceratin skill peaks and valleys that happen from 40-50 and 60-65.

chancetohit = (52 + leveldif + skilind);

// The below caps the skills again, in most parses i have seen 73 percent
// was max hit rate against a level 1 by a 65 level char so seems appropriate.


if (chancetohit >= 73) {
chancetohit = 73;
}
else if (chancetohit <= 35) {
chancetohit = 35;
}


///Check if it's a hit or miss

float tohit_roll = ((float)rand()/RAND_MAX)*100;
if (tohit_roll > chancetohit && other->CastToClient()->disc_inuse != 16){

damage = 0;
return false;
}
}
else {
LogFile->write(EQEMuLog::Error, "Unknown entity type: %s", this->GetName());
}



Any feedback is appreciated on this please :)

Armanthuz
01-21-2004, 03:56 AM
changed a bunch of code/info if it helps anyone to read/understand it.

Opinions?


Thought id mention that the above is only when attempting to hit NPC's i think not clients.

If you were attempting to hit a client AGI would have some small effect.

dcl
03-01-2004, 01:57 PM
Hate to bump an old thread, but I would really like to see combat improved.

Is anyone still working on combat enhancements?

As far as Armanthuz's work here... I like it... but if I remember my days on live correctly, I think a 35 min cap is too high. I seem to remember higher level mobs that seemed like I hit only 10-15% of the time.

This code doesn't touch upon damage, but that's something else I would love to see improved, so that AC might finally mean something.

Lastly, how important is it for the combat system to model live? I always thought it was a bad idea in EQLive for stats to have almost no impact on combat... and it seems like we could make a better system, if we don't try to mimic live. However, as this is an emulator... I can certainly understand wanting to maintain live compatability.


EDIT: Ok I found an answer to my last question

http://www.eqemulator.net/forums/viewtopic.php?t=12663

smogo
03-01-2004, 02:18 PM
It's still good to bump old threads. i had missed this one in that time.

I'd test it when i have some time, though i'm not an experienced Eq Live player, so ...

Anyway, as dcl said Lastly, how important is it for the combat system to model live? I always thought it was a bad idea in EQLive for stats to have almost no impact on combat...
This should be left to server ops imho. Some like to model live, others to build a customized world (including game rules).

i humblely suggest writting combat code with parameters, such as #define for the moment, so that it can easily be changed. Setting a AGI_MODIFIER to 0 once in header file is not much work then, and compilers are pretty good at optimising MOD1+MOD2+MOD3 constants, so no overhead ;)

Except for readability, it does not cost to take in account all parameters in the code, even if in the end AGI, DEX, STR ... modifiers are set to 0, as in Live.

'd love to help, but still busy at other things. If you think it's not fair, just P... me off :lol: . T'was just an opinion.

Armanthuz
03-02-2004, 11:34 AM
For those interested in dmg changes, im still messing with this but i posted this before... it needs alot of work yet sadly..


http://www.eqemulator.net/forums/viewtopic.php?p=67979&highlight=#67979

I got equipment AC to work, but got stumped on how to add spell AC to the mix...

Alot of the problem is mobs have no AC or atk ratings in DB, and even if they did this would be an extremely hard thing to guessimate at as you cant exactly parse mobs ac and atks :) Would be real handy from the aspect of individualizing mobs alot thou.


I like to mess with the combat stuff alot, but unfortunately i can be a pro on how eq combat works, and be good at designing stuff but my coding still stinks :)

dcl
03-02-2004, 04:01 PM
Hmmm... I never thought of the fact that we wouldn't have mobs AC/ATK... I would guess that the easiest way to handle this would be to make it a formula

all level 1 mobs have X1 AC/ Y1 ATK
all level 60 mobs have X60 AC/ Y60 ATK


Something like that