* Copyright (c) 1988 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)hit.c 5.3 (Berkeley) 6/1/90";
* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
object
*fight_monster
= 0;
char hit_message
[80] = "";
extern short halluc
, blind
, cur_level
;
extern short add_strength
, ring_exp
, r_rings
;
extern boolean being_held
, interrupted
, wizard
, con_mon
;
register object
*monster
;
short damage
, hit_chance
;
if (fight_monster
&& (monster
!= fight_monster
)) {
if (cur_level
>= (AMULET_LEVEL
* 2)) {
hit_chance
= monster
->m_hit_chance
;
hit_chance
-= (((2 * rogue
.exp
) + (2 * ring_exp
)) - r_rings
);
if (!rand_percent(hit_chance
)) {
sprintf(hit_message
+ strlen(hit_message
), "the %s misses", mn
);
sprintf(hit_message
+ strlen(hit_message
), "the %s hit", mn
);
if (!(monster
->m_flags
& STATIONARY
)) {
damage
= get_damage(monster
->m_damage
, 1);
if (cur_level
>= (AMULET_LEVEL
* 2)) {
minus
= (float) ((AMULET_LEVEL
* 2) - cur_level
);
minus
= (float) get_armor_class(rogue
.armor
) * 3.00;
minus
= minus
/100.00 * (float) damage
;
damage
= monster
->stationary_damage
++;
rogue_damage(damage
, monster
, 0);
if (monster
->m_flags
& SPECIAL_HIT
) {
rogue_hit(monster
, force_hit
)
register object
*monster
;
short damage
, hit_chance
;
if (check_imitator(monster
)) {
hit_chance
= force_hit
? 100 : get_hit_chance(rogue
.weapon
);
if (!rand_percent(hit_chance
)) {
(void) strcpy(hit_message
, "you miss ");
damage
= get_weapon_damage(rogue
.weapon
);
if (mon_damage(monster
, damage
)) { /* still alive? */
(void) strcpy(hit_message
, "you hit ");
RET
: check_gold_seeker(monster
);
rogue_damage(d
, monster
, other
)
if (d
>= rogue
.hp_current
) {
killed_by(monster
, other
);
register i
= 0, j
, n
, d
, total
= 0;
while ((ds
[i
] != '/') && ds
[i
]) i
++;
for (j
= 0; j
< n
; j
++) {
if ((!obj
) || (obj
->what_is
!= WEAPON
)) {
to_hit
= get_number(obj
->damage
) + obj
->hit_enchant
;
while (obj
->damage
[i
++] != 'd') ;
damage
= get_number(obj
->damage
+ i
) + obj
->d_enchant
;
sprintf(new_damage
, "%dd%d", to_hit
, damage
);
return(get_damage(new_damage
, 1));
while ((s
[i
] >= '0') && (s
[i
] <= '9')) {
total
= (10 * total
) + (s
[i
] - '0');
while ((s
[i
] >= '0') && (s
[i
] <= '9')) {
total
= (10 * total
) + (s
[i
] - '0');
return(get_number(obj
->damage
) + obj
->hit_enchant
);
strength
= rogue
.str_current
+ add_strength
;
mon_damage(monster
, damage
)
monster
->hp_to_kill
-= damage
;
if (monster
->hp_to_kill
<= 0) {
dungeon
[row
][col
] &= ~MONSTER
;
mvaddch(row
, col
, (int) get_dungeon_char(row
, col
));
sprintf(hit_message
+strlen(hit_message
), "defeated the %s", mn
);
add_exp(monster
->kill_exp
, 1);
take_from_pack(monster
, &level_monsters
);
if (monster
->m_flags
& HOLDS
) {
while (!is_direction(ch
= rgetchar(), &d
)) {
message("direction?", 0);
row
= rogue
.row
; col
= rogue
.col
;
get_dir_rc(d
, &row
, &col
, 0);
if (((c
< 'A') || (c
> 'Z')) ||
(!can_move(rogue
.row
, rogue
.col
, row
, col
))) {
message("I see no monster there", 0);
if (!(fight_monster
= object_at(&level_monsters
, row
, col
))) {
if (!(fight_monster
->m_flags
& STATIONARY
)) {
possible_damage
= ((get_damage(fight_monster
->m_damage
, 0) * 2) / 3);
possible_damage
= fight_monster
->stationary_damage
- 1;
(void) one_move_rogue(ch
, 0);
if (((!to_the_death
) && (rogue
.hp_current
<= possible_damage
)) ||
interrupted
|| (!(dungeon
[row
][col
] & MONSTER
))) {
monster
= object_at(&level_monsters
, row
, col
);
if (monster
!= fight_monster
) {
get_dir_rc(dir
, row
, col
, allow_off_screen
)
if (allow_off_screen
|| (*col
> 0)) {
if (allow_off_screen
|| (*row
< (DROWS
-2))) {
if (allow_off_screen
|| (*row
> MIN_ROW
)) {
if (allow_off_screen
|| (*col
< (DCOLS
-1))) {
if (allow_off_screen
|| ((*row
> MIN_ROW
) && (*col
> 0))) {
if (allow_off_screen
|| ((*row
> MIN_ROW
) && (*col
< (DCOLS
-1)))) {
if (allow_off_screen
|| ((*row
< (DROWS
-2)) && (*col
< (DCOLS
-1)))) {
if (allow_off_screen
|| ((*row
< (DROWS
-2)) && (*col
> 0))) {
hit_chance
+= 3 * to_hit(weapon
);
hit_chance
+= (((2 * rogue
.exp
) + (2 * ring_exp
)) - r_rings
);
get_weapon_damage(weapon
)
damage
= get_w_damage(weapon
);
damage
+= damage_for_strength();
damage
+= ((((rogue
.exp
+ ring_exp
) - r_rings
) + 1) / 2);
monster
->m_flags
|= CONFUSED
;
monster
->moves_confused
+= get_rand(12, 22);
message("the monster appears confused", 0);