コード例 #1
0
ファイル: special.c プロジェクト: danielkrainas/ganadia
bool spec_janitor(CHAR_DATA * ch)
{
	OBJ_DATA *trash;
	OBJ_DATA *trash_next;

	if (!IS_AWAKE(ch))
		return FALSE;

	for (trash = ch->in_room->first_content; trash; trash = trash_next) {
		trash_next = trash->next_content;
		if (!IS_SET(trash->wear_flags, ITEM_TAKE)
		    || IS_OBJ_STAT(trash, ITEM_BURRIED))
			continue;
		if (trash->item_type == ITEM_DRINK_CON
		    || trash->item_type == ITEM_TRASH
		    || trash->cost < 10
		    || (trash->pIndexData->vnum == OBJ_VNUM_SHOPPING_BAG
			&& !trash->first_content)) {
			act(AT_ACTION, "$n picks up some trash.", ch, NULL,
			    NULL, TO_ROOM);
			obj_from_room(trash);
			obj_to_char(trash, ch);
			return TRUE;
		}
	}

	return FALSE;
}
コード例 #2
0
bool spec_janitor( CHAR_DATA *ch )
{
	OBJ_DATA *trash;
	OBJ_DATA *trash_next;

	if ( !IS_AWAKE(ch) )
	return FALSE;

	for ( trash = ch->in_room->contents; trash != NULL; trash = trash_next )
	{
	trash_next = trash->next_content;
	if ( !IS_SET( trash->wear_flags, ITEM_TAKE ) || !can_loot(ch,trash))
		continue;
	if ( trash->item_type == ITEM_DRINK_CON
	||   trash->item_type == ITEM_TRASH
	||   trash->cost < 10 )
	{
		act( "$n picks up some trash.", ch, NULL, NULL, TO_ROOM );
		obj_from_room( trash );
		obj_to_char( trash, ch );
		return TRUE;
	}
	}

	return FALSE;
}
コード例 #3
0
ファイル: mob_cmds.c プロジェクト: MikeMayer/act-of-war
/*
 * Lets the mobile to transfer an object. The object must be in the same
 * room with the mobile.
 *
 * Syntax: mob otransfer [item name] [location]
 */
void do_mpotransfer(CHAR_DATA * ch, char *argument)
{
    OBJ_DATA *obj;
    ROOM_INDEX_DATA *location;
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_INPUT_LENGTH];

    argument = one_argument(argument, arg);
    if (arg[0] == '\0') {
	bug("MpOTransfer - Missing argument from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    one_argument(argument, buf);
    if ((location = find_location(ch, buf)) == NULL) {
	bug("MpOTransfer - No such location from vnum %d.",
	    IS_NPC(ch) ? ch->pIndexData->vnum : 0);
	return;
    }
    if ((obj = get_obj_here(ch, arg)) == NULL)
	return;
    if (obj->carried_by == NULL)
	obj_from_room(obj);
    else {
	if (obj->wear_loc != WEAR_NONE)
	    unequip_char(ch, obj);
	obj_from_char(obj);
    }
    obj_to_room(obj, location);
}
コード例 #4
0
ファイル: handler.c プロジェクト: Calebros/aol
/* 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);
}
コード例 #5
0
ファイル: special.c プロジェクト: Onirik79/bardmud
SPEC_RET spec_janitor( CHAR_DATA *ch )
{
	OBJ_DATA *trash;
	OBJ_DATA *trash_next;

	if ( !is_awake(ch) )
		return FALSE;

	for ( trash = ch->in_room->first_content;  trash;  trash = trash_next )
	{
		trash_next = trash->next_content;

		if ( !HAS_BIT(trash->wear_flags, OBJWEAR_TAKE) )	continue;
		if ( HAS_BIT(trash->extra_flags, OBJFLAG_BURIED) )	continue;

		if ( trash->type == OBJTYPE_DRINK_CON
		  || trash->type == OBJTYPE_TRASH
		  || trash->cost < 10
		  || (trash->pObjProto->vnum == VNUM_OBJ_SHOPPING_BAG && !trash->first_content) )
		{
			act( AT_ACTION, "$n raccoglie della spazzatura.", ch, NULL, NULL, TO_ROOM );
			obj_from_room( trash );
			obj_to_char( trash, ch );
			return TRUE;
		}
	}

	return FALSE;
}
コード例 #6
0
ファイル: handler.c プロジェクト: Lundessa/raven3
/* 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);
}
コード例 #7
0
ファイル: Teleport.c プロジェクト: Lundex/wileymud
void Teleport( int pulse )
{
   struct char_data *ch;
   struct obj_data *obj_object, *temp_obj;
   int or;

   if(DEBUG) dlog("Teleport");
   if (pulse < 0) 
      return;

   if(MOUNTED(ch))
   {
     FallOffMount(ch,MOUNTED(ch));
     Dismount(ch,MOUNTED(ch),POSITION_SITTING);
   }
   else
   if(RIDDEN(ch))
   {
     FallOffMount(RIDDEN(ch),ch);
     Dismount(RIDDEN(ch),ch,POSITION_SITTING);
   }

   for (ch = character_list; ch; ch = ch->next) 
   {
     if (ch->in_room != NOWHERE) 
     {
	if (real_roomp(ch->in_room)->tele_targ > 0) 
	{
           if (real_roomp(ch->in_room)->tele_time > 0) 
	   {
              if ((pulse % real_roomp(ch->in_room)->tele_time)==0) 
	      {
		 obj_object = real_roomp(ch->in_room)->contents;
		 while (obj_object) 
		 {
		   temp_obj = obj_object->next_content;
                   obj_from_room(obj_object);
   	           obj_to_room(obj_object, real_roomp(ch->in_room)->tele_targ);
		   obj_object = temp_obj;
		 }

		 or = ch->in_room;
		 char_from_room(ch); 
		 char_to_room(ch, real_roomp(or)->tele_targ);
       	         if (real_roomp(or)->tele_look) 
		 {
                   do_look(ch, "\0",15);
		 }
	       }
	    }
	 }
      }
   }
}
コード例 #8
0
ファイル: handler.c プロジェクト: MUDOmnibus/Rom1
/* Extract an object from the world */
void extract_obj(struct obj_data *obj)
{
    struct obj_data *temp1, *temp2;

    if(obj->in_room != NOWHERE)
	obj_from_room(obj);
    else if(obj->carried_by)
	obj_from_char(obj);
    else if(obj->in_obj)
    {
	temp1 = obj->in_obj;
	if(temp1->contains == obj)   /* head of list */
	    temp1->contains = obj->next_content;
	else
	{
	    for( temp2 = temp1->contains ;
		temp2 && (temp2->next_content != obj);
		temp2 = temp2->next_content );

	    if(temp2) {
		temp2->next_content =
		    obj->next_content; }
	}
    }

    for( ; obj->contains; extract_obj(obj->contains))
	; 
	/* leaves nothing ! */

    if (object_list == obj )       /* head of list */
	object_list = obj->next;
    else
    {
	for(temp1 = object_list; 
	    temp1 && (temp1->next != obj);
	    temp1 = temp1->next)
	    ;
	
	if(temp1)
	    temp1->next = obj->next;
    }

    if(obj->item_number>=0)
	(obj_index[obj->item_number].number)--;
    free_obj(obj);
}
コード例 #9
0
ファイル: handler.c プロジェクト: okeuday/sillymud
void obj_to_room2(struct obj_data *object, int room)
{
  
  if (room == -1)
    room = 4;

  assert(!object->equipped_by && object->eq_pos == -1);

  if (object->in_room > NOWHERE) {
    obj_from_room(object);
  }

  object->next_content = real_roomp(room)->contents;
  real_roomp(room)->contents = object;
  object->in_room = room;
  object->carried_by = 0;
  object->equipped_by = 0; /* should be unnecessary */
}
コード例 #10
0
ファイル: spec_procs.c プロジェクト: MUDOmnibus/DikuMUD-Alfa
int janitor(struct char_data *ch, int cmd, char *arg)
{
	struct obj_data *i, *temp, *next_obj;

	if (cmd || !AWAKE(ch))
		return(FALSE);

	for (i = world[ch->in_room].contents; i; i = i->next_content) {
		if (IS_SET(i->obj_flags.wear_flags, ITEM_TAKE) && 
      ((i->obj_flags.type_flag == ITEM_DRINKCON) ||
		  (i->obj_flags.cost <= 10))) {
			act("$n picks up some trash.", FALSE, ch, 0, 0, TO_ROOM);

			obj_from_room(i);
			obj_to_char(i, ch);
			return(TRUE);
		}
	}
	return(FALSE);
}
コード例 #11
0
ファイル: castle.c プロジェクト: ryantm/deimos-mud
/* Common code for James and the Cleaning Woman. */
int castle_cleaner(struct char_data *ch, int cmd, int gripe)
{
  struct obj_data *i;

  if (cmd || !AWAKE(ch) || GET_POS(ch) == POS_FIGHTING)
    return (FALSE);

  for (i = world[IN_ROOM(ch)].contents; i; i = i->next_content) {
    if (!is_trash(i))
      continue;

    if (gripe) {
      act("$n says: 'My oh my!  I ought to fire that lazy cleaning woman!'",
          FALSE, ch, 0, 0, TO_ROOM);
      act("$n picks up a piece of trash.", FALSE, ch, 0, 0, TO_ROOM);
    }
    obj_from_room(i);
    obj_to_char(i, ch);
    return (TRUE);
  }

  return (FALSE);
}
コード例 #12
0
ファイル: object.cpp プロジェクト: AmagicalFishy/BladeCraft
/*
 * Extract an obj from the world.
 */
void Object::extract_obj ()
{
  Object *obj_content;

  if (in_room != NULL)
    obj_from_room ();
  else if (carried_by != NULL)
    obj_from_char ();
  else if (in_obj != NULL)
    obj_from_obj ();

  ObjIter o, next;
  for (o = contains.begin(); o != contains.end(); o = next) {
    obj_content = *o;
    next = ++o;
    obj_content->extract_obj();
  }

  deepobnext = object_list.erase(find(object_list.begin(), object_list.end(), this));

  AffIter af;
  for (af = affected.begin(); af != affected.end(); af++) {
    delete *af;
  }
  affected.clear();

  std::list<ExtraDescription *>::iterator ed;
  for (ed = extra_descr.begin(); ed != extra_descr.end(); ed++) {
    delete *ed;
  }
  extra_descr.clear();

  --pIndexData->count;
  delete this;
  return;
}
コード例 #13
0
ファイル: oasis_delete.c プロジェクト: mysidia/circle31dgpy
/************************************************************************\
 ** Description :                                                      **
 **   Removes a room from memory, updates the world list, and moves    **
 **   all of the objects, mobiles, and players to the void.            **
 **                                                                    **
 ** Return Value:                                                      **
 **   TRUE if successful...otherwise, FALSE.                           **
 **                                                                    **
 ** Parameters  :                                                      **
 **   rnum      : The real number of the room requested to delete.     **
\************************************************************************/
int remove_room_from_memory(room_rnum rnum)
{
  struct char_data *tch;
  struct obj_data *obj;
  struct room_data *room;
  int i, j;
  
  if (rnum <= 0 || rnum > top_of_world)
    return FALSE;
  
  room = &world[rnum];
  
  add_to_save_list(zone_table[room->zone].number, SL_WLD);
  
  log("GenOLC: delete_room: Deleting room #%d (%s).", room->number, room->name);
  
  /*
   * Dump the contents of this room into the void.  We could also just
   * exract the people, mobs, and objects here.
   */
  for (obj = world[rnum].contents; obj; obj = obj->next_content) {
    obj_from_room(obj);
    obj_to_room(obj, 0);
  }
  
  for (tch = world[rnum].people; tch; tch = tch->next_in_room) {
    char_from_room(tch);
    char_to_room(tch, 0);
  }
  
  free_room(room);
  
  /*
   * Change any exit going to this room to go to the void.  This way,
   * the builders know when they type show errors.
   */
  for (i = top_of_world; i >= 0; i--)
    for (j = 0; j < NUM_OF_DIRS; j++)
      if (W_EXIT(i, j) == NULL)
        continue;
      else if (W_EXIT(i, j)->to_room > rnum)
        W_EXIT(i, j)->to_room--;
      else if (W_EXIT(i, j)->to_room == rnum)
        W_EXIT(i, j)->to_room = 0;
  
  /*
   * Find what zone the room was in so we can update the loading table.
   */
  for (i = 0; i <= top_of_zone_table; i++)
    for (j = 0; ZCMD(i, j).command != 'S'; j++)
      switch (ZCMD(i, j).command) {
        case 'M':
        case 'O':
          if (ZCMD(i, j).arg3 == rnum)
            ZCMD(i, j).command = '*'; 		/* Cancel Command */
          else if (ZCMD(i, j).arg3 > rnum)
            ZCMD(i, j).arg3--;
          break;
        case 'D':
        case 'R':
          if (ZCMD(i, j).arg1 == rnum)
            ZCMD(i, j).command = '*';		/* Cancel Command */
          else if (ZCMD(i, j).arg1 > rnum)
            ZCMD(i, j).arg1--;
          break;
        case 'G':
        case 'P':
        case 'E':
        case '*':
          /* Known zone entries we don't use here. */
          break;
        default:
          mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: delete_room: Unknown zone entry found!");
      }
  
  /*
   * Now we actually move the rooms down.
   */
  for (i = rnum; i < top_of_world; i++) {
    world[i] = world[i + 1];
    
    for (tch = world[i].people; tch; tch = tch->next_in_room)
      IN_ROOM(tch) -= (IN_ROOM(tch) != NOWHERE);  	/* Redundant Check? */
    
    for (obj = world[i].contents; obj; obj = obj->next_content)
      IN_ROOM(obj) -= (IN_ROOM(obj) != NOWHERE);
  }
  
  top_of_world--;
  RECREATE(world, struct room_data, top_of_world + 1);
  return (TRUE);
}
コード例 #14
0
ファイル: assemblies.c プロジェクト: bigmac12/Mac-s-CWG
bool assemblyCheckComponents( long lVnum, struct char_data *pCharacter )
{
    bool         bOk = TRUE;
    long         i = 0;
    long         lRnum = 0;
    struct obj_data **ppComponentObjects = NULL;
    ASSEMBLY     *pAssembly = NULL;

    if( pCharacter == NULL )
    {
        log( "SYSERR: NULL assemblyCheckComponents(): 'pCharacter'." );
        return (FALSE);
    }
    else if( (pAssembly = assemblyGetAssemblyPtr( lVnum )) == NULL )
    {
        log( "SYSERR: NULL assemblyCheckComponents(): Invalid 'lVnum' #%ld.", lVnum );
        return (FALSE);
    }

    if( pAssembly->pComponents == NULL )
        return (FALSE);
    else if( pAssembly->lNumComponents <= 0 )
        return (FALSE);

    CREATE( ppComponentObjects, struct obj_data*, pAssembly->lNumComponents );

    for( i = 0; i < pAssembly->lNumComponents && bOk; i++ )
    {
        if( (lRnum = real_object( pAssembly->pComponents[ i ].lVnum )) < 0 )
            bOk = FALSE;
        else
        {
            if( pAssembly->pComponents[ i ].bInRoom )
            {
                if( (ppComponentObjects[ i ] = get_obj_in_list_num( lRnum,
                                               world[ IN_ROOM( pCharacter ) ].contents )) == NULL )
                    bOk = FALSE;
                else
                    obj_from_room( ppComponentObjects[ i ] );
            }
            else
            {
                if( (ppComponentObjects[ i ] = get_obj_in_list_num( lRnum,
                                               pCharacter->carrying )) == NULL )
                    bOk = FALSE;
                else
                    obj_from_char( ppComponentObjects[ i ] );
            }
        }
    }


    for( i = 0; i < pAssembly->lNumComponents; i++ )
    {
        if( ppComponentObjects[ i ] == NULL )
            continue;

        if( pAssembly->pComponents[ i ].bExtract && bOk )
            extract_obj( ppComponentObjects[ i ] );
        else if( pAssembly->pComponents[ i ].bInRoom )
            obj_to_room( ppComponentObjects[ i ], IN_ROOM( pCharacter ) );
        else
            obj_to_char( ppComponentObjects[ i ], pCharacter );
    }

    free( ppComponentObjects );

    return (bOk);
}
コード例 #15
0
ファイル: update.c プロジェクト: MUDOmnibus/Rom24b6-for-Cpp
/*
 * Mob autonomous action.
 * This function takes 25% to 35% of ALL Merc cpu time.
 * -- Furey
 */
void mobile_update( void )
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    EXIT_DATA *pexit;
    int door;

    /* Examine all mobs. */
    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
	ch_next = ch->next;

	if ( !IS_NPC(ch) || ch->in_room == NULL || IS_AFFECTED(ch,AFF_CHARM))
	    continue;

	if (ch->in_room->area->empty && !IS_SET(ch->act,ACT_UPDATE_ALWAYS))
	    continue;

	/* Examine call for special procedure */
	if ( ch->spec_fun != 0 )
	{
	    if ( (*ch->spec_fun) ( ch ) )
		continue;
	}

	if (ch->pIndexData->pShop != NULL) /* give him some gold */
	    if ((ch->gold * 100 + ch->silver) < ch->pIndexData->wealth)
	    {
		ch->gold += ch->pIndexData->wealth * number_range(1,20)/5000000;
		ch->silver += ch->pIndexData->wealth * number_range(1,20)/50000;
	    }
	 

	/* That's all for sleeping / busy monster, and empty zones */
	if ( ch->position != POS_STANDING )
	    continue;

	/* Scavenge */
	if ( IS_SET(ch->act, ACT_SCAVENGER)
	&&   ch->in_room->contents != NULL
	&&   number_bits( 6 ) == 0 )
	{
	    OBJ_DATA *obj;
	    OBJ_DATA *obj_best;
	    int max;

	    max         = 1;
	    obj_best    = 0;
	    for ( obj = ch->in_room->contents; obj; obj = obj->next_content )
	    {
		if ( CAN_WEAR(obj, ITEM_TAKE) && can_loot(ch, obj)
		     && obj->cost > max  && obj->cost > 0)
		{
		    obj_best    = obj;
		    max         = obj->cost;
		}
	    }

	    if ( obj_best )
	    {
		obj_from_room( obj_best );
		obj_to_char( obj_best, ch );
		act( "$n gets $p.", ch, obj_best, NULL, TO_ROOM );
	    }
	}

	/* Wander */
	if ( !IS_SET(ch->act, ACT_SENTINEL) 
	&& number_bits(3) == 0
	&& ( door = number_bits( 5 ) ) <= 5
	&& ( pexit = ch->in_room->exit[door] ) != NULL
	&&   pexit->u1.to_room != NULL
	&&   !IS_SET(pexit->exit_info, EX_CLOSED)
	&&   !IS_SET(pexit->u1.to_room->room_flags, ROOM_NO_MOB)
	&& ( !IS_SET(ch->act, ACT_STAY_AREA)
	||   pexit->u1.to_room->area == ch->in_room->area ) 
	&& ( !IS_SET(ch->act, ACT_OUTDOORS)
	||   !IS_SET(pexit->u1.to_room->room_flags,ROOM_INDOORS)) 
	&& ( !IS_SET(ch->act, ACT_INDOORS)
	||   IS_SET(pexit->u1.to_room->room_flags,ROOM_INDOORS)))
	{
	    move_char( ch, door, FALSE );
	}
    }

    return;
}
コード例 #16
0
ファイル: special.c プロジェクト: bkero/Smaug
bool spec_wanderer( CHAR_DATA *ch )
{
    OBJ_DATA *trash;
    OBJ_DATA *trash_next;
    OBJ_DATA *obj2;
    ROOM_INDEX_DATA *was_in_room;
    EXIT_DATA *pexit = NULL;
    CHAR_DATA *vch;
    int door;
    int chance=50;
    bool found = FALSE; /* Valid direction */
    bool thrown = FALSE;/* Whether to be thrown or not */
    bool noexit = TRUE; /* Assume there is no valid exits */
    
    
    was_in_room = ch->in_room;
    if ( !IS_AWAKE(ch) )
	return FALSE;

    if((pexit = ch->in_room->first_exit) !=NULL)
			noexit=FALSE;
    
    if(chance>number_percent()){
    /****
     * Look for objects on the ground and pick it up
     ****/
    
    for ( trash = ch->in_room->first_content; trash; trash = trash_next )
    {
	trash_next = trash->next_content;
	if ( !IS_SET( trash->wear_flags, ITEM_TAKE )
	||    IS_OBJ_STAT( trash, ITEM_BURIED ) )
	    continue;
	
	if ( trash->item_type == ITEM_WEAPON
	|| 	 trash->item_type == ITEM_ARMOR
	||   trash->item_type == ITEM_LIGHT ) {
	separate_obj( trash );  /* So there is no 'sword <6>' gets only one object off ground */
	act( AT_ACTION, "$n leans over and gets $p.", ch, trash, NULL, TO_ROOM );	
	obj_from_room( trash );
	trash = obj_to_char( trash, ch );
	
	/*****
	 * If object is too high a level throw it away.
	 *****/
    if ( ch->level < trash->level )
    {
	act( AT_ACTION, "$n tries to use $p, but is too inexperienced.",ch, trash, NULL, TO_ROOM );
        thrown = TRUE;
    }
    
	/*****
	 * Wear the object if it is not to be thrown. The FALSE is passed
	 * so that the mob wont remove a piece of armor already there
	 * if it is not worn it is assumed that they can't use it or 
	 * they already are wearing something.
	 *****/
	
	if(!thrown)
	wear_obj( ch, trash, FALSE, -1 );
	
	/*****
	 * Look for an object in the inventory that is not being worn
	 * then throw it away...
	 *****/
	found=FALSE;
	if(!thrown)
        for ( obj2 = ch->first_carrying; obj2; obj2 = obj2->next_content ){
			if (obj2->wear_loc == WEAR_NONE){
			do_say(ch,"Hmm, I can't use this.");			
			trash=obj2; 
			thrown=TRUE;
	 }
	}
	/*****
	 * Ugly bit of code..
	 * Checks if the object is to be thrown & there is a valid exit, 
	 * randomly pick a direction to throw it, and check to make sure no other
	 * spec_wanderer mobs are in that room.
	 *****/
	if(thrown && !noexit)
	  while(!found && !noexit){
		door=number_door();
		if((pexit = get_exit(ch->in_room,door) ) != NULL
		&&   pexit->to_room
		&&   !IS_SET(pexit->exit_info, EX_CLOSED)
		&&	!xIS_SET(pexit->to_room->room_flags, ROOM_NODROP)){
		  if( (vch = pexit->to_room->first_person) !=NULL)
			for( vch = pexit->to_room->first_person; vch; vch = vch->next_in_room){
			  if (!str_cmp(lookup_spec(vch->spec_fun), "spec_wanderer")){
			  noexit = TRUE;
			  /*act( AT_CYAN,"$n spec_wanderer inroom $T", ch, NULL,dir_name[pexit->vdir], TO_ROOM);*/
			  return FALSE;
			  }
			}
			found = TRUE;
		}
	  }
		if (!noexit && thrown){
		/*if (trash->value*/
		set_cur_obj( trash );
		if( damage_obj( trash ) != rOBJ_SCRAPPED){
		separate_obj(trash);
		act( AT_ACTION, "$n growls and throws $p $T.", ch, trash, dir_name[pexit->vdir], TO_ROOM );
		obj_from_char( trash );
		obj_to_room( trash, pexit->to_room );
		char_from_room(ch);
		char_to_room(ch, pexit->to_room);
		act( AT_CYAN,"$p thrown by $n lands in the room.",ch, trash, ch, TO_ROOM);
		char_from_room(ch);
		char_to_room(ch, was_in_room);
		}
		else{
		do_say(ch,"This thing is junk!");
		act( AT_ACTION, "$n growls and breaks $p.",ch, trash, NULL, TO_ROOM);
		}
	
	return TRUE;
	}
	return TRUE;
    }
   } /* get next obj */
    return FALSE; /* No objects :< */
   }
   return FALSE;
}
コード例 #17
0
ファイル: mage.c プロジェクト: smthbh/dystopia-mud
/* syntax : objectgate <object>
 * ex. objectgate 2.bells
 */
void do_objectgate (CHAR_DATA *ch, char *argument)
{
  OBJ_DATA *obj;
  char arg1[MAX_INPUT_LENGTH];

  argument = one_argument(argument, arg1);

  if (IS_NPC(ch)) return;
  if (!IS_CLASS(ch, CLASS_MAGE) && !IS_CLASS(ch, CLASS_LICH))
  {
    send_to_char("Huh?\n\r", ch );
    return;
  }
  if (IS_CLASS(ch, CLASS_LICH) && ch->pcdata->powers[CON_LORE] < 1)
  {
    send_to_char("But you don't know how to do that silly.\n\r",ch);
    return;
  }
  if (arg1[0] == '\0')
  {
    send_to_char("What object do you want to attempt to gate?\n\r",ch);
    return;
  }
  if ((obj = get_obj_world(ch, arg1)) == NULL)
  {
    send_to_char("No such object.\n\r",ch);
    return;
  }
  if (IS_SET(obj->quest, QUEST_ARTIFACT) || IS_SET(obj->quest, QUEST_RELIC))
  {
    send_to_char("You cannot grab artifacts or relics.\n\r",ch);
    return;
  }
  if (obj->carried_by != NULL)
  {
    send_to_char("Someone is holding the item.\n\r",ch);
    return;
  }
  if (obj->in_room == NULL)
  {
    send_to_char("It seems to be inside something.\n\r",ch);
    return;
  }
  if (!IS_SET(obj->wear_flags, ITEM_TAKE))
  {
    send_to_char("This item is too big.\n\r",ch);
    return;
  }
  if( IS_SET(obj->in_room->room_flags, ROOM_ASTRAL))
  {
    send_to_char( "You can't find it's room.\n\r",ch);
    return;
  }
  if(IS_SET(ch->in_room->room_flags, ROOM_ASTRAL))
  {
    send_to_char( "Your room is not connected to the astral plane.\n\r",ch);
    return;
  }
  obj_from_room( obj );
  obj_to_char( obj, ch );
  send_to_char("The item appears in your hand.\n\r",ch);
  return;
}
コード例 #18
0
ファイル: genwld.c プロジェクト: nitetrip/nitetripCode
int delete_room(room_rnum rnum)
{
  int i, j;
  struct char_data *ppl, *next_ppl;
  struct obj_data *obj, *next_obj;
  struct room_data *room;

  if (rnum <= 0 || rnum > top_of_world)	/* Can't delete void yet. */
    return FALSE;

  room = &world[rnum];

  add_to_save_list(zone_table[room->zone].number, SL_WLD);

  /* This is something you might want to read about in the logs. */
  log("GenOLC: delete_room: Deleting room #%d (%s).", room->number, room->name);

  if (r_mortal_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting mortal start room!");
    r_mortal_start_room = 0;	/* The Void */
  }
  if (r_immort_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting immortal start room!");
    r_immort_start_room = 0;	/* The Void */
  }
  if (r_newbie_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting newbie start room!");
    r_newbie_start_room = 0;	/* The Void */
  }
  if (r_sorin_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting sorin start room!");
    r_sorin_start_room = 0;	/* The Void */
  }
  if (r_frozen_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting frozen start room!");
    r_frozen_start_room = 0;	/* The Void */
  }

  /*
   * Dump the contents of this room into the Void.  We could also just
   * extract the people, mobs, and objects here.
   */
  for (obj = world[rnum].contents; obj; obj = next_obj) {
    next_obj = obj->next_content;
    obj_from_room(obj);
    obj_to_room(obj, 0);
  }
  for (ppl = world[rnum].people; ppl; ppl = next_ppl) {
    next_ppl = ppl->next_in_room;
    char_from_room(ppl);
    char_to_room(ppl, 0);
  }

  free_room_strings(room);

  /*
   * Change any exit going to this room to go the void.
   * Also fix all the exits pointing to rooms above this.
   */
  for (i = top_of_world; i >= 0; i--)
    for (j = 0; j < NUM_OF_DIRS; j++)
      if (W_EXIT(i, j) == NULL)
        continue;
      else if (W_EXIT(i, j)->to_room > rnum)
        W_EXIT(i, j)->to_room--;
      else if (W_EXIT(i, j)->to_room == rnum)
        W_EXIT(i, j)->to_room = 0;	/* Some may argue -1. */

  /*
   * Find what zone that room was in so we can update the loading table.
   */
  for (i = 0; i <= top_of_zone_table; i++)
    for (j = 0; ZCMD(i , j).command != 'S'; j++)
      switch (ZCMD(i, j).command) {
      case 'M':
      case 'O':
      case 'T':
      case 'V':
	if (ZCMD(i, j).arg3 == rnum)
	  ZCMD(i, j).command = '*';	/* Cancel command. */
	else if (ZCMD(i, j).arg3 > rnum)
	  ZCMD(i, j).arg3--;
	break;
      case 'D':
      case 'R':
	if (ZCMD(i, j).arg1 == rnum)
	  ZCMD(i, j).command = '*';	/* Cancel command. */
	else if (ZCMD(i, j).arg1 > rnum)
	  ZCMD(i, j).arg1--;
      case 'G':
      case 'P':
      case 'E':
      case '*':
        /* Known zone entries we don't care about. */
        break;
      default:
        mudlog(BRF, LVL_DEITY, TRUE, "SYSERR: GenOLC: delete_room: Unknown zone entry found!");
      }

  /*
   * Now we actually move the rooms down.
   */
  for (i = rnum; i < top_of_world; i++) {
    world[i] = world[i + 1];

    for (ppl = world[i].people; ppl; ppl = ppl->next_in_room)
      IN_ROOM(ppl) -= (IN_ROOM(ppl) != NOWHERE);	/* Redundant check? */

    for (obj = world[i].contents; obj; obj = obj->next_content)
      IN_ROOM(obj) -= (IN_ROOM(obj) != NOWHERE);	/* Redundant check? */
  }

  top_of_world--;
  RECREATE(world, struct room_data, top_of_world + 1);

  return TRUE;
}
コード例 #19
0
ファイル: handler.c プロジェクト: okeuday/sillymud
/* Extract an object from the world */
void extract_obj(struct obj_data *obj)
{
  struct obj_data *temp1, *temp2;
  extern long obj_count;

#if 0
  if(IS_SET(obj->obj_flags.extra_flags, ITEM_FIGURINE) && obj->link)
     extract_char(obj->link);
#endif
  
  if(obj->in_room != NOWHERE)
    obj_from_room(obj);
  else if(obj->carried_by)
    obj_from_char(obj);
  else if (obj->equipped_by) {
    if (obj->eq_pos > -1) {
      /*
       **  set players equipment slot to 0; that will avoid the garbage items.
       */
      obj->equipped_by->equipment[obj->eq_pos] = 0;
      
    } else {
      logE("Extract on equipped item in slot -1 on:");
      logE(obj->equipped_by->player.name);
      logE(obj->name);
      return;
    }
  } else if(obj->in_obj)	{
    temp1 = obj->in_obj;
    if(temp1->contains == obj)   /* head of list */
      temp1->contains = obj->next_content;
    else		{
      for( temp2 = temp1->contains ;
	  temp2 && (temp2->next_content != obj);
	  temp2 = temp2->next_content );
      
      if(temp2) {
	temp2->next_content =
	  obj->next_content; 
      }
    }
  }
  
  for( ; obj->contains; extract_obj(obj->contains)); 
  /* leaves nothing ! */
  
  if (object_list == obj )       /* head of list */
    object_list = obj->next;
  else {
    for(temp1 = object_list; 
	temp1 && (temp1->next != obj);
	temp1 = temp1->next);
    
    if(temp1) {
      temp1->next = obj->next;
    } else {
      logE("Couldn't find object in object list.");
      assert(0);
    }
  }
  
  if(obj->item_number>=0) {
    (obj_index[obj->item_number].number)--;
    obj_count--;
  }
  free_obj(obj);

}
コード例 #20
0
void get_obj(struct char_data *ch, struct gameobject *obj, struct gameobject *container)
{
    struct char_data *gch;
    int members;
    char buffer[100];

    if (!CAN_WEAR(obj, ITEM_TAKE)) {
	send_to_char("You can't take that.\n\r", ch);
	return;
    }

    if ((ch->carry_number + get_obj_number(obj)) > can_carry_n(ch)
	    && (!IS_IMMORTAL(ch))) {
	act("$d: you can't carry that many items.",
		ch, NULL, object_name_get(obj), TO_CHAR);
	return;
    }


    if ((ch->carry_weight + get_obj_weight(obj)) > can_carry_w(ch)) {
	act("$d: you can't carry that much weight.", ch, NULL, object_name_get(obj), TO_CHAR);
	return;
    }

    if (obj->in_room != NULL) {
	for (gch = obj->in_room->people; gch != NULL; gch = gch->next_in_room) {
	    if (gch->on == obj) {
		act("$N appears to be using $p.", ch, obj, gch, TO_CHAR);
		return;
	    }
	}
    }


    if (container != NULL) {
	if (container->objprototype->vnum == OBJ_VNUM_PIT
		&& get_trust(ch) < obj->level) {
	    send_to_char("You are not powerful enough to use it.\n\r", ch);
	    return;
	}

	if (container->objprototype->vnum == OBJ_VNUM_PIT
		&& !CAN_WEAR(container, ITEM_TAKE)
		&& !IS_OBJ_STAT(obj, ITEM_HAD_TIMER))
	    obj->timer = 0;
	act_new("You get $p from $P.", ch, obj, container, TO_CHAR, POS_RESTING, true);
	act_new("$n gets $p from $P.", ch, obj, container, TO_ROOM, POS_RESTING, true);
	REMOVE_BIT(obj->extra_flags, ITEM_HAD_TIMER);
	obj_from_obj(obj);
    } else {
	act_new("You get $p.", ch, obj, container, TO_CHAR, POS_RESTING, true);
	act_new("$n gets $p.", ch, obj, container, TO_ROOM, POS_RESTING, true);
	obj_from_room(obj);
    }

    if (obj->item_type == ITEM_MONEY) {
	ch->silver += obj->value[0];
	ch->gold += obj->value[1];

	if (IS_SET(ch->act, PLR_AUTOSPLIT)) {
	    members = 0;
	    for (gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room)
		if (!IS_AFFECTED(gch, AFF_CHARM) && is_same_group(gch, ch))
		    members++;

	    if (members > 1 && (obj->value[0] > 1 || obj->value[1])) {
		sprintf(buffer, "%ld %ld", obj->value[0], obj->value[1]);
		do_split(ch, buffer);
	    }
	}

	extract_obj(obj);
    } else {
	obj_to_char(obj, ch);
    }

    return;
}
コード例 #21
0
ファイル: wizard.c プロジェクト: pfchrono/Anotherland_Mud
void do_vortex(CHAR_DATA *ch, char *argument)
{
    ROOM_INDEX_DATA *pRoom;
    ROOM_INDEX_DATA *pDir;
    OBJ_DATA *pObj;
    CHAR_DATA *pChar;
    int i;

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

    if (ch->pcdata->stats[WL_SPELLS] < 8)
    {
        stc("#RYou do not yet have mastery over this spell.\n\r",ch);
        return;
    }

    if (ch->mana < 7500)
    {
        stc("#RYou do not have the required 7500 mana.\n\r",ch);
        return;
    }

    pRoom = ch->in_room;

    for ( i = 0; i < 5; i++ )
    {
        char buf[MAX_STRING_LENGTH];
        if ( !pRoom->exit[i] || !pRoom->exit[i]->to_room )
            continue;
        pDir = pRoom->exit[i]->to_room;
        if ( IS_SET(pDir->room_flags,ROOM_SAFE) )
            continue;
        for ( pObj = pDir->contents; pObj; pObj = pDir->contents )
        {
            if (!pObj) continue;
            if (pObj->in_room == NULL) continue;
            obj_from_room(pObj);
            obj_to_room(pObj,pRoom);
            if ( pDir->people )
            {
                sprintf(buf,"#RA vortex sucks $p to the %s.",dir_name[rev_dir[i]]);
                //              act(buf,pDir->people,pObj,NULL,TO_CHAR);
                act(buf,pDir->people,pObj,NULL,TO_ROOM);
            }
            sprintf(buf,"#RA vortex sucks $p from the %s.",dir_name[i]);
            act(buf,ch,pObj,NULL,TO_CHAR);
            act(buf,ch,pObj,NULL,TO_ROOM);
        }
        for ( pChar = pDir->people; pChar; pChar = pDir->people )
        {
            if (!pChar) continue;
            if (pChar->in_room == NULL) continue;
            if (pChar == ch) continue;
            sprintf(buf,"#RA vortex sucks $n to the %s.",dir_name[rev_dir[i]]);
            act(buf,pChar,NULL,NULL,TO_ROOM);
            sprintf(buf,"#RA vortex sucks you to the %s.",dir_name[rev_dir[i]]);
            send_to_char(buf,pChar);
            char_from_room(pChar);
            char_to_room(pChar,pRoom);
            sprintf(buf,"#RA vortex sucks $N from the %s.",dir_name[i]);
            act(buf,ch,NULL,pChar,TO_CHAR);
            act(buf,ch,NULL,pChar,TO_ROOM);
        }
    }
    ch->mana -= 7500;
    WAIT_STATE(ch, 4);
    return;
}
コード例 #22
0
ファイル: genwld.c プロジェクト: bigmac12/Mac-s-CWG
int delete_room(room_rnum rnum)
{
  room_rnum i;
  int j;
  struct char_data *ppl, *next_ppl;
  struct obj_data *obj, *next_obj;
  struct room_data *room;

  if (rnum <= 0 || rnum > top_of_world)	/* Can't delete void yet. */
    return FALSE;

  room = &world[rnum];

  add_to_save_list(zone_table[room->zone].number, SL_WLD);

  /* remove from realnum lookup tree */
  htree_del(room_htree, room->number);

  /* This is something you might want to read about in the logs. */
  log("GenOLC: delete_room: Deleting room #%d (%s).", room->number, room->name);

  if (r_mortal_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting mortal start room!");
    r_mortal_start_room = 0;	/* The Void */
  }
  if (r_immort_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting immortal start room!");
    r_immort_start_room = 0;	/* The Void */
  }
  if (r_frozen_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting frozen start room!");
    r_frozen_start_room = 0;	/* The Void */
  }

  /*
   * Dump the contents of this room into the Void.  We could also just
   * extract the people, mobs, and objects here.
   */
  for (obj = world[rnum].contents; obj; obj = next_obj) {
    next_obj = obj->next_content;
    obj_from_room(obj);
    obj_to_room(obj, 0);
  }
  for (ppl = world[rnum].people; ppl; ppl = next_ppl) {
    next_ppl = ppl->next_in_room;
    char_from_room(ppl);
    char_to_room(ppl, 0);
  }

  free_room_strings(room);
  if (SCRIPT(room))
    extract_script(room, WLD_TRIGGER);
  free_proto_script(room, WLD_TRIGGER);

  /*
   * Change any exit going to this room to go the void.
   * Also fix all the exits pointing to rooms above this.
   */
  i = top_of_world + 1;
  do {
    i--;
    for (j = 0; j < NUM_OF_DIRS; j++)
      if (W_EXIT(i, j) == NULL)
        continue;
      else if (W_EXIT(i, j)->to_room > rnum)
        W_EXIT(i, j)->to_room -= (W_EXIT(i, j)->to_room != NOWHERE); /* with unsigned NOWHERE > any rnum */
      else if (W_EXIT(i, j)->to_room == rnum) {
      	if ((!W_EXIT(i, j)->keyword || !*W_EXIT(i, j)->keyword) &&
      	    (!W_EXIT(i, j)->general_description || !*W_EXIT(i, j)->general_description)) {
          /* no description, remove exit completely */
          if (W_EXIT(i, j)->keyword)
            free(W_EXIT(i, j)->keyword);
          if (W_EXIT(i, j)->general_description)
            free(W_EXIT(i, j)->general_description);
          free(W_EXIT(i, j));
          W_EXIT(i, j) = NULL;
        } else { 
          /* description is set, just point to nowhere */
          W_EXIT(i, j)->to_room = NOWHERE;
        }
      }
  } while (i > 0);

  /*
   * Find what zone that room was in so we can update the loading table.
   */
  for (i = 0; i <= top_of_zone_table; i++)
    for (j = 0; ZCMD(i , j).command != 'S'; j++)
      switch (ZCMD(i, j).command) {
      case 'M':
      case 'O':
      case 'T':
      case 'V':
	if (ZCMD(i, j).arg3 == rnum)
	  ZCMD(i, j).command = '*';	/* Cancel command. */
	else if (ZCMD(i, j).arg3 > rnum)
	  ZCMD(i, j).arg3 -= (ZCMD(i, j).arg3 != NOWHERE); /* with unsigned NOWHERE > any rnum */
	break;
      case 'D':
      case 'R':
	if (ZCMD(i, j).arg1 == rnum)
	  ZCMD(i, j).command = '*';	/* Cancel command. */
	else if (ZCMD(i, j).arg1 > rnum)
	  ZCMD(i, j).arg1 -= (ZCMD(i, j).arg1 != NOWHERE); /* with unsigned NOWHERE > any rnum */
      case 'G':
      case 'P':
      case 'E':
      case '*':
        /* Known zone entries we don't care about. */
        break;
      default:
        mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: delete_room: Unknown zone entry found!");
      }

  /*
   * Remove this room from all shop lists.
   */
  {
    extern int top_shop;
    for (i = 0;i < top_shop;i++) {
      for (j = 0;SHOP_ROOM(i, j) != NOWHERE;j++) {
        if (SHOP_ROOM(i, j) == world[rnum].number)
          SHOP_ROOM(i, j) = 0; /* set to the void */
      }
    }
  }
  /*
   * Now we actually move the rooms down.
   */
  for (i = rnum; i < top_of_world; i++) {
    world[i] = world[i + 1];
    update_wait_events(&world[i], &world[i+1]);

    for (ppl = world[i].people; ppl; ppl = ppl->next_in_room)
      IN_ROOM(ppl) -= (IN_ROOM(ppl) != NOWHERE);	/* Redundant check? */

    for (obj = world[i].contents; obj; obj = obj->next_content)
      IN_ROOM(obj) -= (IN_ROOM(obj) != NOWHERE);	/* Redundant check? */
  }

  top_of_world--;
  RECREATE(world, struct room_data, top_of_world + 1);

  return TRUE;
}
コード例 #23
0
ファイル: act_enter.c プロジェクト: michaelmwu/bota
/* RT Enter portals */
void do_enter( CHAR_DATA *ch, char *argument)
{    
    ROOM_INDEX_DATA *location; 

    if ( ch->fighting != NULL ) 
	return;

    /* nifty portal stuff */
    if (argument[0] != '\0')
    {
        ROOM_INDEX_DATA *old_room;
	OBJ_DATA *portal;
	CHAR_DATA *fch, *fch_next;

        old_room = ch->in_room;

	portal = get_obj_list( ch, argument,  ch->in_room->contents );
	
	if (portal == NULL)
	{
	    send_to_char("You don't see that here.\n\r",ch);
	    return;
	}

	if (portal->item_type != ITEM_PORTAL 
        ||  (IS_SET(portal->value[1],EX_CLOSED) && !IS_TRUSTED(ch,KNIGHT)))
	{
	    send_to_char("You can't seem to find a way in.\n\r",ch);
	    return;
	}

	if (!IS_TRUSTED(ch,KNIGHT) && !IS_SET(portal->value[2],GATE_NOCURSE)
	&&  IS_AFFECTED(ch,AFF_CURSE) )
	{
	    send_to_char("Something prevents you from leaving...\n\r",ch);
	    return;
	}

	if (IS_SET(portal->value[2],GATE_RANDOM) || portal->value[3] == -1)
	{
	    location = get_random_room(ch);
	    portal->value[3] = location->vnum; /* for record keeping :) */
	}
	else if (IS_SET(portal->value[2],GATE_BUGGY) && (number_percent() < 5))
	    location = get_random_room(ch);
	else
	    location = get_room_index(portal->value[3]);

	if (location == NULL
	||  location == old_room
	||  !can_see_room(ch,location) 
	||  (room_is_private(ch,location) && !IS_TRUSTED(ch,IMPLEMENTOR)))
	{
	   act("$p doesn't seem to go anywhere.",ch,portal,NULL,TO_CHAR);
	   return;
	}

        if (IS_NPC(ch) && IS_SET(ch->act,ACT_AGGRESSIVE)
        &&  IS_SET(location->room_flags,ROOM_LAW))
        {
            send_to_char("Something prevents you from leaving...\n\r",ch);
            return;
        }

	act("$n steps into $p.",ch,portal,NULL,TO_ROOM);
	
	if (IS_SET(portal->value[2],GATE_NORMAL_EXIT))
	    act("You enter $p.",ch,portal,NULL,TO_CHAR);
	else
	    act("You walk through $p and find yourself somewhere else...",
	        ch,portal,NULL,TO_CHAR); 

	char_from_room(ch);
	char_to_room(ch, location);

	if (IS_SET(portal->value[2],GATE_GOWITH)) /* take the gate along */
	{
	    obj_from_room(portal);
	    obj_to_room(portal,location);
	}

	if (IS_SET(portal->value[2],GATE_NORMAL_EXIT))
	    act("$n has arrived.",ch,portal,NULL,TO_ROOM);
	else
	    act("$n has arrived through $p.",ch,portal,NULL,TO_ROOM);

	do_look(ch,"auto");

	/* charges */
	if (portal->value[0] > 0)
	{
	    portal->value[0]--;
	    if (portal->value[0] == 0)
		portal->value[0] = -1;
	}

	/* protect against circular follows */
	if (old_room == location)
	    return;

    	for ( fch = old_room->people; fch != NULL; fch = fch_next )
    	{
            fch_next = fch->next_in_room;

            if (portal == NULL || portal->value[0] == -1) 
	    /* no following through dead portals */
                continue;
 
            if ( fch->master == ch && IS_AFFECTED(fch,AFF_CHARM)
            &&   fch->position < POS_STANDING)
            	do_stand(fch,"");

            if ( fch->master == ch && fch->position == POS_STANDING)
            {
 
                if (IS_SET(ch->in_room->room_flags,ROOM_LAW)
                &&  (IS_NPC(fch) && IS_SET(fch->act,ACT_AGGRESSIVE)))
                {
                    act("You can't bring $N into the city.",
                    	ch,NULL,fch,TO_CHAR);
                    act("You aren't allowed in the city.",
                    	fch,NULL,NULL,TO_CHAR);
                    continue;
            	}
 
            	act( "You follow $N.", fch, NULL, ch, TO_CHAR );
		do_enter(fch,argument);
            }
    	}

 	if (portal != NULL && portal->value[0] == -1)
	{
	    act("$p fades out of existence.",ch,portal,NULL,TO_CHAR);
	    if (ch->in_room == old_room)
		act("$p fades out of existence.",ch,portal,NULL,TO_ROOM);
	    else if (old_room->people != NULL)
	    {
		act("$p fades out of existence.", 
		    old_room->people,portal,NULL,TO_CHAR);
		act("$p fades out of existence.",
		    old_room->people,portal,NULL,TO_ROOM);
	    }
	    extract_obj(portal);
	}

	/* 
	 * If someone is following the char, these triggers get activated
	 * for the followers before the char, but it's safer this way...
	 */
	if ( IS_NPC( ch ) && HAS_TRIGGER( ch, TRIG_ENTRY ) )
	    mp_percent_trigger( ch, NULL, NULL, NULL, TRIG_ENTRY );
	if ( !IS_NPC( ch ) )
	    mp_greet_trigger( ch );

	return;
    }

    send_to_char("Nope, can't do it.\n\r",ch);
    return;
}
コード例 #24
0
ファイル: mobact.c プロジェクト: axanon/tbamud
void mobile_activity(void)
{
  struct char_data *ch, *next_ch, *vict;
  struct obj_data *obj, *best_obj;
  int door, found, max;
  memory_rec *names;

  for (ch = character_list; ch; ch = next_ch) {
    next_ch = ch->next;

    if (!IS_MOB(ch))
      continue;

    /* Examine call for special procedure */
    if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) {
      if (mob_index[GET_MOB_RNUM(ch)].func == NULL) {
	log("SYSERR: %s (#%d): Attempting to call non-existing mob function.",
		GET_NAME(ch), GET_MOB_VNUM(ch));
	REMOVE_BIT_AR(MOB_FLAGS(ch), MOB_SPEC);
      } else {
        char actbuf[MAX_INPUT_LENGTH] = "";
	if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, actbuf))
	  continue;		/* go to next char */
      }
    }

    /* If the mob has no specproc, do the default actions */
    if (FIGHTING(ch) || !AWAKE(ch))
      continue;

    /* hunt a victim, if applicable */
    hunt_victim(ch);

    /* Scavenger (picking up objects) */
    if (MOB_FLAGGED(ch, MOB_SCAVENGER))
      if (world[IN_ROOM(ch)].contents && !rand_number(0, 10)) {
	max = 1;
	best_obj = NULL;
	for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content)
	  if (CAN_GET_OBJ(ch, obj) && GET_OBJ_COST(obj) > max) {
	    best_obj = obj;
	    max = GET_OBJ_COST(obj);
	  }
	if (best_obj != NULL) {
	  obj_from_room(best_obj);
	  obj_to_char(best_obj, ch);
	  act("$n gets $p.", FALSE, ch, best_obj, 0, TO_ROOM);
	}
      }

    /* Mob Movement */
    if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) &&
       ((door = rand_number(0, 18)) < DIR_COUNT) && CAN_GO(ch, door) &&
       !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB) &&
       !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_DEATH) &&
       (!MOB_FLAGGED(ch, MOB_STAY_ZONE) ||
           (world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone))) 
    {
      /* If the mob is charmed, do not move the mob. */
      if (ch->master == NULL)
        perform_move(ch, door, 1);
    }

    /* Aggressive Mobs */
     if (!MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM))) {
      found = FALSE;
      for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
	if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	  continue;

	if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict))
	  continue;

	if (MOB_FLAGGED(ch, MOB_AGGRESSIVE  ) ||
	   (MOB_FLAGGED(ch, MOB_AGGR_EVIL   ) && IS_EVIL(vict)) ||
	   (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) ||
	   (MOB_FLAGGED(ch, MOB_AGGR_GOOD   ) && IS_GOOD(vict))) {

          /* Can a master successfully control the charmed monster? */
          if (aggressive_mob_on_a_leash(ch, ch->master, vict))
            continue;

	  hit(ch, vict, TYPE_UNDEFINED);
	  found = TRUE;
	}
      }
    }

    /* Mob Memory */
    if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
      found = FALSE;
      for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
	if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	  continue;

	for (names = MEMORY(ch); names && !found; names = names->next) {
	  if (names->id != GET_IDNUM(vict))
            continue;

          /* Can a master successfully control the charmed monster? */
          if (aggressive_mob_on_a_leash(ch, ch->master, vict))
            continue;

          found = TRUE;
          act("'Hey!  You're the fiend that attacked me!!!', exclaims $n.", FALSE, ch, 0, 0, TO_ROOM);
          hit(ch, vict, TYPE_UNDEFINED);
        }
      }
    }

    /* Charmed Mob Rebellion: In order to rebel, there need to be more charmed 
     * monsters than the person can feasibly control at a time.  Then the
     * mobiles have a chance based on the charisma of their leader.
     * 1-4 = 0, 5-7 = 1, 8-10 = 2, 11-13 = 3, 14-16 = 4, 17-19 = 5, etc. */
    if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && num_followers_charmed(ch->master) > (GET_CHA(ch->master) - 2) / 3) {
      if (!aggressive_mob_on_a_leash(ch, ch->master, ch->master)) {
        if (CAN_SEE(ch, ch->master) && !PRF_FLAGGED(ch->master, PRF_NOHASSLE))
          hit(ch, ch->master, TYPE_UNDEFINED);
        stop_follower(ch);
      }
    }

    /* Helper Mobs */
    if (MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM))) 
    {
      found = FALSE;
      for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) 
      {
	      if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict))
          continue; 
	      if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict))
          continue;

	      act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM);
	      hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
	      found = TRUE;
      }
    }

    /* Add new mobile actions here */

  }				/* end for() */
}
コード例 #25
0
ファイル: mobact.c プロジェクト: DalilaMud/Dalila-Mud
void mobile_activity(void)
{
  register struct char_data *ch, *next_ch, *vict;
  struct char_data *min_vict = NULL;
  struct obj_data *obj, *next_obj, *best_obj, *cont;
  int door, found, max, where;
  int casual, max_abil=0, curr_abil, gold;
  memory_rec *names;
  room_rnum target_room;

  extern int no_specials;
  ACMD(do_get);

  for (ch = character_list; ch; ch = next_ch) {
    next_ch = ch->next;
    
    if (!IS_MOB(ch))
      continue;
    
    //lance ripristina il master!
 	  if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_SAVE))
 		  chkmaster(ch);

    // Examine call for special procedure
    if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) {
      if (mob_index[GET_MOB_RNUM(ch)].func == NULL) {
	      sprintf(buf, "SYSERR: %s (#%d): Attempting to call non-existing mob func", GET_NAME(ch), GET_MOB_VNUM(ch));
	      log(buf);
	      REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC);
      }
      else {
	      //(mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, "");
	      if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, ""))
	        continue;	     /*  go to next char*/
      }
    }

// If the mob has no specproc, do the default actions
    if (FIGHTING(ch) || !AWAKE(ch))
      continue;

// Nuovo Scavenger (picking up objects) by Rusty 
    if (MOB_FLAGGED(ch, MOB_SCAVENGER))
	  if (world[ch->in_room].contents && (number(0, 10) > 5)) {
		  max = -1000;
		  best_obj = NULL;
		  for (obj = world[ch->in_room].contents; obj; obj = obj->next_content)
	  	if (CAN_GET_OBJ(ch, obj) && objlevel(obj) > max) {
			  best_obj = obj;
			  max = objlevel(obj);
			}
    
		  if (best_obj != NULL) {
			  obj_from_room(best_obj);
			  obj_to_char(best_obj, ch);
			  act("$n prende $p.", FALSE, ch, best_obj, 0, TO_ROOM);

// Orione, tolta la procedura che fa indossare l'eq raccolto ai mob scavenger
// Scavenger Plus:Mob wear the best object
/*
			  where=find_eq_pos(ch, best_obj, 0);
			  if (CAN_WEAR(best_obj, ITEM_WEAR_WIELD))
			    where=WEAR_WIELD;

			  if ( (where>0) && GET_EQ(ch,where)) {
				  // se ce l'ha gia!
				  if ((objlevel((ch)->equipment[where]))< objlevel(best_obj)) {
				    obj_to_char((obj=unequip_char(ch, where)), ch);
					  act("$n smette di usare $p.", FALSE, ch, obj, 0, TO_ROOM);
				  } 
				  else {
					  where = NUM_WEARS; // cioe' oggetto non indossabile
				  }

				  if (GET_LEVEL(ch)>=objlevel(best_obj)) {
					  if (where>=0 && where <NUM_WEARS) {
						  obj_from_char(best_obj);
						  equip_char(ch,best_obj,where);
						  wear_message(ch,best_obj,where);
					  }
				  }
			  }
*/
		  }
	  } //End ifif

// Mob BodyGuard !?       
    if (MOB_FLAGGED(ch, MOB_BGUARD) && (ch->master)) {
      if (   (FIGHTING(ch->master) && (npc_rescue(ch, ch->master) == FALSE))
	        || (ch->master && WHOKILLED(ch->master)) ) {
        act("$N Si schiera Prontamente al tuo fianco!", FALSE,ch->master, 0, ch, TO_CHAR);
	      act("$n Si schiera prontamente al fianco di $N", FALSE, ch, 0, ch->master, TO_ROOM);
	      if (WHOKILLED(ch->master))	
	        hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/
	      else
	        hit(ch, FIGHTING(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/
	    }
     
      if (FIGHTING(ch)) {
	      npc_rescue(ch, ch->master);
		    if (WHOKILLED(ch->master))
		      hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);  /*in ogni caso assiste*/
		    continue;
		  }	  
    }

//MOB_THIEF
    if (   MOB_FLAGGED(ch, MOB_CRIMINAL)  && (GET_POS(ch) == POS_RESTING)
        && IS_AFFECTED(ch, AFF_HIDE) && GET_HIT(ch) >= 2*GET_MAX_HIT(ch)/3) {
      appear(ch);
      GET_POS(ch)=POS_STANDING;
    }
    if (   MOB_FLAGGED(ch, MOB_CRIMINAL) 
        && ( GET_POS(ch) == POS_STANDING) 
        && ( (casual = number(0, 11)) < 6 ) ) {   // 50%  Rubare

      // cerca le vittime  1) Devono aver almeno 1 coin  
      //                   2) Deve aver una buona prob di farcela
      for (found=FALSE, min_vict = NULL, vict = world[ch->in_room].people; vict; vict = vict->next_in_room) {
	      if (CAN_SEE(ch, vict) && (vict != ch)) {
	        if ((min_vict == NULL) || (max_abil < 100)) {
	        //se ha il 100% tanto vale fermarsi
	        //Calcolo dell abilita:presa esattamente da D n'D

	          curr_abil = MIN(90, (10*(GET_LEVEL(ch)) - 5*GET_LEVEL(vict)));
	          curr_abil -=  dex_app[GET_DEX(vict)].reaction;
	          if (GET_POS(vict) < POS_STANDING)
	            curr_abil += 200;
	    // Se la vittima e' addormentata-stunned - incap o morta ovviamente
	    //  deruberai questa sicuramente

	          if (   (curr_abil >= 40) 
	              && (GET_GOLD(vict) != 0) 
	              && (curr_abil > max_abil) ) {
	            min_vict = vict;
	            max_abil = curr_abil;
	            found=TRUE;
	          }
	        }
	      }
      }
      // Se ha trovato la vittima
      if (found == TRUE) {
	      if ((casual = number(1, 100)) > max_abil) {
	        if (!IS_NPC(min_vict))
	          act(" $n cerca di prendere dei soldi dal tuo Borsello", FALSE, ch, 0, min_vict, TO_CHAR);
	        else {
	          act("Oops...", FALSE, ch, 0, min_vict, TO_ROOM);
	          act("$n cerca di rubare soldi a $N..Ma viene Scoperto! ", FALSE, ch, 0, min_vict, TO_ROOM);
	        }
	        
	        //Beccato ... fa 2 tentativi di fuga
	        if (((door = number(1, 7)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door -= 1) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door += 2) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        
	        if (IS_NPC(min_vict)) {
	          act("$n Urla: $N e' uno sporco LADRO!!!!", FALSE, min_vict, 0, ch, TO_ROOM);
	          hit(min_vict, ch, TYPE_UNDEFINED);
	        }
	      }
	      // Il Bastardo ce la fa!
	      else {
	        if (GET_POS(min_vict) < 5) {
	          GET_GOLD(ch) += GET_GOLD(min_vict);
	          GET_GOLD(min_vict) = 0;    //la ripulisce completamente
	        }
	        else {
	          gold = number((GET_GOLD(min_vict) / 10), (GET_GOLD(min_vict) / 2));
	          //gold = MIN(5000, gold);
	          if (gold > 0) {
	            GET_GOLD(ch) += gold;
	            GET_GOLD(min_vict) -= gold;
	            if (GET_GOLD(min_vict) < 0)
	              GET_GOLD(min_vict) = 0;
	          }
	        }
	        // Dopo il furto si allontana
	        if (((door = number(1, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door -=1) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door +=2) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	      }
      }
      else { // Nessuna vittima appetibile:se ne va!
	      
	      if (((door = number(0, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	          !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	        perform_move(ch, door, 1, CAN_SHOW_ROOM);
      }
    }

// Mob Sciacalli indossano EQ    
    if (MOB_FLAGGED(ch, MOB_NECRO) && !FIGHTING(ch) && AWAKE(ch))
    if (world[ch->in_room].contents) {
	    max = -1000;
	    best_obj=NULL;
	    for (cont = world[ch->in_room].contents;cont;cont = cont->next_content)
	    if (GET_OBJ_TYPE(cont) == ITEM_CONTAINER) {
	      for (obj = cont->contains; obj; obj = next_obj) {
		      next_obj = obj->next_content;
		      if (obj != NULL) {
		        if (CAN_SEE_OBJ(ch, obj) && ( (max = objlevel(obj)) <= GET_LEVEL(ch)) ) {
		          perform_get_from_container(ch, obj, cont, FIND_OBJ_INV);
		          if (obj != NULL) {
		            where = find_eq_pos(ch, obj, 0);
		            if (CAN_WEAR(obj, ITEM_WEAR_HOLD))
			            where = WEAR_HOLD;
		            if (GET_OBJ_TYPE(obj)==ITEM_LIGHT)
			            where = WEAR_LIGHT;
		            if (CAN_WEAR(obj, ITEM_WEAR_WIELD))
			            where = WEAR_WIELD;
		            if (where < 0) {
			            sprintf(buf,"SYSERR:pos < 0 ,in cont %s obj %d %s In room %d", 
			                        cont->name, 
			                        GET_OBJ_RNUM(obj), 
			                        obj->name, 
			                        IN_ROOM(ch));
			            log(buf);
			            where = NUM_WEARS;
		            }
		            
		            if (GET_EQ(ch, where) && where < NUM_WEARS) {
			            if ((objlevel((ch)->equipment[where])) < objlevel(obj)) {
			              obj_to_char((best_obj = unequip_char(ch, where)), ch);
			              act("$n smette di usare $p.",FALSE, ch, best_obj, 0, TO_ROOM);
			            }
			            else
			              where = NUM_WEARS;
		            }
		            if (where >= 0 && where < NUM_WEARS) {
			            wear_message(ch, obj, where);
			            obj_from_char(obj);
			            equip_char(ch, obj, where);
		            }
		          }
		        }
		      }
	      }
	    } //End forif
	  } //End ifif

// Mob Movement
    if (HUNTING(ch)) 
      hunt_victim(ch);
    else {
	    if (MOB_FLAGGED(ch , MOB_SEARCHER)) {}
 	    else {
        if (ch->in_room != NOWHERE) {
          if (!IS_IN_WILD(ch)) {
            if (   !MOB_FLAGGED(ch, MOB_SENTINEL) 
                && (GET_POS(ch) == POS_STANDING) 
                && (   (door = number(0, 8)) < NUM_OF_DIRS) 
                    && CAN_GO(ch, door) 
                    && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) 
                    && (   !MOB_FLAGGED(ch, MOB_STAY_ZONE) 
                        || (world[EXIT(ch, door)->to_room].zone == world[ch->in_room].zone))) {
              perform_move(ch, door, 1, CAN_SHOW_ROOM);
            }
          }
          else {  // E' in wilderness
            if (MOB_FLAGGED(ch, MOB_WILDHUNT)) 
              door = wild_mobhunter(ch);
            else 
              door = number(0, 8);
            
            if (door >= 0 && door < NUM_OF_DIRS) 
              target_room = wild_target_room(ch, door);
            else 
              target_room = -1;
            
            if (   !MOB_FLAGGED(ch, MOB_SENTINEL) 
                && (GET_POS(ch) == POS_STANDING) 
                && (target_room != -1) 
                && (   !MOB_FLAGGED(ch, MOB_STAY_ZONE) 
                    || (world[target_room].wild_rnum == world[ch->in_room].wild_rnum))) {
              perform_move(ch, door, 1, CAN_SHOW_ROOM);
            }
          }
        }	
      }
    }

// Aggressive Mobs
    if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
	      if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	        continue;
	      if (number(0, 3) < 2)
	        continue; // Simple simulate Random a Joke from Phantom ;P
	      if (GET_ABIL (vict, ABIL_TRATTATIVA) >= EXPERT_LIV)
	        continue; // I pg con trattativa ad esperto fanno pace con gli aggressivi (by Spini)
	      if (controllo_volo(ch, vict))
		continue;
	      if (affected_by_spell (vict, SPELLSKILL, DISEASE_PESTE))
		continue;

	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_PROP) && (MASTER_ID(ch)==GET_IDNUM(vict)))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_CLAN) && (CLAN_ID(ch)==GET_CLAN(vict)))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_AL_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == ALLIANCE))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_EN_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == WAR))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_PC_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == PEACE))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_VAS_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == VASSALLO))
	  	    continue;

        if (   !MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) 
            || (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) 
            || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) 
            || (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict)) ) {
	        if (GET_MOB_SPEC(ch)== thief)
	          npc_backstab(ch,vict);
	        else
	          hit(ch, vict, TYPE_UNDEFINED);
	        found = TRUE;
	      }
      }
    }

// Mob Memory
    if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
        if (!CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
          continue;
        for (names = MEMORY(ch); names && !found; names = names->next)
        if (names->id == GET_IDNUM(vict)) {
          found = TRUE;
          act("$n esclama, 'Hey!! Tu sei il tipo che mi ha attaccato!!!'", FALSE, ch, 0, 0, TO_ROOM);
          hit(ch, vict, TYPE_UNDEFINED);
        } //End forif
      }
    }

// Helper Mobs Paladino del bene
    if (   MOB_FLAGGED(ch, MOB_HELPER)
        && !MOB_FLAGGED(ch, MOB_CRIMINALHELPER) ) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room)
      if (   ch != vict 
          && IS_NPC(vict) 
          && FIGHTING(vict) 
          && !IS_NPC(FIGHTING(vict)) 
          && ch != FIGHTING(vict) ) {			
        if (   MOB_FLAGGED(vict, MOB_CRIMINAL)
            || (   (ch->master)
                && (FIGHTING(vict) == ch->master) ) ) {
	        hit(ch, vict, TYPE_UNDEFINED);
	        found = TRUE;
	      } 		
	      else { 
	        act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM);
	        hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
	        found = TRUE;
	      }
	    } //End forif
    }
	
// Helper Mobs Servo del male
    if (   MOB_FLAGGED(ch, MOB_CRIMINALHELPER)
        && !MOB_FLAGGED(ch, MOB_HELPER) ) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room)
      if (   ch != vict 
          && IS_NPC(vict) 
          && FIGHTING(vict) 
          && !IS_NPC(FIGHTING(vict)) 
          && ch != FIGHTING(vict) ) {			
        if (   MOB_FLAGGED(vict, MOB_CRIMINAL)
            || (   (ch->master) 
                && (vict == ch->master) ) ) {
          act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM);
          hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
          found = TRUE;
        }
      } //End forif
    }
	
// Add new mobile actions here

  }				// end for()
}
コード例 #26
0
ファイル: spec_procs.c プロジェクト: MUDOmnibus/DikuMUD-Alfa
int worm_ritual(struct char_data *ch, int cmd, char *arg)
{
	struct obj_data *scroll, *herbs, *blood;
	struct char_data *tmpch;
	char buf[MAX_INPUT_LENGTH];
	bool found, equipped = FALSE;
	int room;
	static int scroll_nr = -1, herbs_nr = -1, blood_nr = -1, to_room = -1;

	if (scroll_nr < 1) {
		scroll_nr = real_object(5012);
		herbs_nr = real_object(5002);
		blood_nr = real_object(5003);
		to_room = real_room(5040);
	}

	if (cmd != 207)
		return FALSE;

   arg = one_argument(arg,buf);

	if (!(scroll = get_obj_in_list_vis(ch,buf,ch->carrying))) {
		scroll = ch->equipment[HOLD];
		equipped = TRUE;
	}

   /* which scroll */
	found = (scroll && (scroll->item_number == scroll_nr));

	if (!found)
		return FALSE;

	act("$n recites $p.", TRUE, ch, scroll, 0, TO_ROOM);
	act("You recite $p which dissolves.",FALSE,ch,scroll,0,TO_CHAR);

	room = ch->in_room;
	blood = get_obj_in_list_num(blood_nr,world[room].contents);
	herbs = get_obj_in_list_num(herbs_nr,world[room].contents);

	if (!blood || !herbs || (blood->obj_flags.value[1] < 2))
		return TRUE;

   act("$p dissolves into thin air.", TRUE, ch, herbs, 0, TO_ROOM);
	act("$p dissolves into thin air.", TRUE, ch, herbs, 0, TO_CHAR);
	act("$p is emptied from blood.", FALSE, ch, blood, 0, TO_ROOM);
	act("$p is emptied from blood.", FALSE, ch, blood, 0, TO_CHAR);

	obj_from_room(herbs);
	extract_obj(herbs);            /* herbs dissapear */
	blood->obj_flags.value[1] = 0; /* empty for blood */
	blood->obj_flags.weight -= 2;  /* correct weight  */

   if (equipped)
      unequip_char(ch, HOLD);

   extract_obj(scroll);

   act("You feel yanked downwards.....", FALSE, ch, 0, 0, TO_ROOM);
	act("You feel yanked downwards.....", FALSE, ch, 0, 0, TO_CHAR);

	/* Move'em */
	tmpch = world[room].people;
	while (world[room].people){
		char_from_room(tmpch);
		char_to_room(tmpch,to_room);
		tmpch = world[room].people;
	}
	return TRUE;
}