PDA

View Full Version : combat system


beric
04-26-2002, 07:25 PM
I've added and modified some code in the attack.cpp file for EQEmu version 0.3.1. I thought some of you might be interested in it. I put in player and NPC to-hit chance code. I've also changed the formulas for determining damage for both players and NPCs. I've play tested it for several hours and it seems to be pretty close to EQ live. The code is a little sloppy, but this is my first attempt at programming in C.

I'll attach my modified attack.cpp for anybody who wants to compile it and test it out. I found that it worked best if I adjusted the NPCs' max damage to (NPClevel+1)*2.

In mysql type:

use eq
UPDATE npc_types set maxdmg=(level+1)*2;

This worked pretty well for most of the mobs up to about the mid 30's. After that they start to hit for less than on EQ live.

-Beric

beric
04-26-2002, 11:44 PM
Woah!! Noticed a few stupid mistakes. I'll fix em and post a revised version in a bit. But first... sleep

beric
04-27-2002, 08:03 PM
Alright, I'm back. Here's the revised version of my attack.cpp file. I also changed the AC formula to be more accurate. So I've also included the client.h and client.cpp files. Client.cpp contains my version of the GetAC function.

-Beric

Merkur
04-28-2002, 01:56 AM
I've changed already the NPC-Attack dmgformula with for NPCs on CVS. But i'll look into the one you wrote and try to merge good or replace better parts with your work, Thanks anyway for your work :)

Here is the Dmg-formula which is used atm on CVS:

[code][...]

int damage = 0;
int8 otherlevel = other->GetLevel();
if (otherlevel == 0)
otherlevel = 1;
int8 mylevel = this->GetLevel();
if (mylevel == 0)
mylevel = 1;

float dmgbonusmod = 0;
int8 atks = 1;
float clmod = (float)GetClassLevelFactor()/22;
float basedamage = mylevel*3.1f*clmod;
dmgbonusmod += (float)(this->itembonuses->STR + this->spellbonuses->STR)/3;
dmgbonusmod += (float)(this->spellbonuses->ATK + this->itembonuses->ATK)/5;
basedamage += (float)basedamage/100*dmgbonusmod;
float basedefend = (float) 1.118f * sqrt(other->GetAC());
if (mylevel > 54 && CanThisClassDoubleAttack()) {
float DoubleAttackProbability = (250 + mylevel) / 500.0f; // 62.4 max
float random = (float)rand()/RAND_MAX;
if(random < DoubleAttackProbability)
atks *= 2;
}
if (GetEquipment(7) && GetEquipment(8) && GetEquipment(7) && CanThisClassDuelWield ())
atks *= 2;

if (this->ownerid != 0) {
if ((float)rand()/RAND_MAX < 0.2) {
printf("Trying to cast\n");
printf("Trying to cast0\n");
if (this->typeofpet == 1) {
printf("Trying to cast1\n");
this->SpellFinished(893, this->target->GetID(), 10, 0);
}
if (this->typeofpet == 2) {
printf("Trying to cast2\n");
this->SpellFinished(1021, this->target->GetID(), 10, 0);
}
if (this->typeofpet == 3) {
printf("Trying to cast3\n");
this->SpellFinished(1021, this->target->GetID(), 10, 0);
}
if (this->typeofpet == 4) {
printf("Trying to cast4\n");
this->SpellFinished(1021, this->target->GetID(), 10, 0);
}
}
}
/* else if (rand()%100 < 10) {
int16 SpellId = FindSpell(this->class_, this->level, SE_CurrentHP, 1);
if (SpellId != 0) {
this->CastSpell(SpellId,target->GetID());
}
}*/
float currenthit;
/*cout << "Basedamage: " << basedamage<< endl;
cout << "BaseDefend: " << basedefend << endl;
cout << "Bonus: " << (int16)dmgbonusmod << endl;
cout << "mod: " << clmod << endl;*/
for (int ix = 0;ix != atks;ix++){
if(min_dmg != 0 && max_dmg != 0 && min_dmg <= max_dmg)
{
cout << "Damage amount is a database value" << endl;
if (max_dmg == min_dmg)
damage = min_dmg;

else
currenthit = min_dmg + (float)rand()/RAND_MAX*(max_dmg-min_dmg);
}
else
currenthit = (float)basedamage-basedamage/100*25 + (float)rand()/RAND_MAX * basedamage/100*50;
damage = currenthit - (float)basedamage/100*basedefend;
// chance to hit
float chancetohit = 0;
if (mylevel-other->GetLevel() >= 0) {
// 83% (+30) baschance, if target if lower then me
chancetohit = 68;
}
else {
//