* Copyright (c) 1988 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)throw.c 5.3 (Berkeley) %G%";
* 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
extern char *curse_message
;
extern char hit_message
[];
while (!is_direction(dir
= rgetchar(), &d
)) {
message("direction? ", 0);
if ((wch
= pack_letter("throw what?", WEAPON
)) == CANCEL
) {
if (!(weapon
= get_letter_object(wch
))) {
message("no such item.", 0);
if ((weapon
->in_use_flags
& BEING_USED
) && weapon
->is_cursed
) {
message(curse_message
, 0);
row
= rogue
.row
; col
= rogue
.col
;
if ((weapon
->in_use_flags
& BEING_WIELDED
) && (weapon
->quantity
<= 1)) {
} else if (weapon
->in_use_flags
& BEING_WORN
) {
} else if (weapon
->in_use_flags
& ON_EITHER_HAND
) {
monster
= get_thrown_at_monster(weapon
, d
, &row
, &col
);
mvaddch(rogue
.row
, rogue
.col
, rogue
.fchar
);
if (rogue_can_see(row
, col
) && ((row
!= rogue
.row
) || (col
!= rogue
.col
))){
mvaddch(row
, col
, get_dungeon_char(row
, col
));
check_gold_seeker(monster
);
if (!throw_at_monster(monster
, weapon
)) {
flop_weapon(weapon
, row
, col
);
flop_weapon(weapon
, row
, col
);
vanish(weapon
, 1, &rogue
.pack
);
throw_at_monster(monster
, weapon
)
object
*monster
, *weapon
;
short damage
, hit_chance
;
hit_chance
= get_hit_chance(weapon
);
damage
= get_weapon_damage(weapon
);
if ((weapon
->which_kind
== ARROW
) &&
(rogue
.weapon
&& (rogue
.weapon
->which_kind
== BOW
))) {
damage
+= get_weapon_damage(rogue
.weapon
);
damage
= ((damage
* 2) / 3);
hit_chance
+= (hit_chance
/ 3);
} else if ((weapon
->in_use_flags
& BEING_WIELDED
) &&
((weapon
->which_kind
== DAGGER
) ||
(weapon
->which_kind
== SHURIKEN
) ||
(weapon
->which_kind
== DART
))) {
damage
= ((damage
* 3) / 2);
hit_chance
+= (hit_chance
/ 3);
sprintf(hit_message
, "the %s", name_of(weapon
));
if (!rand_percent(hit_chance
)) {
(void) strcat(hit_message
, "misses ");
(void) strcat(hit_message
, "hit ");
(void) mon_damage(monster
, damage
);
get_thrown_at_monster(obj
, dir
, row
, col
)
orow
= *row
; ocol
= *col
;
ch
= get_mask_char(obj
->what_is
);
for (i
= 0; i
< 24; i
++) {
get_dir_rc(dir
, row
, col
, 0);
if ( (((*col
<= 0) || (*col
>= DCOLS
-1)) ||
(dungeon
[*row
][*col
] == NOTHING
)) ||
((dungeon
[*row
][*col
] & (HORWALL
| VERTWALL
| HIDDEN
)) &&
(!(dungeon
[*row
][*col
] & TRAP
)))) {
if ((i
!= 0) && rogue_can_see(orow
, ocol
)) {
mvaddch(orow
, ocol
, get_dungeon_char(orow
, ocol
));
if (rogue_can_see(*row
, *col
)) {
if (!(dungeon
[*row
][*col
] & MONSTER
)) {
orow
= *row
; ocol
= *col
;
if (dungeon
[*row
][*col
] & MONSTER
) {
if (!imitating(*row
, *col
)) {
return(object_at(&level_monsters
, *row
, *col
));
if (dungeon
[*row
][*col
] & TUNNEL
) {
flop_weapon(weapon
, row
, col
)
object
*new_weapon
, *monster
;
while ((i
< 9) && dungeon
[row
][col
] & ~(FLOOR
| TUNNEL
| DOOR
| MONSTER
)) {
rand_around(i
++, &row
, &col
);
if ((row
> (DROWS
-2)) || (row
< MIN_ROW
) ||
(col
> (DCOLS
-1)) || (col
< 0) || (!dungeon
[row
][col
]) ||
(dungeon
[row
][col
] & ~(FLOOR
| TUNNEL
| DOOR
| MONSTER
))) {
new_weapon
= alloc_object();
new_weapon
->in_use_flags
= NOT_USED
;
new_weapon
->quantity
= 1;
place_at(new_weapon
, row
, col
);
if (rogue_can_see(row
, col
) &&
((row
!= rogue
.row
) || (col
!= rogue
.col
))) {
mon
= dungeon
[row
][col
] & MONSTER
;
dungeon
[row
][col
] &= (~MONSTER
);
dch
= get_dungeon_char(row
, col
);
if (monster
= object_at(&level_monsters
, row
, col
)) {
monster
->trail_char
= dch
;
if ((mch
< 'A') || (mch
> 'Z')) {
dungeon
[row
][col
] |= mon
;
sprintf(msg
, "the %svanishes as it hits the ground",
static char* pos
= "\010\007\001\003\004\005\002\006\0";
for (j
= 0; j
< 5; j
++) {