Here's my first attempt at rewriting the logic in do_hit to accomplish what you want:
Code:
ACMD(do_hit)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
one_argument(argument, arg);
if (!*arg)
send_to_char(ch, "Hit who?\r\n");
else if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "That player is not here.\r\n");
else if (vict == ch) {
send_to_char(ch, "You hit yourself...OUCH!.\r\n");
act("$n hits $mself, and says OUCH!", FALSE, ch, 0, vict, TO_ROOM);
} else if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == vict))
act("$N is just such a good friend, you simply can't hit $M.", FALSE, ch, 0, vict, TO_CHAR);
else {
if (!CONFIG_PK_ALLOWED && !IS_NPC(vict) && !IS_NPC(ch))
check_killer(ch, vict);
if ((GET_POS(ch) == POS_STANDING) && (vict != FIGHTING(ch))) {
if (GET_DEX(ch) > GET_DEX(vict) || (GET_DEX(ch) == GET_DEX(vict) && rand_number(1, 2) == 1)) /* if faster */
hit(ch, vict, TYPE_UNDEFINED); /* first */
else
hit(vict, ch, TYPE_UNDEFINED); /* or the victim is first */
WAIT_STATE(ch, PULSE_VIOLENCE + 2);
+ } else if (GET_POS(ch) == POS_FIGHTING && vict != FIGHTING(ch) && FIGHTING(vict) == ch) {
+ if (GET_SKILL(ch, SKILL_SWITCH) > rand_number(1,95)) {
+ send_to_char(ch, "You switch your target!\r\n");
+ act("$n switches target to $N!", FALSE, ch, 0, vict, TO_ROOM);
+ FIGHTING(ch) = vict;
+ } else {
+ send_to_char(ch, "You failed to switch your target!\r\n");
+ act("$n misses a swing at $N!", FALSE, ch, 0, vict, TO_ROOM);
+ }
} else
send_to_char(ch, "You're fighting the best you can!\r\n");
}
}
This is untested browser code - but it should work.