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 {
				//