Пример #1
0
void
char__do_cards (CHAR_DATA * ch, char *argument, int cmd)
{
  char buf[AVG_STRING_LENGTH] = "";
  OBJ_DATA *card = NULL;

  if (ch->right_hand && GET_ITEM_TYPE (ch->right_hand) == ITEM_CARD)
    {
      send_to_char ("<carried in right hand>  ", ch);
      show_obj_to_char (ch->right_hand, ch, 1);
      for (card = ch->right_hand; card != NULL; card = card->next_content)
	{
	  strcpy (buf, "    #2");
	  strcat (buf, card->short_description);
	  strcat (buf, "#0\n");
	  send_to_char (buf, ch);
	}
    }
  if (ch->left_hand && GET_ITEM_TYPE (ch->left_hand) == ITEM_CARD)
    {
      send_to_char ("<carried in left hand>  ", ch);
      show_obj_to_char (ch->left_hand, ch, 1);
      for (card = ch->left_hand; card != NULL; card = card->next_content)
	{
	  strcpy (buf, "    #2");
	  strcat (buf, obj_short_desc (card));
	  strcat (buf, "#0\n");
	  send_to_char (buf, ch);
	}
    }

}
Пример #2
0
void
creation_water_spell (CHAR_DATA * ch, AFFECTED_TYPE * spell, void *target,
		      int target_type)
{
  OBJ_DATA *tobj;
  char buf[MAX_STRING_LENGTH];

  if ((target_type == TARGET_OTHER_INVENTORY || target_type == TARGET_OBJ)
      && GET_ITEM_TYPE ((tobj = (OBJ_DATA *) target)) == ITEM_DRINKCON)
    {
      sprintf (buf, "#2%s#0 suddenly fills with cool, clear water.",
	       tobj->short_description);
      buf[2] = toupper (buf[2]);
      tobj->o.od.value[2] = 4;
      tobj->o.od.value[1] = spell->a.spell.magnitude * 2;
      tobj->o.od.value[1] = MIN (tobj->o.od.value[0], tobj->o.od.value[1]);
      act (buf, true, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
      act (buf, true, ch, 0, 0, TO_ROOM | _ACT_FORMAT);
      return;
    }

  send_to_char
    ("Your incantation, though complete, does not seem to have any effect.\n",
     ch);
}
Пример #3
0
struct obj_data *unequip_char(struct char_data *ch, int pos)
{
  int j;
  struct obj_data *obj;
   
  assert(pos>=0 && pos<MAX_WEAR);
  assert(ch->equipment[pos]);
  
  obj = ch->equipment[pos];

  assert(!obj->in_obj && obj->in_room == NOWHERE && !obj->carried_by);

  if (GET_ITEM_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) += apply_ac(ch, pos);
  
  ch->equipment[pos] = 0;
  obj->equipped_by = 0;
  obj->eq_pos = -1;
  
  for(j=0; j<MAX_OBJ_AFFECT; j++)
    affect_modify(ch, obj->affected[j].location,
		  (int)obj->affected[j].modifier,
		  obj->obj_flags.bitvector, FALSE);
  
  affect_total(ch);
  
  return(obj);
}
Пример #4
0
/* Return the effect of a piece of armor in position eq_pos */
int apply_ac(struct char_data *ch, int eq_pos)
{
  assert(ch->equipment[eq_pos]);
  
  if (!(GET_ITEM_TYPE(ch->equipment[eq_pos]) == ITEM_ARMOR))
    return 0;
  
  switch (eq_pos) {
    
  case WEAR_BODY:
    return (3*ch->equipment[eq_pos]->obj_flags.value[0]);  /* 30% */
  case WEAR_HEAD:
    return (2*ch->equipment[eq_pos]->obj_flags.value[0]);  /* 20% */
  case WEAR_LEGS:
    return (2*ch->equipment[eq_pos]->obj_flags.value[0]);  /* 20% */
  case WEAR_FEET:
    return (ch->equipment[eq_pos]->obj_flags.value[0]);    /* 10% */
  case WEAR_HANDS:
    return (ch->equipment[eq_pos]->obj_flags.value[0]);    /* 10% */
  case WEAR_ARMS:
    return (ch->equipment[eq_pos]->obj_flags.value[0]);    /* 10% */
  case WEAR_SHIELD:
    return (ch->equipment[eq_pos]->obj_flags.value[0]);    /* 10% */
  }
  return 0;
}
Пример #5
0
void equip_char(struct char_data *ch, struct obj_data *obj, int pos)
{
    int j;

    assert(pos>=0 && pos<MAX_WEAR);
    assert(!(ch->equipment[pos]));

    if (obj->carried_by) {
	log("EQUIP: Obj is carried_by when equip.");
	return;
    }

    if (obj->in_room!=NOWHERE) {
	log("EQUIP: Obj is in_room when equip.");
	return;
    }

    if ((IS_OBJ_STAT(obj, ITEM_ANTI_EVIL) && IS_EVIL(ch)) ||
	(IS_OBJ_STAT(obj, ITEM_ANTI_GOOD) && IS_GOOD(ch)) ||
	(IS_OBJ_STAT(obj, ITEM_ANTI_NEUTRAL) && IS_NEUTRAL(ch))) {
	if (ch->in_room != NOWHERE) {
/*
	    act("You are zapped by $p and instantly drop it.", FALSE, ch, obj, 0, TO_CHAR);
	    act("$n is zapped by $p and instantly drop it.", FALSE, ch, obj, 0, TO_ROOM);
	    obj_to_room(obj, ch->in_room);
	    return; */
	} else {
	    log("ch->in_room = NOWHERE when equipping char.");
	}
    }

    ch->equipment[pos] = obj;

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

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

    affect_total(ch);
}
Пример #6
0
int armor_absorption (CHAR_DATA *target, char *location)
{
    OBJ_DATA	*obj;

    if ( !str_cmp (location, "skull") || !str_cmp (location, "reye") ||
            !str_cmp (location, "leye") || !str_cmp (location, "face") ) {
        if ( (obj = get_equip (target, WEAR_HEAD)) && GET_ITEM_TYPE (obj) == ITEM_ARMOR )
            return obj->o.armor.armor_value;
    }

    else if ( !str_cmp (location, "rshoulder") || !str_cmp (location, "lshoulder") ||
              !str_cmp (location, "rupperarm") || !str_cmp (location, "lupperarm") ||
              !str_cmp (location, "rforearm") || !str_cmp (location, "lforearm") ) {
        if ( (obj = get_equip (target, WEAR_ARMS)) && GET_ITEM_TYPE (obj) == ITEM_ARMOR )
            return obj->o.armor.armor_value;
    }

    else if ( !str_cmp (location, "rhand") || !str_cmp (location, "lhand") ) {
        if ( (obj = get_equip (target, WEAR_HANDS)) && GET_ITEM_TYPE (obj) == ITEM_ARMOR )
            return obj->o.armor.armor_value;
    }

    else if ( !str_cmp (location, "thorax") || !str_cmp (location, "abdomen") ) {
        if ( (obj = get_equip (target, WEAR_ABOUT)) && GET_ITEM_TYPE (obj) == ITEM_ARMOR )
            return obj->o.armor.armor_value;
    }

    else if ( !str_cmp (location, "hip") || !str_cmp (location, "groin") ||
              !str_cmp (location, "rthigh") || !str_cmp (location, "lthigh") ||
              !str_cmp (location, "rknee") || !str_cmp (location, "lknee") ||
              !str_cmp (location, "rcalf") || !str_cmp (location, "lcalf") ) {
        if ( ((obj = get_equip (target, WEAR_LEGS_2)) ||
                (obj = get_equip (target, WEAR_LEGS_1)))
                && GET_ITEM_TYPE (obj) == ITEM_ARMOR )
            return obj->o.armor.armor_value;
    }

    else if ( !str_cmp (location, "rfoot") || !str_cmp (location, "lfoot") ) {
        if ( ((obj = get_equip (target, WEAR_FEET_2)) ||
                (obj = get_equip (target, WEAR_FEET_1)))
                && GET_ITEM_TYPE (obj) == ITEM_ARMOR )
            return obj->o.armor.armor_value;
    }

    return 0;
}
Пример #7
0
void assoc_prefix_unlink(struct default_engine *engine, hash_item *it,
                         const size_t item_size, bool drop_if_empty)
{
    prefix_t *pt = it->pfxptr;
    it->pfxptr = NULL;
    assert(pt != NULL);

    /* update prefix information */
    int item_type = GET_ITEM_TYPE(it);
    pt->items_count[item_type] -= 1;
    pt->items_bytes[item_type] -= item_size;
    pt->total_count_exclusive -= 1;
    pt->total_bytes_exclusive -= item_size;
#if 0 // might be used later
    if (1) {
        prefix_t *curr_pt = pt->parent_prefix;
        while (curr_pt != NULL) {
            curr_pt->total_count_inclusive -= 1;
            curr_pt->total_bytes_inclusive -= item_size;
            curr_pt = curr_pt->parent_prefix;
        }
    }
#endif

    if (drop_if_empty) {
        while (pt != NULL && pt != root_pt) {
            prefix_t *parent_pt = pt->parent_prefix;

            if (pt->prefix_items > 0 || pt->total_count_exclusive > 0)
                break; /* NOT empty */
            assert(pt->total_bytes_exclusive == 0);
            _prefix_delete(engine, engine->server.core->hash(_get_prefix(pt), pt->nprefix, 0),
                           _get_prefix(pt), pt->nprefix);

            pt = parent_pt;
        }
    }
}
Пример #8
0
int fido(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 (GET_ITEM_TYPE(i)==ITEM_CONTAINER && i->obj_flags.value[3]) {
			act("$n savagely devour a corpse.", FALSE, ch, 0, 0, TO_ROOM);
			for(temp = i->contains; temp; temp=next_obj)
			{
				next_obj = temp->next_content;
				obj_from_obj(temp);
				obj_to_room(temp,ch->in_room);
			}
			extract_obj(i);
			return(TRUE);
		}
	}
	return(FALSE);
}
Пример #9
0
void shopping_sell( const char *arg, struct char_data *ch,
                   struct char_data *keeper,int shop_nr)
{
  char argm[100], buf[MAX_STRING_LENGTH];
  int cost,temp_cost, i;
  struct obj_data *temp1;
  float mult = 0;
  
  if(!(is_ok(keeper,ch,shop_nr)))
    return;

  if(keeper->generic != 0)
     for(i = 0; i <= MAX_TRADE; i++) {
       if(keeper->generic == FAMINE)
          if(shop_index[shop_nr].type[i] == ITEM_FOOD) {
            mult = shop_multiplier; /* we're in a famine, we sell food, so we */
            break;             /* our prices to hell ;-) -DM */ 
          }
       if(keeper->generic == DWARVES_STRIKE)
          if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) {
          mult = shop_multiplier;
          break;
       }        
     }
  
  only_argument(arg, argm);
  
  if(!(*argm))        {
    sprintf(buf, "%s What do you want to sell??"
            ,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  if (!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) {
    sprintf(buf, shop_index[shop_nr].no_such_item2,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  if( IS_OBJ_STAT( temp1, ITEM_NODROP ) && !IS_IMMORTAL( ch ) )
  {
     send_to_char("You can't let go of it, it must be CURSED!\n\r", ch);
     return;
  }

  if (!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1)) {
    sprintf(buf,shop_index[shop_nr].do_not_buy,
            GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  if( GET_GOLD(keeper)<(int) (temp1->obj_flags.cost*
      shop_index[shop_nr].profit_sell +
      ((chr_apply[ (int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) +
      (mult * temp1->obj_flags.cost)))
  {
    sprintf(buf,shop_index[shop_nr].missing_cash1,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  cost = temp1->obj_flags.cost;
  
  if ((ITEM_TYPE(temp1) == ITEM_WAND) ||
      (ITEM_TYPE(temp1) == ITEM_STAFF))
  {
    if (temp1->obj_flags.value[1])
    {
      cost = (int)( cost * ( (float)temp1->obj_flags.value[2] /
                             (float)temp1->obj_flags.value[1] ) );
    }
    else
    {
      cost = 0;
    }
  } 
  else if (ITEM_TYPE(temp1) == ITEM_ARMOR)
  {
    if (temp1->obj_flags.value[1])
    {
      cost = (int)( cost * ( (float)temp1->obj_flags.value[0] /
                             (float)temp1->obj_flags.value[1] ) );
    }
    else
    {
      cost = 0;
    }
  }
  
  temp1->obj_flags.cost = cost;
  
  act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM);
  temp_cost = (int) (temp1->obj_flags.cost*shop_index[shop_nr].profit_sell +
             ((chr_apply[ (int)GET_CHR(ch) ].reaction *
             temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost));
  if(temp_cost < 0) temp_cost=0;

  sprintf(buf,shop_index[shop_nr].message_sell,GET_NAME(ch),temp_cost);

/* (int) (temp1->obj_flags.cost*        
                shop_index[shop_nr].profit_sell +
                ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)))
; */
  
  do_tell(keeper,buf,19);
  
  sprintf(buf,"The shopkeeper now has %s.\n\r",
          temp1->short_description);
  send_to_char(buf,ch);
  
  if (GET_GOLD(keeper)< temp_cost) {
 /* (int) (temp1->obj_flags.cost*
              shop_index[shop_nr].profit_sell +
               ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100))) {
 */
    sprintf(buf,shop_index[shop_nr].missing_cash1 ,GET_NAME(ch));
    do_tell(keeper,buf,19);
    return;
  }
  
  GET_GOLD(ch) += temp_cost;
    /* (int) (temp1->obj_flags.cost*
              shop_index[shop_nr].profit_sell +
               ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100));
              */
  GET_GOLD(keeper) -= temp_cost;
    /* (int) (temp1->obj_flags.cost*
              shop_index[shop_nr].profit_sell +
               ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100));
              */
  obj_from_char(temp1);
  if (temp1 == NULL) {
    send_to_char("As far as I am concerned, you are out..\n\r",ch);
    return;
  }
  if ((get_obj_in_list(argm,keeper->carrying)) || 
      (GET_ITEM_TYPE(temp1) == ITEM_TRASH)) {
    extract_obj(temp1);
  } else {
    obj_to_char(temp1,keeper);
  }
  return;
}
Пример #10
0
void equip_char(struct char_data *ch, struct obj_data *obj, int pos)
{
  int j;
  
  assert(pos>=0 && pos<MAX_WEAR);
  assert(!(ch->equipment[pos]));
  
  if (obj->carried_by) {
    logE("EQUIP: Obj is carried_by when equip.");
    assert(0);
  }
  
  if (obj->in_room!=NOWHERE) {
    logE("EQUIP: Obj is in_room when equip.");
    assert(0);
    return;
  }

  /*
    if the item is limited, check its ego.
    use some funky function to determine if pc's ego is higher than objs'
    ego.. if it is, proceed.. otherwise, deny.
    */
  j = ItemEgoClash(ch, obj, 0);
  if (j < -5) {
    act("$p almost seems to say 'You're much too puny to use me, twerp!'",0,
	ch, obj, 0, TO_CHAR); 
    act("$p falls to the floor",0,ch, obj, 0, TO_CHAR); 
    act("$p removes itself, and falls to the floor",0,ch, obj, 0, TO_ROOM); 
    obj_to_room(obj, ch->in_room);
    do_save(ch,"",0);
    return;
  } else if (j < 0) {
    act("$p almost seems to say 'You're pretty puny.  I don't want to be seen with you!\n", 0, ch, obj, 0, TO_CHAR);
    act("$p falls to the floor",0,ch, obj, 0, TO_CHAR); 
    act("$p removes itself, and falls to the floor",0,ch, obj, 0, TO_ROOM); 
    obj_to_room(obj, ch->in_room);
    do_save(ch,"",0);
    return;
  }

  if (ItemAlignClash(ch, obj)) {
    if (ch->in_room != NOWHERE) {
      
      act("You are zapped by $p and instantly drop it.", 
	  FALSE, ch, obj, 0, TO_CHAR);
      act("$n is zapped by $p and instantly drop it.", 
	  FALSE, ch, obj, 0, TO_ROOM);
      obj_to_room(obj, ch->in_room);
      do_save(ch,"",0);
      return;
    } else {
      logE("ch->in_room = NOWHERE when equipping char.");
      assert(0);
    }
  }
  
  if (IS_AFFECTED(ch, AFF_SNEAK) &&
      IsRestricted(GetItemClassRestrictions(obj), CLASS_THIEF))
    affect_from_char(ch, SKILL_SNEAK);
  
  ch->equipment[pos] = obj;
  obj->equipped_by = ch;
  obj->eq_pos = pos;
  
  if (GET_ITEM_TYPE(obj) == ITEM_ARMOR)
    GET_AC(ch) -= apply_ac(ch, pos);
  
  for(j=0; j<MAX_OBJ_AFFECT; j++)
    affect_modify(ch, obj->affected[j].location,
		  (int)obj->affected[j].modifier,
		  obj->obj_flags.bitvector, TRUE);

  if (GET_ITEM_TYPE(obj) == ITEM_WEAPON) {
    /* some nifty manuevering for strength */
    if (IS_NPC(ch) && !IS_SET(ch->specials.act, ACT_POLYSELF))
       GiveMinStrToWield(obj, ch);
  }
  
  affect_total(ch);
}
Пример #11
0
ENGINE_ERROR_CODE assoc_prefix_link(struct default_engine *engine, hash_item *it,
                                    const size_t item_size)
{
    const char *key = item_get_key(it);
    size_t     nkey = it->nkey;
    int prefix_depth = 0;
    int i = 0;
    char *token;
    prefix_t *pt = NULL;
    prefix_t_list_elem prefix_list[DEFAULT_PREFIX_MAX_DEPTH];

    // prefix discovering: we don't even know prefix existence at this time
    while ((token = memchr(key+i+1, engine->config.prefix_delimiter, nkey-i-1)) != NULL) {
        i = token - key;
        prefix_list[prefix_depth].nprefix = i;

        prefix_depth++;
        if (prefix_depth >= DEFAULT_PREFIX_MAX_DEPTH) {
            break;
        }
    }

    if (prefix_depth == 0) {
        pt = root_pt;
        time(&pt->create_time);
        /* save prefix pointer in hash_item */
        it->pfxptr = pt;
    } else {
        for (i = prefix_depth - 1; i >= 0; i--) {
            prefix_list[i].hash = engine->server.core->hash(key, prefix_list[i].nprefix, 0);
            pt = assoc_prefix_find(engine, prefix_list[i].hash, key, prefix_list[i].nprefix);
            if (pt != NULL) break;
        }

        if (i < (prefix_depth - 1)) {
            if (prefix_depth == 1) {
                if (!mc_isvalidname(key, prefix_list[0].nprefix)) {
                    return ENGINE_PREFIX_ENAME; /* Invalid prefix name */
                }
            }

            // need building prefixes
            if (pt != NULL && i >= 0) {
                prefix_list[i].pt = pt; // i >= 0
            }

            for (int j = i + 1; j < prefix_depth; j++) {
                pt = (prefix_t*)malloc(sizeof(prefix_t) + prefix_list[j].nprefix + 1);
                if (pt == NULL) {
                    for (j = j - 1; j >= i + 1; j--) {
                        assert(prefix_list[j].pt != NULL);
                        _prefix_delete(engine, prefix_list[j].hash, key, prefix_list[j].nprefix);
                    }
                    return ENGINE_ENOMEM;
                }

                // building a prefix_t
                memset(pt, 0, sizeof(prefix_t));
                memcpy(pt + 1, key, prefix_list[j].nprefix);
                memcpy((char*)pt+sizeof(prefix_t)+prefix_list[j].nprefix, "\0", 1);
                pt->nprefix = prefix_list[j].nprefix;
                if (PREFIX_IS_RSVD(key, pt->nprefix)) {
                    pt->internal = 1; /* internal prefix */
                }
                pt->parent_prefix = (j == 0 ? root_pt : prefix_list[j-1].pt);
                time(&pt->create_time);

                // registering allocated prefixes to prefix hastable
                _prefix_insert(engine, prefix_list[j].hash, pt);
                prefix_list[j].pt = pt;
            }
        }
        /* save prefix pointer in hash_item */
        it->pfxptr = pt;
    }
    assert(pt != NULL);

    /* update prefix information */
    int item_type = GET_ITEM_TYPE(it);
    pt->items_count[item_type] += 1;
    pt->items_bytes[item_type] += item_size;
    pt->total_count_exclusive += 1;
    pt->total_bytes_exclusive += item_size;
#if 0 // might be used later
    if (1) {
        prefix_t *curr_pt = pt->parent_prefix;
        while (curr_pt != NULL) {
            curr_pt->total_count_inclusive += 1;
            curr_pt->total_bytes_inclusive += item_size;
            curr_pt = curr_pt->parent_prefix;
        }
    }
#endif

    return ENGINE_SUCCESS;
}
Пример #12
0
void shopping_sell( char *arg, struct char_data *ch,
	 struct char_data *keeper,int shop_nr)
{
	char argm[100], buf[MAX_STRING_LENGTH];
	struct obj_data *temp1;
	struct char_data *temp_char;

	if(!(is_ok(keeper,ch,shop_nr)))
		return;

	one_argument(arg, argm);

	if(!(*argm))
	{
		sprintf(buf,
		"%s What do you want to sell??"
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying)))
	{
		sprintf(buf,
		shop_index[shop_nr].no_such_item2
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if(!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1))
	{
		sprintf(buf,
		shop_index[shop_nr].do_not_buy,
		GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	if (GET_GOLD(keeper)<(int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_sell)) {
		sprintf(buf,shop_index[shop_nr].missing_cash1
		,GET_NAME(ch));
		do_tell(keeper,buf,19);
		return;
	}

	act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM);

	sprintf(buf,shop_index[shop_nr].message_sell,
		GET_NAME(ch),(int) (temp1->obj_flags.cost*
			shop_index[shop_nr].profit_sell));
	do_tell(keeper,buf,19);
	sprintf(buf,"The shopkeeper now has %s.\n\r",
		temp1->short_description);
	send_to_char(buf,ch);
	GET_GOLD(ch) += (int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_sell);
	GET_GOLD(keeper) -= (int) (temp1->obj_flags.cost*
		shop_index[shop_nr].profit_sell);

	if((get_obj_in_list(argm,keeper->carrying)) || 
   (GET_ITEM_TYPE(temp1) == ITEM_TRASH))
		extract_obj(temp1);
	else
	{
		obj_from_char(temp1);
		obj_to_char(temp1,keeper);
	}

	return;
}
Пример #13
0
void do_look(struct char_data *ch, char *argument, int cmd)
{
    char buffer[MAX_STRING_LENGTH];
    char arg1[MAX_STRING_LENGTH];
    char arg2[MAX_STRING_LENGTH];
    int keyword_no;
    int j, bits, temp;
    bool found;
    struct obj_data *tmp_object, *found_object;
    struct char_data *tmp_char;
    char *tmp_desc;
    static char *keywords[]= {
        "north",
        "east",
        "south",
        "west",
        "up",
        "down",
        "in",
        "at",
        "",  /* Look at '' case */
        "\n"
    };

    if (!ch->desc)
        return;

    if (GET_POS(ch) < POSITION_SLEEPING)
        send_to_char("You can't see anything but stars!\n\r", ch);
    else if (GET_POS(ch) == POSITION_SLEEPING)
        send_to_char("You can't see anything, you're sleeping!\n\r", ch);
    else if ( IS_AFFECTED(ch, AFF_BLIND) )
        send_to_char("You can't see a damn thing, you're blinded!\n\r", ch);
    else if ( IS_DARK(ch->in_room) )
        send_to_char("It is pitch black...\n\r", ch);
    else {
        argument_split_2(argument,arg1,arg2);
        keyword_no = search_block(arg1, keywords, FALSE); /* Partiel Match */

        if ((keyword_no == -1) && *arg1) {
            keyword_no = 7;
            strcpy(arg2, arg1); /* Let arg2 become the target object (arg1) */
        }

        found = FALSE;
        tmp_object = 0;
        tmp_char	 = 0;
        tmp_desc	 = 0;

        switch(keyword_no) {
        /* look <dir> */
        case 0 :
        case 1 :
        case 2 :
        case 3 :
        case 4 :
        case 5 : {

            if (EXIT(ch, keyword_no)) {

                if (EXIT(ch, keyword_no)->general_description) {
                    send_to_char(EXIT(ch, keyword_no)->
                                 general_description, ch);
                } else {
                    send_to_char("You see nothing special.\n\r", ch);
                }

                if (IS_SET(EXIT(ch, keyword_no)->exit_info, EX_CLOSED) &&
                        (EXIT(ch, keyword_no)->keyword)) {
                    sprintf(buffer, "The %s is closed.\n\r",
                            fname(EXIT(ch, keyword_no)->keyword));
                    send_to_char(buffer, ch);
                }	else {
                    if (IS_SET(EXIT(ch, keyword_no)->exit_info, EX_ISDOOR) &&
                            EXIT(ch, keyword_no)->keyword) {
                        sprintf(buffer, "The %s is open.\n\r",
                                fname(EXIT(ch, keyword_no)->keyword));
                        send_to_char(buffer, ch);
                    }
                }
            } else {
                send_to_char("Nothing special there...\n\r", ch);
            }
        }
        break;

        /* look 'in'	*/
        case 6: {
            if (*arg2) {
                /* Item carried */

                bits = generic_find(arg2, FIND_OBJ_INV | FIND_OBJ_ROOM |
                                    FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object);

                if (bits) { /* Found something */
                    if (GET_ITEM_TYPE(tmp_object)== ITEM_DRINKCON)
                    {
                        if (tmp_object->obj_flags.value[1] <= 0) {
                            act("It is empty.", FALSE, ch, 0, 0, TO_CHAR);
                        } else {
                            temp=((tmp_object->obj_flags.value[1]*3)/tmp_object->obj_flags.value[0]);
                            sprintf(buffer,"It's %sfull of a %s liquid.\n\r",
                                    fullness[temp],color_liquid[tmp_object->obj_flags.value[2]]);
                            send_to_char(buffer, ch);
                        }
                    } else if (GET_ITEM_TYPE(tmp_object) == ITEM_CONTAINER) {
                        if (!IS_SET(tmp_object->obj_flags.value[1],CONT_CLOSED)) {
                            send_to_char(fname(tmp_object->name), ch);
                            switch (bits) {
                            case FIND_OBJ_INV :
                                send_to_char(" (carried) : \n\r", ch);
                                break;
                            case FIND_OBJ_ROOM :
                                send_to_char(" (here) : \n\r", ch);
                                break;
                            case FIND_OBJ_EQUIP :
                                send_to_char(" (used) : \n\r", ch);
                                break;
                            }
                            list_obj_to_char(tmp_object->contains, ch, 2, TRUE);
                        }
                        else
                            send_to_char("It is closed.\n\r", ch);
                    } else {
                        send_to_char("That is not a container.\n\r", ch);
                    }
                } else { /* wrong argument */
                    send_to_char("You do not see that item here.\n\r", ch);
                }
            } else { /* no argument */
                send_to_char("Look in what?!\n\r", ch);
            }
        }
        break;

        /* look 'at'	*/
        case 7 : {


            if (*arg2) {

                bits = generic_find(arg2, FIND_OBJ_INV | FIND_OBJ_ROOM |
                                    FIND_OBJ_EQUIP | FIND_CHAR_ROOM, ch, &tmp_char, &found_object);

                if (tmp_char) {
                    show_char_to_char(tmp_char, ch, 1);
                    if (ch != tmp_char) {
                        act("$n looks at you.", TRUE, ch, 0, tmp_char, TO_VICT);
                        act("$n looks at $N.", TRUE, ch, 0, tmp_char, TO_NOTVICT);
                    }
                    return;
                }


                /* Search for Extra Descriptions in room and items */

                /* Extra description in room?? */
                if (!found) {
                    tmp_desc = find_ex_description(arg2,
                                                   world[ch->in_room].ex_description);
                    if (tmp_desc) {
                        page_string(ch->desc, tmp_desc, 0);
                        return; /* RETURN SINCE IT WAS A ROOM DESCRIPTION */
                        /* Old system was: found = TRUE; */
                    }
                }

                /* Search for extra descriptions in items */

                /* Equipment Used */

                if (!found) {
                    for (j = 0; j< MAX_WEAR && !found; j++) {
                        if (ch->equipment[j]) {
                            if (CAN_SEE_OBJ(ch,ch->equipment[j])) {
                                tmp_desc = find_ex_description(arg2,
                                                               ch->equipment[j]->ex_description);
                                if (tmp_desc) {
                                    page_string(ch->desc, tmp_desc, 1);
                                    found = TRUE;
                                }
                            }
                        }
                    }
                }

                /* In inventory */

                if (!found) {
                    for(tmp_object = ch->carrying;
                            tmp_object && !found;
                            tmp_object = tmp_object->next_content) {
                        if CAN_SEE_OBJ(ch, tmp_object) {
                            tmp_desc = find_ex_description(arg2,
                                                           tmp_object->ex_description);
                            if (tmp_desc) {
                                page_string(ch->desc, tmp_desc, 1);
                                found = TRUE;
                            }
                        }
                    }
                }

                /* Object In room */

                if (!found) {
                    for(tmp_object = world[ch->in_room].contents;
                            tmp_object && !found;
                            tmp_object = tmp_object->next_content) {
                        if CAN_SEE_OBJ(ch, tmp_object) {
                            tmp_desc = find_ex_description(arg2,
                                                           tmp_object->ex_description);
                            if (tmp_desc) {
                                page_string(ch->desc, tmp_desc, 1);
                                found = TRUE;
                            }
                        }
                    }
                }
                /* wrong argument */

                if (bits) { /* If an object was found */
                    if (!found)
                        show_obj_to_char(found_object, ch, 5); /* Show no-description */
                    else
                        show_obj_to_char(found_object, ch, 6); /* Find hum, glow etc */
                } else if (!found) {
                    send_to_char("You do not see that here.\n\r", ch);
                }
            } else {
                /* no argument */

                send_to_char("Look at what?\n\r", ch);
            }
        }
Пример #14
0
void
transformation_animal_spell (CHAR_DATA * ch, AFFECTED_TYPE * spell,
			     void *target, int target_type)
{
  WOUND_DATA *wound, *next_wound;
  CHAR_DATA *tch;
  OBJ_DATA *tobj, *obj, *next_obj;
  char buf[MAX_STRING_LENGTH];
  bool base = false, extended = false;

  if (target_type == TARGET_OBJ)
    {
      tobj = (OBJ_DATA *) target;
      if (GET_ITEM_TYPE (tobj) == ITEM_CONTAINER
	  && tobj->nVirtual == VNUM_CORPSE)
	{
	  if ((spell->a.spell.discipline == SKILL_VOODOO
	       || spell->a.spell.discipline == SKILL_VOODOO)
	      && spell->a.spell.magnitude < MAGNITUDE_POWERFUL)
	    {
	      sprintf (buf,
		       "Suddenly, #2%s#0 appears to mend slightly, looking decidedly less decayed.",
		       tobj->short_description);
	      act (buf, false, ch, tobj, 0, TO_ROOM | _ACT_FORMAT);
	      act (buf, false, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
	      tobj->obj_timer += spell->a.spell.magnitude;
	      return;
	    }
	  else
	    if ((spell->a.spell.discipline == SKILL_VOODOO
		 || spell->a.spell.discipline == SKILL_VOODOO)
		&& spell->a.spell.magnitude >= MAGNITUDE_POWERFUL)
	    {
	      sprintf (buf,
		       "A faint white aura briefly limns #2%s#0 before fading away.",
		       tobj->short_description);
	      act (buf, false, ch, tobj, 0, TO_ROOM | _ACT_FORMAT);
	      act (buf, false, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
	      tobj->obj_flags.extra_flags &= ~ITEM_TIMER;
	      return;
	    }
	  if (spell->a.spell.discipline == SKILL_VOODOO
	      && spell->a.spell.magnitude < MAGNITUDE_POWERFUL)
	    {
	      sprintf (buf,
		       "Before your very eyes, #2%s#0 appears to putrefy with startling abruptness.",
		       tobj->short_description);
	      act (buf, false, ch, tobj, 0, TO_ROOM | _ACT_FORMAT);
	      act (buf, false, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
	      tobj->obj_timer -= spell->a.spell.magnitude;
	      tobj->obj_timer = MAX (1, tobj->obj_timer);
	      return;
	    }
	  else if (spell->a.spell.discipline == SKILL_VOODOO
		   && spell->a.spell.magnitude >= MAGNITUDE_POWERFUL)
	    {
	      sprintf (buf,
		       "Without warning, #2%s#0 putrifies wretchedly before decaying into nothingness.",
		       tobj->short_description);
	      act (buf, false, ch, tobj, 0, TO_ROOM | _ACT_FORMAT);
	      act (buf, false, ch, 0, 0, TO_CHAR | _ACT_FORMAT);
	      for (obj = tobj->contains; obj; obj = next_obj)
		{
		  next_obj = obj->next_content;
		  obj->obj_timer = 12;
		  obj_from_obj (&obj, 0);
		  if (tobj->in_room != NOWHERE)
		    obj_to_room (obj, tobj->in_room);
		  else
		    extract_obj (obj);
		}
	      extract_obj (tobj);
	      return;
	    }
	}
    }

  else if (target_type == TARGET_OTHER || target_type == TARGET_SELF)
    {
      tch = (CHAR_DATA *) target;
      if (spell->a.spell.discipline == SKILL_VOODOO)
	{
	  sprintf (buf,
		   "You suddenly feel quite envigorated, tingling with health and well-being.\n");
	  send_to_char (buf, tch);
	  sprintf (buf,
		   "$n's eyes suddenly take on an envigorated sparkle, and $s posture straightens.");
	  act (buf, true, tch, 0, 0, TO_ROOM | _ACT_FORMAT);
	  tch->move += spell->a.spell.magnitude * 10;
	  return;
	}
      else if (spell->a.spell.discipline == SKILL_VOODOO)
	{
	  for (wound = tch->wounds; wound; wound = next_wound)
	    {
	      next_wound = wound->next;
	      wound->healerskill =
		ch->skills[SKILL_VOODOO] + (spell->a.spell.magnitude * 5);
	      wound->healerskill = MIN (90, wound->healerskill);
	      base = true;
	      if (wound->infection)
		wound->infection = -1;
	      if (wound->bleeding)
		wound->bleeding = 0;
	      if (spell->a.spell.magnitude > MAGNITUDE_STAUNCH)
		{
		  if (wound->infection)
		    wound->infection = 0;
		  adjust_wound (tch, wound, spell->a.spell.magnitude * -1);
		  extended = true;
		}
	    }
	  sprintf (buf,
		   "You are briefly surrounded by a cool, soothing nimbus of white light.\n");
	  send_to_char (buf, tch);

	  if (base)
	    {
	      sprintf (buf,
		       "\nYour wounds ache less beneath the touch of the magical radiance.\n");
	      send_to_char (buf, tch);
	    }

	  if (extended)
	    {
	      sprintf (buf,
		       "\nBefore your very eyes, your wounds begin to gently mend themselves.\n");
	      send_to_char (buf, tch);
	    }

	  sprintf (buf,
		   "$n is briefly surrounded by a soft nimbus of white light.");
	  act (buf, true, tch, 0, 0, TO_ROOM | _ACT_FORMAT);

	  return;
	}
      else if (spell->a.spell.discipline == SKILL_VOODOO)
	{
	  sprintf (buf,
		   "You are briefly surrounded by an inky cloud of fetid darkness.\n");
	  send_to_char (buf, tch);

	  sprintf (buf, "$n is momentarily enveloped in an inky darkness.");
	  act (buf, true, tch, 0, 0, TO_ROOM | _ACT_FORMAT);

	  for (wound = tch->wounds; wound; wound = next_wound)
	    {
	      next_wound = wound->next;
	      if (((ch->skills[SKILL_VOODOO] / 5 +
		    spell->a.spell.magnitude) > tch->con)
		  || number (1, 25) > tch->con)
		{
		  wound->infection = -1;
		  wound->healerskill = 0;
		  base = true;
		}
	      if (spell->a.spell.magnitude > MAGNITUDE_STAUNCH)
		{
		  if (adjust_wound (tch, wound, spell->a.spell.magnitude))
		    return;
		  extended = true;
		}
	    }

	  if (base)
	    {
	      sprintf (buf,
		       "\nYour wounds ache at the darkness' touch, before slowly beginning to pustulate.\n");
	      send_to_char (buf, tch);
	    }

	  if (extended)
	    {
	      sprintf (buf,
		       "\nHorrified, you watch as your wounds seem to worsen before your very eyes.\n");
	      send_to_char (buf, tch);
	    }

	  criminalize (ch, tch, tch->room->zone, CRIME_KILL);

	  return;
	}
    }

  send_to_char
    ("Your incantation, though complete, does not seem to have any effect.\n",
     ch);
}