]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/spec_hit.c
1 /* $NetBSD: spec_hit.c,v 1.7 2008/01/14 00:23:53 dholland Exp $ */
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
38 static char sccsid
[] = "@(#)spec_hit.c 8.1 (Berkeley) 5/31/93";
40 __RCSID("$NetBSD: spec_hit.c,v 1.7 2008/01/14 00:23:53 dholland Exp $");
47 * This source herein may be modified and/or distributed by anybody who
48 * so desires, with the following restrictions:
49 * 1.) No portion of this notice shall be removed.
50 * 2.) Credit shall not be taken for the creation of this source.
51 * 3.) This code is not to be traded, sold, or used for personal
65 if ((monster
->m_flags
& CONFUSED
) && rand_percent(66)) {
68 if (monster
->m_flags
& RUSTS
) {
71 if ((monster
->m_flags
& HOLDS
) && !levitate
) {
74 if (monster
->m_flags
& FREEZES
) {
77 if (monster
->m_flags
& STINGS
) {
80 if (monster
->m_flags
& DRAINS_LIFE
) {
83 if (monster
->m_flags
& DROPS_LEVEL
) {
86 if (monster
->m_flags
& STEALS_GOLD
) {
88 } else if (monster
->m_flags
& STEALS_ITEM
) {
97 if ((!rogue
.armor
) || (get_armor_class(rogue
.armor
) <= 1) ||
98 (rogue
.armor
->which_kind
== LEATHER
)) {
101 if ((rogue
.armor
->is_protected
) || maintain_armor
) {
102 if (monster
&& (!(monster
->m_flags
& RUST_VANISHED
))) {
103 messagef(0, "the rust vanishes instantly");
104 monster
->m_flags
|= RUST_VANISHED
;
107 rogue
.armor
->d_enchant
--;
108 messagef(0, "your armor weakens");
109 print_stats(STAT_ARMOR
);
117 short freeze_percent
= 99;
120 if (rand_percent(12)) {
123 freeze_percent
-= (rogue
.str_current
+(rogue
.str_current
/ 2));
124 freeze_percent
-= ((rogue
.exp
+ ring_exp
) * 4);
125 freeze_percent
-= (get_armor_class(rogue
.armor
) * 5);
126 freeze_percent
-= (rogue
.hp_max
/ 3);
128 if (freeze_percent
> 10) {
129 monster
->m_flags
|= FREEZING_ROGUE
;
130 messagef(1, "you are frozen");
133 for (i
= 0; i
< n
; i
++) {
136 if (rand_percent(freeze_percent
)) {
137 for (i
= 0; i
< 50; i
++) {
140 killed_by((object
*)0, HYPOTHERMIA
);
142 messagef(1, you_can_move_again
);
143 monster
->m_flags
&= (~FREEZING_ROGUE
);
153 if ((rogue
.gold
<= 0) || rand_percent(10)) {
157 amount
= get_rand((cur_level
* 10), (cur_level
* 30));
159 if (amount
> rogue
.gold
) {
162 rogue
.gold
-= amount
;
163 messagef(0, "your purse feels lighter");
164 print_stats(STAT_GOLD
);
175 boolean has_something
= 0;
177 if (rand_percent(15)) {
180 obj
= rogue
.pack
.next_object
;
186 if (!(obj
->in_use_flags
& BEING_USED
)) {
190 obj
= obj
->next_object
;
192 if (!has_something
) {
195 n
= get_rand(0, MAX_PACK_COUNT
);
196 obj
= rogue
.pack
.next_object
;
198 for (i
= 0; i
<= n
; i
++) {
199 obj
= obj
->next_object
;
200 while ((!obj
) || (obj
->in_use_flags
& BEING_USED
)) {
202 obj
= rogue
.pack
.next_object
;
204 obj
= obj
->next_object
;
208 if (obj
->what_is
!= WEAPON
) {
212 get_desc(obj
, desc
, sizeof(desc
));
213 messagef(0, "she stole %s", desc
);
215 obj
->quantity
= ((obj
->what_is
!= WEAPON
) ? t
: 1);
217 vanish(obj
, 0, &rogue
.pack
);
231 dungeon
[row
][col
] &= ~MONSTER
;
232 if (rogue_can_see(row
, col
)) {
233 mvaddch(row
, col
, get_dungeon_char(row
, col
));
235 take_from_pack(monster
, &level_monsters
);
236 free_object(monster
);
245 short row
, col
, i
, n
;
247 if (cur_level
< max_level
) {
251 if (monster
->m_flags
& STEALS_GOLD
) {
252 obj
= alloc_object();
254 obj
->quantity
= get_rand((cur_level
* 15), (cur_level
* 30));
256 if (!rand_percent((int)monster
->drop_percent
)) {
264 for (n
= 0; n
<= 5; n
++) {
265 for (i
= -n
; i
<= n
; i
++) {
266 if (try_to_cough(row
+n
, col
+i
, obj
)) {
269 if (try_to_cough(row
-n
, col
+i
, obj
)) {
273 for (i
= -n
; i
<= n
; i
++) {
274 if (try_to_cough(row
+i
, col
-n
, obj
)) {
277 if (try_to_cough(row
+i
, col
+n
, obj
)) {
286 try_to_cough(row
, col
, obj
)
290 if ((row
< MIN_ROW
) ||
291 (row
> (DROWS
-2)) || (col
< 0) || (col
>(DCOLS
-1))) {
294 if ((!(dungeon
[row
][col
] & (OBJECT
| STAIRS
| TRAP
))) &&
295 (dungeon
[row
][col
] & (TUNNEL
| FLOOR
| DOOR
))) {
296 place_at(obj
, row
, col
);
297 if (((row
!= rogue
.row
) || (col
!= rogue
.col
)) &&
298 (!(dungeon
[row
][col
] & MONSTER
))) {
299 mvaddch(row
, col
, get_dungeon_char(row
, col
));
312 if ((rn
= get_room_number(monster
->row
, monster
->col
)) < 0) {
315 for (i
= rooms
[rn
].top_row
+1; i
< rooms
[rn
].bottom_row
; i
++) {
316 for (j
= rooms
[rn
].left_col
+1; j
< rooms
[rn
].right_col
; j
++) {
317 if ((gold_at(i
, j
)) && !(dungeon
[i
][j
] & MONSTER
)) {
318 monster
->m_flags
|= CAN_FLIT
;
319 s
= mon_can_go(monster
, i
, j
);
320 monster
->m_flags
&= (~CAN_FLIT
);
322 move_mon_to(monster
, i
, j
);
323 monster
->m_flags
|= ASLEEP
;
324 monster
->m_flags
&= (~(WAKENS
| SEEKS_GOLD
));
327 monster
->m_flags
&= (~SEEKS_GOLD
);
328 monster
->m_flags
|= CAN_FLIT
;
329 mv_1_monster(monster
, i
, j
);
330 monster
->m_flags
&= (~CAN_FLIT
);
331 monster
->m_flags
|= SEEKS_GOLD
;
343 if (dungeon
[row
][col
] & OBJECT
) {
346 if ((obj
= object_at(&level_objects
, row
, col
)) &&
347 (obj
->what_is
== GOLD
)) {
355 check_gold_seeker(monster
)
358 monster
->m_flags
&= (~SEEKS_GOLD
);
362 check_imitator(monster
)
365 if (monster
->m_flags
& IMITATES
) {
368 mvaddch(monster
->row
, monster
->col
,
369 get_dungeon_char(monster
->row
, monster
->col
));
371 messagef(1, "wait, that's a %s!", mon_name(monster
));
382 if (dungeon
[row
][col
] & MONSTER
) {
385 if ((monster
= object_at(&level_monsters
, row
, col
)) != NULL
) {
386 if (monster
->m_flags
& IMITATES
) {
398 short sting_chance
= 35;
400 if ((rogue
.str_current
<= 3) || sustain_strength
) {
403 sting_chance
+= (6 * (6 - get_armor_class(rogue
.armor
)));
405 if ((rogue
.exp
+ ring_exp
) > 8) {
406 sting_chance
-= (6 * ((rogue
.exp
+ ring_exp
) - 8));
408 if (rand_percent(sting_chance
)) {
409 messagef(0, "the %s's bite has weakened you",
412 print_stats(STAT_STRENGTH
);
421 if (rand_percent(80) || (rogue
.exp
<= 5)) {
424 rogue
.exp_points
= level_points
[rogue
.exp
-2] - get_rand(9, 29);
427 if ((rogue
.hp_current
-= hp
) <= 0) {
428 rogue
.hp_current
= 1;
430 if ((rogue
.hp_max
-= hp
) <= 0) {
441 if (rand_percent(60) || (rogue
.hp_max
<= 30) || (rogue
.hp_current
< 10)) {
444 n
= get_rand(1, 3); /* 1 Hp, 2 Str, 3 both */
446 if ((n
!= 2) || (!sustain_strength
)) {
447 messagef(0, "you feel weaker");
455 if ((rogue
.str_current
> 3) && (!sustain_strength
)) {
462 print_stats((STAT_STRENGTH
| STAT_HP
));
469 if (!rogue_can_see(monster
->row
, monster
->col
)) {
472 if (rand_percent(45)) {
473 monster
->m_flags
&= (~CONFUSES
); /* will not confuse the rogue */
476 if (rand_percent(55)) {
477 monster
->m_flags
&= (~CONFUSES
);
478 messagef(1, "the gaze of the %s has confused you",
492 if ((!mon_sees(monster
, rogue
.row
, rogue
.col
)) || coin_toss()) {
495 row
= rogue
.row
- monster
->row
;
496 col
= rogue
.col
- monster
->col
;
503 if (((row
!= 0) && (col
!= 0) && (row
!= col
)) ||
504 ((row
> 7) || (col
> 7))) {
507 dir
= get_dir(monster
->row
, monster
->col
, row
, col
);
508 bounce(FIRE
, dir
, monster
->row
, monster
->col
, 0);
514 get_dir(srow
, scol
, drow
, dcol
)
515 short srow
, scol
, drow
, dcol
;
531 if ((srow
> drow
) && (scol
> dcol
)) {
534 if ((srow
< drow
) && (scol
< dcol
)) {
537 if ((srow
< drow
) && (scol
> dcol
)) {
540 /*if ((srow > drow) && (scol < dcol)) {*/