Weapons with "magic" flag not receiving bonus correctly

Issue #22 closed
drewhershey created an issue

In combat.cc, line 4115 is the following code:

if ((tobj=dynamic_cast<TObj *>(o))) {
    if(tobj->isObjStat(ITEM_MAGIC))
      total=1;

    total = tobj->itemHitroll();
  } else if(!o && doesKnowSkill(SKILL_VOPLAT))
    total=getSkillValue(SKILL_VOPLAT)/15;

  if(total < 1){
    imm_num=vict->getImmunity(IMMUNE_NONMAGIC);
  } else if (total < 2) {
    imm_num=vict->getImmunity(IMMUNE_PLUS1);
  } else if (total < 3) {
    imm_num=vict->getImmunity(IMMUNE_PLUS2);
  } else {
    imm_num=vict->getImmunity(IMMUNE_PLUS3);
  }

This would work if the tobj->itemHitroll() method took the ITEM_MAGIC flag into account, but it doesn't - it only looks for APPLY_HITROLL and APPLY_HITNDAM affects on the item, which are extremely rare. So, by assigning the value of itemHitroll() to total, it's wiping out the bonus for the weapon having the ITEM_MAGIC flag.

I believe the line:

total = tobj->itemHitroll();

should actually be:

total += tobj->itemHitroll();

and that this was just a typo that was never caught.

What it means is that, all these years, items with the ITEM_MAGIC flag (which means they can't have enhance weapon used on them) were being checked against mobs' nonmagic immunity instead of their +1 immunity, if they didn't have any +hitroll or hitndam modifiers - which again, are basically nonexistent on weapons. So weapons that should have been doing damage to nonmagic immune mobs actually weren't.

Comments (4)

  1. Ryan Smith-Roberts

    There are only two items in the database that have the relevant APPLY flags set (Grawg-Yum gnome tenderizer, and big stick), and both of them also have ITEM_MAGIC set. There are a lot of ITEM_MAGIC weapons however (431). There are 443 mobs with nonmagic immunity, 92 with plus1, 39 with plus2, and 28 with plus3. I guess this is where monks really shine, since they're the only ones who can get their total above 2.

    Anyway, I've pushed your change to master, no idea when or if it'll end up at sneezymud.com.

  2. drewhershey reporter

    Yeah, without reviewing the database/code again, I'd guess that many of those 400+ mobs that were immune to nonmagic but not +1 were often killed during groups where it would have been nice for any physical hitters besides voplat monks to contribute damage to the fight.

    Especially since I don't think many monk players took voplat besides those played by people with access to the code (I specifically remember that Angus had it on his monk but was very reticent to give any details as to why). I've talked to several veteran players who were surprised by how good voplat actually is when I described what it does in the code.

  3. Ryan Smith-Roberts

    The term 'immunity' is a misnomer, 'resistance' would be more accurate. Each immunity reduces damage of the appropriate type by a certain builder-specified percentage. Each hitroll bonus point just changes which immunity affects that damage, from NOMAGIC, to PLUS1, etc. In fact, there's no reason a bad builder couldn't create a mob with MORE immunity at PLUS3 than NOMAGIC!

  4. Log in to comment