1*6dee362eSjoerg /* $NetBSD: spec_hit.c,v 1.9 2011/05/23 23:01:17 joerg Exp $ */
27ee35daaScgd
361f28255Scgd /*
47ee35daaScgd * Copyright (c) 1988, 1993
57ee35daaScgd * The Regents of the University of California. All rights reserved.
661f28255Scgd *
761f28255Scgd * This code is derived from software contributed to Berkeley by
861f28255Scgd * Timothy C. Stoehr.
961f28255Scgd *
1061f28255Scgd * Redistribution and use in source and binary forms, with or without
1161f28255Scgd * modification, are permitted provided that the following conditions
1261f28255Scgd * are met:
1361f28255Scgd * 1. Redistributions of source code must retain the above copyright
1461f28255Scgd * notice, this list of conditions and the following disclaimer.
1561f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright
1661f28255Scgd * notice, this list of conditions and the following disclaimer in the
1761f28255Scgd * documentation and/or other materials provided with the distribution.
18e5aeb4eaSagc * 3. Neither the name of the University nor the names of its contributors
1961f28255Scgd * may be used to endorse or promote products derived from this software
2061f28255Scgd * without specific prior written permission.
2161f28255Scgd *
2261f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2361f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2461f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2561f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2661f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2761f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2861f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2961f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3061f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3161f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3261f28255Scgd * SUCH DAMAGE.
3361f28255Scgd */
3461f28255Scgd
352736b511Slukem #include <sys/cdefs.h>
3661f28255Scgd #ifndef lint
377ee35daaScgd #if 0
387ee35daaScgd static char sccsid[] = "@(#)spec_hit.c 8.1 (Berkeley) 5/31/93";
397ee35daaScgd #else
40*6dee362eSjoerg __RCSID("$NetBSD: spec_hit.c,v 1.9 2011/05/23 23:01:17 joerg Exp $");
417ee35daaScgd #endif
4261f28255Scgd #endif /* not lint */
4361f28255Scgd
4461f28255Scgd /*
4561f28255Scgd * special_hit.c
4661f28255Scgd *
4761f28255Scgd * This source herein may be modified and/or distributed by anybody who
4861f28255Scgd * so desires, with the following restrictions:
4961f28255Scgd * 1.) No portion of this notice shall be removed.
5061f28255Scgd * 2.) Credit shall not be taken for the creation of this source.
5161f28255Scgd * 3.) This code is not to be traded, sold, or used for personal
5261f28255Scgd * gain or profit.
5361f28255Scgd *
5461f28255Scgd */
5561f28255Scgd
5661f28255Scgd #include "rogue.h"
5761f28255Scgd
58130a8172Sdholland static void disappear(object *);
59130a8172Sdholland static void drain_life(void);
60130a8172Sdholland static void drop_level(void);
61130a8172Sdholland static void freeze(object *);
62130a8172Sdholland static int get_dir(short, short, short, short);
63130a8172Sdholland static boolean gold_at(short, short);
64130a8172Sdholland static void steal_gold(object *);
65130a8172Sdholland static void steal_item(object *);
66130a8172Sdholland static void sting(object *);
67130a8172Sdholland static boolean try_to_cough(short, short, object *);
68130a8172Sdholland
6961f28255Scgd short less_hp = 0;
7061f28255Scgd boolean being_held;
7161f28255Scgd
722736b511Slukem void
special_hit(object * monster)73130a8172Sdholland special_hit(object *monster)
7461f28255Scgd {
7561f28255Scgd if ((monster->m_flags & CONFUSED) && rand_percent(66)) {
7661f28255Scgd return;
7761f28255Scgd }
7861f28255Scgd if (monster->m_flags & RUSTS) {
7961f28255Scgd rust(monster);
8061f28255Scgd }
8161f28255Scgd if ((monster->m_flags & HOLDS) && !levitate) {
8261f28255Scgd being_held = 1;
8361f28255Scgd }
8461f28255Scgd if (monster->m_flags & FREEZES) {
8561f28255Scgd freeze(monster);
8661f28255Scgd }
8761f28255Scgd if (monster->m_flags & STINGS) {
8861f28255Scgd sting(monster);
8961f28255Scgd }
9061f28255Scgd if (monster->m_flags & DRAINS_LIFE) {
9161f28255Scgd drain_life();
9261f28255Scgd }
9361f28255Scgd if (monster->m_flags & DROPS_LEVEL) {
9461f28255Scgd drop_level();
9561f28255Scgd }
9661f28255Scgd if (monster->m_flags & STEALS_GOLD) {
9761f28255Scgd steal_gold(monster);
9861f28255Scgd } else if (monster->m_flags & STEALS_ITEM) {
9961f28255Scgd steal_item(monster);
10061f28255Scgd }
10161f28255Scgd }
10261f28255Scgd
1032736b511Slukem void
rust(object * monster)104130a8172Sdholland rust(object *monster)
10561f28255Scgd {
10661f28255Scgd if ((!rogue.armor) || (get_armor_class(rogue.armor) <= 1) ||
10761f28255Scgd (rogue.armor->which_kind == LEATHER)) {
10861f28255Scgd return;
10961f28255Scgd }
11061f28255Scgd if ((rogue.armor->is_protected) || maintain_armor) {
11161f28255Scgd if (monster && (!(monster->m_flags & RUST_VANISHED))) {
112e94a5bc9Sdholland messagef(0, "the rust vanishes instantly");
11361f28255Scgd monster->m_flags |= RUST_VANISHED;
11461f28255Scgd }
11561f28255Scgd } else {
11661f28255Scgd rogue.armor->d_enchant--;
117e94a5bc9Sdholland messagef(0, "your armor weakens");
11861f28255Scgd print_stats(STAT_ARMOR);
11961f28255Scgd }
12061f28255Scgd }
12161f28255Scgd
1222736b511Slukem void
freeze(object * monster)123130a8172Sdholland freeze(object *monster)
12461f28255Scgd {
12561f28255Scgd short freeze_percent = 99;
12661f28255Scgd short i, n;
12761f28255Scgd
12861f28255Scgd if (rand_percent(12)) {
12961f28255Scgd return;
13061f28255Scgd }
13161f28255Scgd freeze_percent -= (rogue.str_current+(rogue.str_current / 2));
13261f28255Scgd freeze_percent -= ((rogue.exp + ring_exp) * 4);
13361f28255Scgd freeze_percent -= (get_armor_class(rogue.armor) * 5);
13461f28255Scgd freeze_percent -= (rogue.hp_max / 3);
13561f28255Scgd
13661f28255Scgd if (freeze_percent > 10) {
13761f28255Scgd monster->m_flags |= FREEZING_ROGUE;
138e94a5bc9Sdholland messagef(1, "you are frozen");
13961f28255Scgd
14061f28255Scgd n = get_rand(4, 8);
14161f28255Scgd for (i = 0; i < n; i++) {
14261f28255Scgd mv_mons();
14361f28255Scgd }
14461f28255Scgd if (rand_percent(freeze_percent)) {
14561f28255Scgd for (i = 0; i < 50; i++) {
14661f28255Scgd mv_mons();
14761f28255Scgd }
148130a8172Sdholland killed_by(NULL, HYPOTHERMIA);
14961f28255Scgd }
150*6dee362eSjoerg messagef(1, "%s", you_can_move_again);
15161f28255Scgd monster->m_flags &= (~FREEZING_ROGUE);
15261f28255Scgd }
15361f28255Scgd }
15461f28255Scgd
1552736b511Slukem void
steal_gold(object * monster)156130a8172Sdholland steal_gold(object *monster)
15761f28255Scgd {
15861f28255Scgd int amount;
15961f28255Scgd
16061f28255Scgd if ((rogue.gold <= 0) || rand_percent(10)) {
16161f28255Scgd return;
16261f28255Scgd }
16361f28255Scgd
16461f28255Scgd amount = get_rand((cur_level * 10), (cur_level * 30));
16561f28255Scgd
16661f28255Scgd if (amount > rogue.gold) {
16761f28255Scgd amount = rogue.gold;
16861f28255Scgd }
16961f28255Scgd rogue.gold -= amount;
170e94a5bc9Sdholland messagef(0, "your purse feels lighter");
17161f28255Scgd print_stats(STAT_GOLD);
17261f28255Scgd disappear(monster);
17361f28255Scgd }
17461f28255Scgd
1752736b511Slukem void
steal_item(object * monster)176130a8172Sdholland steal_item(object *monster)
17761f28255Scgd {
17861f28255Scgd object *obj;
1792736b511Slukem short i, n, t = 0;
18061f28255Scgd char desc[80];
18161f28255Scgd boolean has_something = 0;
18261f28255Scgd
18361f28255Scgd if (rand_percent(15)) {
18461f28255Scgd return;
18561f28255Scgd }
18661f28255Scgd obj = rogue.pack.next_object;
18761f28255Scgd
18861f28255Scgd if (!obj) {
18961f28255Scgd goto DSPR;
19061f28255Scgd }
19161f28255Scgd while (obj) {
19261f28255Scgd if (!(obj->in_use_flags & BEING_USED)) {
19361f28255Scgd has_something = 1;
19461f28255Scgd break;
19561f28255Scgd }
19661f28255Scgd obj = obj->next_object;
19761f28255Scgd }
19861f28255Scgd if (!has_something) {
19961f28255Scgd goto DSPR;
20061f28255Scgd }
20161f28255Scgd n = get_rand(0, MAX_PACK_COUNT);
20261f28255Scgd obj = rogue.pack.next_object;
20361f28255Scgd
20461f28255Scgd for (i = 0; i <= n; i++) {
20561f28255Scgd obj = obj->next_object;
20661f28255Scgd while ((!obj) || (obj->in_use_flags & BEING_USED)) {
20761f28255Scgd if (!obj) {
20861f28255Scgd obj = rogue.pack.next_object;
20961f28255Scgd } else {
21061f28255Scgd obj = obj->next_object;
21161f28255Scgd }
21261f28255Scgd }
21361f28255Scgd }
21461f28255Scgd if (obj->what_is != WEAPON) {
21561f28255Scgd t = obj->quantity;
21661f28255Scgd obj->quantity = 1;
21761f28255Scgd }
218e94a5bc9Sdholland get_desc(obj, desc, sizeof(desc));
219e94a5bc9Sdholland messagef(0, "she stole %s", desc);
22061f28255Scgd
22161f28255Scgd obj->quantity = ((obj->what_is != WEAPON) ? t : 1);
22261f28255Scgd
22361f28255Scgd vanish(obj, 0, &rogue.pack);
22461f28255Scgd DSPR:
22561f28255Scgd disappear(monster);
22661f28255Scgd }
22761f28255Scgd
228130a8172Sdholland static void
disappear(object * monster)229130a8172Sdholland disappear(object *monster)
23061f28255Scgd {
23161f28255Scgd short row, col;
23261f28255Scgd
23361f28255Scgd row = monster->row;
23461f28255Scgd col = monster->col;
23561f28255Scgd
23661f28255Scgd dungeon[row][col] &= ~MONSTER;
23761f28255Scgd if (rogue_can_see(row, col)) {
23861f28255Scgd mvaddch(row, col, get_dungeon_char(row, col));
23961f28255Scgd }
24061f28255Scgd take_from_pack(monster, &level_monsters);
24161f28255Scgd free_object(monster);
24261f28255Scgd mon_disappeared = 1;
24361f28255Scgd }
24461f28255Scgd
2452736b511Slukem void
cough_up(object * monster)246130a8172Sdholland cough_up(object *monster)
24761f28255Scgd {
24861f28255Scgd object *obj;
24961f28255Scgd short row, col, i, n;
25061f28255Scgd
25161f28255Scgd if (cur_level < max_level) {
25261f28255Scgd return;
25361f28255Scgd }
25461f28255Scgd
25561f28255Scgd if (monster->m_flags & STEALS_GOLD) {
25661f28255Scgd obj = alloc_object();
25761f28255Scgd obj->what_is = GOLD;
25861f28255Scgd obj->quantity = get_rand((cur_level * 15), (cur_level * 30));
25961f28255Scgd } else {
26061f28255Scgd if (!rand_percent((int)monster->drop_percent)) {
26161f28255Scgd return;
26261f28255Scgd }
26361f28255Scgd obj = gr_object();
26461f28255Scgd }
26561f28255Scgd row = monster->row;
26661f28255Scgd col = monster->col;
26761f28255Scgd
26861f28255Scgd for (n = 0; n <= 5; n++) {
26961f28255Scgd for (i = -n; i <= n; i++) {
27061f28255Scgd if (try_to_cough(row+n, col+i, obj)) {
27161f28255Scgd return;
27261f28255Scgd }
27361f28255Scgd if (try_to_cough(row-n, col+i, obj)) {
27461f28255Scgd return;
27561f28255Scgd }
27661f28255Scgd }
27761f28255Scgd for (i = -n; i <= n; i++) {
27861f28255Scgd if (try_to_cough(row+i, col-n, obj)) {
27961f28255Scgd return;
28061f28255Scgd }
28161f28255Scgd if (try_to_cough(row+i, col+n, obj)) {
28261f28255Scgd return;
28361f28255Scgd }
28461f28255Scgd }
28561f28255Scgd }
28661f28255Scgd free_object(obj);
28761f28255Scgd }
28861f28255Scgd
289130a8172Sdholland static boolean
try_to_cough(short row,short col,object * obj)290130a8172Sdholland try_to_cough(short row, short col, object *obj)
29161f28255Scgd {
2922736b511Slukem if ((row < MIN_ROW) ||
2932736b511Slukem (row > (DROWS-2)) || (col < 0) || (col>(DCOLS-1))) {
29461f28255Scgd return(0);
29561f28255Scgd }
29661f28255Scgd if ((!(dungeon[row][col] & (OBJECT | STAIRS | TRAP))) &&
29761f28255Scgd (dungeon[row][col] & (TUNNEL | FLOOR | DOOR))) {
29861f28255Scgd place_at(obj, row, col);
29961f28255Scgd if (((row != rogue.row) || (col != rogue.col)) &&
30061f28255Scgd (!(dungeon[row][col] & MONSTER))) {
30161f28255Scgd mvaddch(row, col, get_dungeon_char(row, col));
30261f28255Scgd }
30361f28255Scgd return(1);
30461f28255Scgd }
30561f28255Scgd return(0);
30661f28255Scgd }
30761f28255Scgd
3082736b511Slukem boolean
seek_gold(object * monster)309130a8172Sdholland seek_gold(object *monster)
31061f28255Scgd {
31161f28255Scgd short i, j, rn, s;
31261f28255Scgd
31361f28255Scgd if ((rn = get_room_number(monster->row, monster->col)) < 0) {
31461f28255Scgd return(0);
31561f28255Scgd }
31661f28255Scgd for (i = rooms[rn].top_row+1; i < rooms[rn].bottom_row; i++) {
31761f28255Scgd for (j = rooms[rn].left_col+1; j < rooms[rn].right_col; j++) {
31861f28255Scgd if ((gold_at(i, j)) && !(dungeon[i][j] & MONSTER)) {
31961f28255Scgd monster->m_flags |= CAN_FLIT;
32061f28255Scgd s = mon_can_go(monster, i, j);
32161f28255Scgd monster->m_flags &= (~CAN_FLIT);
32261f28255Scgd if (s) {
32361f28255Scgd move_mon_to(monster, i, j);
32461f28255Scgd monster->m_flags |= ASLEEP;
32561f28255Scgd monster->m_flags &= (~(WAKENS | SEEKS_GOLD));
32661f28255Scgd return(1);
32761f28255Scgd }
32861f28255Scgd monster->m_flags &= (~SEEKS_GOLD);
32961f28255Scgd monster->m_flags |= CAN_FLIT;
33061f28255Scgd mv_1_monster(monster, i, j);
33161f28255Scgd monster->m_flags &= (~CAN_FLIT);
33261f28255Scgd monster->m_flags |= SEEKS_GOLD;
33361f28255Scgd return(1);
33461f28255Scgd }
33561f28255Scgd }
33661f28255Scgd }
33761f28255Scgd return(0);
33861f28255Scgd }
33961f28255Scgd
340130a8172Sdholland static boolean
gold_at(short row,short col)341130a8172Sdholland gold_at(short row, short col)
34261f28255Scgd {
34361f28255Scgd if (dungeon[row][col] & OBJECT) {
34461f28255Scgd object *obj;
34561f28255Scgd
34661f28255Scgd if ((obj = object_at(&level_objects, row, col)) &&
34761f28255Scgd (obj->what_is == GOLD)) {
34861f28255Scgd return(1);
34961f28255Scgd }
35061f28255Scgd }
35161f28255Scgd return(0);
35261f28255Scgd }
35361f28255Scgd
3542736b511Slukem void
check_gold_seeker(object * monster)355130a8172Sdholland check_gold_seeker(object *monster)
35661f28255Scgd {
35761f28255Scgd monster->m_flags &= (~SEEKS_GOLD);
35861f28255Scgd }
35961f28255Scgd
3602736b511Slukem boolean
check_imitator(object * monster)361130a8172Sdholland check_imitator(object *monster)
36261f28255Scgd {
36361f28255Scgd if (monster->m_flags & IMITATES) {
36461f28255Scgd wake_up(monster);
36561f28255Scgd if (!blind) {
36661f28255Scgd mvaddch(monster->row, monster->col,
36761f28255Scgd get_dungeon_char(monster->row, monster->col));
36861f28255Scgd check_message();
369e94a5bc9Sdholland messagef(1, "wait, that's a %s!", mon_name(monster));
37061f28255Scgd }
37161f28255Scgd return(1);
37261f28255Scgd }
37361f28255Scgd return(0);
37461f28255Scgd }
37561f28255Scgd
3762736b511Slukem boolean
imitating(short row,short col)377130a8172Sdholland imitating(short row, short col)
37861f28255Scgd {
37961f28255Scgd if (dungeon[row][col] & MONSTER) {
3802736b511Slukem object *monster;
38161f28255Scgd
3822736b511Slukem if ((monster = object_at(&level_monsters, row, col)) != NULL) {
38361f28255Scgd if (monster->m_flags & IMITATES) {
38461f28255Scgd return(1);
38561f28255Scgd }
38661f28255Scgd }
38761f28255Scgd }
38861f28255Scgd return(0);
38961f28255Scgd }
39061f28255Scgd
391130a8172Sdholland static void
sting(object * monster)392130a8172Sdholland sting(object *monster)
39361f28255Scgd {
39461f28255Scgd short sting_chance = 35;
39561f28255Scgd
39661f28255Scgd if ((rogue.str_current <= 3) || sustain_strength) {
39761f28255Scgd return;
39861f28255Scgd }
39961f28255Scgd sting_chance += (6 * (6 - get_armor_class(rogue.armor)));
40061f28255Scgd
40161f28255Scgd if ((rogue.exp + ring_exp) > 8) {
40261f28255Scgd sting_chance -= (6 * ((rogue.exp + ring_exp) - 8));
40361f28255Scgd }
40461f28255Scgd if (rand_percent(sting_chance)) {
405e94a5bc9Sdholland messagef(0, "the %s's bite has weakened you",
40661f28255Scgd mon_name(monster));
40761f28255Scgd rogue.str_current--;
40861f28255Scgd print_stats(STAT_STRENGTH);
40961f28255Scgd }
41061f28255Scgd }
41161f28255Scgd
412130a8172Sdholland static void
drop_level(void)413130a8172Sdholland drop_level(void)
41461f28255Scgd {
41561f28255Scgd int hp;
41661f28255Scgd
41761f28255Scgd if (rand_percent(80) || (rogue.exp <= 5)) {
41861f28255Scgd return;
41961f28255Scgd }
42061f28255Scgd rogue.exp_points = level_points[rogue.exp-2] - get_rand(9, 29);
42161f28255Scgd rogue.exp -= 2;
42261f28255Scgd hp = hp_raise();
42361f28255Scgd if ((rogue.hp_current -= hp) <= 0) {
42461f28255Scgd rogue.hp_current = 1;
42561f28255Scgd }
42661f28255Scgd if ((rogue.hp_max -= hp) <= 0) {
42761f28255Scgd rogue.hp_max = 1;
42861f28255Scgd }
42961f28255Scgd add_exp(1, 0);
43061f28255Scgd }
43161f28255Scgd
4322736b511Slukem void
drain_life(void)433130a8172Sdholland drain_life(void)
43461f28255Scgd {
43561f28255Scgd short n;
43661f28255Scgd
43761f28255Scgd if (rand_percent(60) || (rogue.hp_max <= 30) || (rogue.hp_current < 10)) {
43861f28255Scgd return;
43961f28255Scgd }
44061f28255Scgd n = get_rand(1, 3); /* 1 Hp, 2 Str, 3 both */
44161f28255Scgd
44261f28255Scgd if ((n != 2) || (!sustain_strength)) {
443e94a5bc9Sdholland messagef(0, "you feel weaker");
44461f28255Scgd }
44561f28255Scgd if (n != 2) {
44661f28255Scgd rogue.hp_max--;
44761f28255Scgd rogue.hp_current--;
44861f28255Scgd less_hp++;
44961f28255Scgd }
45061f28255Scgd if (n != 1) {
45161f28255Scgd if ((rogue.str_current > 3) && (!sustain_strength)) {
45261f28255Scgd rogue.str_current--;
45361f28255Scgd if (coin_toss()) {
45461f28255Scgd rogue.str_max--;
45561f28255Scgd }
45661f28255Scgd }
45761f28255Scgd }
45861f28255Scgd print_stats((STAT_STRENGTH | STAT_HP));
45961f28255Scgd }
46061f28255Scgd
4612736b511Slukem boolean
m_confuse(object * monster)462130a8172Sdholland m_confuse(object *monster)
46361f28255Scgd {
46461f28255Scgd if (!rogue_can_see(monster->row, monster->col)) {
46561f28255Scgd return(0);
46661f28255Scgd }
46761f28255Scgd if (rand_percent(45)) {
46861f28255Scgd monster->m_flags &= (~CONFUSES); /* will not confuse the rogue */
46961f28255Scgd return(0);
47061f28255Scgd }
47161f28255Scgd if (rand_percent(55)) {
47261f28255Scgd monster->m_flags &= (~CONFUSES);
473e94a5bc9Sdholland messagef(1, "the gaze of the %s has confused you",
474e94a5bc9Sdholland mon_name(monster));
47561f28255Scgd cnfs();
47661f28255Scgd return(1);
47761f28255Scgd }
47861f28255Scgd return(0);
47961f28255Scgd }
48061f28255Scgd
4812736b511Slukem boolean
flame_broil(object * monster)482130a8172Sdholland flame_broil(object *monster)
48361f28255Scgd {
48461f28255Scgd short row, col, dir;
48561f28255Scgd
48661f28255Scgd if ((!mon_sees(monster, rogue.row, rogue.col)) || coin_toss()) {
48761f28255Scgd return(0);
48861f28255Scgd }
48961f28255Scgd row = rogue.row - monster->row;
49061f28255Scgd col = rogue.col - monster->col;
49161f28255Scgd if (row < 0) {
49261f28255Scgd row = -row;
49361f28255Scgd }
49461f28255Scgd if (col < 0) {
49561f28255Scgd col = -col;
49661f28255Scgd }
49761f28255Scgd if (((row != 0) && (col != 0) && (row != col)) ||
49861f28255Scgd ((row > 7) || (col > 7))) {
49961f28255Scgd return(0);
50061f28255Scgd }
50161f28255Scgd dir = get_dir(monster->row, monster->col, row, col);
50261f28255Scgd bounce(FIRE, dir, monster->row, monster->col, 0);
50361f28255Scgd
50461f28255Scgd return(1);
50561f28255Scgd }
50661f28255Scgd
507130a8172Sdholland static int
get_dir(short srow,short scol,short drow,short dcol)508130a8172Sdholland get_dir(short srow, short scol, short drow, short dcol)
50961f28255Scgd {
51061f28255Scgd if (srow == drow) {
51161f28255Scgd if (scol < dcol) {
51261f28255Scgd return(RIGHT);
51361f28255Scgd } else {
51461f28255Scgd return(LEFT);
51561f28255Scgd }
51661f28255Scgd }
51761f28255Scgd if (scol == dcol) {
51861f28255Scgd if (srow < drow) {
51961f28255Scgd return(DOWN);
52061f28255Scgd } else {
52161f28255Scgd return(UPWARD);
52261f28255Scgd }
52361f28255Scgd }
52461f28255Scgd if ((srow > drow) && (scol > dcol)) {
52561f28255Scgd return(UPLEFT);
52661f28255Scgd }
52761f28255Scgd if ((srow < drow) && (scol < dcol)) {
52861f28255Scgd return(DOWNRIGHT);
52961f28255Scgd }
53061f28255Scgd if ((srow < drow) && (scol > dcol)) {
53161f28255Scgd return(DOWNLEFT);
53261f28255Scgd }
53361f28255Scgd /*if ((srow > drow) && (scol < dcol)) {*/
53461f28255Scgd return(UPRIGHT);
53561f28255Scgd /*}*/
53661f28255Scgd }
537