Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Yahoo!

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] Disenchant Weapon spell...
Forum Rules | Mark all | Recent Posts

[Bug] Disenchant Weapon spell is disfunctional at best
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 14, 2007, 9:02 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: Disenchant Weapon spell is disfunctional at best
Danger: Trivial - This spell is not active by default
Found by: Remcon
Fixed by: Samson, Remcon

---

mud.h, item_extra_flags list

Change:
   ITEM_MULTI_INVOKE, MAX_ITEM_FLAG


To:
   ITEM_MULTI_INVOKE, ITEM_ENCHANTED, MAX_ITEM_FLAG


build.c, o_flags array

Change:
   "nolocate", "groundrot", "lootable", "personal", "multi_invoke"


To:
   "nolocate", "groundrot", "lootable", "personal", "multi_invoke", "enchanted"


magic.c, spell_enchant_weapon

Replace the function as follows:
ch_ret spell_enchant_weapon( int sn, int level, CHAR_DATA * ch, void *vo )
{
   OBJ_DATA *obj = ( OBJ_DATA * ) vo;
   AFFECT_DATA *paf;

   if( obj->item_type != ITEM_WEAPON || IS_OBJ_STAT( obj, ITEM_MAGIC ) || IS_OBJ_STAT( obj, ITEM_ENCHANTED ) || obj->first_affect )
   {
      act( AT_MAGIC, "Your magic twists and winds around $p but cannot take hold.", ch, obj, NULL, TO_CHAR );
      act( AT_MAGIC, "$n's magic twists and winds around $p but cannot take hold.", ch, obj, NULL, TO_NOTVICT );
      return rSPELL_FAILED;
   }

   /*
    * Bug fix here. -- Alty 
    */
   separate_obj( obj );
   CREATE( paf, AFFECT_DATA, 1 );
   paf->type = -1;
   paf->duration = -1;
   paf->location = APPLY_HITROLL;
   paf->modifier = level / 15;
   xCLEAR_BITS( paf->bitvector );
   LINK( paf, obj->first_affect, obj->last_affect, next, prev );

   CREATE( paf, AFFECT_DATA, 1 );
   paf->type = -1;
   paf->duration = -1;
   paf->location = APPLY_DAMROLL;
   paf->modifier = level / 15;
   xCLEAR_BITS( paf->bitvector );
   LINK( paf, obj->first_affect, obj->last_affect, next, prev );

   xSET_BIT( obj->extra_flags, ITEM_ENCHANTED );

   if( IS_GOOD( ch ) )
   {
      xSET_BIT( obj->extra_flags, ITEM_ANTI_EVIL );
      act( AT_BLUE, "$p gleams with flecks of blue energy.", ch, obj, NULL, TO_ROOM );
      act( AT_BLUE, "$p gleams with flecks of blue energy.", ch, obj, NULL, TO_CHAR );
   }
   else if( IS_EVIL( ch ) )
   {
      xSET_BIT( obj->extra_flags, ITEM_ANTI_GOOD );
      act( AT_BLOOD, "A crimson stain flows slowly over $p.", ch, obj, NULL, TO_CHAR );
      act( AT_BLOOD, "A crimson stain flows slowly over $p.", ch, obj, NULL, TO_ROOM );
   }
   else
   {
      xSET_BIT( obj->extra_flags, ITEM_ANTI_EVIL );
      xSET_BIT( obj->extra_flags, ITEM_ANTI_GOOD );
      act( AT_YELLOW, "$p glows with a disquieting light.", ch, obj, NULL, TO_ROOM );
      act( AT_YELLOW, "$p glows with a disquieting light.", ch, obj, NULL, TO_CHAR );
   }
   return rNONE;
}


magic.c, spell_disenchant_weapon

Replace the function as follows:
ch_ret spell_disenchant_weapon( int sn, int level, CHAR_DATA * ch, void *vo )
{
   OBJ_DATA *obj = ( OBJ_DATA * ) vo;
   AFFECT_DATA *paf, *paf_next;

   if( obj->item_type != ITEM_WEAPON )
   {
      send_to_char( "You can only disenchant weapons.", ch );
      return rSPELL_FAILED;
   }

   if( !IS_OBJ_STAT( obj, ITEM_ENCHANTED ) || !obj->first_affect )
   {
      send_to_char( "This weapon appears to have no enchantments on it.", ch );
      return rSPELL_FAILED;
   }

   separate_obj( obj );
   for( paf = obj->first_affect; paf; paf = paf->next )
   {
      paf_next = paf->next;
      if( paf->location == APPLY_HITROLL || paf->location == APPLY_DAMROLL )
      {
         UNLINK( paf, obj->first_affect, obj->last_affect, next, prev );
         DISPOSE( paf );
      }
   }

   if( IS_OBJ_STAT( obj, ITEM_ANTI_GOOD ) )
   {
      xREMOVE_BIT( obj->extra_flags, ITEM_ANTI_GOOD );
      act( AT_BLUE, "$p momentarily absorbs all blue light around it.", ch, obj, NULL, TO_CHAR );
   }
   if( IS_OBJ_STAT( obj, ITEM_ANTI_EVIL ) )
   {
      xREMOVE_BIT( obj->extra_flags, ITEM_ANTI_EVIL );
      act( AT_RED, "$p momentarily absorbs all red light around it.", ch, obj, NULL, TO_CHAR );
   }
   successful_casting( get_skilltype( sn ), ch, NULL, obj );
   return rNONE;
}



system/skills.dat

Add the following entry to your skill file:
#SKILL
Name         disenchant weapon~
Type         Spell
Info         0
Flags        0
Target       4
Minpos       112
Mana         100
Rounds       24
Code         spell_disenchant_weapon
Dammsg       ~
Wearoff      !Disenchant Weapon!~
Minlevel     0
End


After rebooting, assign it to whichever classes you wish - FUSS will ship with it assigned to the same classes that get enchant weapon, at the same levels.

Another one of Smaug's mostly finished relics that pops up from time to time. The Disenchant Weapon spell is not actually active in the game by default due to the skill entry being missing in skills.dat.

As written the spell has some problems:

* A memory leak when removing the affects, they are not DISPOSEd.
* The wrong anti-alignment flag is removed from the weapon.
* It has no way to know if you added the ITEM_MAGIC flag in another manner.
* It also has no way to be sure the affects added to it came from an enchantment.
* It will not remove enchantments from a weapon if its prototype has the anti-alignment flags.

To solve the problem of not knowing the origins of the ITEM_MAGIC flag, a new ITEM_ENCHANTED flag needs to be created, with the default intent that it be used to track weapons which have been enchanted by the spell. So in addition to looking for magical affects and the ITEM_MAGIC flag, enchant_weapon had to be modified to check for ITEM_ENCHANTED and apply it during the process. This also preserves the obvious intention that enchant_weapon not be usable to beef up already magical items. Since enchant_weapon did not specifically seek to prevent altering anti-alignment flags if the prototype already had them, it makes no sense to block disenchantment because they do.
       
Pages:<< prev 1 next >>