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.]