예제 #1
0
int can_edit_zone(struct char_data *ch, zone_rnum rnum)
{
  /* no access if called with bad arguments */
  if (!ch->desc || IS_NPC(ch) || rnum == NOWHERE)
    return FALSE;

  /* always access if ch is high enough level */
  if (GET_LEVEL(ch) >= LVL_GRGOD)
    return (TRUE);
  
  /* always access if a player have helped build the zone in the first place */
  if (is_name(GET_NAME(ch), zone_table[rnum].builders))
    return (FALSE);
  
  /* no access if you haven't been assigned a zone */
  if (GET_OLC_ZONE(ch) == NOWHERE)
    return FALSE;

  /* no access if you're not at least LVL_BUILDER */
  if (GET_LEVEL(ch) < LVL_BUILDER)
    return FALSE;

  /* always access if you're assigned to this zone */
  if (real_zone(GET_OLC_ZONE(ch)) == rnum)
    return TRUE;

  return (FALSE);
}
예제 #2
0
파일: pvp.c 프로젝트: TempusMUD/Tempuscode
// Calculates the amount of reputation gained by the killer if they
// were to pkill the victim
int
pk_reputation_gain(struct creature *perp, struct creature *victim)
{
    if (perp == victim
        || IS_NPC(perp)
        || IS_NPC(victim))
        return 0;

    // Start with 10 for causing hassle
    int gain = 10;

    // adjust for level/gen difference
    gain += ((GET_LEVEL(perp) + GET_REMORT_GEN(perp) * 50)
             - (GET_LEVEL(victim) + GET_REMORT_GEN(victim) * 50)) / 5;

    // Additional adjustment for killing an innocent
    if (reputation_of(victim) == 0)
        gain *= 2;

    // Additional adjustment for killing a lower gen
    if (GET_REMORT_GEN(perp) > GET_REMORT_GEN(victim))
        gain += (GET_REMORT_GEN(perp) - GET_REMORT_GEN(victim)) * 9;

    if (IS_CRIMINAL(victim))
        gain /= 4;

    gain = MAX(1, gain);

    return gain;
}
예제 #3
0
/* manapoint gain per game hour */
int mana_gain(CharData * ch)
{
    int malnourishCount = 0;
    struct affected_type *hjp, *next;

    if (IN_ROOM(ch) == -1) return 0;

    if(!IS_NPC(ch) && ((GET_COND(ch, HUNGER) == 0 && !IS_VAMPIRE(ch)) || GET_COND(ch, THIRST) == 0)) {
        if(ch->desc && percentSuccess(2)) {
            if(!affected_by_spell(ch, SKILL_EMACIATED))
                add_affect( ch, ch, SKILL_EMACIATED, GET_LEVEL(ch), 0, 0, -1,
                        0, FALSE, FALSE, FALSE, FALSE);

            for (hjp = ch->affected; hjp; hjp = next) {
                next = hjp->next;
                if (hjp->type == SKILL_EMACIATED_MANA)
                    malnourishCount++;
            }

            if(malnourishCount < 18)
                add_affect( ch, ch, SKILL_EMACIATED_MANA, GET_LEVEL(ch), APPLY_MANA, -MIN(50, GET_MANA(ch)/20), -1,
                        0, FALSE, FALSE, FALSE, FALSE);
        }
    }

    int base = calcManaBase(ch);
    int multiplier = calcManaMulti(ch);
    int bonus = calcManaBonus(ch);
    
    int gain = base*multiplier/100 + bonus;
    if (affected_by_spell(ch, SKILL_POTENCY)) gain *= 5;
    return (gain);
}
예제 #4
0
파일: skills.c 프로젝트: quixadhal/wileymud
void do_peer(struct char_data *ch, char *argument, int cmd)
{
  void do_look(struct char_data *ch,char *arg,int cmd);

  if( GET_MANA(ch) < (15 - GET_LEVEL(ch,BestThiefClass(ch))/4))
  {
    send_to_char("You don't really see anything...\n\r",ch);
    return;
  }

  if(!*argument)
  {
    send_to_char("You must peer in a direction...\n\r",ch);
    return;
  }

  if(ch->skills[SKILL_PEER].learned < number(1,101))
  {
    do_look(ch,argument,0);
    GET_MANA(ch) -= 5; 
    return;
  }

  GET_MANA(ch) -= (20 - GET_LEVEL(ch,BestThiefClass(ch))/4);
  if(ch->skills[SKILL_PEER].learned < 50)
    ch->skills[SKILL_PEER].learned +=2;

  act("$n peers about the area.", TRUE, ch, 0, 0, TO_ROOM);

  do_look(ch,argument,SKILL_PEER);
}
예제 #5
0
파일: limits.c 프로젝트: matthewbode/mg2
void gain_exp_regardless(struct char_data * ch, int gain)
{
  int is_altered = FALSE;
  int num_levels = 0;

  GET_EXP(ch) += gain;
  if (GET_EXP(ch) < 0)
    GET_EXP(ch) = 0;

  if (!IS_NPC(ch)) {
    while (GET_LEVEL(ch) < LVL_IMPL &&
	GET_EXP(ch) >= level_exp(GET_CLASS(ch), GET_LEVEL(ch) + 1)) {
      GET_LEVEL(ch) += 1;
      num_levels++;
      advance_level(ch);
      is_altered = TRUE;
    }

    if (is_altered) {
      sprintf(buf, "%s advanced %d level%s to level %d.",
		GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s",
		GET_LEVEL(ch));
      mudlog(buf, BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE);
      if (num_levels == 1)
        send_to_char("You rise a level!\r\n", ch);
      else {
	sprintf(buf, "You rise %d levels!\r\n", num_levels);
	send_to_char(buf, ch);
      }
      set_title(ch, NULL);
      check_autowiz(ch);
    }
  }
}
예제 #6
0
파일: magic.c 프로젝트: nawglan/ShadowWind
int mag_savingthrow(struct char_data * ch, int type)
{
  int save;

  /* negative apply_saving_throw values make saving throws better! */
  if (!ch) {
    return 0;
  }

  if (IS_NPC(ch)) {
    save = class_saving_throws[(int) CLASS_WARRIOR][type] - (GET_LEVEL(ch) / 3);
    save += mob_race_saving_throws[(int) GET_RACE(ch)][type];
  } else {
    save = class_saving_throws[(int) GET_CLASS(ch)][type] - (GET_LEVEL(ch) / 4);
    save += race_saving_throws[(int) GET_RACE(ch)][type];
  }

  save += GET_SAVE(ch, type);

  /* throwing a 0 is always a failure */
  if (MAX(1, save) < number(0, 20))
    return TRUE;
  else
    return FALSE;
}
예제 #7
0
void
gain_skill_prof(struct creature *ch, int skl)
{
    int learned;
    if (skl == SKILL_READ_SCROLLS || skl == SKILL_USE_WANDS)
        learned = 10;
    else
        learned = LEARNED(ch);

    // NPCs don't learn
    if (IS_NPC(ch))
        return;

    // You can't gain in a skill that you don't really know
    if (GET_LEVEL(ch) < SPELL_LEVEL(skl, GET_CLASS(ch))) {
        if (!IS_REMORT(ch))
            return;
        if (GET_LEVEL(ch) < SPELL_LEVEL(skl, GET_REMORT_CLASS(ch)))
            return;
    }
    // Check for remort classes too
    if (SPELL_GEN(skl, GET_CLASS(ch)) > 0 &&
        GET_REMORT_GEN(ch) < SPELL_GEN(skl, GET_CLASS(ch)))
        return;

    if (GET_SKILL(ch, skl) >= (learned - 10))
        if ((GET_SKILL(ch, skl) - GET_LEVEL(ch)) <= 66)
            SET_SKILL(ch, skl, GET_SKILL(ch, skl) + 1);
}
예제 #8
0
void quest_join(struct char_data *ch, struct char_data *qm, char argument[MAX_INPUT_LENGTH])
{
  qst_vnum vnum;
  qst_rnum rnum;
  char buf[MAX_INPUT_LENGTH];

  if (!*argument)
    snprintf(buf, sizeof(buf),
             "%s What quest did you wish to join?", GET_NAME(ch));
  else if (GET_QUEST(ch) != NOTHING)
    snprintf(buf, sizeof(buf),
             "%s But you are already part of a quest!", GET_NAME(ch));
  else if((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING)
    snprintf(buf, sizeof(buf),
             "%s I don't know of such a quest!", GET_NAME(ch));
  else if ((rnum = real_quest(vnum)) == NOTHING)
    snprintf(buf, sizeof(buf),
             "%s I don't know of such a quest!", GET_NAME(ch));
  else if (GET_LEVEL(ch) < QST_MINLEVEL(rnum))
    snprintf(buf, sizeof(buf),
             "%s You are not experienced enough for that quest!", GET_NAME(ch));
  else if (GET_LEVEL(ch) > QST_MAXLEVEL(rnum))
    snprintf(buf, sizeof(buf),
             "%s You are too experienced for that quest!", GET_NAME(ch));
  else if (is_complete(ch, vnum))
    snprintf(buf, sizeof(buf),
             "%s You have already completed that quest!", GET_NAME(ch));
  else if ((QST_PREV(rnum) != NOTHING) && !is_complete(ch, QST_PREV(rnum)))
    snprintf(buf, sizeof(buf),
             "%s That quest is not available to you yet!", GET_NAME(ch));
  else if ((QST_PREREQ(rnum) != NOTHING) &&
           (real_object(QST_PREREQ(rnum)) != NOTHING) &&
           (get_obj_in_list_num(real_object(QST_PREREQ(rnum)),
       ch->carrying) == NULL))
    snprintf(buf, sizeof(buf),
             "%s You need to have %s first!", GET_NAME(ch),
      obj_proto[real_object(QST_PREREQ(rnum))].short_description);
  else {
    act("You join the quest.",    TRUE, ch, NULL, NULL, TO_CHAR);
    act("$n has joined a quest.", TRUE, ch, NULL, NULL, TO_ROOM);
    snprintf(buf, sizeof(buf),
             "%s Listen carefully to the instructions.", GET_NAME(ch));
    do_tell(qm, buf, cmd_tell, 0);
    set_quest(ch, rnum);
    send_to_char(ch, "%s", QST_INFO(rnum));
    if (QST_TIME(rnum) != -1)
      snprintf(buf, sizeof(buf),
        "%s You have a time limit of %d turn%s to complete the quest.",
        GET_NAME(ch), QST_TIME(rnum), QST_TIME(rnum) == 1 ? "" : "s");
    else
      snprintf(buf, sizeof(buf),
        "%s You can take however long you want to complete the quest.",
 GET_NAME(ch));
  }
  do_tell(qm, buf, cmd_tell, 0);
  save_char(ch);
}
예제 #9
0
int BestClassBIT(struct char_data *ch)
{
  int max=0, iClass=0, i;

  for (i=0; i< MAX_CLASS; i++)
    if (max < GET_LEVEL(ch,i)) 
    {
      max = GET_LEVEL(ch, i);
      iClass = i;
    }

  assert(max > 0);

  switch(iClass) 
  {
  case MAGE_LEVEL_IND:
    return(1);
    break;
  case CLERIC_LEVEL_IND:
    return(2);
    break;
  case WARRIOR_LEVEL_IND:
    return(4);
    break;
  case THIEF_LEVEL_IND:
    return(8);
    break; 
  case DRUID_LEVEL_IND:
    return(16);
    break;
  case MONK_LEVEL_IND:
    return(32);
    break;
  case BARBARIAN_LEVEL_IND:
    return(64);
    break;
  case SORCERER_LEVEL_IND:
    return(128);
    break;   
  case PALADIN_LEVEL_IND:
    return(256);
    break;      
  case RANGER_LEVEL_IND:
    return(512);
    break;   
  case PSI_LEVEL_IND: 
    return(1024);
    break;
  default:  
    mudlog( LOG_SYSERR, "Error in BestClassBIT"); 
    break; 
 } /* switch */
 
  return(iClass);
}
예제 #10
0
int max_exp_gain_pc(CHAR_DATA * ch)
{
	int result = 1;
	if (!IS_NPC(ch))
	{
		int max_per_lev =
			level_exp(ch, GET_LEVEL(ch) + 1) - level_exp(ch, GET_LEVEL(ch) + 0);
		result = max_per_lev / (10 + GET_REMORT(ch));
	}
	return result;
}
예제 #11
0
/*
** doInvigorate
*/
void
doInvigorate(CharData* ch)
{
   int gain = 0;

   gain += number(1, GET_LEVEL(ch)/3);
   gain += number(1, (GET_MAX_HIT(ch) - GET_LEVEL(ch)*12)/15);

   if (GET_HIT(ch) < GET_MAX_HIT(ch)) 
       GET_HIT(ch) = MIN( GET_MAX_HIT(ch), GET_HIT(ch) + gain );
}
예제 #12
0
int GetMaxLevel(struct char_data *ch)
{
  register int max=0, i;

  for (i=0; i< MAX_CLASS; i++) {
    if (GET_LEVEL(ch, i) > max)
      max = GET_LEVEL(ch,i);
  }

  return(max);
}
예제 #13
0
파일: objsave.c 프로젝트: sean/dominionmud
int Crash_offer_rent(struct char_data * ch, struct char_data * receptionist,
			 int display, int factor)
{
  char buf[MAX_INPUT_LENGTH];
  int i;
  long totalcost = 0, numitems = 0, norent = 0;

  norent = Crash_report_unrentables(ch, receptionist, ch->carrying);
  for (i = 0; i < NUM_WEARS; i++)
    norent += Crash_report_unrentables(ch, receptionist, GET_EQ(ch, i));

  if (norent)
    return 0;

  totalcost = min_rent_cost * factor;

  Crash_report_rent(ch, receptionist, ch->carrying, &totalcost, &numitems, display, factor);

  for (i = 0; i < NUM_WEARS; i++)
    Crash_report_rent(ch, receptionist, GET_EQ(ch, i), &totalcost, &numitems, display, factor);

  if (!numitems) {
    sprintf(buf, "%s But you are not carrying anything!  Just quit!", GET_NAME(ch));
    do_tell(receptionist, buf, 0, 0);
    return (0);
  }
  if (numitems > max_obj_save) {
    sprintf(buf, "%s Sorry, but I cannot store more than %d items.",
		GET_NAME(ch), max_obj_save);
    do_tell(receptionist, buf, 0, 0);
    return (0);
  }
  if (display) {
    sprintf(buf, "%s Plus, my %d coin fee..", GET_NAME(ch),
	    min_rent_cost * factor);
    do_tell(receptionist, buf, 0, 0);
    sprintf(buf, "%s Totalling %ld, minus your rent credit of %ld...",
	    GET_NAME(ch), totalcost, (long)(GET_LEVEL(ch) * 800));
    do_tell(receptionist, buf, 0, 0);
    totalcost = MAX(0, (int)(totalcost - (GET_LEVEL(ch) * 800)));
    sprintf(buf, "%s That will be %ld coin%s%s.", GET_NAME(ch),
	    totalcost, (totalcost == 1 ? "" : "s"),
	    (factor == RENT_FACTOR ? " per day" : ""));
    do_tell(receptionist, buf, 0, 0);
    if (totalcost > GET_GOLD(ch)) {
      sprintf(buf, "%s ...which I see you can't afford.", GET_NAME(ch));
      do_tell(receptionist, buf, 0, 0);
      return (0);
    } else if (factor == RENT_FACTOR)
      Crash_rent_deadline(ch, receptionist, totalcost);
  }
  return (totalcost);
}
예제 #14
0
파일: board.c 프로젝트: MUDOmnibus/Rom1
void Board_write_message(int board_type, struct char_data *ch, char *arg)
{
    char buf[200], buf2[200];
    char *tmstr;
    int ct, len;

    if (GET_LEVEL(ch) < WRITE_LVL(board_type)) {
	send_to_char("You are not advanced enough to write on this board.\n\r", ch);
	return;
    }

   if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) {
	send_to_char("The board is full.\n\r", ch);
	return;
   }

   if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) {
	send_to_char("The board is malfunctioning - sorry.\n\r", ch);
	log("Board: failed to find empty slot on write.");
	return;
   }

   /* skip blanks */
   /* RT removed for(; isspace(*arg); arg++); */
   if (!*arg) {
     send_to_char("We must have a headline!\n\r", ch);
     return;
   }

   ct = time(0);
   tmstr = (char *) asctime(localtime(&ct));
   *(tmstr + strlen(tmstr) - 1) = '\0';

   sprintf(buf2, "(%s)", GET_NAME(ch));
   sprintf(buf, "%6.10s %-12s :: %s", tmstr, buf2, arg);
   len = strlen(buf) + 1;
   if (!(NEW_MSG_INDEX(board_type).heading = (char *)malloc(sizeof(char)*len))) {
		send_to_char("The board is malfunctioning - sorry.\n\r", ch);
		return;
   }
   strcpy(NEW_MSG_INDEX(board_type).heading, buf);
   NEW_MSG_INDEX(board_type).heading[len-1] = '\0';
   NEW_MSG_INDEX(board_type).level = GET_LEVEL(ch);

   send_to_char("Write your message.  Terminate with a @.\n\r\n\r", ch);
   act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM);
 
   ch->desc->str = &(msg_storage[NEW_MSG_INDEX(board_type).slot_num]);
   ch->desc->max_str = MAX_MESSAGE_LENGTH;
   
   num_of_msgs[board_type]++;
}
예제 #15
0
/*----------------------------------------------------------------------------*
 *  NAME
 *      getLevelFromCCTLut
 *
 *  DESCRIPTION
 *      This function linearly interpolates the color value from LUT and
 *      color temperature.
 *
 *  RETURNS
 *      Level of the colour from 0 - 255.
 *
 *---------------------------------------------------------------------------*/
static uint8 getLevelFromCCTLut(uint16 temp, const uint16 *color_lut,
                                             uint16 sizeof_lut)
{
    uint16 idx;
    int16  x2,y2,x1,y1;
    int32  val;
    uint16 thk = temp/CCT_TEMP_FACTOR;

    for (idx = 0; idx < sizeof_lut; idx++)
    {
        /* Find the temperature just greater than temperature to be set */
        if (thk < GET_TEMP(color_lut[idx]))
        {
            if (0 == idx)
            {
                /* if the temperature is less than first LUT element
                 * then saturate at that value.
                 */
                return GET_LEVEL(color_lut[idx]);
            }
            else
            {
                /* Get the points on interpolation line
                 * Multiply temperature by unit factor to get value
                 * in Kelvin.
                 */
                y1 = (int16)GET_LEVEL(color_lut[idx - 1]);
                x1 = (int16)GET_TEMP(color_lut[idx - 1]) * CCT_TEMP_FACTOR;
                y2 = (int16)GET_LEVEL(color_lut[idx]);
                x2 = (int16)GET_TEMP(color_lut[idx]) * CCT_TEMP_FACTOR;

                /* Apply Straight Line interpolation.
                 * y = y1 + ((y2 - y1) * (x -x1))/(x2 - x1)
                 */
                val = ((int32)(y2 - y1))*((int16)temp - x1);
                val = (val)/(x2 - x1) + y1;

                /* return the calculated value */
                return ((uint8)val);
            }
        }
    }

    /* If temperature is greater than last element in LUT,
     * saturate to the highest
     */
    return GET_LEVEL(color_lut[sizeof_lut - 1]);

}
예제 #16
0
void do_eat(struct char_data *ch, char *argument, int cmd)
{
	char buf[100];
	struct obj_data *temp;
	struct affected_type af;

	one_argument(argument,buf);

	if(!(temp = get_obj_in_list_vis(ch,buf,ch->carrying)))
	{
		act("You can't find it!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if((temp->obj_flags.type_flag != ITEM_FOOD) && (GET_LEVEL(ch) < 22))
	{
		act("Your stomach refuses to eat that!?!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	if(GET_COND(ch,FULL)>20) /* Stomach full */
	{	
		act("You are to full to eat more!",FALSE,ch,0,0,TO_CHAR);
		return;
	}

	act("$n eats $p",TRUE,ch,temp,0,TO_ROOM);
	act("You eat the $o.",FALSE,ch,temp,0,TO_CHAR);

	gain_condition(ch,FULL,temp->obj_flags.value[0]);

	if(GET_COND(ch,FULL)>20)
		act("You are full.",FALSE,ch,0,0,TO_CHAR);

	if(temp->obj_flags.value[3] && (GET_LEVEL(ch) < 21)) /* The shit was poisoned ! */
	{
		act("Ooups, it tasted rather strange ?!!?",FALSE,ch,0,0,TO_CHAR);
		act("$n coughs and utters some strange sounds.",FALSE,ch,0,0,TO_ROOM);

		af.type = SPELL_POISON;
		af.duration = temp->obj_flags.value[0]*2;
		af.modifier = 0;
		af.location = APPLY_NONE;
		af.bitvector = AFF_POISON;
		affect_join(ch,&af, FALSE, FALSE);
	}

	extract_obj(temp);
}
예제 #17
0
int Board_write_message(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
  (void)board;
  char *tmstr;
  time_t ct;
  char buf[MAX_INPUT_LENGTH], buf2[MAX_NAME_LENGTH + 3];

  if (GET_LEVEL(ch) < WRITE_LVL(board_type)) {
    send_to_char(ch, "You are not holy enough to write on this board.\r\n");
    return (1);
  }
  if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) {
    send_to_char(ch, "The board is full.\r\n");
    return (1);
  }
  if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) {
    send_to_char(ch, "The board is malfunctioning - sorry.\r\n");
    log("SYSERR: Board: failed to find empty slot on write.");
    return (1);
  }
  /* skip blanks */
  skip_spaces(&arg);
  delete_doubledollar(arg);

  /* JE 27 Oct 95 - Truncate headline at 80 chars if it's longer than that */
  arg[80] = '\0';

  if (!*arg) {
    send_to_char(ch, "We must have a headline!\r\n");
    return (1);
  }
  ct = time(0);
  tmstr = (char *) asctime(localtime(&ct));
  *(tmstr + strlen(tmstr) - 1) = '\0';

  snprintf(buf2, sizeof(buf2), "(%s)", GET_NAME(ch));
  snprintf(buf, sizeof(buf), "%6.10s %-12s :: %s", tmstr, buf2, arg);
  NEW_MSG_INDEX(board_type).heading = strdup(buf);
  NEW_MSG_INDEX(board_type).level = GET_LEVEL(ch);

  send_to_char(ch, "Write your message.  Terminate with a @ on a new line.\r\n\r\n");
  act("$n starts to write a message.", TRUE, ch, 0, 0, CommTarget::TO_ROOM);

  string_write(ch->desc, &(msg_storage[NEW_MSG_INDEX(board_type).slot_num]),
		MAX_MESSAGE_LENGTH, board_type + BOARD_MAGIC, NULL);

  num_of_msgs[board_type]++;
  return (1);
}
예제 #18
0
int BestClassIND(struct char_data *ch)
{

  int max=0, iClass=0, i;

  for (i=0; i< MAX_CLASS; i++)
    if (max < GET_LEVEL(ch,i)) {
      max = GET_LEVEL(ch, i);
      iClass = i;
    }

  assert(max > 0);
  return(iClass);

}
예제 #19
0
int calcMoveBase(CharData *ch) {
    int base = 0;

    base += graf(age(ch).year, 40, 39, 34, 30, 26, 24, 23);

    /* Class/Level calculations */
    if (GET_CLASS(ch) == CLASS_RANGER)
        base += GET_LEVEL(ch);
    else if (GET_CLASS(ch) == CLASS_ASSASSIN || GET_CLASS(ch) == CLASS_THIEF)
        base += GET_LEVEL(ch)*2/3;
    else
        base += GET_LEVEL(ch)/3;
        
    return base;
}
예제 #20
0
void list_skills(struct char_data *ch)
{
  const char *overflow = "\r\n**OVERFLOW**\r\n";
  int i, sortpos;
  size_t len = 0, nlen;
  char buf2[MAX_STRING_LENGTH];

  len = snprintf(buf2, sizeof(buf2), "You have %d practice session%s remaining.\r\n"
	"You know of the following %ss:\r\n", GET_PRACTICES(ch),
	GET_PRACTICES(ch) == 1 ? "" : "s", SPLSKL(ch));

  int cnt = 0;
  for (sortpos = 1; sortpos <= MAX_SKILLS; sortpos++) {
    i = spell_sort_info[sortpos];
    if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) {
      cnt += 1;
      nlen = snprintf(buf2 + len, sizeof(buf2) - len, (cnt%2) ? "%-20s %s | " : "%-20s %s\r\n", spell_info[i].name, how_good(GET_SKILL(ch, i)));
      if (len + nlen >= sizeof(buf2) || nlen < 0)
        break;
      len += nlen;
    }
  }
  if (len >= sizeof(buf2))
    strcpy(buf2 + sizeof(buf2) - strlen(overflow) - 1, overflow); /* strcpy: OK */

  parse_at(buf2);
  page_string(ch->desc, buf2, TRUE);
}
예제 #21
0
bool
can_see_creature(struct creature * self, struct creature * vict)
{
    // Can always see self
    if (self == vict)
        return true;

    // Immortals players can always see non-immortal players
    if (IS_IMMORT(self) && !IS_IMMORT(vict))
        return true;

    //only immortals can see utility mobs
    if (IS_NPC(vict) && NPC_FLAGGED(vict, NPC_UTILITY) && !IS_IMMORT(self)) {
        return false;
    }
    // Nothing at all gets through immort invis
    if (IS_IMMORT(vict) && GET_LEVEL(self) < GET_INVIS_LVL(vict))
        return false;

    if (PRF_FLAGGED(self, PRF_HOLYLIGHT))
        return true;

    if (!check_sight_self(self))
        return false;

    if (!check_sight_room(self, vict->in_room))
        return false;

    if (!check_sight_vict(self, vict))
        return false;

    return true;
}
예제 #22
0
bool
summon_criminal_demons(struct creature *vict)
{
    struct creature *mob;
    int vnum_base = (IS_EVIL(vict)) ? ARCHONIC_BASE : DEMONIC_BASE;
    int demon_num = GET_REMORT_GEN(vict) / 2 + 1;
    int idx;

    for (idx = 0; idx < demon_num; idx++) {
        mob = read_mobile(vnum_base + MIN(4, (GET_LEVEL(vict) / 9))
            + number(0, 1));
        if (!mob) {
            errlog("Unable to load mob in demonic_overmind");
            return false;
        }
        start_hunting(mob, vict);
        SET_BIT(NPC_FLAGS(mob), NPC_SPIRIT_TRACKER);
        CREATE(mob->mob_specials.func_data, int, 1);
        *((int *)mob->mob_specials.func_data) = GET_IDNUM(vict);

        char_to_room(mob, vict->in_room, true);
        act("The air suddenly cracks open and $n steps out!", false,
            mob, NULL, NULL, TO_ROOM);
    }

    if (IS_EVIL(vict))
        mudlog(GET_INVIS_LVL(vict), NRM, true,
            "%d archons dispatched to hunt down %s",
            demon_num, GET_NAME(vict));
    else
        mudlog(GET_INVIS_LVL(vict), NRM, true,
            "%d demons dispatched to hunt down %s", demon_num, GET_NAME(vict));

    return true;
}
예제 #23
0
/* simple function to determine if char can walk on water */
int has_boat(struct char_data *ch)
{
  struct obj_data *obj;
  int i;

/*
  if (ROOM_IDENTITY(IN_ROOM(ch)) == DEAD_SEA)
    return (1);
*/

  if (GET_LEVEL(ch) >= LVL_IMMORT)
    return (1);

  if (AFF_FLAGGED(ch, AFF_WATERWALK) || AFF_FLAGGED(ch, AFF_AIRWALK))
    return (1);

  /* non-wearable boats in inventory will do it */
  for (obj = ch->carrying; obj; obj = obj->next_content)
    if (GET_OBJ_TYPE(obj) == ITEM_BOAT && (find_eq_pos(ch, obj, NULL) < 0))
      return (1);

  /* and any boat you're wearing will do it too */
  for (i = 0; i < NUM_WEARS; i++)
    if (GET_EQ(ch, i) && GET_OBJ_TYPE(GET_EQ(ch, i)) == ITEM_BOAT)
      return (1);

  return (0);
}
예제 #24
0
void loss_breath(struct char_data * ch, int breath)
{

	if (AFF2_FLAGGED(ch, AFF2_IRON_BODY))
		return;

	if (ROOM_AFFECTED(ch->in_room, RAFF_LIQUID_AIR)) {
		GET_OXI(ch) -= number(2, 10);
	}

	if(GET_LEVEL(ch) < LVL_IMMORT && breath > 0)
	{
		if(GET_OXI(ch) >= 1)
		{
			GET_OXI(ch) -= breath;
			send_to_char("Your breath becomes deeper and slower...\r\n", ch);
		} else {
			if(GET_HIT(ch) > 0)
			{
            	GET_HIT(ch) -= (GET_MAX_HIT(ch)*0.15);
            	send_to_char("&RYou need some oxygen, your life is almost extinguished!&n\r\n", ch);
			} else {
	           	GET_HIT(ch) = 0;
	           	send_to_char("&RYour breath becomes so slow that you die because of it.&n\r\n", ch);
            	raw_kill(ch, NULL);
			}
		}
	}
}
예제 #25
0
void perform_mob_flag_list(struct char_data * ch, char *arg)
{
  int num, mob_flag, found = 0, len;
  struct char_data *mob;
  char buf[MAX_STRING_LENGTH];

  mob_flag = atoi(arg);

  if (mob_flag < 0 || mob_flag > NUM_MOB_FLAGS) {
    send_to_char(ch, "Invalid flag number!\r\n");
    return;
  }

  len = snprintf(buf, sizeof(buf), "Listing mobiles with %s%s%s flag set.\r\n", QYEL, action_bits[mob_flag], QNRM);

  for(num=0;num<=top_of_mobt;num++) {
    if(IS_SET_AR((mob_proto[num].char_specials.saved.act), mob_flag)) {

      if ((mob = read_mobile(num, REAL)) != NULL) {
        char_to_room(mob, 0);
        len += snprintf(buf + len, sizeof(buf) - len, "%s%3d. %s[%s%5d%s]%s Level %s%-3d%s %s%s\r\n", CCNRM(ch, C_NRM),++found,
                      CCCYN(ch, C_NRM), CCYEL(ch, C_NRM), GET_MOB_VNUM(mob), CCCYN(ch, C_NRM), CCNRM(ch, C_NRM),
                      CCYEL(ch, C_NRM), GET_LEVEL(mob), CCNRM(ch, C_NRM), GET_NAME(mob), CCNRM(ch, C_NRM));
        extract_char(mob); /* Finished with the mob - remove it from the MUD */
        if (len > sizeof(buf))
		  break;
      }
    }
  }
  if (!found)
    send_to_char(ch,"None Found!\r\n");
  else
    page_string(ch->desc, buf, TRUE);
  return;
}
예제 #26
0
 /* Hey! Don't go calling this w/o making checks! */
static void
npc_regen(struct char_data * ch) {
  int regen_rate = 2;
  GET_HIT(ch) += GET_LEVEL(ch) * regen_rate;
  if(GET_HIT(ch) > GET_MAX_HIT(ch))
     GET_HIT(ch) = GET_MAX_HIT(ch);
}
예제 #27
0
struct obj_data *
findCostliestObj(struct creature *ch)
{
    struct obj_data *cur_obj, *result;

    if (GET_LEVEL(ch) >= LVL_AMBASSADOR)
        return NULL;

    result = NULL;

    cur_obj = ch->carrying;
    while (cur_obj) {
        if (cur_obj &&
            (!result || GET_OBJ_COST(result) < GET_OBJ_COST(cur_obj)))
            result = cur_obj;

        if (cur_obj->contains)
            cur_obj = cur_obj->contains;    // descend into obj
        else if (!cur_obj->next_content && cur_obj->in_obj)
            cur_obj = cur_obj->in_obj->next_content;    // ascend out of obj
        else
            cur_obj = cur_obj->next_content;    // go to next obj
    }

    return result;
}
예제 #28
0
void Character::SendTell(Character *target, char *arg)
{
	target->send(COLOR_RED(target, CL_NORMAL));
	sprintf(buf, "$n tells you, '%s'", (char*)this->ScrambleSpeech(arg, target).c_str());
	Act(buf, FALSE, this, 0, target, TO_VICT | TO_SLEEP);
	target->send(COLOR_NORMAL(target, CL_NORMAL));

	if(!IS_NPC(target) && NEWB_FLAGGED(target, NEW_TELL) && !IS_NPC(this))
	{
		REMOVE_BIT_AR(NEWB_FLAGS(target), NEW_TELL);
		target->NewbieTip("You can reply to %s by typing 'reply' followed by the message you wish to send.\r\n",
		                GET_NAME(this), GET_NAME(this));
	}

	if (!IS_NPC(this) && PRF_FLAGGED(this, PRF_NOREPEAT))
		this->send(OK);
	else
	{
		CommManager::GetManager().SaveComm(std::string("tell"), arg, this, this->in_room->getVnum(), target);
		sprintf(buf, "You tell $N, '%s'", arg);
		Act(buf, FALSE, this, 0, target, TO_CHAR);

		if(IS_NPC(target) && !IS_NPC(this))
			MudLog(CMP, MAX(GET_LEVEL(this), LVL_GOD), TRUE, "%s tells %s '%s' in room %d.",
			GET_NAME(this), GET_NAME(target), arg, this->in_room->getVnum());

		if(this->IsIgnoring(target->player.name))
			this->RemoveIgnore(target->player.name);
	}

	if (!IS_NPC(target) && !IS_NPC(this))
		target->last_tell = this->player.idnum;

	js_tell_triggers(this, target, arg);
}
예제 #29
0
int Board_show_board(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
  int i;
  char tmp[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];

  if (!ch->desc)
    return (0);

  one_argument(arg, tmp);

  if (!*tmp || !isname(tmp, board->name))
    return (0);

  if (GET_LEVEL(ch) < READ_LVL(board_type)) {
    send_to_char(ch, "You try but fail to understand the holy words.\r\n");
    return (1);
  }
  act("$n studies the board.", TRUE, ch, 0, 0, CommTarget::TO_ROOM);

  if (!num_of_msgs[board_type])
    send_to_char(ch, "This is a bulletin board.  Usage: READ/REMOVE <messg #>, WRITE <header>.\r\nThe board is empty.\r\n");
  else {
    size_t len = 0;
    int nlen;

    len = snprintf(buf, sizeof(buf),
		"This is a bulletin board.  Usage: READ/REMOVE <messg #>, WRITE <header>.\r\n"
		"You will need to look at the board to save your message.\r\n"
		"There are %d messages on the board.\r\n",
		num_of_msgs[board_type]);
#if NEWEST_AT_TOP
    for (i = num_of_msgs[board_type] - 1; i >= 0; i--) {
      if (!MSG_HEADING(board_type, i))
        goto fubar;

      nlen = snprintf(buf + len, sizeof(buf) - len, "%-2d : %s\r\n", num_of_msgs[board_type] - i, MSG_HEADING(board_type, i));
      if (len + nlen >= sizeof(buf) || nlen < 0)
        break;
      len += nlen;
    }
#else
    for (i = 0; i < num_of_msgs[board_type]; i++) {
      if (!MSG_HEADING(board_type, i))
        goto fubar;

      nlen = snprintf(buf + len, sizeof(buf) - len, "%-2d : %s\r\n", i + 1, MSG_HEADING(board_type, i));
      if (len + nlen >= sizeof(buf) || nlen < 0)
        break;
      len += nlen;
    }
#endif
    page_string(ch->desc, buf, TRUE);
  }
  return (1);

fubar:
  log("SYSERR: Board %d is fubar'd.", board_type);
  send_to_char(ch, "Sorry, the board isn't working.\r\n");
  return (1);
}
예제 #30
0
int
cast_spell (struct char_data *ch, struct char_data *tch,
			struct obj_data *tobj, int spellnum)
{
	if (spellnum < 0 || spellnum > TOP_SPELL_DEFINE)
	{
		log ("SYSERR: cast_spell trying to call spellnum %d/%d.\n", spellnum,
			 TOP_SPELL_DEFINE);
		return (0);
	}

	if (GET_POS (ch) < SINFO.min_position)
	{
		switch (GET_POS (ch))
		{
		case POS_SLEEPING:
			send_to_char ("You dream about great magical powers.\r\n", ch);
			break;
		case POS_RESTING:
			send_to_char ("You cannot concentrate while resting.\r\n", ch);
			break;
		case POS_SITTING:
			send_to_char ("You can't do this sitting!\r\n", ch);
			break;
		case POS_FIGHTING:
			send_to_char ("Impossible!  You can't concentrate enough!\r\n",
						  ch);
			break;
		default:
			send_to_char ("You can't do much of anything like this!\r\n", ch);
			break;
		}
		return (0);
	}
	if (AFF_FLAGGED (ch, AFF_CHARM) && (ch->master == tch))
	{
		send_to_char ("You are afraid you might hurt your master!\r\n", ch);
		return (0);
	}
	if ((tch != ch) && IS_SET (SINFO.targets, TAR_SELF_ONLY))
	{
		send_to_char ("You can only cast this spell upon yourself!\r\n", ch);
		return (0);
	}
	if ((tch == ch) && IS_SET (SINFO.targets, TAR_NOT_SELF))
	{
		send_to_char ("You cannot cast this spell upon yourself!\r\n", ch);
		return (0);
	}
	if (IS_SET (SINFO.routines, MAG_GROUPS) && !AFF_FLAGGED (ch, AFF_GROUP))
	{
		send_to_char
			("You can't cast this spell if you're not in a group!\r\n", ch);
		return (0);
	}
	send_to_char (OK, ch);
	say_spell (ch, spellnum, tch, tobj);

	return (call_magic (ch, tch, tobj, spellnum, GET_LEVEL (ch), CAST_SPELL));
}