Exemple #1
0
void do_mppurge(CHAR_DATA * ch, char *argument)
{
	char arg[MAX_INPUT_LENGTH];
	CHAR_DATA *victim;
	OBJ_DATA *obj;

	if (!IS_NPC(ch)) {
		send_to_char(C_DEFAULT, "Huh?\n\r", ch);
		return;
	}

	if (IS_SET(ch->act, ACT_PET) || IS_AFFECTED(ch, AFF_CHARM))
		return;

	one_argument(argument, arg);

	if (arg[0] == '\0') {
		/* 'purge' */
		CHAR_DATA *vnext;
		OBJ_DATA *obj_next;

		for (victim = ch->in_room->people; victim != NULL;
		     victim = vnext) {
			vnext = victim->next_in_room;
			if (IS_NPC(victim) && victim != ch)
				extract_char(victim, TRUE);
		}

		for (obj = ch->in_room->contents; obj != NULL; obj = obj_next) {
			obj_next = obj->next_content;
			extract_obj(obj);
		}

		return;
	}

	if ((victim = get_char_room(ch, arg)) == NULL) {
		if ((obj = get_obj_here(ch, arg))) {
			extract_obj(obj);
		} else {
			sprintf(log_buf,
				"Mppurge - Bad argument: vnum %d name %s short %s.",
				ch->pIndexData->vnum, ch->name,
				ch->short_descr);
			bug(log_buf, -1);
		}
		return;
	}

	if (!IS_NPC(victim)) {
		sprintf(log_buf,
			"Mppurge - Purging a PC: vnum %d name %s short %s.",
			ch->pIndexData->vnum, ch->name, ch->short_descr);
		bug(log_buf, -1);
		return;
	}

	extract_char(victim, TRUE);
	return;
}
Exemple #2
0
void do_mpjunk(CHAR_DATA * ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH];
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;

    one_argument(argument, arg);

    if (arg[0] == '\0')
	return;

    if (str_cmp(arg, "all") && str_prefix("all.", arg)) {
	if ((obj = get_obj_wear(ch, arg)) != NULL) {
	    unequip_char(ch, obj);
	    extract_obj(obj);
	    return;
	}
	if ((obj = get_obj_carry(ch, arg, ch)) == NULL)
	    return;
	extract_obj(obj);
    } else
	for (obj = ch->carrying; obj != NULL; obj = obj_next) {
	    obj_next = obj->next_content;
	    if (arg[3] == '\0' || is_name(&arg[4], obj->name)) {
		if (obj->wear_loc != WEAR_NONE)
		    unequip_char(ch, obj);
		extract_obj(obj);
	    }
	}

    return;

}
Exemple #3
0
void
do_pre_test(struct creature *ch)
{
	struct obj_data *obj = NULL, *next_obj = NULL;

	for (obj = ch->carrying; obj; obj = next_obj) {
		next_obj = obj->next_content;
		extract_obj(obj);
	}

	for (int i = 0; i < NUM_WEARS; i++) {
		if ((obj = GET_EQ(ch, i))) {
			extract_obj(GET_EQ(ch, i));
		}
	}

	while (ch->affected)
		   affect_remove(ch, ch->affected);

	for (obj = ch->in_room->contents; obj; obj = next_obj) {
		 next_obj = obj->next_content;
		 extract_obj(obj);
	}

	if (GET_COND(ch, FULL) >= 0)
		GET_COND(ch, FULL) = 24;
	if (GET_COND(ch, THIRST) >= 0)
		GET_COND(ch, THIRST) = 24;

	SET_BIT(ch->in_room->room_flags, ROOM_NORECALL);
}
Exemple #4
0
/*
 * Lets the mobile purge all objects and other npcs in the room,
 * or purge a specified object or mob in the room. The mobile cannot
 * purge itself for safety reasons.
 *
 * syntax mob purge {target}
 */
void do_mppurge( CHAR_DATA *ch, char *argument )
{
    char       arg[ MAX_INPUT_LENGTH ];
    CHAR_DATA *victim;
    OBJ_DATA  *obj;

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
        /* 'purge' */
        CHAR_DATA *vnext;
        OBJ_DATA  *obj_next;

	for ( victim = ch->in_room->people; victim != NULL; victim = vnext )
	{
	    vnext = victim->next_in_room;
	    if ( IS_NPC( victim ) && victim != ch 
	    &&   !IS_SET(victim->act, ACT_NOPURGE) )
		extract_char( victim, TRUE );
	}

	for ( obj = ch->in_room->contents; obj != NULL; obj = obj_next )
	{
	    obj_next = obj->next_content;
	    if ( !IS_SET(obj->extra_flags, ITEM_NOPURGE) )
		extract_obj( obj );
	}

	return;
    }

    if ( ( victim = get_char_room( ch, arg ) ) == NULL )
    {
	if ( ( obj = get_obj_here( ch, arg ) ) )
	{
	    extract_obj( obj );
	}
	else
	{
	    bug( "Mppurge - Bad argument from vnum %d.",
		IS_NPC(ch) ? ch->pIndexData->vnum : 0 );
	}
	return;
    }

    if ( !IS_NPC( victim ) )
    {
	bug( "Mppurge - Purging a PC from vnum %d.", 
		IS_NPC(ch) ? ch->pIndexData->vnum : 0 );
	return;
    }
    extract_char( victim, TRUE );
    return;
}
Exemple #5
0
/*
 *  mag_materials:
 *  Checks for up to 3 vnums (spell reagents) in the player's inventory.
 *
 * No spells implemented in Circle 3.0 use mag_materials, but you can use
 * it to implement your own spells which require ingredients (i.e., some
 * heal spell which requires a rare herb or some such.)
 */
int mag_materials(struct char_data * ch, int item0, int item1, int item2, int extract, int verbose)
{
  struct obj_data *tobj = NULL;
  struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL;

  for (tobj = ch->carrying; tobj; tobj = tobj->next) {
    if ((item0 > 0) && (GET_OBJ_VNUM(tobj) == item0)) {
      obj0 = tobj;
      item0 = -1;
    } else if ((item1 > 0) && (GET_OBJ_VNUM(tobj) == item1)) {
      obj1 = tobj;
      item1 = -1;
    } else if ((item2 > 0) && (GET_OBJ_VNUM(tobj) == item2)) {
      obj2 = tobj;
      item2 = -1;
    }
  }
  if ((item0 > 0) || (item1 > 0) || (item2 > 0)) {
    if (verbose) {
      switch (number(0, 2)) {
        case 0:
          send_to_char("A wart sprouts on your nose.\r\n", ch);
          break;
        case 1:
          send_to_char("Your hair falls out in clumps.\r\n", ch);
          break;
        case 2:
          send_to_char("A huge corn develops on your big toe.\r\n", ch);
          break;
      }
    }
    return (FALSE);
  }
  if (extract) {
    if (item0 < 0) {
      obj_from_char(obj0);
      extract_obj(obj0);
    }
    if (item1 < 0) {
      obj_from_char(obj1);
      extract_obj(obj1);
    }
    if (item2 < 0) {
      obj_from_char(obj2);
      extract_obj(obj2);
    }
  }
  if (verbose) {
    send_to_char("A puff of smoke rises from your pack.\r\n", ch);
    act("A puff of smoke rises from $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM);
  }
  return (TRUE);
}
Exemple #6
0
void do_mpjunk( CHAR_DATA *ch, char *argument )
{
    char      arg[ MAX_INPUT_LENGTH ];
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;

    if ( !IS_NPC( ch ) )
    {
        send_to_char(C_DEFAULT, "Huh?\n\r", ch );
	return;
    }

    if ( IS_AFFECTED( ch, AFF_CHARM ) )
    {
        return;
    }

    one_argument( argument, arg );

    if ( arg[0] == '\0')
    {
        bug( "Mpjunk - No argument: vnum %d.", ch->pIndexData->vnum );
	return;
    }

    if ( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) )
    {
      if ( ( obj = get_obj_wear( ch, arg ) ) != NULL )
      {
	unequip_char( ch, obj );
	extract_obj( obj );
	return;
      }
      if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
	return; 
      extract_obj( obj );
    }
    else
      for ( obj = ch->carrying; obj != NULL; obj = obj_next )
      {
        obj_next = obj->next_content;
        if ( arg[3] == '\0' || is_name( &arg[4], obj->name ) )
        {
          if ( obj->wear_loc != WEAR_NONE)
	    unequip_char( ch, obj );
          extract_obj( obj );
        } 
      }

    return;

}
Exemple #7
0
void do_mpjunk( CHAR_DATA *ch, char *argument )
{
    char      arg[ MAX_INPUT_LENGTH ];
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;

    if ( !IS_NPC( ch ) )
    {
	typo_message( ch );
	return;
    }

    if ( IS_SET( ch->act , ACT_PET ) || IS_AFFECTED( ch, AFF_CHARM ) )
          return;

    one_argument( argument, arg );

    if ( arg[0] == '\0')
    {
        sprintf( log_buf, "Mpjunk - No argument: vnum %d name %s short %s.",
                 ch->pIndexData->vnum, ch->name, ch->short_descr );
        bug( log_buf, -1 );
	return;
    }

    if ( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) )
    {
      if ( ( obj = get_obj_wear( ch, arg ) ) != NULL )
      {
	unequip_char( ch, obj );
	extract_obj( obj );
	return;
      }
      if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
	return; 
      extract_obj( obj );
    }
    else
      for ( obj = ch->carrying; obj != NULL; obj = obj_next )
      {
        obj_next = obj->next_content;
        if ( arg[3] == '\0' || is_name( ch, &arg[4], obj->name ) )
        {
          if ( !IS_SET( obj->wear_loc, WEAR_NONE ) )
	    unequip_char( ch, obj );
          extract_obj( obj );
        } 
      }

    return;

}
Exemple #8
0
int dump(struct char_data *ch, int cmd, char *arg) 
{
   struct obj_data *k;
	char buf[100];
   struct char_data *tmp_char;
   int value=0;

	void do_drop(struct char_data *ch, char *argument, int cmd);
	char *fname(char *namelist);

	for(k = world[ch->in_room].contents; k ; k = world[ch->in_room].contents)
	{
		sprintf(buf, "The %s vanish in a puff of smoke.\n\r" ,fname(k->name));
		for(tmp_char = world[ch->in_room].people; tmp_char;
			tmp_char = tmp_char->next_in_room)
			if (CAN_SEE_OBJ(tmp_char, k))
				send_to_char(buf,tmp_char);
		extract_obj(k);
	}

	if(cmd!=60) return(FALSE);

	do_drop(ch, arg, cmd);

	value = 0;

	for(k = world[ch->in_room].contents; k ; k = world[ch->in_room].contents)
	{
		sprintf(buf, "The %s vanish in a puff of smoke.\n\r",fname(k->name));
		for(tmp_char = world[ch->in_room].people; tmp_char;
			tmp_char = tmp_char->next_in_room)
			if (CAN_SEE_OBJ(tmp_char, k))
				send_to_char(buf,tmp_char);
			value += MAX(1, MIN(50, k->obj_flags.cost/10));

		extract_obj(k);
	}

	if (value) 
	{
		act("You are awarded for outstanding performance.", FALSE, ch, 0, 0, TO_CHAR);
		act("$n has been awarded for being a good citizen.", TRUE, ch, 0,0, TO_ROOM);

		if (GET_LEVEL(ch) < 3)
			gain_exp(ch, value);
		else
			GET_GOLD(ch) += value;
	}
}
Exemple #9
0
struct obj_data *
slide_obj(struct obj_data * obj, struct char_data * keeper, int shop_nr)
/*
   This function is a slight hack!  To make sure that duplicate items are
   only listed once on the "list", this function groups "identical"
   objects together on the shopkeeper's inventory list.  The hack involves
   knowing how the list is put together, and manipulating the order of
   the objects on the list.  (But since most of DIKU is not encapsulated,
   and information hiding is almost never used, it isn't that big a deal) -JF
*/
{
  struct obj_data *loop;
  int temp;

  if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper))
    sort_keeper_objs(keeper, shop_nr);

  /* Extract the object if it is identical to one produced */
  if (shop_producing(obj, shop_nr))
    {
      temp = GET_OBJ_RNUM(obj);
      extract_obj(obj);
      return (&obj_proto[temp]);
    }

  /* randomly remove a piece of eq from shopkeeper inventory */
  if (number(0, 5)==0) {
    temp = GET_OBJ_RNUM(obj);
    extract_obj(obj);
    return (&obj_proto[temp]);
  }

  SHOP_SORT(shop_nr)++;
  loop = keeper->carrying;
  obj_to_char(obj, keeper);
  keeper->carrying = loop;
  while (loop)
    {
      if (same_obj(obj, loop))
    {
      obj->next_content = loop->next_content;
      loop->next_content = obj;
      return (obj);
    }
      loop = loop->next_content;
    }
  keeper->carrying = obj;
  return (obj);
}
Exemple #10
0
void clear_quest(  )
{
    /*
     * Clear ALL values, ready for next quest
     */

    quest = FALSE;
    extract_obj( quest_object );
    if ( quest_mob )
    {
        quest_mob->long_descr = quest_mob->long_descr_orig;
        quest_mob->long_descr_orig.clear();
    }
    if ( quest_target )
    {
        quest_target->long_descr = quest_target->long_descr_orig;
        quest_target->long_descr_orig.clear();
    }


    quest_mob = NULL;
    quest_target = NULL;
    quest_object = NULL;
    quest_timer = 0;
    quest_wait = 2 + number_range( 1, 4 );
    quest_personality = 0;

    return;
}
Exemple #11
0
char_data::~char_data()
{
    is_free = true;

    while ( first_carry != NULL )
        extract_obj(first_carry);

    while ( first_affect != NULL )
        affect_remove(this, first_affect);

    imc_freechardata(this);
    delete bank_money;
    if ( current_brand )
        delete current_brand;
    delete email;
    delete money;
    if ( pnote )
        delete pnote;
    delete casting;
    delete quest_info;
    delete records;
    delete super;

    aggro_list.remove(this);
}
Exemple #12
0
void redirect_exec(cmd_rec *cmd,word *m_actor,int *vcode,
	      word *m_dobj,word *m_prep,word *m_iobj)
{
  *m_actor=extract_actor(cmd->actor);
  vb=*vcode=verb_code(it_name(expand_redirect(cmd->verbcmd)));
  *m_dobj=extract_obj(cmd->nouncmd,cmd->noun_adj);  
  if (cmd->prep==-1)
    *m_prep=0;
  else 
    *m_prep=it_name(expand_redirect(cmd->prep)); 
  *m_iobj=extract_obj(cmd->objcmd,cmd->obj_adj);
  
  /* This shuffles the _real_ objects if $noun$ forms are being
     used */
  objcode_fix(cmd);
}
Character::~Character()
{
	OBJ_DATA *obj_next;
	AFFECT_DATA *paf_next;
    if ( this->short_descr ) free_string( this->short_descr );
    if ( this->long_descr ) free_string( this->long_descr );
    if ( this->prompt ) free_string( this->prompt );
    if ( this->prefix ) free_string( this->prefix );
    if ( this->material ) free_string( this->material );

    for (OBJ_DATA *obj = this->carrying; obj != NULL; obj = obj_next)
    {
		obj_next = obj->next_content;
		extract_obj(obj);
    }

    for (AFFECT_DATA *paf = this->affected; paf != NULL; paf = paf_next)
    {
		paf_next = paf->next;
		affect_remove(this,paf);
    }

    if (this->pcdata != NULL) {
        delete this->pcdata;
        this->pcdata = NULL;
    }

    INVALIDATE(this);
}
Exemple #14
0
/**
 * przenoszenie pieniêdzy z objektu na character,
 * wykorzystywane przy podnoszeniu ITEM_MONEY
 */
void money_gain_from_obj ( CHAR_DATA *ch, OBJ_DATA *obj, OBJ_DATA *container )
{
    if ( obj->item_type == ITEM_MONEY )
    {
        long int copper = money_count_copper( ch );

        ch->copper  += UMAX ( 0, obj->value[ 0 ] );
        ch->silver  += UMAX ( 0, obj->value[ 1 ] );
        ch->gold    += UMAX ( 0, obj->value[ 2 ] );
        ch->mithril += UMAX ( 0, obj->value[ 3 ] );

        if ( container )
        {
            append_file_format_daily
                (
                 ch,
                 MONEY_LOG_FILE,
                 "-> S: %ld %ld (%ld) - /%d/%d/%d/%d/- wzi±³ kasê z kontenera [%5d] w lokacji [%5d]",
                 copper,
                 money_count_copper( ch ),
                 money_count_copper( ch ) - copper,
                 obj->value[ 0 ],
                 obj->value[ 1 ],
                 obj->value[ 2 ],
                 obj->value[ 3 ],
                 container->pIndexData ? container->pIndexData->vnum : 0,
                 container->in_room ? container->in_room->vnum : 0 
                );
            if 
                ( 
                 container->item_type == ITEM_CORPSE_NPC || 
                 (
                  container->item_type == ITEM_CORPSE_PC &&
                  str_cmp( container->hidden_description, ch->name2 )
                 )
                )
                {
                    money_split_auto( ch, obj );
                }
        }
        else
        {
            append_file_format_daily
                (
                 ch,
                 MONEY_LOG_FILE,
                 "-> S: %ld %ld (%ld) - /%d/%d/%d/%d/ - podniós³ kasê w lokacji [%5d]",
                 copper,
                 money_count_copper( ch ),
                 money_count_copper( ch ) - copper,
                 obj->value[ 0 ],
                 obj->value[ 1 ],
                 obj->value[ 2 ],
                 obj->value[ 3 ],
                 ch->in_room ? ch->in_room->vnum : 0
                );
        }
        extract_obj( obj );
    }
}
Exemple #15
0
bool spec_fido( CHAR_DATA *ch )
{
	OBJ_DATA *corpse;
	OBJ_DATA *c_next;
	OBJ_DATA *obj;
	OBJ_DATA *obj_next;

	if ( !IS_AWAKE(ch) )
	return FALSE;

	for ( corpse = ch->in_room->contents; corpse != NULL; corpse = c_next )
	{
	c_next = corpse->next_content;
	if ( corpse->item_type != ITEM_CORPSE_NPC )
		continue;

	act( "$n savagely devours a corpse.", ch, NULL, NULL, TO_ROOM );
	for ( obj = corpse->contains; obj; obj = obj_next )
	{
		obj_next = obj->next_content;
		obj_from_obj( obj );
		obj_to_room( obj, ch->in_room );
	}
	extract_obj( corpse );
	return TRUE;
	}

	return FALSE;
}
Exemple #16
0
void
perform_defile(struct room_data *room, int *state, char **olddesc,
    char **oldtitle)
{

    struct obj_data *fount = NULL;

    if (*state != STATE_HOLY) {
        errlog("invalid state in perform_defile from unholy_square.");
        return;
    }

    *state = STATE_UNHOLY;

    for (fount = room->contents; fount; fount = fount->next_content)
        if (GET_OBJ_VNUM(fount) == FOUNT_HOLY) {
            extract_obj(fount);
            break;
        }

    if (!(fount = read_object(FOUNT_UNHOLY)))
        errlog("unable to load unholy fount in unholy_square.");
    else
        obj_to_room(fount, room);

    *olddesc = room->description;
    *oldtitle = room->name;
    room->name = strdup(TITLE_UNHOLY);
    room->description = strdup(DESC_UNHOLY);

    SET_BIT(room->zone->flags, ZONE_LOCKED);

    REMOVE_BIT(room->room_flags, ROOM_PEACEFUL);
}
Exemple #17
0
/* Extract an object from the world */
void extract_obj(struct obj_data * obj)
{
  struct obj_data *temp;

  if (obj->worn_by != NULL)
    if (unequip_char(obj->worn_by, obj->worn_on) != obj)
      log("SYSERR: Inconsistent worn_by and worn_on pointers!!");
  if (obj->in_room != NOWHERE)
    obj_from_room(obj);
  else if (obj->carried_by)
    obj_from_char(obj);
  else if (obj->in_obj)
    obj_from_obj(obj);

  /* Get rid of the contents of the object, as well. */
  while (obj->contains)
    extract_obj(obj->contains);

  REMOVE_FROM_LIST(obj, object_list, next);

  if (GET_OBJ_RNUM(obj) >= 0)
    (obj_index[GET_OBJ_RNUM(obj)].number)--;

  if (SCRIPT(obj))
    extract_script(SCRIPT(obj));

  free_obj(obj);
}
Exemple #18
0
/*
 * Lets the mobile to strip an object or all objects from the victim.
 * Useful for removing e.g. quest objects from a character.
 *
 * Syntax: mob remove [victim] [object vnum|'all']
 */
void do_mpremove(CHAR_DATA * ch, char *argument)
{
    CHAR_DATA *victim;
    OBJ_DATA *obj, *obj_next;
    sh_int vnum = 0;
    bool fAll = FALSE;
    char arg[MAX_INPUT_LENGTH];

    argument = one_argument(argument, arg);
    if ((victim = get_char_room(ch, arg)) == NULL)
	return;

    one_argument(argument, arg);
    if (!str_cmp(arg, "all"))
	fAll = TRUE;
    else if (!is_number(arg)) {
	bug("MpRemove: Invalid object from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    } else
	vnum = atoi(arg);

    for (obj = victim->carrying; obj; obj = obj_next) {
	obj_next = obj->next_content;
	if (fAll || obj->pIndexData->vnum == vnum) {
	    unequip_char(ch, obj);
	    obj_from_char(obj);
	    extract_obj(obj);
	}
    }
}
void take_obj_list(struct char_data *ch,struct obj_data *o,int *amount,struct char_data *give_to)
{
  char buf[MAX_STRING_LENGTH];

  if (*amount<=0 && !o) return;
  if (o->contains)
    take_obj_list(ch,o->contains,amount,give_to);
  else if (o->next_content)
    take_obj_list(ch,o->next_content,amount,give_to);
  else {
    if (o->carried_by)
      obj_from_char(o);
    if (o->in_obj)
      obj_from_obj(o);
    *amount -= o->obj_flags.cost;
    sendf(ch,"Your %s is taken.\n",o->short_description);
    if (give_to)
      sendf(give_to,"You take his %s.\n",o->short_description);
    if (give_to) {
      sprintf(buf,"FINE: %d take from %s",o->virtual,GET_NAME(ch));
      slog(buf);
      obj_to_char(o,give_to);
      o->held_for=mystrdup(GET_NAME(ch));
    } else {
      sprintf(buf,"LINK: %d take from %s",o->virtual,GET_NAME(ch));
      slog(buf);
      extract_obj(o);
    }
  }
Exemple #20
0
struct obj_data *
get_purchase_obj(struct char_data * ch, char *arg,
         struct char_data * keeper, int shop_nr, int msg)
{
  char buf[MAX_STRING_LENGTH], name[MAX_INPUT_LENGTH];
  struct obj_data *obj;

  one_argument(arg, name);
  do {
    if (*name == '#')
      obj = get_hash_obj_vis(ch, name, keeper->carrying);
    else
      obj = get_slide_obj_vis(ch, name, keeper->carrying);
    if (!obj)
      {
    if (msg)
      {
        sprintf(buf, shop_index[shop_nr].no_such_item1, GET_NAME(ch));
        do_tell(keeper, buf, cmd_tell, 0);
      }
    return (0);
      }
    if (GET_OBJ_COST(obj) <= 0)
      {
    extract_obj(obj);
    obj = 0;
      }
  } while (!obj);
  return (obj);
}
Exemple #21
0
void extract_char(Character *ch, bool fPull)
{

    for (Object * obj_next, *obj = ch->carrying; obj != NULL;
            obj = obj_next)
    {
        obj_next = obj->next_content;
        extract_obj(obj);
    }

    if (ch->inRoom != NULL) {
        char_from_room(ch);
    }
    /*
     * Death room is set in the clan tabe now
     */

    if (!fPull)
    {
        char_to_room(ch, get_room_by_id(DEFAULT_ROOM));
        return;
    }
    UNLINK(first_character, Character, ch, next);

    if (ch->pc) {
        UNLINK(first_player, Character, ch, next_player);
    }
    destroy_char(ch);
}
Exemple #22
0
int
loadCorpse(struct creature *ch)
{

    char *path = get_corpse_file_path(GET_IDNUM(ch));
    int axs = access(path, W_OK);
    struct obj_data *corpse_obj;

    if (axs != 0) {
        if (errno != ENOENT) {
            errlog("Unable to open xml corpse file '%s': %s",
                path, strerror(errno));
            return -1;
        } else {
            return 1;           // normal no eq file
        }
    }
    xmlDocPtr doc = xmlParseFile(path);
    if (!doc) {
        errlog("XML parse error while loading %s", path);
        return -1;
    }

    xmlNodePtr root = xmlDocGetRootElement(doc);
    if (!root) {
        xmlFreeDoc(doc);
        errlog("XML file %s is empty", path);
        return 1;
    }

    xmlNodePtr node = root->xmlChildrenNode;
    while (!xmlMatches(node->name, "object")) {
        node = node->next;
        if (node == NULL) {
            xmlFreeDoc(doc);
            errlog("First child in XML file (%s) not an object", path);
            return 1;
        }
    }

    corpse_obj = load_object_from_xml(NULL, ch, NULL, node);
    if (!corpse_obj) {
        xmlFreeDoc(doc);
        errlog("Could not create corpse object from file %s", path);
        return 1;
    }

    if (!IS_CORPSE(corpse_obj)) {
        xmlFreeDoc(doc);
        extract_obj(corpse_obj);
        errlog("First object in corpse file %s not a corpse", path);
        return 1;
    }

    xmlFreeDoc(doc);

    remove(path);
    return 0;
}
Exemple #23
0
void Crash_extract_objs(struct obj_data * obj)
{
  if (obj) {
    Crash_extract_objs(obj->contains);
    Crash_extract_objs(obj->next_content);
    extract_obj(obj);
  }
}
Exemple #24
0
void do_taste(struct char_data *ch, char *argument, int cmd)
{
	struct affected_type af;
	char arg[MAX_STRING_LENGTH];
	char buf[MAX_STRING_LENGTH];
	struct obj_data *temp;

	one_argument(argument,arg);

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

	if(temp->obj_flags.type_flag==ITEM_DRINKCON)
	{
		do_sip(ch,argument,0);
		return;
	}

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

	act("$n tastes the $o", FALSE, ch, temp, 0, TO_ROOM);
	act("You taste the $o", FALSE, ch, temp, 0, TO_CHAR);

	gain_condition(ch,FULL,1);

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

	if(temp->obj_flags.value[3]&&!IS_AFFECTED(ch,AFF_POISON)) /* The shit was poisoned ! */
	{
		act("Ooups, it did not taste good at all!",FALSE,ch,0,0,TO_CHAR);

		af.type = SPELL_POISON;
		af.duration = 2;
		af.modifier = 0;
		af.location = APPLY_NONE;
		af.bitvector = AFF_POISON;
		affect_to_char(ch,&af);
	}

	temp->obj_flags.value[0]--;

	if(!temp->obj_flags.value[0])	/* Nothing left */
	{
		act("There is nothing left now.",FALSE,ch,0,0,TO_CHAR);
		extract_obj(temp);
	}

	return;

}
Exemple #25
0
void Crash_extract_norents(struct obj_data * obj)
{
  if (obj) {
    Crash_extract_norents(obj->contains);
    Crash_extract_norents(obj->next_content);
    if (Crash_is_unrentable(obj))
      extract_obj(obj);
  }
}
Exemple #26
0
void free_char (CHAR_DATA *ch)
{
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    AFFECT_DATA *paf;
    AFFECT_DATA *paf_next;

    if (!IS_VALID(ch))
	return;

    if (IS_NPC(ch))
	mobile_count--;

    for (obj = ch->carrying; obj != NULL; obj = obj_next)
    {
	obj_next = obj->next_content;
	extract_obj(obj);
    }

    for (paf = ch->affected; paf != NULL; paf = paf_next)
    {
	paf_next = paf->next;
	affect_remove(ch,paf);
    }


    free_string(ch->name);
    free_string(ch->wkname);
    free_string(ch->real_name);
    free_string(ch->short_descr);
    free_string(ch->long_descr);
    free_string(ch->description);
    free_string(ch->hood_description);
    free_string(ch->veil_description);
    free_string(ch->wolf_description);
    free_string(ch->wound_description);
    free_string(ch->aura_description);
    free_string(ch->prompt);
    free_string(ch->prefix);
    
    free_string(ch->gtitle);
    free_string(ch->sguild_title);
    free_string(ch->tguild_title);
    free_string(ch->mtitle);
    free_string(ch->mname);
    
    
  /*  free_note  (ch->pnote); */
    free_pcdata(ch->pcdata);

    ch->next = char_free;
    char_free  = ch;

    INVALIDATE(ch);
    return;
}
Exemple #27
0
void Crash_extract_expensive(struct obj_data * obj)
{
  struct obj_data *tobj, *max;

  max = obj;
  for (tobj = obj; tobj; tobj = tobj->next_content)
    if (GET_OBJ_RENT(tobj) > GET_OBJ_RENT(max))
      max = tobj;
  extract_obj(max);
}
Exemple #28
0
/* Extract an object from the world */
void extract_obj(struct obj_data *obj)
{
  struct char_data *ch, *next = NULL;
  struct obj_data *temp;

  if (obj->worn_by != NULL)
    if (unequip_char(obj->worn_by, obj->worn_on) != obj)
      log("SYSERR: Inconsistent worn_by and worn_on pointers!!");
  if (IN_ROOM(obj) != NOWHERE)
    obj_from_room(obj);
  else if (obj->carried_by)
    obj_from_char(obj);
  else if (obj->in_obj)
    obj_from_obj(obj);

  if (OBJ_SAT_IN_BY(obj)){
    for (ch = OBJ_SAT_IN_BY(obj); OBJ_SAT_IN_BY(obj); ch = next){
      if (!NEXT_SITTING(ch))
        OBJ_SAT_IN_BY(obj) = NULL;
      else
        OBJ_SAT_IN_BY(obj) = (next = NEXT_SITTING(ch));
      SITTING(ch) = NULL;
      NEXT_SITTING(ch) = NULL;
    }
  }

  /* Get rid of the contents of the object, as well. */
  while (obj->contains)
    extract_obj(obj->contains);

  REMOVE_FROM_LIST(obj, object_list, next);

  if (GET_OBJ_RNUM(obj) != NOTHING)
    (obj_index[GET_OBJ_RNUM(obj)].number)--;

  if (SCRIPT(obj))
    extract_script(obj, OBJ_TRIGGER);

  if (obj->events != NULL) {
	  if (obj->events->iSize > 0) {
		struct event * pEvent;

		while ((pEvent = simple_list(obj->events)) != NULL)
		  event_cancel(pEvent);
	  }
	  free_list(obj->events);
    obj->events = NULL;
  }

  if (GET_OBJ_RNUM(obj) == NOTHING || obj->proto_script != obj_proto[GET_OBJ_RNUM(obj)].proto_script)
    free_proto_script(obj, OBJ_TRIGGER);

  free_obj(obj);
}
Exemple #29
0
void Crash_listrent(struct char_data * ch, char *name)
{
  FILE *fl;
  char fname[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH];
  struct obj_file_elem object;
  struct obj_data *obj;
  struct rent_info rent;

  if (!get_filename(name, fname, CRASH_FILE))
    return;
  if (!(fl = fopen(fname, "rb"))) {
    sprintf(buf, "%s has no rent file.\r\n", name);
    send_to_char(buf, ch);
    return;
  }
  sprintf(buf, "%s\r\n", fname);
  if (!feof(fl))
    fread(&rent, sizeof(struct rent_info), 1, fl);
  switch (rent.rentcode) {
  case RENT_RENTED:
    strcat(buf, "Rent\r\n");
    break;
  case RENT_CRASH:
    strcat(buf, "Crash\r\n");
    break;
  case RENT_CRYO:
    strcat(buf, "Cryo\r\n");
    break;
  case RENT_TIMEDOUT:
  case RENT_FORCED:
    strcat(buf, "TimedOut\r\n");
    break;
  default:
    strcat(buf, "Undef\r\n");
    break;
  }
  while (!feof(fl)) {
    fread(&object, sizeof(struct obj_file_elem), 1, fl);
    if (ferror(fl)) {
      fclose(fl);
      return;
    }
    if (!feof(fl))
      if (real_object(object.item_number) > -1) {
	obj = read_object(object.item_number, VNUMBER);
	sprintf(buf, "%s [%ld] (%5dau) %-20s\r\n", buf,
		object.item_number, GET_OBJ_RENT(obj),
		obj->short_description);
	extract_obj(obj);
      }
  }
  send_to_char(buf, ch);
  fclose(fl);
}
Exemple #30
0
int spell_ethereal_snake_devour(int sn, int level, CHAR_DATA *ch, void *vo )
{

    CHAR_DATA *victim = (CHAR_DATA *) vo;
    OBJ_DATA  *obj_lose;
    OBJ_DATA  *obj_next;
        
    if ( !IS_NPC(victim) )
    {
      send_to_char(AT_BLUE, "You failed.\n\r", ch);
      return SKPELL_MISSED;
    }
        
    if ( number_percent( ) < level && !saves_spell( level, victim ) )
      for ( obj_lose = victim->carrying; obj_lose; obj_lose = obj_next )
      {
          obj_next = obj_lose->next_content;
          if ( obj_lose->deleted )
              continue;
   
          if ( number_bits( 2 ) != 0 )
              continue;
     
          act(AT_WHITE, "$p has been devoured by an ethereal snake!",      victim, obj_lose, NULL, TO_CHAR );
          act(AT_WHITE, "$n's $p has been devoured by an ethereal snake!", victim, obj_lose, NULL, TO_ROOM );
          extract_obj( obj_lose ) ;
      }
        
    if ( !saves_spell( level, victim ) )

    /*
     * Devour char, do not generate a corpse, do not
     * give experience for kill.  Extract_char will take care   
     * of items carried/wielded by victim.
     */
    {
        act(AT_WHITE, "Your ethereal snake has DEVOURED $N!",         ch, NULL, victim, TO_CHAR );
        act(AT_WHITE, "You have been DEVOURED by $n's ethereal snake!", ch, NULL, victim, TO_VICT );
        act(AT_WHITE, "$n's ethereal snake DEDVOURS $N!",       ch, NULL, victim, TO_ROOM );
    
        if ( IS_NPC( victim ) )
	{
            extract_char( victim, TRUE );
	}
        else
	{
            extract_char( victim, FALSE );
	}
    }     
    return SKPELL_NO_DAMAGE;
}