/*
* Here is a littl more complex checking for a Critical Strike, but it checks for misses
* due to code placement and the such. Also allows for improvement and ability.
*
* Valnir - Legend of the Nobles
*
* telnet://play.legendofthenobles.com: 5400
* http://www.legendofthenobles.com
*
* Please feel free to contact me with questions, I will help where I can.
* valnir@legendofthenobles.com
*
*/
/*
* Add in fight.c in 'bool damage' just above the call to dam_message.
*/
/* check for critical hit */
if ( dam >= 10 /* make sure it's a hit worth a critical */
&& dam_type <= 3 /* NOT a backstab */
&& dt >= TYPE_HIT ) /* only non-spell damage */
{
if ( check_critical(ch,victim) )
dam *= 2;
}
/*
* Put this in fight.c and declare it at the top.
* bool check_critical args( ( CHAR_DATA *ch, CHAR_DATA *victim ) );
*
* throw_damage is a fight.c local boolean used in our mud. Please remove the throw check
* or modify to fit your mud.
*
*/
bool check_critical(CHAR_DATA *ch, CHAR_DATA *victim)
{
OBJ_DATA *obj = NULL;
int chance;
/* check for damage from hand-held weapons */
if ( !throw_damage )
{
obj = get_eq_char(ch,WEAR_WIELD);
if (
( ( obj == NULL && get_skill(ch,gsn_hand_to_hand) != 100 ) ||
( obj != NULL && get_weapon_skill(ch,get_weapon_sn(ch)) < 90 ) )
)
return FALSE;
}
else
{
if ( get_skill(ch,gsn_throw) < 90 )
return FALSE;
}
/* mob even get a 1% chance of landing a Critical Hit */
if ( IS_NPC( ch ) )
chance = 1;
else
{
if ( obj == NULL ) /* no weapon? 2% chance for hand to hand */
chance = 2;
else /* increased chance when weapon skill is >= 90% */
chance = 10 - ( 100 - get_weapon_skill( ch, get_weapon_sn( ch ) ) );
if ( IS_IMMORTAL( ch ) ) /* Immortals?? 50% chance, just cause you rock */
chance = 50;
}
if ( number_range(0,100) > chance )
return FALSE; /* check to see if it was your lucky day */
/* Now, if it passed all the tests... */
if ( obj == NULL ) /* you personally strike */
{
act("$n ^cCRITICALLY STRIKES^0 $N!",ch,NULL,victim,TO_NOTVICT);
act("You ^cCRITICALLY STRIKE^0 $N!",ch,NULL,victim,TO_CHAR);
}
else /* your weapon strikes */
act("$p ^cCRITICALLY STRIKES^0 $n!",victim,obj,NULL,TO_NOTVICT);
/* let the victim know they just got a beat down */
act("^cCRITICAL STRIKE!^0",ch,NULL,victim,TO_VICT);
return TRUE;
}