/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Timothy C. Stoehr.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* move.c
*
* 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
* gain or profit.
*
*/
#include "rogue.h"
short m_moves = 0;
boolean jump = 0;
const char you_can_move_again[] = "you can move again";
void
multiple_move_rogue(short dirch)
{
short row, col;
short m;
switch(dirch) {
case '\010':
case '\012':
case '\013':
case '\014':
case '\031':
case '\025':
case '\016':
case '\002':
do {
row = rogue.row;
col = rogue.col;
if (((m = one_move_rogue((dirch + 96), 1)) == MOVE_FAILED) ||
(m == STOPPED_ON_SOMETHING) ||
interrupted) {
break;
}
} while (!next_to_something(row, col));
if ( (!interrupted) && passgo && (m == MOVE_FAILED) &&
(dungeon[rogue.row][rogue.col] & TUNNEL)) {
turn_passage(dirch + 96, 0);
}
break;
case 'H':
case 'J':
case 'K':
case 'L':
case 'B':
case 'Y':
case 'U':
case 'N':
while ((!interrupted) && (one_move_rogue((dirch + 32), 1) == MOVED))
;
if (++m_moves >= 120) {
m_moves = 0;
wanderer();
}
if (halluc) {
if (!(--halluc)) {
unhallucinate();
} else {
hallucinate();
}
}
if (blind) {
if (!(--blind)) {
unblind();
}
}
if (confused) {
if (!(--confused)) {
unconfuse();
}
}
if (bear_trap) {
bear_trap--;
}
if (levitate) {
if (!(--levitate)) {
messagef(1, "you float gently to the ground");
if (dungeon[rogue.row][rogue.col] & TRAP) {
trap_player(rogue.row, rogue.col);
}
}
}
if (haste_self) {
if (!(--haste_self)) {
messagef(0, "you feel yourself slowing down");
}
}
heal();
if (auto_search > 0) {
search(auto_search, auto_search);
}
return(fainted);
}
void
rest(int count)
{
int i;
interrupted = 0;
for (i = 0; i < count; i++) {
if (interrupted) {
break;
}
(void)reg_move();
}
}
static char
gr_dir(void)
{
short d;
d = get_rand(1, 8);
switch(d) {
case 1:
d = 'j';
break;
case 2:
d = 'k';
break;
case 3:
d = 'l';
break;
case 4:
d = 'h';
break;
case 5:
d = 'y';
break;
case 6:
d = 'u';
break;
case 7:
d = 'b';
break;
case 8:
d = 'n';
break;
}
return(d);
}
static void
heal(void)
{
static short heal_exp = -1, n, c = 0;
static boolean alt;
if (rogue.hp_current == rogue.hp_max) {
c = 0;
return;
}
if (rogue.exp != heal_exp) {
heal_exp = rogue.exp;
switch(heal_exp) {
case 1:
n = 20;
break;
case 2:
n = 18;
break;
case 3:
n = 17;
break;
case 4:
n = 14;
break;
case 5:
n = 13;
break;
case 6:
n = 10;
break;
case 7:
n = 9;
break;
case 8:
n = 8;
break;
case 9:
n = 7;
break;
case 10:
n = 4;
break;
case 11:
n = 3;
break;
case 12:
default:
n = 2;
}
}
if (++c >= n) {
c = 0;
rogue.hp_current++;
if ((alt = !alt) != 0) {
rogue.hp_current++;
}
if ((rogue.hp_current += regeneration) > rogue.hp_max) {
rogue.hp_current = rogue.hp_max;
}
print_stats(STAT_HP);
}
}
static boolean
can_turn(short nrow, short ncol)
{
if ((dungeon[nrow][ncol] & TUNNEL) && is_passable(nrow, ncol)) {
return(1);
}
return(0);
}