I doubt if anyone will remember me, but I was around about a year ago (primarily did some quest work) before a new job took hold of all my free time. But I decided to jump in again with a fairly minor code revision.
This allows characters under the effect of a magic weapon buff to hit creatures that are immune to nonmagical weapons. To the best of my knowledge, the bard song Magical Monologue is the only spell with this effect, but I thought it might be useful to custom servers as well.
I tested it locally and it seems to work. I also structured it so that the additional buff checks are only made if a magic weapon is not present, so it shouldn't make the server do too much extra work.
.diff file against revision 360
Code:
Index: zone/attack.cpp
===================================================================
--- zone/attack.cpp (revision 360)
+++ zone/attack.cpp (working copy)
@@ -903,8 +903,22 @@
if(against->SpecAttacks[IMMUNE_MELEE_NONMAGICAL]){
if(weapon_item){
- if(weapon_item->GetItem() && weapon_item->GetItem()->Magic){
-
+
+ // check to see if the weapon is magic
+ bool MagicWeapon = false;
+ if(weapon_item->GetItem() && weapon_item->GetItem()->Magic)
+ MagicWeapon = true;
+ else { // if it isn't, check to see if a MagicWeapon buff is active
+ int buffs_i;
+ for (buffs_i = 0; buffs_i < BUFF_COUNT; buffs_i++)
+ if(IsEffectInSpell(buffs[buffs_i].spellid, SE_MagicWeapon)) {
+ MagicWeapon = true;
+ break; // no need to keep looking once we find one
+ }
+ }
+
+ if(MagicWeapon) {
+
if(IsClient() && GetLevel() < weapon_item->GetItem()->RecLevel){
dmg = CastToClient()->CalcRecommendedLevelBonus(GetLevel(), weapon_item->GetItem()->RecLevel, weapon_item->GetItem()->Damage);
}
Index: zone/spell_effects.cpp
===================================================================
--- zone/spell_effects.cpp (revision 360)
+++ zone/spell_effects.cpp (working copy)
@@ -1895,9 +1895,6 @@
#ifdef SPELL_EFFECT_SPAM
snprintf(effect_desc, _EDLEN, "Magic Weapon");
#endif
- // solar: TODO implement this
- const char *msg = "Magic Weapon is not implemented.";
- if(caster) caster->Message(13, msg);
break;
}