PDA

View Full Version : Magic weapon spell effects


realityincarnate
02-24-2009, 09:50 PM
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

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;
}

trevius
02-24-2009, 10:14 PM
Nice work! It is great to see more spell effects get added. And it is nice to see more code submissions too. Welcome back :)

I don't really have the time to test this right now, but hopefully someone can and get it added to the SVN soon if all goes well with the testing.

cavedude
02-26-2009, 12:25 AM
This seems to work great. I'll put it up on TGC and let them have at it before committing. Thanks!