Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Today, 5:42 pm
By Remcon
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
LOP 1.45
Author: Remcon
Submitted by: Remcon
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
Users Online
CommonCrawl, Yahoo!, Sogou

Members: 0
Guests: 14
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » AFKMud Support & Development » Changing Enchant Weapon
Forum Rules | Mark all | Recent Posts

Changing Enchant Weapon
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Dec 12, 2011, 10:09 am   Last edited Dec 12, 2011, 4:52 pm by Kayle
Go to the top of the page
Go to the bottom of the page

Sherm
Fledgling
GroupMembers
Posts33
JoinedDec 20, 2010

So been working on changing the enchant weapon code.

Ran into a snag that I want to add to the existing hit and dam to object. Give a change to add some better effects.

Issue is that it adds a new entry each time for for hit and damage. Not a super programmer I tend to tinker more.

So here is the code I have been working on so far.

This is still a work in progress with debuggin in it to figueout my issues.

SPELLF( spell_enchant_weapon )
{
   obj_data *obj = ( obj_data * ) vo;
   affect_data *paf;
   int enchant_weapon_chance = 0;
   // int objaf;
   
   //if( obj->item_type != ITEM_WEAPON || obj->extra_flags.test( ITEM_MAGIC ) || !obj->affects.empty(  ) )
   if( obj->item_type != ITEM_WEAPON  )
   {
      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;
   }
    // initialize random seed
    srand (time(NULL) );
    
    // generate a number of 1 to 100 and put into enchant_weapon_chance
    
    enchant_weapon_chance = rand () %100 +1; 
    
    if ( enchant_weapon_chance >=1 && enchant_weapon_chance <= 65)
	{
	  enchant_weapon_chance = 1;
	  	  
	}
	
	    
	      if ( enchant_weapon_chance >=66 && enchant_weapon_chance <= 85)
		{
		enchant_weapon_chance = 2;
		}
		else
		{
		  
		  if ( enchant_weapon_chance >=86 && enchant_weapon_chance <= 100)
		  { 
		    enchant_weapon_chance = 3;
		  }
		  else
		    if ( enchant_weapon_chance == 0)
		    {
		      puts ("Error I should not get here";);
		      ch->printf( "You can't find %s!\r\n", target_name.c_str(  ) );
		    }
		
		}
	    
	    
	    
   switch ( enchant_weapon_chance = 1)  // I set this to 1 so i know what I am going to get.
   {
           
     case 1:  
     {
       // I started here to parse the exisitng affects.  
       list < affect_data * >::iterator objaf;
   for( objaf = obj->affects.begin(  ); objaf != obj->affects.end(  ); ++objaf )
   {
      affect_data *af = *objaf;
      
      ch->printf ("affect is %s\r\n",  af );
   }
       
       
	obj->separate(  );
	paf = new affect_data;
	paf->type = -1;
	paf->duration = -1;
	paf->location = APPLY_HITROLL;
	paf->modifier = 1;
	//paf->modifier = level / 15;
	paf->bit = 0;
	obj->affects.push_back( paf );

	paf = new affect_data;
	paf->type = -1;
	paf->duration = -1;
	paf->location = APPLY_DAMROLL;
	paf->modifier = 1;
	//paf->modifier = level / 15;
	paf->bit = 0;
	obj->affects.push_back( paf );
       
	// obj->extra_flags.set( ITEM_MAGIC );

	if( ch->IS_GOOD(  ) )
	{
	    //obj->extra_flags.set( 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( ch->IS_EVIL(  ) )
	{
	    //obj->extra_flags.set( 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
	{
	    //obj->extra_flags.set( ITEM_ANTI_EVIL );
	    //obj->extra_flags.set( 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;
	break;
     }
     case 2:
      obj->separate(  );
	paf = new affect_data;
	paf->type = -1;
	paf->duration = -1;
	paf->location = APPLY_HITROLL;
	paf->modifier = 2;
	//paf->modifier = level / 15;
	paf->bit = 0;
	obj->affects.push_back( paf );

	paf = new affect_data;
	paf->type = -1;
	paf->duration = -1;
	paf->location = APPLY_DAMROLL;
	paf->modifier = 2;
	paf->bit = 0;
	obj->affects.push_back( paf );

	// obj->extra_flags.set( ITEM_MAGIC );

	if( ch->IS_GOOD(  ) )
	{
	    //obj->extra_flags.set( ITEM_ANTI_EVIL );
	    act( AT_BLUE, "$p gleams with flecks of bright blue energy.", ch, obj, NULL, TO_ROOM );
	    act( AT_BLUE, "$p gleams with flecks of bright blue energy.", ch, obj, NULL, TO_CHAR );
	}
	else if( ch->IS_EVIL(  ) )
	{
	    //obj->extra_flags.set( ITEM_ANTI_GOOD );
	    act( AT_BLOOD, "A bright crimson stain flows slowly over $p.", ch, obj, NULL, TO_CHAR );
	    act( AT_BLOOD, "A bright crimson stain flows slowly over $p.", ch, obj, NULL, TO_ROOM );
	}
	else
	{
	    //obj->extra_flags.set( ITEM_ANTI_EVIL );
	    //obj->extra_flags.set( ITEM_ANTI_GOOD );
	    act( AT_YELLOW, "$p glows with a bright disquieting light.", ch, obj, NULL, TO_ROOM );
	    act( AT_YELLOW, "$p glows with a bright disquieting light.", ch, obj, NULL, TO_CHAR );
	}
	return rNONE;
	break;
     
     case 3:
	
       // initialize random seed
	srand (time(NULL) );
	enchant_weapon_chance = 0;
      
      // generate a number of 1 to 100 and put into enchant_weapon_chance
      
      enchant_weapon_chance = rand () %100 +1; 
      
      if ( enchant_weapon_chance >=1 && enchant_weapon_chance <= 74)
	  {
	    enchant_weapon_chance = 1;
	  }
	  

      if ( enchant_weapon_chance >=75 && enchant_weapon_chance <= 100)
	 {
	    enchant_weapon_chance = 2;
	 }
		  

		
	  switch ( enchant_weapon_chance )
	  {
	    case 1:
	      act( AT_MAGIC, "Your magic missfires as it winds around $p, all affects appear gone now.", ch, obj, NULL, TO_CHAR );
	      act( AT_MAGIC, "$n's magic missfires as it winds around $p, all affects appear gone now.", ch, obj, NULL, TO_NOTVICT );  
	    
	      // clear all affect on the item
	      obj->affects.clear( );
	      break;
	    
	    case 2:
		act( AT_MAGIC, "$p glows brightly and then fades away.", ch, obj, NULL, TO_CHAR );
		act( AT_MAGIC, "$n glows brightly and then fades away.", ch, obj, NULL, TO_NOTVICT );
		
		// extract the item here
		obj->extract ();
		break;
	  }
	
		
	return rNONE;
	break;
     
     default:
       return rNONE;
       break;
	
    }   
  }

So looking for a little help.

[Edit by Kayle: Added Code tags for readability.]
       
Post is unread #2 Dec 14, 2011, 12:57 pm   Last edited Dec 14, 2011, 1:05 pm by Sherm
Go to the top of the page
Go to the bottom of the page

Sherm
Fledgling
GroupMembers
Posts33
JoinedDec 20, 2010

to help add to what I want to do.

This is a maul unenchanted.

|Name   : maul huge wooden
|Short  : a huge wooden maul
|Long   : A huge wooden maul rests here.
|Area   : The Keep of Mahn-Tor
|Vnum   :  2383 |Type  :        weapon |Count     : 001 |Gcount: 001
|Number : 01/01 |Weight:     0022/0022 |Wear_loc  :  16 |Layers: 0
|Cost   : 100000 |Ego*  :     -2 |Ego   :      0 |Timer: 0
|In room:     0 |In obj: (NONE) |Level :     27 |Limit:     1
|On map       : (NONE)
|Object Coords: -1 -1
|Wear flags   : take wield
|Extra flags  : 
|Carried by   : keeper minotaur ring-keeper
|Prizeowner   : (NONE)
|Seller       : (NONE)
|Buyer        : (NONE)
|Current bid  : 0
|Scheduled donation date: (NONE)
|Index Values : 12  5  5  6  0  0 12  0  0  0  0
|Object Values: 12  5 25  6  0  0 12  0  0  0  0
|Objprogs     : None

Additional Object information:
Value[0] - Base Condition: 12
Value[1] - Min. Damage: 5
Value[2] - Max Damage: 25
Average Hit: 15
Value[3] - Damage Type (6): pierce
Value[4] - Skill Required (0): Barehand
Value[6] - Current Condition: 12
Condition:  [In Perfect Condition]
Value[7] - Available sockets: 0
Socket 1: None
Socket 2: None
Socket 3: None
The following 3 settings only apply to automatically generated weapons.
Value[8] - Weapon Type (0): Not Defined
Value[9] - Weapon Material (0): Not Defined
Value[10] - Weapon Quality (0): Not Defined


this is what is looks like with the first enchant.

|Long   : A huge wooden maul rests here.
|Area   : The Keep of Mahn-Tor
|Vnum   :  2383 |Type  :        weapon |Count     : 002 |Gcount: 001
|Number : 01/01 |Weight:     0022/0022 |Wear_loc  : -01 |Layers: 0
|Cost   : 100000 |Ego*  :     -2 |Ego   :      0 |Timer: 0
|In room:     0 |In obj: (NONE) |Level :      1 |Limit:     1
|On map       : (NONE)
|Object Coords: -1 -1
|Wear flags   : take wield
|Extra flags  : 
|Carried by   : Snoopy
|Prizeowner   : (NONE)
|Seller       : (NONE)
|Buyer        : (NONE)
|Current bid  : 0
|Scheduled donation date: (NONE)
|Index Values : 12  5  5  6  0  0 12  0  0  0  0
|Object Values: 12  5 25  6  0  0 12  0  0  0  0
|Objprogs     : None

Additional Object information:
Value[0] - Base Condition: 12
Value[1] - Min. Damage: 5
Value[2] - Max Damage: 25
Average Hit: 15
Value[3] - Damage Type (6): pierce
Value[4] - Skill Required (0): Barehand
Value[6] - Current Condition: 12
Condition:  [In Perfect Condition]
Value[7] - Available sockets: 0
Socket 1: None
Socket 2: None
Socket 3: None
The following 3 settings only apply to automatically generated weapons.
Value[8] - Weapon Type (0): Not Defined
Value[9] - Weapon Material (0): Not Defined
Value[10] - Weapon Quality (0): Not Defined

Affects:         hitroll by   1.
Affects:         damroll by   1.


this is what is look like with an addition enchant to it.

|Vnum   :  2383 |Type  :        weapon |Count     : 002 |Gcount: 001
|Number : 01/01 |Weight:     0022/0022 |Wear_loc  : -01 |Layers: 0
|Cost   : 100000 |Ego*  :     -2 |Ego   :      0 |Timer: 0
|In room:     0 |In obj: (NONE) |Level :      1 |Limit:     1
|On map       : (NONE)
|Object Coords: -1 -1
|Wear flags   : take wield
|Extra flags  : 
|Carried by   : Snoopy
|Prizeowner   : (NONE)
|Seller       : (NONE)
|Buyer        : (NONE)
|Current bid  : 0
|Scheduled donation date: (NONE)
|Index Values : 12  5  5  6  0  0 12  0  0  0  0
|Object Values: 12  5 25  6  0  0 12  0  0  0  0
|Objprogs     : None

Additional Object information:
Value[0] - Base Condition: 12
Value[1] - Min. Damage: 5
Value[2] - Max Damage: 25
Average Hit: 15
Value[3] - Damage Type (6): pierce
Value[4] - Skill Required (0): Barehand
Value[6] - Current Condition: 12
Condition:  [In Perfect Condition]
Value[7] - Available sockets: 0
Socket 1: None
Socket 2: None
Socket 3: None
The following 3 settings only apply to automatically generated weapons.
Value[8] - Weapon Type (0): Not Defined
Value[9] - Weapon Material (0): Not Defined
Value[10] - Weapon Quality (0): Not Defined

Affects:         hitroll by   1.
Affects:         damroll by   1.
Affects:         hitroll by   1.
Affects:         damroll by   1


But I want it to look like,



|Name   : maul huge wooden
|Short  : a huge wooden maul
|Long   : A huge wooden maul rests here.
|Area   : The Keep of Mahn-Tor
|Vnum   :  2383 |Type  :        weapon |Count     : 002 |Gcount: 001
|Number : 01/01 |Weight:     0022/0022 |Wear_loc  : -01 |Layers: 0
|Cost   : 100000 |Ego*  :     -2 |Ego   :      0 |Timer: 0
|In room:     0 |In obj: (NONE) |Level :      1 |Limit:     1
|On map       : (NONE)
|Object Coords: -1 -1
|Wear flags   : take wield
|Extra flags  : 
|Carried by   : Snoopy
|Prizeowner   : (NONE)
|Seller       : (NONE)
|Buyer        : (NONE)
|Current bid  : 0
|Scheduled donation date: (NONE)
|Index Values : 12  5  5  6  0  0 12  0  0  0  0
|Object Values: 12  5 25  6  0  0 12  0  0  0  0
|Objprogs     : None

Additional Object information:
Value[0] - Base Condition: 12
Value[1] - Min. Damage: 5
Value[2] - Max Damage: 25
Average Hit: 15
Value[3] - Damage Type (6): pierce
Value[4] - Skill Required (0): Barehand
Value[6] - Current Condition: 12
Condition:  [In Perfect Condition]
Value[7] - Available sockets: 0
Socket 1: None
Socket 2: None
Socket 3: None
The following 3 settings only apply to automatically generated weapons.
Value[8] - Weapon Type (0): Not Defined
Value[9] - Weapon Material (0): Not Defined
Value[10] - Weapon Quality (0): Not Defined

Affects:         hitroll by   2.
Affects:         damroll by   2.


Looking for some advise as what I should do to get that result.
       
Post is unread #3 Dec 20, 2011, 5:14 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

Well what you have to do is go through the current additions on it and look for the one your modifying and then just modify it instead of adding a new one. If it doesn't contain an old one then add a new one sort of thing. In LoP I use
/* Get a previous enchantment to modify */
AFFECT_DATA *has_enchantment( OBJ_DATA *obj, int ench, int mod )
{
   AFFECT_DATA *paf;

   for( paf = obj->first_affect; paf; paf = paf->next )
   {
      if( ( paf->location % REVERSE_APPLY ) == ench && paf->enchantment )
      {
         if( ( paf->location % REVERSE_APPLY ) != APPLY_STAT ) /* If not stat return paf */
            return paf;
         if( xIS_SET( paf->bitvector, mod ) ) /* If stat and is same stat return paf */
            return paf;
      }
   }

   return NULL;
}

That should at least give you an idea of what you need to do. Hope it helps :)
       
Post is unread #4 Dec 22, 2011, 5:45 am
Go to the top of the page
Go to the bottom of the page

Sherm
Fledgling
GroupMembers
Posts33
JoinedDec 20, 2010

Thanks for the help.
       
Pages:<< prev 1 next >>