Example #1
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;
}
Example #2
0
/* remove an object from an object */
void obj_from_obj(struct obj_data *obj)
{
  struct obj_data *tmp, *obj_from;
  char buf[100];

  if (obj->carried_by) {
    sprintf(buf, "%s carried by %s in obj_from_obj\n", obj->name,
	    obj->carried_by->player.name);
    logE(buf);
  }
  if (obj->equipped_by) {
    sprintf(buf, "%s equipped by %s in obj_from_obj\n", obj->name,
	    obj->equipped_by->player.name);
    logE(buf);
  }
  if (obj->in_room != NOWHERE) {
    sprintf(buf, "%s in room %d in obj_from_obj\n", obj->name,
	    obj->in_room);
    logE(buf);
  }

  assert(!obj->carried_by && !obj->equipped_by && obj->in_room == NOWHERE);
  
  if (obj->in_obj) {
    obj_from = obj->in_obj;
    if (obj == obj_from->contains)   /* head of list */
      obj_from->contains = obj->next_content;
    else {
      for (tmp = obj_from->contains; 
	   tmp && (tmp->next_content != obj);
	   tmp = tmp->next_content); /* locate previous */
      
      if (!tmp) {
	perror("Fatal error in object structures.");
	assert(0);
      }
      
      tmp->next_content = obj->next_content;
    }
        
    /* Subtract weight from containers container */
    for(tmp = obj->in_obj; tmp->in_obj; tmp = tmp->in_obj)
      GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
    
    GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
    
    /* Subtract weight from char that carries the object */
    if (tmp->carried_by)
      IS_CARRYING_W(tmp->carried_by) -= GET_OBJ_WEIGHT(obj);
    
    obj->in_obj = 0;
    obj->next_content = 0;
  } else {
    perror("Trying to object from object when in no object.");
    assert(0);
  }
  if(obj_from->in_room != NOWHERE)
      if(IS_SET(real_roomp(obj_from->in_room)->room_flags, SAVE_ROOM))
         save_room(obj_from->in_room);  
}
Example #3
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);
  }
}
Example #4
0
void Crash_restore_weight(struct obj_data * obj)
{
  if (obj) {
    Crash_restore_weight(obj->contains);
    Crash_restore_weight(obj->next_content);
    if (obj->in_obj)
      GET_OBJ_WEIGHT(obj->in_obj) += GET_OBJ_WEIGHT(obj);
  }
}
Example #5
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;

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

    for(tmp_obj = obj->in_obj; tmp_obj;
      GET_OBJ_WEIGHT(tmp_obj) += GET_OBJ_WEIGHT(obj), tmp_obj = tmp_obj->in_obj);
}
Example #6
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;
}
Example #7
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;
}
Example #8
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);
}
Example #9
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);
}
Example #10
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);
}
Example #11
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;
}
Example #12
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));
}
Example #13
0
int contained_weight(struct obj_data *container)
{
  struct obj_data *tmp;
  int	rval = 0;

  for (tmp = container->contains; tmp; tmp = tmp->next_content)
    rval += GET_OBJ_WEIGHT(tmp);
  return rval;
}
Example #14
0
int Crash_save(struct obj_data * obj, FILE * fp, int locate)
{
  struct obj_data *tmp;
  int result;

  if (obj) {
    Crash_save(obj->next_content, fp, locate);
    Crash_save(obj->contains, fp, MIN(0,locate)-1);
    result = Obj_to_store_from(obj, fp, locate);

    for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj)
      GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);

    if (!result)
      return 0;
  }
  return TRUE;
}
Example #15
0
/* give an object to a char   */
void obj_to_char(struct obj_data *object, struct char_data *ch)
{
    object->next_content = ch->carrying;
    ch->carrying = object;
    object->carried_by = ch;
    object->in_room = NOWHERE;
    IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
    IS_CARRYING_N(ch)++;
}
Example #16
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;
  
  obj->next_content = obj_to->contains;
  obj_to->contains = obj;
  obj->in_obj = obj_to;
  /*  
    (jdb)  hopefully this will fix the object problem   
    */
  obj->carried_by = 0;
  obj->equipped_by = 0;
  
  for(tmp_obj = obj->in_obj; tmp_obj;
      GET_OBJ_WEIGHT(tmp_obj) += GET_OBJ_WEIGHT(obj), tmp_obj = tmp_obj->in_obj);
  if(obj_to->in_room != NOWHERE)
      if(IS_SET(real_roomp(obj_to->in_room)->room_flags, SAVE_ROOM))
         save_room(obj_to->in_room);  
}
Example #17
0
/* Save all objects for a house (recursive; initial call must be followed
   by a call to House_restore_weight)  Assumes file is open already. */
int House_save(struct obj_data * obj, FILE * fp)
{
  struct obj_data *tmp;
  int result;

  if (obj) {
    if (!IS_OBJ_STAT(obj, ITEM_NORENT)) {
      House_save(obj->contains, fp);
      House_save(obj->next_content, fp);
      result = Obj_to_store(obj, fp);
      if (!result)
        return 0;

    for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj)
      GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
    }
  }
  return 1;
}
Example #18
0
void weight_change_object(struct obj_data *obj, int weight)
{
	struct obj_data *tmp_obj;
	struct char_data *tmp_ch;

	if (obj->in_room != NOWHERE) {
		GET_OBJ_WEIGHT(obj) += weight;
	} else if (tmp_ch = obj->carried_by) {
		obj_from_char(obj);
		GET_OBJ_WEIGHT(obj) += weight;
		obj_to_char(obj, tmp_ch);
	} else if (tmp_obj = obj->in_obj) {
		obj_from_obj(obj);
		GET_OBJ_WEIGHT(obj) += weight;
		obj_to_obj(obj, tmp_obj);
	} else {
		log("Unknown attempt to subtract weight from an object.");
	}
}
Example #19
0
/* take an object from a char */
void obj_from_char(struct obj_data *object)
{
  struct obj_data *tmp;
  
  if (!object) {
    logE("No object to be take from char.");
    assert(0);
  }
  
  
  if (!object->carried_by) {
    logE("this object is not carried by anyone");
    assert(0);
  }
  
  if (!object->carried_by->carrying) {
    logE("No one is carrying this object");
    assert(0);
  }

  if (object->in_obj) {
    logE("Obj in more than one place.");
    assert(0);
  }

  if (object->equipped_by) {
    logE("Obj in more than one place.");
    assert(0);
  }
  
  if (object->carried_by->carrying == object)   /* head of list */
    object->carried_by->carrying = object->next_content;
  
  else
    {
      for (tmp = object->carried_by->carrying; 
	   tmp && (tmp->next_content != object); 
	   tmp = tmp->next_content); /* locate previous */
      
      if (!tmp) {
	logE("Couldn't find object on character");
	assert(0);
      }
      
      tmp->next_content = object->next_content;
    }
  
  IS_CARRYING_W(object->carried_by) -= GET_OBJ_WEIGHT(object);
  IS_CARRYING_N(object->carried_by)--;
  object->carried_by = 0;
  object->equipped_by = 0; /* should be unnecessary, but, why risk it */
  object->next_content = 0;
  object->in_obj = 0;
}
Example #20
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 or same source and target obj passed to obj_to_obj");
    return;
  }

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

  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);
}
Example #21
0
/* remove an object from an object */
void obj_from_obj(struct obj_data *obj)
{
    struct obj_data *tmp, *obj_from;

    if (obj->in_obj) {
	obj_from = obj->in_obj;
	if (obj == obj_from->contains)   /* head of list */
	   obj_from->contains = obj->next_content;
	else {
	    for (tmp = obj_from->contains; 
		tmp && (tmp->next_content != obj);
		tmp = tmp->next_content); /* locate previous */

	    if (!tmp) {
		perror("Fatal error in object structures.");
		abort();
	    }

	    tmp->next_content = obj->next_content;
	}


	/* Subtract weight from containers container */
	for(tmp = obj->in_obj; tmp->in_obj; tmp = tmp->in_obj)
	    GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);

	GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);

	/* Subtract weight from char that carries the object */
	if (tmp->carried_by)
	    IS_CARRYING_W(tmp->carried_by) -= GET_OBJ_WEIGHT(obj);

	obj->in_obj = 0;
	obj->next_content = 0;
    } else {
	perror("Trying to object from object when in no object.");
	abort();
    }
}
Example #22
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("error (handler.c): trying to illegally extract obj from obj");
    return;
  }
  obj_from = obj->in_obj;
  REMOVE_FROM_LIST(obj, obj_from->contains, next_content);

  /* Subtract weight from containers container */
  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;
}
Example #23
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;
		}
	}
}
Example #24
0
/* give an object to a char   */
void obj_to_char(struct obj_data * object, struct char_data * ch)
{
  if (object && ch) {
    object->next_content = ch->carrying;
    ch->carrying = object;
    object->carried_by = ch;
    object->in_room = NOWHERE;
    IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
    IS_CARRYING_N(ch)++;

    /* set flag for crash-save system */
    SET_BIT(PLR_FLAGS(ch), PLR_CRASH);
  } else
    log("SYSERR: NULL obj or char passed to obj_to_char");
}
Example #25
0
int GiveMinStrToWield(struct obj_data *obj, struct char_data *ch)
{
  int str=0;

  GET_STR(ch) = 16;  /* nice, semi-reasonable start */
  /* 
    will have a problem with except. str, that i do not care to solve
  */

  while (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w)
     GET_STR(ch)++;

  return(str);

}
Example #26
0
/* Give an object to a char. */
void obj_to_char(struct obj_data *object, struct char_data *ch)
{
  if (object && ch) {
    object->next_content = ch->carrying;
    ch->carrying = object;
    object->carried_by = ch;
    IN_ROOM(object) = NOWHERE;
    IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
    IS_CARRYING_N(ch)++;

    autoquest_trigger_check(ch, NULL, object, AQ_OBJ_FIND);

    /* set flag for crash-save system, but not on mobs! */
    if (!IS_NPC(ch))
      SET_BIT_AR(PLR_FLAGS(ch), PLR_CRASH);
  } else
    log("SYSERR: NULL obj (%p) or char (%p) passed to obj_to_char.", object, ch);
}
Example #27
0
/* take an object from a char */
void obj_from_char(struct obj_data * object)
{
  struct obj_data *temp;

  if (object == NULL) {
    log("SYSERR: NULL object passed to obj_from_char");
    return;
  }
  REMOVE_FROM_LIST(object, object->carried_by->carrying, next_content); 

  /* set flag for crash-save system */
  SET_BIT(PLR_FLAGS(object->carried_by), PLR_CRASH); 

  IS_CARRYING_W(object->carried_by) -= GET_OBJ_WEIGHT(object);
  IS_CARRYING_N(object->carried_by)--;
  object->carried_by = NULL;
  object->next_content = NULL;
}
Example #28
0
/* give an object to a char   */
void obj_to_char(struct obj_data *object, struct char_data *ch)
{

  assert(!object->in_obj && !object->carried_by && !object->equipped_by &&
	 object->in_room == NOWHERE);
  
  if (ch->carrying)
    object->next_content = ch->carrying;
  else
    object->next_content = 0;
  
  ch->carrying = object;
  object->carried_by = ch;
  object->in_room = NOWHERE;
  object->equipped_by = 0;
  object->in_obj = 0;
  IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
  IS_CARRYING_N(ch)++;
}
Example #29
0
/* take an object from a char */
void obj_from_char(struct obj_data *object)
{
    struct obj_data *tmp;

    if (object->carried_by->carrying == object)   /* head of list */
	 object->carried_by->carrying = object->next_content;

    else
    {
	for (tmp = object->carried_by->carrying; 
	     tmp && (tmp->next_content != object); 
	      tmp = tmp->next_content); /* locate previous */

	tmp->next_content = object->next_content;
    }

    IS_CARRYING_W(object->carried_by) -= GET_OBJ_WEIGHT(object);
    IS_CARRYING_N(object->carried_by)--;
    object->carried_by = 0;
    object->next_content = 0;
}
Example #30
0
void
postmaster_receive_mail (struct char_data *ch, struct char_data *mailman,
						 int cmd, char *arg)
{
	char buf[256];
	struct obj_data *obj;

	if (!has_mail (GET_IDNUM (ch)))
	{
		sprintf (buf,
				 "$n tells you, 'Sorry, you don't have any mail waiting.'");
		act (buf, FALSE, mailman, 0, ch, TO_VICT);
		return;
	}
	while (has_mail (GET_IDNUM (ch)))
	{
		obj = create_obj ();
		obj->item_number = NOTHING;
		obj->name = str_dup ("mail paper letter");
		obj->short_description = str_dup ("a piece of mail");
		obj->description = str_dup ("Someone has left a piece of mail here.");

		GET_OBJ_TYPE (obj) = ITEM_NOTE;
		GET_OBJ_WEAR (obj) = ITEM_WEAR_TAKE | ITEM_WEAR_HOLD;
		GET_OBJ_WEIGHT (obj) = 1;
		GET_OBJ_COST (obj) = 30;
		GET_OBJ_RENT (obj) = 10;
		obj->action_description = read_delete (GET_IDNUM (ch));

		if (obj->action_description == NULL)
			obj->action_description =
				str_dup
				("Mail system error - please report.  Error #11.\r\n");

		obj_to_char (obj, ch);

		act ("$n gives you a piece of mail.", FALSE, mailman, 0, ch, TO_VICT);
		act ("$N gives $n a piece of mail.", FALSE, ch, 0, mailman, TO_ROOM);
	}
}