Not sure this is code used by p1999
eq emulator code i found from q quick search:
http://www.eqemulator.org/forums/showthread.php?t=6100
"// This is a Ranged Weapon Attack / Bow
const Item_Struct* Rangeweapon = 0;
const Item_Struct* Ammo = 0;
Rangeweapon = database.GetItem(pp.inventory[11]);
Ammo = database.GetItem(pp.inventory[21]);
if (!Rangeweapon) {
Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing to throw!", pp.inventory[11]);
break;
}
if (!Ammo) {
Message(0, "Error: Ammo: GetItem(%i)==0, you have nothing to throw!", pp.inventory[11]);
break;
}
uint8 WDmg = Rangeweapon->common.damage;
uint8 ADmg = Ammo->common.damage;
// These dmg formulae were taken from all over the net.
//No-one knows but Verant. This should be fairly close -BoB
// ** ToDO: take into account trueshot disc (x2.0) and
// Archery Mastery AA when they are available.
// I am still looking for 'double' information too.
// Note: Rangers have a chance of crit dmg with a bow (affected by Dex)
uint8 levelBonus = (pp.STR+pp.level+GetSkill(ARCHERY)) / 100;
uint8 MaxDmg = (WDmg+ADmg)*levelBonus;
sint32 TotalDmg = 0;
sint32 critDmg = 0;
if(GetClass()==RANGER)
{
critDmg = (sint32)(MaxDmg * 1.72);
}
if (MaxDmg == 0)
MaxDmg = 1;
TotalDmg = 1 + rand()%MaxDmg;
// TODO: post 50 dmg bonus
// TODO: Tone down the PvP dmg
// borrowed this from attack.cpp
// chance to hit
float chancetohit = GetSkill(ARCHERY) / 3.75;
if (pp.level-target->GetLevel() < 0) {
chancetohit -= (float)((target->GetLevel()-pp.level)*(target->GetLevel()-pp.level))/4;
}
int16 targetagi = target->GetAGI();
int16 playerDex = (int16)(this->itembonuses->DEX + this->spellbonuses->DEX)/2;
targetagi = (targetagi <= 200) ? targetagi:targetagi + ((targetagi-200)/5);
chancetohit -= (float)targetagi*0.05;
chancetohit += playerDex;
chancetohit = (chancetohit > 0) ? chancetohit+30:30;
chancetohit = chancetohit > 95 ? 95 : chancetohit; /* cap to 95% */
// Hit?
if (((float)rand()/RAND_MAX)*100 > chancetohit)
{
this->Message(MT_Emote, "You missed your target");
target->CastToNPC()->Damage(this, 0, 0xffff, 0x07);
}
else
{
// no crits before level 12 cap is maxed
if((GetClass()==RANGER)&&(GetSkill(ARCHERY )>65)&&(rand()%255<(GetSkill(ARCHERY)+ p layerDex)/2)&&(chancetohit > 85))
{
this->Message(MT_Emote, "You score a critical hit!(%d)", critDmg);
target->CastToNPC()->Damage(this, critDmg, 0xffff, 0x07);
}
else
{
this->Message(MT_Emote, "You Hit for a total of %d non-melee damage.", TotalDmg);
target->CastToNPC()->Damage(this, TotalDmg, 0xffff, 0x07);
}
So, from this we see max damage is ..
uint8 WDmg = Rangeweapon->common.damage;
uint8 ADmg = Ammo->common.damage;
// These dmg formulae were taken from all over the net.
//No-one knows but Verant. This should be fairly close -BoB
// ** ToDO: take into account trueshot disc (x2.0) and
// Archery Mastery AA when they are available.
// I am still looking for 'double' information too.
// Note: Rangers have a chance of crit dmg with a bow (affected by Dex)
uint8 levelBonus = (pp.STR+pp.level+GetSkill(ARCHERY)) / 100;
uint8 MaxDmg = (WDmg+ADmg)*levelBonus;
sint32 TotalDmg = 0;
sint32 critDmg = 0;
So, max damage should for a 150 damage bow with dmg. 7 arrows,
(150+7) * lvlBonus, where levelbonus is STR+LEVEL+SKILL/100, so assume a Str of 100, level of 20, and skill of 100, and you get 220/100 = 2 by integer division, so max damage should be
157*2 = 314
Then
if (MaxDmg == 0)
MaxDmg = 1;
TotalDmg = 1 + rand()%MaxDmg;
so, damage done on a noncrit for a 150 damage weapon should be
between 1 and 315...
"