I've been working on a pet project, adding Open Gaming mechanics to a base MWSmaug 1.5. One of the things I've done is to add a BAB (Base Attack Bonus) table for each class, and then changed the multi_attack code to reflect the number of attacks based on the BAB bonus of the character (in other words, the skills for each attack are gone.) It works fairly well, except that the way I've reflected the BAB penalty for each successive attack, seems to be leaving the character's hitroll in the negative at times. I tried to apply a negative to the ch->hitroll before the one_hit command, then add it back after.
any suggestions on how to make this penalty reflected in the one_hit and dual_hit (essentially a clone of the one_hit code for the offhand) without a write to the pfile?
ch_ret multi_hit( CHAR_DATA * ch, CHAR_DATA * victim, int dt )
{
int chance;
ch_ret retcode;
<snip down to the important part>
if( get_eq_char( ch, WEAR_DUAL_WIELD ) )
{
retcode = dual_hit( ch, victim, dt );
if( retcode != rNONE || who_fighting( ch ) != victim )
return retcode;
}
/*
* NPC predetermined number of attacks -Thoric
*/
if( IS_NPC( ch ) && ch->numattacks > 0 )
{
for( chance = 0; chance < ch->numattacks; chance++ )
{
retcode = one_hit( ch, victim, dt );
if( retcode != rNONE || who_fighting( ch ) != victim )
return retcode;
}
return retcode;
}
/*
* Change to determine no. of hits by BAB - Kregor
*/
if( BAB_BONUS( ch ) > 5 )
{
ch->hitroll -= 5;
retcode = one_hit( ch, victim, dt );
ch->hitroll += 5;
if( retcode != rNONE || who_fighting( ch ) != victim )
return retcode;
}
if( BAB_BONUS( ch ) > 10 )
{
ch->hitroll -= 10;
retcode = one_hit( ch, victim, dt );
ch->hitroll += 10;
if( retcode != rNONE || who_fighting( ch ) != victim )
return retcode;
}
if( BAB_BONUS( ch ) > 15 )
{
ch->hitroll -= 15;
retcode = one_hit( ch, victim, dt );
ch->hitroll += 15;
if( retcode != rNONE || who_fighting( ch ) != victim )
return retcode;
}
if( get_eq_char( ch, WEAR_DUAL_WIELD ) )
{
if( LEARNED( ch, gsn_improved_two_weapon ) )
{
ch->hitroll -= 5;
retcode = dual_hit( ch, victim, dt );
ch->hitroll += 5;
if( retcode != rNONE || who_fighting( ch ) != victim )
return retcode;
}
}
retcode = rNONE;
chance = IS_NPC( ch ) ? ( int )( ch->level / 2 ) : 0;
if( number_percent( ) < chance )
retcode = one_hit( ch, victim, dt );
if( retcode == rNONE )
{
int move;
if( !IS_AFFECTED( ch, AFF_FLYING ) && !IS_AFFECTED( ch, AFF_FLOATING ) )
move = encumbrance( ch, movement_loss[UMIN( SECT_MAX - 1, ch->in_room->sector_type )] );
else
move = encumbrance( ch, 1 );
if( ch->move )
ch->move = UMAX( 0, ch->move - move );
}
return retcode;
}any suggestions on how to make this penalty reflected in the one_hit and dual_hit (essentially a clone of the one_hit code for the offhand) without a write to the pfile?