📄 fight.c
字号:
if ( dt == TYPE_HIT )
{
sprintf( buf1, "$n %s $N%c", vp, punct );
sprintf( buf2, "You %s $N%c", vs, punct );
sprintf( buf3, "$n %s you%c", vp, punct );
}
else
{
if ( dt >= 0 && dt < MAX_SKILL )
attack = skill_table[dt].noun_damage;
else if ( dt >= TYPE_HIT
&& dt < TYPE_HIT + sizeof(attack_table)/sizeof(attack_table[0]) )
attack = attack_table[dt - TYPE_HIT];
else
{
bug( "Dam_message: bad dt %d.", dt );
dt = TYPE_HIT;
attack = attack_table[0];
}
sprintf( buf1, "$n's %s %s $N%c", attack, vp, punct );
sprintf( buf2, "Your %s %s $N%c", attack, vp, punct );
sprintf( buf3, "$n's %s %s you%c", attack, vp, punct );
}
act( buf1, ch, NULL, victim, TO_NOTVICT );
act( buf2, ch, NULL, victim, TO_CHAR );
act( buf3, ch, NULL, victim, TO_VICT );
return;
}
/*
* Disarm a creature.
* Caller must check for successful attack.
*/
void disarm( CHAR_DATA *ch, CHAR_DATA *victim )
{
OBJ_DATA *obj;
if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
return;
if ( get_eq_char( ch, WEAR_WIELD ) == NULL /*&& number_bits( 1 ) == 0*/ )
return;
act( "$n DISARMS you!", ch, NULL, victim, TO_VICT );
act( "You disarm $N!", ch, NULL, victim, TO_CHAR );
act( "$n DISARMS $N!", ch, NULL, victim, TO_NOTVICT );
obj_from_char( obj );
if ( IS_NPC(victim) )
obj_to_char( obj, victim );
else
obj_to_room( obj, victim->in_room );
return;
}
/*
* Trip a creature.
* Caller must check for successful attack.
*/
void trip( CHAR_DATA *ch, CHAR_DATA *victim )
{
if ( victim->wait == 0 )
{
act( "$n trips you and you go down!", ch, NULL, victim, TO_VICT );
act( "You trip $N and $N goes down!", ch, NULL, victim, TO_CHAR );
act( "$n trips $N and $N goes down!", ch, NULL, victim, TO_NOTVICT );
WAIT_STATE( ch, 2 * PULSE_VIOLENCE );
WAIT_STATE( victim, 2 * PULSE_VIOLENCE );
victim->position = POS_RESTING;
}
return;
}
void do_kill( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Kill whom?\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( !IS_NPC(victim) )
{
if ( !IS_SET(victim->act, PLR_KILLER)
&& !IS_SET(victim->act, PLR_THIEF) )
{
send_to_char( "You must MURDER a player.\n\r", ch );
return;
}
}
else
{
if ( IS_AFFECTED(victim, AFF_CHARM) && victim->master != NULL )
{
send_to_char( "You must MURDER a charmed creature.\n\r", ch );
return;
}
}
if ( victim == ch )
{
send_to_char( "You hit yourself. Ouch!\n\r", ch );
multi_hit( ch, ch, TYPE_UNDEFINED );
return;
}
if ( is_safe( ch, victim ) )
return;
if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
{
act( "$N is your beloved master.", ch, NULL, victim, TO_CHAR );
return;
}
if ( ch->position == POS_FIGHTING )
{
send_to_char( "You do the best you can!\n\r", ch );
return;
}
WAIT_STATE( ch, 1 * PULSE_VIOLENCE );
check_killer( ch, victim );
multi_hit( ch, victim, TYPE_UNDEFINED );
return;
}
void do_murde( CHAR_DATA *ch, char *argument )
{
send_to_char( "If you want to MURDER, spell it out.\n\r", ch );
return;
}
void do_murder( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Murder whom?\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( victim == ch )
{
send_to_char( "Suicide is a mortal sin.\n\r", ch );
return;
}
if ( is_safe( ch, victim ) )
return;
if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
{
act( "$N is your beloved master.", ch, NULL, victim, TO_CHAR );
return;
}
if ( ch->position == POS_FIGHTING )
{
send_to_char( "You do the best you can!\n\r", ch );
return;
}
WAIT_STATE( ch, 1 * PULSE_VIOLENCE );
sprintf( buf, "Help! I am being attacked by %s!", ch->name );
do_shout( victim, buf );
check_killer( ch, victim );
multi_hit( ch, victim, TYPE_UNDEFINED );
return;
}
void do_backstab( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
OBJ_DATA *obj;
if ( !IS_NPC(ch)
&& ch->level < skill_table[gsn_backstab].skill_level[ch->class] )
{
send_to_char(
"You better leave the assassin trade to thieves.\n\r", ch );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Backstab whom?\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( victim == ch )
{
send_to_char( "How can you sneak up on yourself?\n\r", ch );
return;
}
if ( is_safe( ch, victim ) )
return;
if ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) == NULL
|| obj->value[3] != 11 )
{
send_to_char( "You need to wield a piercing weapon.\n\r", ch );
return;
}
if ( victim->fighting != NULL )
{
send_to_char( "You can't backstab a fighting person.\n\r", ch );
return;
}
if ( victim->hit < victim->max_hit )
{
act( "$N is hurt and suspicious ... you can't sneak up.",
ch, NULL, victim, TO_CHAR );
return;
}
check_killer( ch, victim );
WAIT_STATE( ch, skill_table[gsn_backstab].beats );
if ( !IS_AWAKE(victim)
|| IS_NPC(ch)
|| number_percent( ) < ch->pcdata->learned[gsn_backstab] )
multi_hit( ch, victim, gsn_backstab );
else
damage( ch, victim, 0, gsn_backstab );
return;
}
void do_flee( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *was_in;
ROOM_INDEX_DATA *now_in;
CHAR_DATA *victim;
int attempt;
if ( ( victim = ch->fighting ) == NULL )
{
if ( ch->position == POS_FIGHTING )
ch->position = POS_STANDING;
send_to_char( "You aren't fighting anyone.\n\r", ch );
return;
}
was_in = ch->in_room;
for ( attempt = 0; attempt < 6; attempt++ )
{
EXIT_DATA *pexit;
int door;
door = number_door( );
if ( ( pexit = was_in->exit[door] ) == 0
|| pexit->to_room == NULL
|| IS_SET(pexit->exit_info, EX_CLOSED)
|| ( IS_NPC(ch)
&& ( IS_SET(pexit->to_room->room_flags, ROOM_NO_MOB)
|| ( IS_SET(ch->act, ACT_STAY_AREA)
&& pexit->to_room->area != ch->in_room->area ) ) ) )
continue;
move_char( ch, door );
if ( ( now_in = ch->in_room ) == was_in )
continue;
ch->in_room = was_in;
act( "$n has fled!", ch, NULL, NULL, TO_ROOM );
ch->in_room = now_in;
if ( !IS_NPC(ch) )
{
send_to_char( "You flee from combat! You lose 25 exps.\n\r", ch );
gain_exp( ch, -25 );
}
stop_fighting( ch, TRUE );
return;
}
send_to_char( "You failed! You lose 10 exps.\n\r", ch );
gain_exp( ch, -10 );
return;
}
void do_rescue( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
CHAR_DATA *fch;
if ( !IS_NPC(ch)
&& ch->level < skill_table[gsn_rescue].skill_level[ch->class] )
{
send_to_char(
"You better leave the heroic acts to warriors.\n\r", ch );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Rescue whom?\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( victim == ch )
{
send_to_char( "What about fleeing instead?\n\r", ch );
return;
}
if ( !IS_NPC(ch) && IS_NPC(victim) )
{
send_to_char( "Doesn't need your help!\n\r", ch );
return;
}
if ( ch->fighting == victim )
{
send_to_char( "Too late.\n\r", ch );
return;
}
if ( ( fch = victim->fighting ) == NULL )
{
send_to_char( "That person is not fighting right now.\n\r", ch );
return;
}
WAIT_STATE( ch, skill_table[gsn_rescue].beats );
if ( !IS_NPC(ch) && number_percent( ) > ch->pcdata->learned[gsn_rescue] )
{
send_to_char( "You fail the rescue.\n\r", ch );
return;
}
act( "You rescue $N!", ch, NULL, victim, TO_CHAR );
act( "$n rescues you!", ch, NULL, victim, TO_VICT );
act( "$n rescues $N!", ch, NULL, victim, TO_NOTVICT );
stop_fighting( fch, FALSE );
stop_fighting( victim, FALSE );
check_killer( ch, fch );
set_fighting( ch, fch );
set_fighting( fch, ch );
return;
}
void do_kick( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
if ( !IS_NPC(ch)
&& ch->level < skill_table[gsn_kick].skill_level[ch->class] )
{
send_to_char(
"You better leave the martial arts to fighters.\n\r", ch );
return;
}
if ( ( victim = ch->fighting ) == NULL )
{
send_to_char( "You aren't fighting anyone.\n\r", ch );
return;
}
WAIT_STATE( ch, skill_table[gsn_kick].beats );
if ( IS_NPC(ch) || number_percent( ) < ch->pcdata->learned[gsn_kick] )
damage( ch, victim, number_range( 1, ch->level ), gsn_kick );
else
damage( ch, victim, 0, gsn_kick );
return;
}
void do_disarm( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
OBJ_DATA *obj;
int percent;
if ( !IS_NPC(ch)
&& ch->level < skill_table[gsn_disarm].skill_level[ch->class] )
{
send_to_char( "You don't know how to disarm opponents.\n\r", ch );
return;
}
if ( get_eq_char( ch, WEAR_WIELD ) == NULL )
{
send_to_char( "You must wield a weapon to disarm.\n\r", ch );
return;
}
if ( ( victim = ch->fighting ) == NULL )
{
send_to_char( "You aren't fighting anyone.\n\r", ch );
return;
}
if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
{
send_to_char( "Your opponent is not wielding a weapon.\n\r", ch );
return;
}
WAIT_STATE( ch, skill_table[gsn_disarm].beats );
percent = number_percent( ) + victim->level - ch->level;
if ( IS_NPC(ch) || percent < ch->pcdata->learned[gsn_disarm] * 2 / 3 )
disarm( ch, victim );
else
send_to_char( "You failed.\n\r", ch );
return;
}
void do_sla( CHAR_DATA *ch, char *argument )
{
send_to_char( "If you want to SLAY, spell it out.\n\r", ch );
return;
}
void do_slay( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
char arg[MAX_INPUT_LENGTH];
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Slay whom?\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( ch == victim )
{
send_to_char( "Suicide is a mortal sin.\n\r", ch );
return;
}
if ( !IS_NPC(victim) && victim->level >= ch->level )
{
send_to_char( "You failed.\n\r", ch );
return;
}
act( "You slay $M in cold blood!", ch, NULL, victim, TO_CHAR );
act( "$n slays you in cold blood!", ch, NULL, victim, TO_VICT );
act( "$n slays $N in cold blood!", ch, NULL, victim, TO_NOTVICT );
raw_kill( victim );
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -