Exemplo n.º 1
0
struct obj_data *
roll_joint(struct obj_data *tobac, struct obj_data *paper)
{
    struct obj_data *obj;
    struct extra_descr_data *new_descr;
    char buf[200];

    if (!tobac || !paper) {
        errlog(" Attempt to roll_joint with NULL tobac or paper.");
        return NULL;
    }
    obj = make_object();
    obj->shared = null_obj_shared;
    CREATE(new_descr, struct extra_descr_data, 1);

    snprintf(buf, sizeof(buf), "cig cigarette joint %s", fname(tobac->aliases));
    obj->aliases = strdup(buf);
    snprintf(buf, sizeof(buf), "a %s cigarette", fname(tobac->aliases));
    obj->name = strdup(buf);
    snprintf_cat(buf, sizeof(buf), " has been dropped here.", sizeof(buf), "It looks like a %s cigarette, waiting to be smoked.",
        fname(tobac->aliases));
    new_descr->description = strdup(buf);
    new_descr->next = NULL;
    obj->ex_description = new_descr;

    GET_OBJ_TYPE(obj) = ITEM_CIGARETTE;
    GET_OBJ_VAL(obj, 0) = 3 + (GET_OBJ_WEIGHT(tobac) * 3);
    GET_OBJ_VAL(obj, 1) = GET_OBJ_VAL(tobac, 2);
    GET_OBJ_VAL(obj, 2) = SMOKE_TYPE(tobac);
    GET_OBJ_WEAR(obj) = ITEM_WEAR_TAKE + ITEM_WEAR_HOLD;
    GET_OBJ_COST(obj) = GET_OBJ_COST(tobac);

    return obj;
}
Exemplo n.º 2
0
void enchant::apply_to_obj(OBJ_DATA *obj) const
{
	for (auto i = affected_.cbegin(), iend = affected_.cend(); i != iend; ++i)
	{
		for (int k = 0; k < MAX_OBJ_AFFECT; k++)
		{
			if (obj->affected[k].location == i->location)
			{
				obj->affected[k].modifier += i->modifier;
				break;
			}
			else if (obj->affected[k].location == APPLY_NONE)
			{
				obj->affected[k].location = i->location;
				obj->affected[k].modifier = i->modifier;
				break;
			}
		}
	}

	GET_OBJ_AFFECTS(obj) += affects_flags_;
	obj->obj_flags.extra_flags += extra_flags_;
	obj->obj_flags.no_flag += no_flags_;

	GET_OBJ_WEIGHT(obj) += weight_;

	if (GET_OBJ_TYPE(obj) == ITEM_WEAPON)
	{
		GET_OBJ_VAL(obj, 1) += ndice_;
		GET_OBJ_VAL(obj, 2) += sdice_;
	}

	correct_values(obj);
	obj->enchants.add(*this);
}
Exemplo n.º 3
0
void update_char_objects(struct char_data * ch)
{
  int i;

  if (GET_EQ(ch, WEAR_LIGHT) != NULL)
    if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
      if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2) > 0) {
	i = --GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2);
	if (i == 1) {
	  act("Your light begins to flicker and fade.", FALSE, ch, 0, 0, TO_CHAR);
	  act("$n's light begins to flicker and fade.", FALSE, ch, 0, 0, TO_ROOM);
	} else if (i == 0) {
	  act("Your light sputters out and dies.", FALSE, ch, 0, 0, TO_CHAR);
	  act("$n's light sputters out and dies.", FALSE, ch, 0, 0, TO_ROOM);
	  world[ch->in_room].light--;
	}
      }

  for (i = 0; i < NUM_WEARS; i++)
    if (GET_EQ(ch, i))
      update_object(GET_EQ(ch, i), 2);

  if (ch->carrying)
    update_object(ch->carrying, 1);
}
Exemplo n.º 4
0
void Enchants::update_set_bonus(OBJ_DATA *obj, const obj_sets::ench_type *set_ench)
{
	for (auto i = list_.begin(); i != list_.end(); ++i)
	{
		if (i->type_ == ENCHANT_FROM_SET)
		{
			if (i->weight_ != set_ench->weight
				|| i->ndice_ != set_ench->ndice
				|| i->sdice_ != set_ench->sdice)
			{
				// вес
				GET_OBJ_WEIGHT(obj) += set_ench->weight - i->weight_;
				// дайсы пушек
				if (GET_OBJ_TYPE(obj) == ITEM_WEAPON)
				{
					GET_OBJ_VAL(obj, 1) += set_ench->ndice - i->ndice_;
					GET_OBJ_VAL(obj, 2) += set_ench->sdice - i->sdice_;
				}
				correct_values(obj);
				i->weight_ = set_ench->weight;
				i->ndice_ = set_ench->ndice;
				i->sdice_ = set_ench->sdice;
			}
			return;
		}
	}

	obj::enchant tmp;
	tmp.type_ = obj::ENCHANT_FROM_SET;
	tmp.name_ = "набором предметов";
	tmp.weight_ = set_ench->weight;
	tmp.ndice_ = set_ench->ndice;
	tmp.sdice_ = set_ench->sdice;
	tmp.apply_to_obj(obj);
}
Exemplo n.º 5
0
char *
list_object(struct char_data *ch, struct obj_data *obj,
        int cnt, int index, int shop_nr)
{
  static char buf[256];
  char buf2[300], buf3[200];
  extern char *drinks[];

  if (shop_producing(obj, shop_nr))
    strcpy(buf2, "Unlimited   ");
  else
    sprintf(buf2, "%5d       ", cnt);
  sprintf(buf, " %2d)  %s", index, buf2);

  /* Compile object name and information */
  strcpy(buf3, obj->short_description);
  if ((GET_OBJ_TYPE(obj) == ITEM_DRINKCON) && (GET_OBJ_VAL(obj, 1)))
    sprintf(END_OF(buf3), " of %s", drinks[GET_OBJ_VAL(obj, 2)]);

  /* FUTURE: */
  /* Add glow/hum/etc */

  if ((GET_OBJ_TYPE(obj) == ITEM_WAND) || (GET_OBJ_TYPE(obj) == ITEM_STAFF))
    if (GET_OBJ_VAL(obj, 2) < GET_OBJ_VAL(obj, 1))
      strcat(buf3, " (partially used)");

  sprintf(buf2, "%-48s %6d\n\r", buf3, buy_price(ch, obj, shop_nr));
  strcat(buf, CAP(buf2));
  return (buf);
}
Exemplo n.º 6
0
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location)
{
  struct obj_data *obj;
  int j;

  *location = 0;
  if (real_object(object.item_number) != NOTHING) {
    obj = read_object(object.item_number, VIRTUAL);
#if USE_AUTOEQ
    *location = object.location;
#endif
    GET_OBJ_VAL(obj, 0) = object.value[0];
    GET_OBJ_VAL(obj, 1) = object.value[1];
    GET_OBJ_VAL(obj, 2) = object.value[2];
    GET_OBJ_VAL(obj, 3) = object.value[3];
    GET_OBJ_EXTRA(obj) = object.extra_flags;
    GET_OBJ_WEIGHT(obj) = object.weight;
    GET_OBJ_TIMER(obj) = object.timer;
    obj->obj_flags.bitvector = object.bitvector;

    for (j = 0; j < MAX_OBJ_AFFECT; j++)
      obj->affected[j] = object.affected[j];

    return (obj);
  } else
    return (NULL);
}
Exemplo n.º 7
0
int Obj_to_store_from(struct obj_data * obj, FILE * fl, int locate)
{
  int j;
  struct obj_file_elem object;

  object.item_number = GET_OBJ_VNUM(obj);
  object.locate = (sh_int) locate; /* where worn or inventory? */
  object.value[0] = GET_OBJ_VAL(obj, 0);
  object.value[1] = GET_OBJ_VAL(obj, 1);
  object.value[2] = GET_OBJ_VAL(obj, 2);
  object.value[3] = GET_OBJ_VAL(obj, 3);
  object.value[4] = GET_OBJ_VAL(obj, 4);
  object.value[5] = GET_OBJ_VAL(obj, 5);
  object.value[6] = GET_OBJ_VAL(obj, 6);
  object.value[7] = GET_OBJ_VAL(obj, 7);
  object.value[8] = GET_OBJ_VAL(obj, 8);
  object.value[9] = GET_OBJ_VAL(obj, 9);
  object.extra_flags = GET_OBJ_EXTRA(obj);
  object.weight = GET_OBJ_WEIGHT(obj);
  object.timer = GET_OBJ_TIMER(obj);
  object.bitvector = obj->obj_flags.bitvector;
  for (j = 0; j < MAX_OBJ_AFFECT; j++)
    object.affected[j] = obj->affected[j];

  if (fwrite(&object, sizeof(struct obj_file_elem), 1, fl) < 1) {
    perror("Error writing object in Obj_to_store");
    return 0;
  }
  return 1;
}
Exemplo n.º 8
0
struct obj_data * Obj_from_store(struct obj_file_elem object, int *locate)
{
  struct obj_data *obj;
  int j;

  if (real_object(object.item_number) > -1) {
    obj = read_object(object.item_number, VNUMBER);
    *locate = (int) object.locate;
    GET_OBJ_VAL(obj, 0) = object.value[0];
    GET_OBJ_VAL(obj, 1) = object.value[1];
    GET_OBJ_VAL(obj, 2) = object.value[2];
    GET_OBJ_VAL(obj, 3) = object.value[3];
    GET_OBJ_VAL(obj, 4) = object.value[4];
    GET_OBJ_VAL(obj, 5) = object.value[5];
    GET_OBJ_VAL(obj, 6) = object.value[6];
    GET_OBJ_VAL(obj, 7) = object.value[7];
    GET_OBJ_VAL(obj, 8) = object.value[8];
    GET_OBJ_VAL(obj, 9) = object.value[9];
    GET_OBJ_EXTRA(obj) = object.extra_flags;
    GET_OBJ_WEIGHT(obj) = object.weight;
    GET_OBJ_TIMER(obj) = object.timer;
    obj->obj_flags.bitvector = object.bitvector;

    for (j = 0; j < MAX_OBJ_AFFECT; j++)
      obj->affected[j] = object.affected[j];

    return obj;
  } else
    return NULL;
}
Exemplo n.º 9
0
void make_corpse(struct char_data * ch)
{
  struct obj_data *corpse, *o;
  struct obj_data *money;
  int i;

  corpse = create_obj();

  corpse->item_number = NOTHING;
  IN_ROOM(corpse) = NOWHERE;
  corpse->name = str_dup("corpse");

  sprintf(buf2, "The corpse of %s is lying here.", GET_NAME(ch));
  corpse->description = str_dup(buf2);

  sprintf(buf2, "the corpse of %s", GET_NAME(ch));
  corpse->short_description = str_dup(buf2);

  GET_OBJ_TYPE(corpse) = ITEM_CONTAINER;
  GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE;
  GET_OBJ_EXTRA(corpse) = ITEM_NODONATE;
  GET_OBJ_VAL(corpse, 0) = 0;	/* You can't store stuff in a corpse */
  GET_OBJ_VAL(corpse, 3) = 1;	/* corpse identifier */
  GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch);
  GET_OBJ_RENT(corpse) = 100000;
  if (IS_NPC(ch))
    GET_OBJ_TIMER(corpse) = max_npc_corpse_time;
  else
    GET_OBJ_TIMER(corpse) = max_pc_corpse_time;

  /* transfer character's inventory to the corpse */
  corpse->contains = ch->carrying;
  for (o = corpse->contains; o != NULL; o = o->next_content)
    o->in_obj = corpse;
  object_list_new_owner(corpse, NULL);

  /* transfer character's equipment to the corpse */
  for (i = 0; i < NUM_WEARS; i++)
    if (GET_EQ(ch, i)) {
      remove_otrigger(GET_EQ(ch, i), ch);
      obj_to_obj(unequip_char(ch, i), corpse);
    }

  /* transfer gold */
  if (GET_GOLD(ch) > 0) {
    /* following 'if' clause added to fix gold duplication loophole */
    if (IS_NPC(ch) || (!IS_NPC(ch) && ch->desc)) {
      money = create_money(GET_GOLD(ch));
      obj_to_obj(money, corpse);
    }
    GET_GOLD(ch) = 0;
  }
  ch->carrying = NULL;
  IS_CARRYING_N(ch) = 0;
  IS_CARRYING_W(ch) = 0;

  obj_to_room(corpse, IN_ROOM(ch));
}
Exemplo n.º 10
0
void list_wands_staves (struct char_data *ch, char *input)
{
	int type=0;
	int i=0;
	int j=0;
	int k=0;
	char *wsbuf = get_buffer(MAX_STRING_LENGTH);

	skip_spaces(&input);
	switch (input[0]) {
	case 'T':
	case 't':
		type = ITEM_STAFF; 
		break;
	case 'W':
	case 'w':
		type = ITEM_WAND; 
		break;
	default:
		extended_mudlog(NRM, SYSL_BUGS, TRUE, "Default reached in list_scrolls_potions (arg = %s)", input);
		release_buffer(wsbuf);
		return; 
	}	/*switch...*/

	wsbuf[0]='\0';
	for (i=0;i<top_of_objt;i++) {
		j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/
		if (j == type) { /*found one*/
			sprintf(wsbuf+strlen(wsbuf),"[%5d] %-30s", /*print vnum, short description*/
			GET_OBJ_VNUM(&obj_proto[i]),
			obj_proto[i].short_description);

			/*
			 * values 0-3:
			 * Potion, Scroll - up to three spells [values 1-3]
			 */

			sprintf(wsbuf+strlen(wsbuf), " Spells: ");
			if (type==ITEM_STAFF) { /*staves have only one spell*/
				if ((GET_OBJ_VAL(&obj_proto[i], 3)) != (-1))
					sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], 3)));
			} else {
				for (k=1; k < 4; k++) {
					if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1))
						sprintf(wsbuf+strlen(wsbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k)));
				}
				sprintf(wsbuf+strlen(wsbuf), "\r\n");
			}
		}	/*if j == type*/
	}	/*for i...*/
	page_string (ch->desc, wsbuf, 1);
	release_buffer(wsbuf);
}
Exemplo n.º 11
0
void list_scrolls_potions (struct char_data *ch, char *input)
{
	int type=0;
	int i=0;
	int j=0;
	int k=0;
	char *spbuf = get_buffer(MAX_STRING_LENGTH);

	skip_spaces(&input);
	switch (input[0]) {
	case 'S':
	case 's':
		type = ITEM_SCROLL; 
		break;
	case 'P':
	case 'p':
		type = ITEM_POTION; 
		break;
	default :
		mlog("SYSERR:  Default reached in list_scrolls_potions (arg = %s)", input);
		release_buffer(spbuf);
		return;
	}/*switch...*/

	spbuf[0]='\0';
	for (i=0;i<top_of_objt;i++) {
		j=obj_proto[i].obj_flags.type_flag; /*look for specific sort of item*/
		if (j == type) { /*found one*/
			sprintf(spbuf+strlen(spbuf),"[%5d] %-20s", /*print vnum, short description*/
			GET_OBJ_VNUM(&obj_proto[i]),
			obj_proto[i].short_description);

			/*
			 * values 0-3:
			 * Potion, Scroll - up to three spells [values 1-3]
			 */

			sprintf(spbuf+strlen(spbuf), " Spells: ");
			for (k=1;k<4;k++) {
				if ((GET_OBJ_VAL(&obj_proto[i], k)) != (-1))
					sprintf(spbuf+strlen(spbuf), "%s ", skill_name(GET_OBJ_VAL(&obj_proto[i], k)));
			}


			sprintf(spbuf+strlen(spbuf), "\r\n");

		}/*if j == type*/
	}/*for i...*/
	page_string (ch->desc, spbuf, 1);
	release_buffer(spbuf);
}
Exemplo n.º 12
0
void Enchants::remove_set_bonus(OBJ_DATA *obj)
{
	for (auto i = list_.begin(); i != list_.end(); ++i)
	{
		if (i->type_ == ENCHANT_FROM_SET)
		{
			GET_OBJ_WEIGHT(obj) -= i->weight_;
			GET_OBJ_VAL(obj, 1) -= i->ndice_;
			GET_OBJ_VAL(obj, 2) -= i->sdice_;
			correct_values(obj);
			list_.erase(i);
			return;
		}
	}
}
Exemplo n.º 13
0
/* Return the effect of a piece of armor in position eq_pos */
static int apply_ac(struct char_data *ch, int eq_pos)
{
  int factor;

  if (GET_EQ(ch, eq_pos) == NULL) {
    core_dump();
    return (0);
  }

  if (!(GET_OBJ_TYPE(GET_EQ(ch, eq_pos)) == ITEM_ARMOR))
    return (0);

  switch (eq_pos) {

  case WEAR_BODY:
    factor = 3;
    break;			/* 30% */
  case WEAR_HEAD:
    factor = 2;
    break;			/* 20% */
  case WEAR_LEGS:
    factor = 2;
    break;			/* 20% */
  default:
    factor = 1;
    break;			/* all others 10% */
  }

  return (factor * GET_OBJ_VAL(GET_EQ(ch, eq_pos), 0));
}
Exemplo n.º 14
0
/* place a character in a room */
void char_to_room(struct char_data *ch, room_rnum room)
{
  if (ch == NULL || room == NOWHERE || room > top_of_world)
    log("SYSERR: Illegal value(s) passed to char_to_room. (Room: %d/%d Ch: %p",
		room, top_of_world, ch);
  else {
    ch->next_in_room = world[room].people;
    world[room].people = ch;
    IN_ROOM(ch) = room;

    autoquest_trigger_check(ch, 0, 0, AQ_ROOM_FIND);
    autoquest_trigger_check(ch, 0, 0, AQ_MOB_FIND);

    if (GET_EQ(ch, WEAR_LIGHT))
      if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
	if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2))	/* Light ON */
	  world[room].light++;

    /* Stop fighting now, if we left. */
    if (FIGHTING(ch) && IN_ROOM(ch) != IN_ROOM(FIGHTING(ch))) {
      stop_fighting(FIGHTING(ch));
      stop_fighting(ch);
    }
  }
}
Exemplo n.º 15
0
struct obj_data *unequip_char(struct char_data *ch, int pos)
{
  int j;
  struct obj_data *obj;

  if ((pos < 0 || pos >= NUM_WEARS) || GET_EQ(ch, pos) == NULL) {
    core_dump();
    return (NULL);
  }

  obj = GET_EQ(ch, pos);
  obj->worn_by = NULL;
  obj->worn_on = -1;

  if (GET_OBJ_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) += apply_ac(ch, pos);

  if (IN_ROOM(ch) != NOWHERE) {
    if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT)
      if (GET_OBJ_VAL(obj, 2))	/* if light is ON */
	world[IN_ROOM(ch)].light--;
  } else
    log("SYSERR: IN_ROOM(ch) = NOWHERE when unequipping char %s.", GET_NAME(ch));

  GET_EQ(ch, pos) = NULL;

  for (j = 0; j < MAX_OBJ_AFFECT; j++)
    affect_modify_ar(ch, obj->affected[j].location,
		  obj->affected[j].modifier,
		  GET_OBJ_AFFECT(obj), FALSE);

  affect_total(ch);

  return (obj);
}
Exemplo n.º 16
0
/* remove an object from an object */
void obj_from_obj(struct obj_data *obj)
{
  struct obj_data *temp, *obj_from;

  if (obj->in_obj == NULL) {
    log("SYSERR: (%s): trying to illegally extract obj from obj.", __FILE__);
    return;
  }
  obj_from = obj->in_obj;
  temp = obj->in_obj;
  REMOVE_FROM_LIST(obj, obj_from->contains, next_content);

  /* Subtract weight from containers container unless unlimited. */
  if (GET_OBJ_VAL(obj->in_obj, 0) > 0) {
    for (temp = obj->in_obj; temp->in_obj; temp = temp->in_obj)
      GET_OBJ_WEIGHT(temp) -= GET_OBJ_WEIGHT(obj);

    /* Subtract weight from char that carries the object */
    GET_OBJ_WEIGHT(temp) -= GET_OBJ_WEIGHT(obj);
    if (temp->carried_by)
      IS_CARRYING_W(temp->carried_by) -= GET_OBJ_WEIGHT(obj);
  }
  obj->in_obj = NULL;
  obj->next_content = NULL;
}
Exemplo n.º 17
0
/* put an object in an object (quaint)  */
void obj_to_obj(struct obj_data *obj, struct obj_data *obj_to)
{
  struct obj_data *tmp_obj;

  if (!obj || !obj_to || obj == obj_to) {
    log("SYSERR: NULL object (%p) or same source (%p) and target (%p) obj passed to obj_to_obj.",
	obj, obj, obj_to);
    return;
  }

  obj->next_content = obj_to->contains;
  obj_to->contains = obj;
  obj->in_obj = obj_to;
  tmp_obj = obj->in_obj;

  /* Add weight to container, unless unlimited. */
  if (GET_OBJ_VAL(obj->in_obj, 0) > 0) {
    for (tmp_obj = obj->in_obj; tmp_obj->in_obj; tmp_obj = tmp_obj->in_obj)
      GET_OBJ_WEIGHT(tmp_obj) += GET_OBJ_WEIGHT(obj);

    /* top level object.  Subtract weight from inventory if necessary. */
    GET_OBJ_WEIGHT(tmp_obj) += GET_OBJ_WEIGHT(obj);
    if (tmp_obj->carried_by)
      IS_CARRYING_W(tmp_obj->carried_by) += GET_OBJ_WEIGHT(obj);
  }
}
Exemplo n.º 18
0
struct obj_data *create_money(int amount)
{
  struct obj_data *obj;
  struct extra_descr_data *new_descr;
  char buf[200];
  int y;

  if (amount <= 0) {
    log("SYSERR: Try to create negative or 0 money. (%d)", amount);
    return (NULL);
  }
  obj = create_obj();
  CREATE(new_descr, struct extra_descr_data, 1);

  if (amount == 1) {
    obj->name = strdup("coin gold");
    obj->short_description = strdup("a gold coin");
    obj->description = strdup("One miserable gold coin is lying here.");
    new_descr->keyword = strdup("coin gold");
    new_descr->description = strdup("It's just one miserable little gold coin.");
  } else {
    obj->name = strdup("coins gold");
    obj->short_description = strdup(money_desc(amount));
    snprintf(buf, sizeof(buf), "%s is lying here.", money_desc(amount));
    obj->description = strdup(CAP(buf));

    new_descr->keyword = strdup("coins gold");
    if (amount < 10)
      snprintf(buf, sizeof(buf), "There are %d coins.", amount);
    else if (amount < 100)
      snprintf(buf, sizeof(buf), "There are about %d coins.", 10 * (amount / 10));
    else if (amount < 1000)
      snprintf(buf, sizeof(buf), "It looks to be about %d coins.", 100 * (amount / 100));
    else if (amount < 100000)
      snprintf(buf, sizeof(buf), "You guess there are, maybe, %d coins.",
	      1000 * ((amount / 1000) + rand_number(0, (amount / 1000))));
    else
      strcpy(buf, "There are a LOT of coins.");	/* strcpy: OK (is < 200) */
    new_descr->description = strdup(buf);
  }

  new_descr->next = NULL;
  obj->ex_description = new_descr;

  GET_OBJ_TYPE(obj) = ITEM_MONEY;
  for(y = 0; y < TW_ARRAY_MAX; y++)
    obj->obj_flags.wear_flags[y] = 0;
  SET_BIT_AR(GET_OBJ_WEAR(obj), ITEM_WEAR_TAKE);
  GET_OBJ_VAL(obj, 0) = amount;
  GET_OBJ_COST(obj) = amount;
  obj->item_number = NOTHING;

  return (obj);
}
Exemplo n.º 19
0
void equip_char(struct char_data *ch, struct obj_data *obj, int pos)
{
  int j;

  if (pos < 0 || pos >= NUM_WEARS) {
    core_dump();
    return;
  }

  if (GET_EQ(ch, pos)) {
    log("SYSERR: Char is already equipped: %s, %s", GET_NAME(ch),
	    obj->short_description);
    return;
  }
  if (obj->carried_by) {
    log("SYSERR: EQUIP: Obj is carried_by when equip.");
    return;
  }
  if (IN_ROOM(obj) != NOWHERE) {
    log("SYSERR: EQUIP: Obj is in_room when equip.");
    return;
  }
  if (invalid_align(ch, obj) || invalid_class(ch, obj)) {
    act("You are zapped by $p and instantly let go of it.", FALSE, ch, obj, 0, TO_CHAR);
    act("$n is zapped by $p and instantly lets go of it.", FALSE, ch, obj, 0, TO_ROOM);
    /* Changed to drop in inventory instead of the ground. */
    obj_to_char(obj, ch);
    return;
  }

  GET_EQ(ch, pos) = obj;
  obj->worn_by = ch;
  obj->worn_on = pos;

  if (GET_OBJ_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) -= apply_ac(ch, pos);

  if (IN_ROOM(ch) != NOWHERE) {
    if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT)
      if (GET_OBJ_VAL(obj, 2))	/* if light is ON */
	world[IN_ROOM(ch)].light++;
  } else
    log("SYSERR: IN_ROOM(ch) = NOWHERE when equipping char %s.", GET_NAME(ch));

  for (j = 0; j < MAX_OBJ_AFFECT; j++)
    affect_modify_ar(ch, obj->affected[j].location,
		  obj->affected[j].modifier,
		  GET_OBJ_AFFECT(obj), TRUE);

  affect_total(ch);
}
Exemplo n.º 20
0
/*
 * For container flags.
 */
void oedit_disp_container_flags_menu(struct descriptor_data *d)
{
  char bits[MAX_STRING_LENGTH];
  get_char_colors(d->character);
  clear_screen(d);

  sprintbit(GET_OBJ_VAL(OLC_OBJ(d), 1), container_bits, bits, sizeof(bits));
  write_to_output(d, 
	  "%s1%s) CLOSEABLE\r\n"
	  "%s2%s) PICKPROOF\r\n"
	  "%s3%s) CLOSED\r\n"
	  "%s4%s) LOCKED\r\n"
	  "Container flags: %s%s%s\r\n"
	  "Enter flag, 0 to quit : ",
	  grn, nrm, grn, nrm, grn, nrm, grn, nrm, cyn, bits, nrm);
}
Exemplo n.º 21
0
/**
* Зелья, перелитые в контейнеры, можно пить во время боя.
* На случай, когда придется добавлять еще пошенов, которые
* уже будут идти не подряд по номерам.
*/
bool is_potion(OBJ_DATA *obj)
{
	switch(GET_OBJ_VAL(obj, 2))
	{
	case LIQ_POTION:
	case LIQ_POTION_RED:
	case LIQ_POTION_BLUE:
	case LIQ_POTION_WHITE:
	case LIQ_POTION_GOLD:
	case LIQ_POTION_BLACK:
	case LIQ_POTION_GREY:
	case LIQ_POTION_FUCHSIA:
		return true;
		break;
	}
	return false;
}
Exemplo n.º 22
0
/* Return the effect of a piece of armor in position eq_pos */
int apply_ac(struct char_data * ch, int eq_pos)
{
  int armor;

  assert(GET_EQ(ch, eq_pos));

  if (!(GET_OBJ_TYPE(GET_EQ(ch, eq_pos)) == ITEM_ARMOR))
    return 0;

  armor = GET_OBJ_VAL(GET_EQ(ch, eq_pos), 0);

  switch (eq_pos)
  {
    case WEAR_BODY:
      armor *= 3;
      break;

    case WEAR_SHIELD:
      armor *= 2;
      break;

    case WEAR_ARMS:
    case WEAR_LEGS:
      armor *= 1.5;
      break;

    case WEAR_ANKLE_L:
    case WEAR_ANKLE_R:
    case WEAR_WRIST_L:
    case WEAR_WRIST_R:
      armor *= .5;
      break;

    case WEAR_FINGER_L:
    case WEAR_FINGER_R:
    case WEAR_NOSE:
      armor *= 0;
      break;
    default:
      break;

  }

  return armor;
}
Exemplo n.º 23
0
struct obj_data *unequip_char(struct char_data * ch, int pos)
{
  int j;
  struct obj_data *obj;

  assert(pos >= 0 && pos < NUM_WEARS);
  assert(GET_EQ(ch, pos));

  obj = GET_EQ(ch, pos);
  obj->worn_by = NULL;
  obj->worn_on = -1;

  if (GET_OBJ_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) += apply_ac(ch, pos);

  if (ch->in_room != NOWHERE) {
    if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT)
      if (GET_OBJ_VAL(obj, 2))	/* if light is ON */
	world[ch->in_room].light--;
  } else {
    log("SYSERR: ch->in_room = NOWHERE when un-equipping char.");
  }

  GET_EQ(ch, pos) = NULL;

  for (j = 0; j < MAX_OBJ_AFFECT; j++)
    affect_modify(ch, obj->affected[j].location,
		  obj->affected[j].modifier,
		  obj->obj_flags.bitvector, FALSE);

  if (affected_by_spell(ch, SKILL_ENVENOM) && (pos == WEAR_WIELD))
  {
    send_to_char("As your weapon leaves your hand, the venom on it dissipates.\r\n", ch);
    affect_from_char(ch, SKILL_ENVENOM);
  }

  if (affected_by_spell(ch, SPELL_ADAMANT_MACE) && (pos == WEAR_WIELD))
    affect_from_char(ch, SPELL_ADAMANT_MACE);

  affect_total(ch);

  return (obj);
}
Exemplo n.º 24
0
enchant::enchant(OBJ_DATA *obj)
{
	name_ = GET_OBJ_PNAME(obj, 4) ? GET_OBJ_PNAME(obj, 4) : "<null>";
	type_ = ENCHANT_FROM_OBJ;

	for (int i = 0; i < MAX_OBJ_AFFECT; i++)
	{
		if (obj->affected[i].location != APPLY_NONE
			&& obj->affected[i].modifier != 0)
		{
			affected_.push_back(obj->affected[i]);
		}
	}

	affects_flags_ = GET_OBJ_AFFECTS(obj);
	extra_flags_ = obj->obj_flags.extra_flags;
	REMOVE_BIT(GET_FLAG(extra_flags_, ITEM_TICKTIMER), ITEM_TICKTIMER);
	no_flags_ = GET_OBJ_NO(obj);
	weight_ = GET_OBJ_VAL(obj, 0);
	ndice_ = 0;
	sdice_ = 0;
}
Exemplo n.º 25
0
/* place a character in a room */
void char_to_room(struct char_data * ch, room_rnum room)
{
  if (ch == NULL || room < 0 || room > top_of_world)
    log("SYSERR: Illegal value(s) passed to char_to_room");
  else {
    ch->next_in_room = world[room].people;
    world[room].people = ch;
    ch->in_room = room;

    if ( affected_by_spell(ch, SPELL_LIGHT) ) {
      world[ch->in_room].light += 10;
    }
    if ( affected_by_spell(ch, SPELL_DARKNESS) ) {
      world[ch->in_room].light -= 10;
    }

    if (GET_EQ(ch, WEAR_LIGHT))
      if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
	if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2))	/* Light ON */
	  world[room].light++;
  }
}
Exemplo n.º 26
0
/* move a player out of a room */
void char_from_room(struct char_data * ch)
{
  struct char_data *temp;

  if (ch == NULL || ch->in_room == NOWHERE) {
    log("SYSERR: NULL or NOWHERE in handler.c, char_from_room");
    exit(1);
  }

  if (FIGHTING(ch) != NULL) {
    stop_fighting(ch);
  }

  if ( affected_by_spell(ch, SPELL_LIGHT) ) {
    world[ch->in_room].light -= 10;
  }
  if ( affected_by_spell(ch, SPELL_DARKNESS) ) {
    world[ch->in_room].light += 10;
  }

  if (GET_EQ(ch, WEAR_LIGHT) != NULL) {
    if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) {
      if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2)) {     /* Light is ON */
	world[ch->in_room].light--;
      }
    }
  }

/*
  if (affected_by_spell(ch, SPELL_ENTANGLE))
    affect_from_char(ch, SPELL_ENTANGLE);
  if (affected_by_spell(ch, SPELL_MIRE))
    affect_from_char(ch, SPELL_MIRE);
*/

  REMOVE_FROM_LIST(ch, world[ch->in_room].people, next_in_room);
  ch->in_room = NOWHERE;
  ch->next_in_room = NULL;
}
Exemplo n.º 27
0
int
trade_with(struct obj_data * item, int shop_nr)
{
  int counter;

  if (GET_OBJ_COST(item) < 1)
    return (OBJECT_NOTOK);

  if (IS_OBJ_STAT(item, ITEM_NOSELL))
    return (OBJECT_NOTOK);

  for (counter = 0; SHOP_BUYTYPE(shop_nr, counter) != NOTHING; counter++)
    if (SHOP_BUYTYPE(shop_nr, counter) == GET_OBJ_TYPE(item)) {
      if ((GET_OBJ_VAL(item, 2) == 0) &&
      ((GET_OBJ_TYPE(item) == ITEM_WAND) ||
       (GET_OBJ_TYPE(item) == ITEM_STAFF)))
    return (OBJECT_DEAD);
      else if (evaluate_expression(item, SHOP_BUYWORD(shop_nr, counter)))
    return (OBJECT_OK);
    }

  return (OBJECT_NOTOK);
}
Exemplo n.º 28
0
/* move a player out of a room */
void char_from_room(struct char_data *ch)
{
  struct char_data *temp;

  if (ch == NULL || IN_ROOM(ch) == NOWHERE) {
    log("SYSERR: NULL character or NOWHERE in %s, char_from_room", __FILE__);
    exit(1);
  }

  if (FIGHTING(ch) != NULL)
    stop_fighting(ch);

  char_from_furniture(ch);

  if (GET_EQ(ch, WEAR_LIGHT) != NULL)
    if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
      if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2))	/* Light is ON */
	world[IN_ROOM(ch)].light--;

  REMOVE_FROM_LIST(ch, world[IN_ROOM(ch)].people, next_in_room);
  IN_ROOM(ch) = NOWHERE;
  ch->next_in_room = NULL;
}
Exemplo n.º 29
0
/*
 * Object value #4
 */
void oedit_disp_val4_menu(struct descriptor_data *d)
{
  OLC_MODE(d) = OEDIT_VALUE_4;
  switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
  case ITEM_SCROLL:
  case ITEM_POTION:
  case ITEM_WAND:
  case ITEM_STAFF:
    oedit_disp_spells_menu(d);
    break;
  case ITEM_WEAPON:
    oedit_disp_weapon_menu(d);
    break;
  case ITEM_DRINKCON:
  case ITEM_FOUNTAIN:
  case ITEM_FOOD:
    write_to_output(d, "Poisoned (0 = not poison) : ");
    break;
  case ITEM_VEHICLE:
    write_to_output(d, "What is the vehicle's appearance? (-1 for transparent) : ");
    break;
  case ITEM_PORTAL:
    write_to_output(d, "What is the portal's appearance? (-1 for transparent) : ");
    break;
  case ITEM_WINDOW:
    if (GET_OBJ_VAL(OLC_OBJ(d), 0) < 0)
      write_to_output(d, "What is the viewport room vnum (-1 for default location) : ");
    else
      oedit_disp_menu(d);
    break;
  case ITEM_BOARD:
    write_to_output(d, "Minimum level to remove messages: ");
    break;
  default:
    oedit_disp_menu(d);
  }
}
Exemplo n.º 30
0
/* mag_objectmagic: This is the entry-point for all magic items.  This should
 * only be called by the 'quaff', 'use', 'recite', etc. routines.
 * For reference, object values 0-3:
 * staff  - [0]	level	[1] max charges	[2] num charges	[3] spell num
 * wand   - [0]	level	[1] max charges	[2] num charges	[3] spell num
 * scroll - [0]	level	[1] spell num	[2] spell num	[3] spell num
 * potion - [0] level	[1] spell num	[2] spell num	[3] spell num
 * Staves and wands will default to level 14 if the level is not specified; the
 * DikuMUD format did not specify staff and wand levels in the world files */
void mag_objectmagic(struct char_data *ch, struct obj_data *obj,
		          char *argument)
{
  char arg[MAX_INPUT_LENGTH];
  int i, k;
  struct char_data *tch = NULL, *next_tch;
  struct obj_data *tobj = NULL;

  one_argument(argument, arg);

  k = generic_find(arg, FIND_CHAR_ROOM | FIND_OBJ_INV | FIND_OBJ_ROOM |
		   FIND_OBJ_EQUIP, ch, &tch, &tobj);

  switch (GET_OBJ_TYPE(obj)) {
  case ITEM_STAFF:
    act("You tap $p three times on the ground.", FALSE, ch, obj, 0, TO_CHAR);
    if (obj->action_description)
      act(obj->action_description, FALSE, ch, obj, 0, TO_ROOM);
    else
      act("$n taps $p three times on the ground.", FALSE, ch, obj, 0, TO_ROOM);

    if (GET_OBJ_VAL(obj, 2) <= 0) {
      send_to_char(ch, "It seems powerless.\r\n");
      act("Nothing seems to happen.", FALSE, ch, obj, 0, TO_ROOM);
    } else {
      GET_OBJ_VAL(obj, 2)--;
      WAIT_STATE(ch, PULSE_VIOLENCE);
      /* Level to cast spell at. */
      k = GET_OBJ_VAL(obj, 0) ? GET_OBJ_VAL(obj, 0) : DEFAULT_STAFF_LVL;

      /* Area/mass spells on staves can cause crashes. So we use special cases
       * for those spells spells here. */
      if (HAS_SPELL_ROUTINE(GET_OBJ_VAL(obj, 3), MAG_MASSES | MAG_AREAS)) {
        for (i = 0, tch = world[IN_ROOM(ch)].people; tch; tch = tch->next_in_room)
	  i++;
	while (i-- > 0)
	  call_magic(ch, NULL, NULL, GET_OBJ_VAL(obj, 3), k, CAST_STAFF);
      } else {
	for (tch = world[IN_ROOM(ch)].people; tch; tch = next_tch) {
	  next_tch = tch->next_in_room;
	  if (ch != tch)
	    call_magic(ch, tch, NULL, GET_OBJ_VAL(obj, 3), k, CAST_STAFF);
	}
      }
    }
    break;
  case ITEM_WAND:
    if (k == FIND_CHAR_ROOM) {
      if (tch == ch) {
	act("You point $p at yourself.", FALSE, ch, obj, 0, TO_CHAR);
	act("$n points $p at $mself.", FALSE, ch, obj, 0, TO_ROOM);
      } else {
	act("You point $p at $N.", FALSE, ch, obj, tch, TO_CHAR);
	if (obj->action_description)
	  act(obj->action_description, FALSE, ch, obj, tch, TO_ROOM);
	else
	  act("$n points $p at $N.", TRUE, ch, obj, tch, TO_ROOM);
      }
    } else if (tobj != NULL) {
      act("You point $p at $P.", FALSE, ch, obj, tobj, TO_CHAR);
      if (obj->action_description)
	act(obj->action_description, FALSE, ch, obj, tobj, TO_ROOM);
      else
	act("$n points $p at $P.", TRUE, ch, obj, tobj, TO_ROOM);
    } else if (IS_SET(spell_info[GET_OBJ_VAL(obj, 3)].routines, MAG_AREAS | MAG_MASSES)) {
      /* Wands with area spells don't need to be pointed. */
      act("You point $p outward.", FALSE, ch, obj, NULL, TO_CHAR);
      act("$n points $p outward.", TRUE, ch, obj, NULL, TO_ROOM);
    } else {
      act("At what should $p be pointed?", FALSE, ch, obj, NULL, TO_CHAR);
      return;
    }

    if (GET_OBJ_VAL(obj, 2) <= 0) {
      send_to_char(ch, "It seems powerless.\r\n");
      act("Nothing seems to happen.", FALSE, ch, obj, 0, TO_ROOM);
      return;
    }
    GET_OBJ_VAL(obj, 2)--;
    WAIT_STATE(ch, PULSE_VIOLENCE);
    if (GET_OBJ_VAL(obj, 0))
      call_magic(ch, tch, tobj, GET_OBJ_VAL(obj, 3),
		 GET_OBJ_VAL(obj, 0), CAST_WAND);
    else
      call_magic(ch, tch, tobj, GET_OBJ_VAL(obj, 3),
		 DEFAULT_WAND_LVL, CAST_WAND);
    break;
  case ITEM_SCROLL:
    if (*arg) {
      if (!k) {
	act("There is nothing to here to affect with $p.", FALSE,
	    ch, obj, NULL, TO_CHAR);
	return;
      }
    } else
      tch = ch;

    act("You recite $p which dissolves.", TRUE, ch, obj, 0, TO_CHAR);
    if (obj->action_description)
      act(obj->action_description, FALSE, ch, obj, tch, TO_ROOM);
    else
      act("$n recites $p.", FALSE, ch, obj, NULL, TO_ROOM);

    WAIT_STATE(ch, PULSE_VIOLENCE);
    for (i = 1; i <= 3; i++)
      if (call_magic(ch, tch, tobj, GET_OBJ_VAL(obj, i),
		       GET_OBJ_VAL(obj, 0), CAST_SCROLL) <= 0)
	break;

    if (obj != NULL)
      extract_obj(obj);
    break;
  case ITEM_POTION:
    tch = ch;

  if (!consume_otrigger(obj, ch, OCMD_QUAFF))  /* check trigger */
    return;

    act("You quaff $p.", FALSE, ch, obj, NULL, TO_CHAR);
    if (obj->action_description)
      act(obj->action_description, FALSE, ch, obj, NULL, TO_ROOM);
    else
      act("$n quaffs $p.", TRUE, ch, obj, NULL, TO_ROOM);

    WAIT_STATE(ch, PULSE_VIOLENCE);
    for (i = 1; i <= 3; i++)
      if (call_magic(ch, ch, NULL, GET_OBJ_VAL(obj, i),
		       GET_OBJ_VAL(obj, 0), CAST_POTION) <= 0)
	break;

    if (obj != NULL)
      extract_obj(obj);
    break;
  default:
    log("SYSERR: Unknown object_type %d in mag_objectmagic.",
	GET_OBJ_TYPE(obj));
    break;
  }
}