示例#1
0
void 
set_initial_hp (CHAR_DATA * ch)
{
  int init_hp;
  int init_mp;
  if (IS_MOB (ch))
    {
      init_hp = pow.initial_hp[0] / 2;	/* Take into account mobs are usually */
      init_mp = (pow.initial_mv[0] * 2) / 3;	/* Higher level */
    }
  else
    {
      if (ch->pcdata->remort_times > 0)
	{
	  init_hp = number_range (pow.remort_hp[0], pow.remort_hp[1]);
	  init_mp = number_range (pow.remort_mv[0], pow.remort_mv[1]);
	}
      else
	{
	  init_hp = number_range (pow.initial_hp[0], pow.initial_hp[1]);
	  init_mp = number_range (pow.initial_mv[0], pow.initial_mv[1]);
	}
    }

  ch->max_hit = init_hp;
  ch->max_move = init_mp;
  if (IS_MOB (ch) || pow.restore_when_level)
    {
      MAXHIT(ch);
      MAXMOVE(ch);
    }
  return;
}
示例#2
0
void
procmain(void)
{
	int ch;			/* input */
	double x;		/* desired new x coordinate */
	double y;		/* desired new y coordinate */
	double temp;		/* for temporary calculations */
	FILE *fp;		/* for opening files */
	int loop;		/* a loop counter */
	bool hasmoved = FALSE;	/* set if player has moved */

	ch = inputoption();
	mvaddstr(4, 0, "\n\n");	/* clear status area */

	move(7, 0);
	clrtobot();		/* clear data on bottom area of screen */

	if (Player.p_specialtype == SC_VALAR && (ch == '1' || ch == '7'))
		/* valar cannot move */
		ch = ' ';

	switch (ch) {
	case 'K':		/* move up/north */
	case 'N':
		x = Player.p_x;
		y = Player.p_y + MAXMOVE();
		hasmoved = TRUE;
		break;

	case 'J':		/* move down/south */
	case 'S':
		x = Player.p_x;
		y = Player.p_y - MAXMOVE();
		hasmoved = TRUE;
		break;

	case 'L':		/* move right/east */
	case 'E':
		x = Player.p_x + MAXMOVE();
		y = Player.p_y;
		hasmoved = TRUE;
		break;

	case 'H':		/* move left/west */
	case 'W':
		x = Player.p_x - MAXMOVE();
		y = Player.p_y;
		hasmoved = TRUE;
		break;

	default:		/* rest */
		Player.p_energy += (Player.p_maxenergy + Player.p_shield) / 15.0 +
		    Player.p_level / 3.0 + 2.0;
		Player.p_energy =
		    MIN(Player.p_energy, Player.p_maxenergy + Player.p_shield);

		if (Player.p_status != S_CLOAKED) {
			/* cannot find mana if cloaked */
			Player.p_mana += (Circle + Player.p_level) / 4.0;

			if (drandom() < 0.2 && Player.p_status == S_PLAYING && !Throne)
				/* wandering monster */
				encounter(-1);
		}
		break;

	case 'X':		/* change/examine a character */
		changestats(TRUE);
		break;

	case '1':		/* move */
		for (loop = 3; loop; --loop) {
			mvaddstr(4, 0, "X Y Coordinates ? ");
			getstring(Databuf, SZ_DATABUF);

			if (sscanf(Databuf, "%lf %lf", &x, &y) != 2)
				mvaddstr(5, 0, "Try again\n");
			else if (distance(Player.p_x, x, Player.p_y, y) > MAXMOVE())
				ILLMOVE();
			else {
				hasmoved = TRUE;
				break;
			}
		}
		break;

	case '2':		/* players */
		userlist(TRUE);
		break;

	case '3':		/* message */
		mvaddstr(4, 0, "Message ? ");
		getstring(Databuf, SZ_DATABUF);
		/* we open the file for writing to erase any data which is already there */
		fp = fopen(_PATH_MESS, "w");
		if (Databuf[0] != '\0')
			fprintf(fp, "%s: %s", Player.p_name, Databuf);
		fclose(fp);
		break;

	case '4':		/* stats */
		allstatslist();
		break;

	case '5':		/* good-bye */
		leavegame();
		/* NOTREACHED */

	case '6':		/* cloak */
		if (Player.p_level < MEL_CLOAK || Player.p_magiclvl < ML_CLOAK)
			ILLCMD();
		else if (Player.p_status == S_CLOAKED)
			Player.p_status = S_PLAYING;
		else if (Player.p_mana < MM_CLOAK)
			mvaddstr(5, 0, "No mana left.\n");
		else {
			Changed = TRUE;
			Player.p_mana -= MM_CLOAK;
			Player.p_status = S_CLOAKED;
		}
		break;

	case '7':		/* teleport */

		/*
		 * conditions for teleport
		 *	- 20 per (level plus magic level)
		 *	- OR council of the wise or valar or ex-valar
		 *	- OR transport from throne
		 * transports from throne cost no mana
		 */
		if (Player.p_level < MEL_TELEPORT || Player.p_magiclvl < ML_TELEPORT)
			ILLCMD();
		else
			for (loop = 3; loop; --loop) {
				mvaddstr(4, 0, "X Y Coordinates ? ");
				getstring(Databuf, SZ_DATABUF);

				if (sscanf(Databuf, "%lf %lf", &x, &y) == 2) {
					temp = distance(Player.p_x, x, Player.p_y, y);
					if (!Throne
					/* can transport anywhere from throne */
					    && Player.p_specialtype <= SC_COUNCIL
					/* council, valar can transport anywhere */
					    && temp > (Player.p_level + Player.p_magiclvl) * 20.0)
						/* can only move 20 per exp. level + mag. level */
						ILLMOVE();
					else {
						temp = (temp / 75.0 + 1.0) * 20.0;	/* mana used */

						if (!Throne && temp > Player.p_mana)
							mvaddstr(5, 0, "Not enough power for that distance.\n");
						else {
							if (!Throne)
								Player.p_mana -= temp;
							hasmoved = TRUE;
							break;
						}
					}
				}
			}
		break;

	case 'C':
	case '9':		/* monster */
		if (Throne)
			/* no monsters while on throne */
			mvaddstr(5, 0, "No monsters in the chamber!\n");
		else if (Player.p_specialtype != SC_VALAR) {
			/* the valar cannot call monsters */
			Player.p_sin += 1e-6;
			encounter(-1);
		}
		break;

	case '0':		/* decree */
		if (Wizard || (Player.p_specialtype == SC_KING && Throne))
			/* kings must be on throne to decree */
			dotampered();
		else
			ILLCMD();
		break;

	case '8':		/* intervention */
		if (Wizard || Player.p_specialtype >= SC_COUNCIL)
			dotampered();
		else
			ILLCMD();
		break;
	}

	if (hasmoved) {
		/* player has moved -- alter coordinates, and do random monster */
		altercoordinates(x, y, A_SPECIFIC);

		if (drandom() < 0.2 && Player.p_status == S_PLAYING && !Throne)
			encounter(-1);
	}
}
示例#3
0
void 
add_level_bonuses (CHAR_DATA * ch, int how_many)
{
  int i, jh, jm, j, jhr, jmr;
  int hitgain = 0;
  int movegain = 0;
  char buffer[500];
  for (i = 0; i < how_many; i++)
    {
      hitgain = 0;
      movegain = 0;
      if (IS_MOB(ch))
	{
	  int adder;
	  adder = LEVEL(ch)/17;
          if (adder > 8) adder = 8;
	  hitgain = number_range((1 + adder),(4+ adder));
	  movegain = number_range((1 + adder/2),(2 + adder/2));
	}
      else
	{
     
	  jh = 10; 
	  jm = 10;
	  jhr = 10;
	  jmr = 10;
	  
	  for (j = 0; j < 10; j++)
	    {
	      if  ((LEVEL (ch) - i) >= pow.hitgain[j][0] && (LEVEL (ch) - i) <= pow.hitgain[j][1])
		jh = j;
	      if  ((LEVEL (ch) - i) >= pow.movegain[j][0] && (LEVEL (ch) - i) <= pow.movegain[j][1])        
		jm = j;
	      if  ((LEVEL (ch) - i) >= pow.rem_hitgain[j][0] && (LEVEL (ch) - i) <= pow.rem_hitgain[j][1])
		jhr = j;
	      if  ((LEVEL (ch) - i) >= pow.rem_movegain[j][0] && (LEVEL (ch) - i) <= pow.rem_movegain[j][1])
		jmr = j;
	    }
	  
	  { 
	    int remort_mult = 0; /* amt of times remort bonus is added */
	    int up_hitgain = 0;  /* Upper range of the randomness... */
	    int low_hitgain = 0; /* Lower range of randomness */
	    int up_movegain = 0; /* Upper range of randomness for moves */
	    int low_movegain = 0; /* Lower range of the randomness...*/
	    
	    if (pow.remort_bonus_fixed)
	      {
		if (ch->pcdata->remort_times == 0)
		  remort_mult = 0;
		else
		  remort_mult = 1;
	      }
	    else
	      remort_mult = ch->pcdata->remort_times;
	    /* The basic structure of the hitgain/movegain is as follows : */
	    /* From the above we have a list of 4 numbers jh, jhr, jm, jmr which tell 
	       the "place" for hitgain, movegain, remorts hitgain, remorts movegain
	       and then hitgain is made to be the conbonus * (the reg conbonus + the
	       remort bonus times the multiplier). The same idea is used for movegain
	       except now the bonuses are the only things we add and the lower number
	       is the regular number + remortnumber * remort mult. */
	    
	    
	    up_hitgain = pow.hitgain[jh][4] + (ch->pcdata->remort_times) * pow.rem_hitgain[jhr][4];
	    low_hitgain = pow.hitgain[jh][3] + (ch->pcdata->remort_times) * pow.rem_hitgain[jhr][3];
	    hitgain = (con_app[get_curr_con (ch) - 1].hit * ( pow.hitgain[jh][2] + (pow.rem_hitgain[jhr][2] * remort_mult)));
	    hitgain += number_range (low_hitgain, up_hitgain);
	    hitgain /= 100;
	    hitgain += race_info[ch->pcdata->race].hps_bonus;
	    hitgain += align_info[ch->pcdata->alignment].hps_bonus;
	    
	    /* Move gain down here for players... */
	    
	    
	    low_movegain = pow.movegain[jm][2] + (pow.rem_movegain[jmr][2] * remort_mult);
	    up_movegain = pow.movegain[jm][3] + (pow.rem_movegain[jmr][3]  * remort_mult); 
	    movegain = number_range(low_movegain, up_movegain);
	    movegain /= 100;
	    
	  } 
	}
      ch->max_hit += hitgain;
      ch->max_move += movegain;

      sprintf(buffer,"\x1B[1;30m-->\x1B[1;32m%3d hit points\x1B[1;37m and\x1B[1;32m%3d move points\x1B[1;37m gained\n\r",hitgain,movegain);
      send_to_char(buffer,ch);

    }
      MAXMOVE(ch);
      MAXHIT(ch);
      return;
}