]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/spec_hit.c
2 * Copyright (c) 1988 The Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid
[] = "@(#)spec_hit.c 5.3 (Berkeley) 6/1/90";
44 * This source herein may be modified and/or distributed by anybody who
45 * so desires, with the following restrictions:
46 * 1.) No portion of this notice shall be removed.
47 * 2.) Credit shall not be taken for the creation of this source.
48 * 3.) This code is not to be traded, sold, or used for personal
58 extern short cur_level
, max_level
, blind
, levitate
, ring_exp
;
59 extern long level_points
[];
60 extern boolean detect_monster
, mon_disappeared
;
61 extern boolean sustain_strength
, maintain_armor
;
62 extern char *you_can_move_again
;
67 if ((monster
->m_flags
& CONFUSED
) && rand_percent(66)) {
70 if (monster
->m_flags
& RUSTS
) {
73 if ((monster
->m_flags
& HOLDS
) && !levitate
) {
76 if (monster
->m_flags
& FREEZES
) {
79 if (monster
->m_flags
& STINGS
) {
82 if (monster
->m_flags
& DRAINS_LIFE
) {
85 if (monster
->m_flags
& DROPS_LEVEL
) {
88 if (monster
->m_flags
& STEALS_GOLD
) {
90 } else if (monster
->m_flags
& STEALS_ITEM
) {
98 if ((!rogue
.armor
) || (get_armor_class(rogue
.armor
) <= 1) ||
99 (rogue
.armor
->which_kind
== LEATHER
)) {
102 if ((rogue
.armor
->is_protected
) || maintain_armor
) {
103 if (monster
&& (!(monster
->m_flags
& RUST_VANISHED
))) {
104 message("the rust vanishes instantly", 0);
105 monster
->m_flags
|= RUST_VANISHED
;
108 rogue
.armor
->d_enchant
--;
109 message("your armor weakens", 0);
110 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 message("you are frozen", 1);
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 message(you_can_move_again
, 1);
143 monster
->m_flags
&= (~FREEZING_ROGUE
);
152 if ((rogue
.gold
<= 0) || rand_percent(10)) {
156 amount
= get_rand((cur_level
* 10), (cur_level
* 30));
158 if (amount
> rogue
.gold
) {
161 rogue
.gold
-= amount
;
162 message("your purse feels lighter", 0);
163 print_stats(STAT_GOLD
);
173 boolean has_something
= 0;
175 if (rand_percent(15)) {
178 obj
= rogue
.pack
.next_object
;
184 if (!(obj
->in_use_flags
& BEING_USED
)) {
188 obj
= obj
->next_object
;
190 if (!has_something
) {
193 n
= get_rand(0, MAX_PACK_COUNT
);
194 obj
= rogue
.pack
.next_object
;
196 for (i
= 0; i
<= n
; i
++) {
197 obj
= obj
->next_object
;
198 while ((!obj
) || (obj
->in_use_flags
& BEING_USED
)) {
200 obj
= rogue
.pack
.next_object
;
202 obj
= obj
->next_object
;
206 (void) strcpy(desc
, "she stole ");
207 if (obj
->what_is
!= WEAPON
) {
211 get_desc(obj
, desc
+10);
214 obj
->quantity
= ((obj
->what_is
!= WEAPON
) ? t
: 1);
216 vanish(obj
, 0, &rogue
.pack
);
229 dungeon
[row
][col
] &= ~MONSTER
;
230 if (rogue_can_see(row
, col
)) {
231 mvaddch(row
, col
, get_dungeon_char(row
, col
));
233 take_from_pack(monster
, &level_monsters
);
234 free_object(monster
);
242 short row
, col
, i
, n
;
244 if (cur_level
< max_level
) {
248 if (monster
->m_flags
& STEALS_GOLD
) {
249 obj
= alloc_object();
251 obj
->quantity
= get_rand((cur_level
* 15), (cur_level
* 30));
253 if (!rand_percent((int) monster
->drop_percent
)) {
261 for (n
= 0; n
<= 5; n
++) {
262 for (i
= -n
; i
<= n
; i
++) {
263 if (try_to_cough(row
+n
, col
+i
, obj
)) {
266 if (try_to_cough(row
-n
, col
+i
, obj
)) {
270 for (i
= -n
; i
<= n
; i
++) {
271 if (try_to_cough(row
+i
, col
-n
, obj
)) {
274 if (try_to_cough(row
+i
, col
+n
, obj
)) {
282 try_to_cough(row
, col
, obj
)
286 if ((row
< MIN_ROW
) || (row
> (DROWS
-2)) || (col
< 0) || (col
>(DCOLS
-1))) {
289 if ((!(dungeon
[row
][col
] & (OBJECT
| STAIRS
| TRAP
))) &&
290 (dungeon
[row
][col
] & (TUNNEL
| FLOOR
| DOOR
))) {
291 place_at(obj
, row
, col
);
292 if (((row
!= rogue
.row
) || (col
!= rogue
.col
)) &&
293 (!(dungeon
[row
][col
] & MONSTER
))) {
294 mvaddch(row
, col
, get_dungeon_char(row
, col
));
306 if ((rn
= get_room_number(monster
->row
, monster
->col
)) < 0) {
309 for (i
= rooms
[rn
].top_row
+1; i
< rooms
[rn
].bottom_row
; i
++) {
310 for (j
= rooms
[rn
].left_col
+1; j
< rooms
[rn
].right_col
; j
++) {
311 if ((gold_at(i
, j
)) && !(dungeon
[i
][j
] & MONSTER
)) {
312 monster
->m_flags
|= CAN_FLIT
;
313 s
= mon_can_go(monster
, i
, j
);
314 monster
->m_flags
&= (~CAN_FLIT
);
316 move_mon_to(monster
, i
, j
);
317 monster
->m_flags
|= ASLEEP
;
318 monster
->m_flags
&= (~(WAKENS
| SEEKS_GOLD
));
321 monster
->m_flags
&= (~SEEKS_GOLD
);
322 monster
->m_flags
|= CAN_FLIT
;
323 mv_1_monster(monster
, i
, j
);
324 monster
->m_flags
&= (~CAN_FLIT
);
325 monster
->m_flags
|= SEEKS_GOLD
;
336 if (dungeon
[row
][col
] & OBJECT
) {
339 if ((obj
= object_at(&level_objects
, row
, col
)) &&
340 (obj
->what_is
== GOLD
)) {
347 check_gold_seeker(monster
)
350 monster
->m_flags
&= (~SEEKS_GOLD
);
353 check_imitator(monster
)
358 if (monster
->m_flags
& IMITATES
) {
361 mvaddch(monster
->row
, monster
->col
,
362 get_dungeon_char(monster
->row
, monster
->col
));
364 sprintf(msg
, "wait, that's a %s!", mon_name(monster
));
373 register short row
, col
;
375 if (dungeon
[row
][col
] & MONSTER
) {
376 object
*object_at(), *monster
;
378 if (monster
= object_at(&level_monsters
, row
, col
)) {
379 if (monster
->m_flags
& IMITATES
) {
390 short sting_chance
= 35;
393 if ((rogue
.str_current
<= 3) || sustain_strength
) {
396 sting_chance
+= (6 * (6 - get_armor_class(rogue
.armor
)));
398 if ((rogue
.exp
+ ring_exp
) > 8) {
399 sting_chance
-= (6 * ((rogue
.exp
+ ring_exp
) - 8));
401 if (rand_percent(sting_chance
)) {
402 sprintf(msg
, "the %s's bite has weakened you",
406 print_stats(STAT_STRENGTH
);
414 if (rand_percent(80) || (rogue
.exp
<= 5)) {
417 rogue
.exp_points
= level_points
[rogue
.exp
-2] - get_rand(9, 29);
420 if ((rogue
.hp_current
-= hp
) <= 0) {
421 rogue
.hp_current
= 1;
423 if ((rogue
.hp_max
-= hp
) <= 0) {
433 if (rand_percent(60) || (rogue
.hp_max
<= 30) || (rogue
.hp_current
< 10)) {
436 n
= get_rand(1, 3); /* 1 Hp, 2 Str, 3 both */
438 if ((n
!= 2) || (!sustain_strength
)) {
439 message("you feel weaker", 0);
447 if ((rogue
.str_current
> 3) && (!sustain_strength
)) {
454 print_stats((STAT_STRENGTH
| STAT_HP
));
462 if (!rogue_can_see(monster
->row
, monster
->col
)) {
465 if (rand_percent(45)) {
466 monster
->m_flags
&= (~CONFUSES
); /* will not confuse the rogue */
469 if (rand_percent(55)) {
470 monster
->m_flags
&= (~CONFUSES
);
471 sprintf(msg
, "the gaze of the %s has confused you", mon_name(monster
));
484 if ((!mon_sees(monster
, rogue
.row
, rogue
.col
)) || coin_toss()) {
487 row
= rogue
.row
- monster
->row
;
488 col
= rogue
.col
- monster
->col
;
495 if (((row
!= 0) && (col
!= 0) && (row
!= col
)) ||
496 ((row
> 7) || (col
> 7))) {
499 dir
= get_dir(monster
->row
, monster
->col
, row
, col
);
500 bounce(FIRE
, dir
, monster
->row
, monster
->col
, 0);
505 get_dir(srow
, scol
, drow
, dcol
)
506 short srow
, scol
, drow
, dcol
;
522 if ((srow
> drow
) && (scol
> dcol
)) {
525 if ((srow
< drow
) && (scol
< dcol
)) {
528 if ((srow
< drow
) && (scol
> dcol
)) {
531 /*if ((srow > drow) && (scol < dcol)) {*/