示例#1
0
// Returns true if a creature can see an object
bool
check_sight_object(struct creature * self, struct obj_data * obj)
{
    if (PRF_FLAGGED(self, PRF_HOLYLIGHT))
        return true;

    if (!OBJ_APPROVED(obj) && !NPC2_FLAGGED(self, NPC2_UNAPPROVED) &&
        !IS_IMMORT(self) && !is_authorized(self, TESTER, NULL))
        return false;

    if (IS_OBJ_STAT(obj, ITEM_TRANSPARENT) &&
        !(AFF3_FLAGGED(self, AFF3_SONIC_IMAGERY) ||
            AFF_FLAGGED(self, AFF_RETINA) ||
            affected_by_spell(self, ZEN_AWARENESS)))
        return false;

    if (AFF_FLAGGED(self, AFF_DETECT_INVIS) ||
        AFF2_FLAGGED(self, AFF2_TRUE_SEEING))
        return true;

    if (IS_OBJ_STAT(obj, ITEM_INVISIBLE))
        return false;

    return true;
}
示例#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->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( IS_OBJ_STAT( trash, ITEM_PROTOTYPE ) && !IS_SET( ch->act, ACT_PROTOTYPE ) )
         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;
}
示例#3
0
/*
 * Disarm a creature.
 * Caller must check for successful attack.
 */
void disarm( CHAR_DATA *ch, CHAR_DATA *victim )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
	return;

    if ( IS_OBJ_STAT(obj,ITEM_NOREMOVE))
    {
	act("$S weapon won't budge!",ch,NULL,victim,TO_CHAR, 1);
	act("$n tries to disarm you, but your weapon won't budge!",
	    ch,NULL,victim,TO_VICT, 0);
	act("$n tries to disarm $N, but fails.",ch,NULL,victim,TO_NOTVICT, 0);
	return;
    }

    act( "$n DISARMS you and sends your weapon flying!",
	 ch, NULL, victim, TO_VICT, 1 );
    act( "You disarm $N!",  ch, NULL, victim, TO_CHAR, 1 );
    act( "$n disarms $N!",  ch, NULL, victim, TO_NOTVICT, 0 );

    obj_from_char( obj );
    if ( IS_OBJ_STAT(obj,ITEM_NODROP) || IS_OBJ_STAT(obj,ITEM_INVENTORY) )
	obj_to_char( obj, victim );
    else
    {
	obj_to_room( obj, victim->in_room );
	if (IS_NPC(victim) && victim->wait == 0 && can_see_obj(victim,obj))
	    get_obj(victim,obj,NULL);
    }

    return;
}
示例#4
0
void add_obj_reset( ROOM_INDEX_DATA * room, char cm, OBJ_DATA * obj, int v2, int v3 )
{
	OBJ_DATA *inobj;
	static int iNest;

	if ( ( cm == 'O' || cm == 'P' ) && obj->pIndexData->vnum == OBJ_VNUM_TRAP )
	{
		if ( cm == 'O' )
			add_reset( room, 'T', obj->value[3], obj->value[1], obj->value[0], v3 );
		return;
	}
	add_reset( room, cm, ( cm == 'P' ? iNest : 0 ), obj->pIndexData->vnum, v2, v3 );
	if ( cm == 'O' && IS_OBJ_STAT( obj, ITEM_HIDDEN ) && !CAN_WEAR( obj, ITEM_TAKE ) )
		add_reset( room, 'H', 1, 0, 0, 0 );
	for ( inobj = obj->first_content; inobj; inobj = inobj->next_content )
	{
		if ( inobj->pIndexData->vnum == OBJ_VNUM_TRAP )
			add_obj_reset( room, 'O', inobj, 0, 0 );
	}
	if ( cm == 'P' )
		iNest++;
	for ( inobj = obj->first_content; inobj; inobj = inobj->next_content )
		add_obj_reset( room, 'P', inobj, inobj->count, obj->pIndexData->vnum );
	if ( cm == 'P' )
		iNest--;
	return;
}
示例#5
0
bool check_x_metal(CHAR_DATA *ch, CHAR_DATA *victim, int type, int spell)
{
    OBJ_DATA *obj;
    //true nie czaruje, false czaruje

    for( obj = victim->carrying; obj != NULL; obj = obj->next_content )
    {
        switch( obj->wear_loc )
        {
        case WEAR_FEET:
        case WEAR_LEGS:
        case WEAR_BODY:
        case WEAR_HEAD:
        case WEAR_SHIELD:
        case WEAR_ARMS:
        case WEAR_HANDS:
        case WEAR_WIELD:
        case WEAR_SECOND:
            break;
        default:
            continue;
        }

        if (obj->item_type != ITEM_ARMOR && obj->item_type != ITEM_WEAPON )
            continue;

        if (IS_OBJ_STAT( obj, ITEM_NOMAGIC ) )
            continue;

        if ( IS_SET(material_table[obj->material].flag, MAT_METAL) )
            return FALSE;
    }

    return TRUE;
}
示例#6
0
文件: handler.c 项目: MUDOmnibus/Rom1
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);
}
示例#7
0
int Crash_is_unrentable(struct obj_data * obj)
{
  if (!obj)
    return 0;

  if (IS_OBJ_STAT(obj, ITEM_NORENT) || GET_OBJ_RENT(obj) < 0 ||
      GET_OBJ_RNUM(obj) <= NOTHING || GET_OBJ_TYPE(obj) == ITEM_KEY)
    return 1;

  return 0;
}
示例#8
0
void Crash_extract_norents_from_equipped(struct char_data * ch)
{
  int j;

  for (j = 0;j < NUM_WEARS;j++) {
    if (GET_EQ(ch,j)) {
      if (IS_OBJ_STAT(GET_EQ(ch,j), ITEM_NORENT) ||
	  GET_OBJ_RENT(GET_EQ(ch,j)) < 0 ||
	  GET_OBJ_RNUM(GET_EQ(ch,j)) <= NOTHING ||
	  GET_OBJ_TYPE(GET_EQ(ch,j)) == ITEM_KEY)
	obj_to_char(unequip_char(ch,j),ch);
      else
	Crash_extract_norents(GET_EQ(ch,j));
    }
  }
}
示例#9
0
文件: house.c 项目: vedicveko/Dibrova
/* Save all objects for a house (recursive; initial call must be followed
   by a call to House_restore_weight)  Assumes file is open already. */
int House_save(struct obj_data * obj, FILE * fp)
{
  struct obj_data *tmp;
  int result;

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

    for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj)
      GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
    }
  }
  return 1;
}
示例#10
0
文件: races.c 项目: Calebros/aol
/*
 * invalid_race is used by handler.c to determine if a piece of equipment is
 * usable by a particular race, based on the ITEM_ANTI_{race} bitvectors.
 */
int invalid_race(struct char_data *ch, struct obj_data *obj) {

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_BARBAR) && IS_BARBARIAN(ch) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_DWARF) &&
            ( IS_HYLAR(ch) || IS_DAEWAR(ch) || IS_NEIDAR(ch) ) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_ELF) &&
            ( IS_SILVANESTI(ch) || IS_QUALINESTI(ch) || IS_KAGONESTI(ch) ) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_HALFELF) && IS_HALFELVEN(ch) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_KENDER) && IS_KENDER(ch) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_MINOTAUR) && IS_MINOTAUR(ch) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_GNOME) && IS_GNOME(ch) ) {
        return 1;
    }

    if ( IS_OBJ_STAT(obj, ITEM_ANTI_HUMAN) && IS_HUMAN(ch) ) {
        return 1;
    }


    return 0;
}
示例#11
0
文件: shop.c 项目: rparet/darkpawns
int
trade_with(struct obj_data * item, int shop_nr)
{
  int counter;

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

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

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

  return (OBJECT_NOTOK);
}
示例#12
0
/*
** Update PCs, NPCs, and objects
*/
void
point_update( void )
{
    int slot;

    void update_char_objects(CharData * ch); /* handler.c */
    void extract_obj(ObjData * obj);	     /* handler.c */
    void update_char_quests(CharData * ch);  /* quest.c */
    CharData *i, *next_char;
    ObjData  *j, *next_thing, *jj, *next_thing2, *debugnext;
    int loopvar;

    /* characters */
    for( i = character_list; i; i = next_char )
    {
        next_char = i->next;

        // state flags
        i->tickstate = 0;

        /* dismount anyone who's gotten separated from their steed */
        /* Note that it's superfluous to check for both rider AND mount */
        if (i->rider && i->rider->in_room != i->in_room) {
            i->rider->mount = NULL;
            i->rider = NULL;
        }

        /* Prayer timer */
        if (i->player_specials->saved.prayer_time > 0) {
            if (i->player_specials->saved.prayer_time == 1) {
                i->player_specials->saved.prayer_time = 0;
                send_to_char("Your prayers will be heard once again.\r\n", i);
            } else
                i->player_specials->saved.prayer_time -= 1;
        }

        for(slot = 0; slot<4; slot++) {
            if (COOLDOWN(i, slot) ) {
                COOLDOWN(i, slot) -= 1;
                if (!COOLDOWN(i, slot) ) {
                    switch( GET_CLASS(i) ) {
                        case CLASS_DEATH_KNIGHT:
                            break;
                        case CLASS_SOLAMNIC_KNIGHT:
                            break;
                        case CLASS_MAGIC_USER:
                            break;
                        case CLASS_SHADOW_DANCER:
                            if(slot == SLOT_SLIPPERY_MIND)
                                break;
                            else if(slot == SLOT_NODESHIFT)
                                sendChar(i, "You may once again shift your spectrum.\r\n");
                            else sendChar(i, "ERROR!\r\n");
                            break;
                        case CLASS_THIEF:
                            if(slot== SLOT_BLACKJACK) {
                                sendChar(i, "You are able to use blackjack again.\r\n");
                                break;
                            }
                            else sendChar(i, "ERROR!\r\n");
                        case CLASS_ASSASSIN:
                            if(slot == SLOT_DETERRENCE)
                                sendChar(i, "You are able to use deterrence again.\r\n");
                            else sendChar(i, "ERROR!\r\n");
                            break;
                        case CLASS_CLERIC:
                            if(slot == SLOT_SHADOW_FORM)
                                sendChar(i, "You are ready to enter shadow form again..\r\n");
                            else sendChar(i, "ERROR!\r\n");
                        case CLASS_WARRIOR:
                            if(slot == SLOT_REDOUBT)
                                sendChar(i, "You can shield yourself again.\r\n");
                            else if(slot == SLOT_COMMANDING_SHOUT)
                                sendChar(i, "You can shout commands again.\r\n");
                            else sendChar(i, "ERROR!\r\n");
                            break;
                        case CLASS_SHOU_LIN:
                            break;
                        case CLASS_RANGER:
                            break;
                        case CLASS_NECROMANCER:
                            if(slot == SLOT_QUICKEN)
                                sendChar(i, "You may once again rise from the grave.\r\n");
                            else if(slot == SLOT_METAMORPHOSIS)
                                sendChar(i, "You may once again metamorphisize.\r\n");
                            else sendChar(i, "ERROR!\r\n");
                            break;

                        default:
                            sendChar(i, "ERROR!\r\n");
                            break;
                    }
                }
            }
        }

        if( IS_AFFECTED(i, AFF_PLAGUE )) infectious(i);

        if( !IS_NPC(i) )
        {
            update_char_objects(i);
            if( GET_LEVEL(i) < LVL_GOD )
                check_idling(i);
            update_char_quests(i);
        }
        gain_condition(i, HUNGER, IS_AFFECTED(i, AFF_REGENERATE)? -2:-1);
        gain_condition(i, DRUNK, -1);

        /* Amara get thirsty in different ways */
        if (IS_AMARA(i)) {
            if (IN_ROOM(i) >= 0 && IN_ROOM(i) <= top_of_world) {
                switch (SECT(IN_ROOM(i))) {
                    case SECT_WATER_SWIM:
                    case SECT_WATER_NOSWIM:
                        gain_condition(i, THIRST, 1);
                        break;
                    case SECT_UNDERWATER:
                    case SECT_UNDERWATER_RIVER:
                        gain_condition(i, THIRST, 24);
                        break;
                    default:
                        gain_condition(i, THIRST, -2);
                        break;
                }
            } else gain_condition(i, THIRST, -2);
        } else gain_condition(i, THIRST, -1);
    }/* for */

    debugnext = NULL;
    /* objects */
    for( j = object_list; j; j = next_thing )
    {
        next_thing = j->next;	/* Next in object list */
        debugnext = j;		// we didn't crash if we got here

        if( IS_SET_AR( j->obj_flags.extra_flags, ITEM_TIMED ))
        {
            if( GET_OBJ_TIMER(j) > 0 )
                GET_OBJ_TIMER(j)--;

            if (GET_OBJ_TIMER(j) == 0) {
                if(contains_soulbound(j)) {
                    GET_OBJ_TIMER(j) = 1;
                    continue;
                }

                if (SCRIPT_CHECK(j, OTRIG_TIMER)) {
                    REMOVE_BIT_AR(j->obj_flags.extra_flags, ITEM_TIMED);
                    timer_otrigger(j);
                    continue;    // don't do anything more with this
                }
            }

            if( GET_OBJ_TYPE(j) == ITEM_KEY )
            {
                static char *keyVaporMsgs[] = {
                    "$p vanishes with a flash.",
                    "$p begins to shake violently.",
                    "$p begins to vibrate.",
                    "$p begins to hum.",
                    "$p begins to glow."
                };

                if( GET_OBJ_TIMER(j) < (sizeof( keyVaporMsgs )/sizeof( *keyVaporMsgs )))
                {
                    int vaporMsg = GET_OBJ_TIMER(j);

                    if( j->carried_by )
                        act( keyVaporMsgs[ vaporMsg ], FALSE, j->carried_by, j, 0, TO_CHAR);

                    else if( j->worn_by )
                    {
                        act( keyVaporMsgs[ vaporMsg ], FALSE, j->worn_by, j, 0, TO_CHAR);
                        for( loopvar = 0; loopvar < NUM_WEARS; loopvar++ )
                        {
                            if( j->worn_by->equipment[loopvar] == j )
                                j->worn_by->equipment[loopvar] = 0;
                        }
                    }
                    else if( j->in_room != NOWHERE && world[j->in_room].people )
                    {
                        act( keyVaporMsgs[ vaporMsg ], FALSE, world[j->in_room].people, j, 0, TO_CHAR);
                        act( keyVaporMsgs[ vaporMsg ], FALSE, world[j->in_room].people, j, 0, TO_ROOM);
                    }
                    extract_obj(j);
                    continue;
                }/* ITEM_KEY has timed out */
            }/* if ITEM_KEY */
            else if (GET_OBJ_TYPE(j) == ITEM_AFFECT)
            {
                if (!GET_OBJ_TIMER(j)) {
                    if (j->in_room != NOWHERE && world[j->in_room].people) {
                        act(j->action_description, FALSE, world[j->in_room].people,
                                j, 0, TO_CHAR);
                        act(j->action_description, FALSE, world[j->in_room].people,
                                j, 0, TO_ROOM);
                    }
                    extract_obj(j);
                    continue; // object gone, don't act further on it!
                }
            }
            else if( !GET_OBJ_TIMER(j) )
            {
                /* The object timed out - delete it */
                if( j->carried_by )
                    act( "$p crumbles to dust and is blown away.", FALSE, j->carried_by, j, 0, TO_CHAR );

                else if( j->worn_by )
                {
                    act("$p crumbles to dust and is blown away.", FALSE, j->worn_by, j, 0, TO_CHAR);
                    unequip_char( j->worn_by, j->worn_at );
                }
                else if( j->in_room != NOWHERE && world[j->in_room].people )
                {
                    act( "$p crumbles to dust and is blown away.",
                            FALSE, world[j->in_room].people, j, 0, TO_CHAR);
                    act( "$p crumbles to dust and is blown away.",
                            FALSE, world[j->in_room].people, j, 0, TO_ROOM);
                }
                extract_obj(j);
                continue; // object gone, don't act further on it!
            }
        } /* if OBJ_TIMED */

        /* if this looks like a portal */
        if ( (GET_OBJ_RNUM(j) >= 0 && GET_OBJ_RNUM(j) <= top_of_objt) &&
                obj_index[GET_OBJ_RNUM(j)].func == portal_proc &&
                GET_OBJ_TYPE(j) == ITEM_OTHER )
        { /* Mage created portals are type other, permanent portals are type portal. */
            /* Permanent portals thus don't decay. */
            if (GET_OBJ_VAL(j, 2) > 0)
                GET_OBJ_VAL(j,2)--;
        }
        /*
         ** Digger
         */
        /* If this is a corpse */
        if ((GET_OBJ_TYPE(j) == ITEM_CONTAINER) && GET_OBJ_VAL(j, 3)) {
            /* timer count down */
            if (GET_OBJ_TIMER(j) > 0)
                GET_OBJ_TIMER(j)--;

            // PC corpses which are empty will decay eventually..
            if(!CAN_WEAR(j, ITEM_WEAR_TAKE) && !(j->contains))
            {
                GET_OBJ_TIMER(j) = MAX(GET_OBJ_TIMER(j) / 3, 0);
            }

            if (!GET_OBJ_TIMER(j)) {
                if(contains_soulbound(j)) {
                    GET_OBJ_TIMER(j) = 1;
                    continue;
                }

                if (j->carried_by)
                    act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
                
                else if ((j->in_room != NOWHERE) && (world[j->in_room].people)) {
                    static char *decay_messages[] = {
                        "A quivering hoard of maggots consumes $p.",
                        "A flock of vultures swoop down from the sky to devour $p.",
                        "The $p rots and decays as the shards of bone are blown to the four winds.",
                        "The $p rots and decays leaving behind the pungent stench of death.",
                        "A bolt of holy fire streaks from the heavens to burn the corpse of $p to ash.",
                        "The $p rots to ash and is swept away by the winds of time."
                    };
                    int decay_idx = (int)( random() % ( sizeof( decay_messages ) / sizeof( *decay_messages )));

                    act( decay_messages[ decay_idx ], TRUE, world[j->in_room].people, j, 0, TO_ROOM);
                    act( decay_messages[ decay_idx ], TRUE, world[j->in_room].people, j, 0, TO_CHAR);
                }/* JBP */
                
                for (jj = j->contains; jj; jj = next_thing2) {
                    next_thing2 = jj->next_content;	/* Next in inventory */
                    obj_from_obj(jj);

                    if (j->in_obj) {
                        if ( GET_OBJ_TYPE(j) != ITEM_KEY    &&
                                GET_OBJ_TYPE(j) != ITEM_SCROLL &&
                                GET_OBJ_TYPE(j) != ITEM_POTION &&
                                GET_OBJ_TYPE(j) != ITEM_DUST   &&
                                (GET_OBJ_VNUM(j) == 1460 ||
                                GET_OBJ_VNUM(j) == 1461 ||
                                GET_OBJ_VNUM(j) == 1462   ) )
                            continue;  // Refrigeration to keep food from rotting.
                        obj_to_obj(jj, j->in_obj);
                    }
                    else if (j->carried_by)
                        obj_to_room(jj, j->carried_by->in_room);
                    else if (j->in_room != NOWHERE)
                        obj_to_room(jj, j->in_room);
                    else
                    {
                        /* OLD WAY: assert(FALSE); */
                        mudlog(NRM, LVL_IMMORT, TRUE, "SYSERR: Something is wrong with a container." );
                        obj_to_room(jj, real_room(1201));
                    }
                }
                extract_obj(j);
            }
        }

        /* Imhotep: Added support for ITEM_TROPHY pieces that decay after
         * a given MUD date */        
        if(IS_OBJ_STAT(j, ITEM_TROPHY)) {
            if(GET_OBJ_TIMER(j) < TICKS_SO_FAR) {
                if (j->carried_by)
                    act("$p shimmers and vanishes out of your hands!", FALSE, j->carried_by, j, 0,
                            TO_CHAR);
                else if (j->worn_by) {
                    act("$p shimmers and vanishes!", FALSE, j->worn_by, j, 0, TO_CHAR);
                    unequip_char(j->worn_by, j->worn_at);
                } else if (j->in_room != NOWHERE && world[j->in_room].people) {
                    act("$p shimmers and vanishes!", FALSE,
                            world[j->in_room].people, j, 0, TO_CHAR);
                    act("$p shimmers and vanishes!", FALSE,
                            world[j->in_room].people, j, 0, TO_ROOM);
                }
                extract_obj(j);
                continue;
            }
        }
    }
}/* point_update */
示例#13
0
文件: shop.c 项目: frasten/openleu
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;
}
示例#14
0
void do_mposet( CHAR_DATA * ch, const char *argument )
{
	char arg1[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	char arg3[MAX_INPUT_LENGTH];
	char buf[MAX_STRING_LENGTH];
	OBJ_DATA *obj;
	char outbuf[MAX_STRING_LENGTH];
	int value, tmp;

	/*
	 * A desc means switched.. too many loopholes if we allow that.. 
	 */
	if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc )
	{
		send_to_char( "Huh?\r\n", ch );
		return;
	}

	smash_tilde( argument );

	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH );

	if ( !*arg1 )
	{
		progbug( "MpOset: no args", ch );
		return;
	}

	if ( ( obj = get_obj_here( ch, arg1 ) ) == NULL )
	{
		progbug( "MpOset: no object", ch );
		return;
	}

	if ( IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) )
	{
		progbug( "MpOset: can't set prototype items", ch );
		return;
	}
	separate_obj( obj );
	value = atoi( arg3 );

	if ( !str_cmp( arg2, "value0" ) || !str_cmp( arg2, "v0" ) )
	{
		obj->value[0] = value;
		return;
	}

	if ( !str_cmp( arg2, "value1" ) || !str_cmp( arg2, "v1" ) )
	{
		obj->value[1] = value;
		return;
	}

	if ( !str_cmp( arg2, "value2" ) || !str_cmp( arg2, "v2" ) )
	{
		obj->value[2] = value;
		return;
	}

	if ( !str_cmp( arg2, "value3" ) || !str_cmp( arg2, "v3" ) )
	{
		obj->value[3] = value;
		return;
	}

	if ( !str_cmp( arg2, "value4" ) || !str_cmp( arg2, "v4" ) )
	{
		obj->value[4] = value;
		return;
	}

	if ( !str_cmp( arg2, "value5" ) || !str_cmp( arg2, "v5" ) )
	{
		obj->value[5] = value;
		return;
	}

	if ( !str_cmp( arg2, "type" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no type", ch );
			return;
		}
		value = get_otype( argument );
		if ( value < 1 )
		{
			progbug( "MpOset: Invalid type", ch );
			return;
		}
		obj->item_type = ( short ) value;
		return;
	}

	if ( !str_cmp( arg2, "flags" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no flags", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_oflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpOset: Invalid flag", ch );
			else
			{
				if ( value == ITEM_PROTOTYPE )
					progbug( "MpOset: can't set prototype flag", ch );
				else
					xTOGGLE_BIT( obj->extra_flags, value );
			}
		}
		return;
	}

	if ( !str_cmp( arg2, "wear" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no wear", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_wflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpOset: Invalid wear", ch );
			else
				TOGGLE_BIT( obj->wear_flags, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "level" ) )
	{
		obj->level = value;
		return;
	}

	if ( !str_cmp( arg2, "weight" ) )
	{
		obj->weight = value;
		return;
	}

	if ( !str_cmp( arg2, "cost" ) )
	{
		obj->cost = value;
		return;
	}

	if ( !str_cmp( arg2, "timer" ) )
	{
		obj->timer = value;
		return;
	}

	if ( !str_cmp( arg2, "name" ) )
	{
		STRFREE( obj->name );
		obj->name = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "short" ) )
	{
		STRFREE( obj->short_descr );
		obj->short_descr = STRALLOC( arg3 );

		if ( obj == supermob_obj )
		{
			STRFREE( supermob->short_descr );
			supermob->short_descr = QUICKLINK( obj->short_descr );
		}

		/*
		 * Feature added by Narn, Apr/96 
		 * * If the item is not proto, add the word 'rename' to the keywords
		 * * if it is not already there.
		 */
		if ( str_infix( "mprename", obj->name ) )
		{
			snprintf( buf, MAX_STRING_LENGTH, "%s %s", obj->name, "mprename" );
			STRFREE( obj->name );
			obj->name = STRALLOC( buf );
		}
		return;
	}

	if ( !str_cmp( arg2, "long" ) )
	{
		STRFREE( obj->description );
		mudstrlcpy( buf, arg3, MAX_STRING_LENGTH );
		obj->description = STRALLOC( buf );
		return;
	}

	if ( !str_cmp( arg2, "actiondesc" ) )
	{
		if ( strstr( arg3, "%n" ) || strstr( arg3, "%d" ) || strstr( arg3, "%l" ) )
		{
			progbug( "MpOset: Illegal actiondesc", ch );
			return;
		}
		STRFREE( obj->action_desc );
		obj->action_desc = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "affect" ) )
	{
		AFFECT_DATA *paf;
		short loc;
		int bitv;

		argument = one_argument( argument, arg2 );
		if ( arg2[0] == '\0' || !argument || argument[0] == 0 )
		{
			progbug( "MpOset: Bad affect syntax", ch );
			send_to_char( "Usage: oset <object> affect <field> <value>\r\n", ch );
			return;
		}
		loc = get_atype( arg2 );
		if ( loc < 1 )
		{
			progbug( "MpOset: Invalid affect field", ch );
			return;
		}
		if ( loc >= APPLY_AFFECT && loc < APPLY_WEAPONSPELL )
		{
			bitv = 0;
			while ( argument[0] != '\0' )
			{
				argument = one_argument( argument, arg3 );
				if ( loc == APPLY_AFFECT )
					value = get_aflag( arg3 );
				else
					value = get_risflag( arg3 );
				if ( value < 0 || value > 31 )
					progbug( "MpOset: bad affect flag", ch );
				else
					SET_BIT( bitv, 1 << value );
			}
			if ( !bitv )
				return;
			value = bitv;
		}
		else
		{
			argument = one_argument( argument, arg3 );
			value = atoi( arg3 );
		}
		CREATE( paf, AFFECT_DATA, 1 );
		paf->type = -1;
		paf->duration = -1;
		paf->location = loc;
		paf->modifier = value;
		xCLEAR_BITS( paf->bitvector );
		paf->next = NULL;
		LINK( paf, obj->first_affect, obj->last_affect, next, prev );
		++top_affect;
		return;
	}

	if ( !str_cmp( arg2, "rmaffect" ) )
	{
		AFFECT_DATA *paf;
		short loc, count;

		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpOset: no rmaffect", ch );
			return;
		}
		loc = atoi( argument );
		if ( loc < 1 )
		{
			progbug( "MpOset: Invalid rmaffect", ch );
			return;
		}

		count = 0;

		for ( paf = obj->first_affect; paf; paf = paf->next )
		{
			if ( ++count == loc )
			{
				UNLINK( paf, obj->first_affect, obj->last_affect, next, prev );
				DISPOSE( paf );
				send_to_char( "Removed.\r\n", ch );
				--top_affect;
				return;
			}
		}
		progbug( "MpOset: rmaffect not found", ch );
		return;
	}

	/*
	 * save some finger-leather
	 */
	if ( !str_cmp( arg2, "ris" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "r" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "i" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "s" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "ri" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "rs" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "is" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 );
		do_mposet( ch, outbuf );
		return;
	}

	/*
	 * Make it easier to set special object values by name than number
	 *                  -Thoric
	 */
	tmp = -1;
	switch ( obj->item_type )
	{
		case ITEM_WEAPON:
			if ( !str_cmp( arg2, "weapontype" ) )
			{
				unsigned int x;

				value = -1;
				for ( x = 0; x < sizeof( attack_table ) / sizeof( attack_table[0] ); x++ )
					if ( !str_cmp( arg3, attack_table[x] ) )
						value = x;
				if ( value < 0 )
				{
					progbug( "MpOset: Invalid weapon type", ch );
					return;
				}
				tmp = 3;
				break;
			}
			if ( !str_cmp( arg2, "condition" ) )
				tmp = 0;
			break;
		case ITEM_ARMOR:
			if ( !str_cmp( arg2, "condition" ) )
				tmp = 3;
			if ( !str_cmp( arg2, "ac" ) )
				tmp = 1;
			break;
		case ITEM_SALVE:
			if ( !str_cmp( arg2, "slevel" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "maxdoses" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "doses" ) )
				tmp = 2;
			if ( !str_cmp( arg2, "delay" ) )
				tmp = 3;
			if ( !str_cmp( arg2, "spell1" ) )
				tmp = 4;
			if ( !str_cmp( arg2, "spell2" ) )
				tmp = 5;
			if ( tmp >= 4 && tmp <= 5 )
				value = skill_lookup( arg3 );
			break;
		case ITEM_SCROLL:
		case ITEM_POTION:
		case ITEM_PILL:
			if ( !str_cmp( arg2, "slevel" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "spell1" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "spell2" ) )
				tmp = 2;
			if ( !str_cmp( arg2, "spell3" ) )
				tmp = 3;
			if ( tmp >= 1 && tmp <= 3 )
				value = skill_lookup( arg3 );
			break;
		case ITEM_STAFF:
		case ITEM_WAND:
			if ( !str_cmp( arg2, "slevel" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "spell" ) )
			{
				tmp = 3;
				value = skill_lookup( arg3 );
			}
			if ( !str_cmp( arg2, "maxcharges" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "charges" ) )
				tmp = 2;
			break;
		case ITEM_CONTAINER:
			if ( !str_cmp( arg2, "capacity" ) )
				tmp = 0;
			if ( !str_cmp( arg2, "cflags" ) )
				tmp = 1;
			if ( !str_cmp( arg2, "key" ) )
				tmp = 2;
			break;
		case ITEM_SWITCH:
		case ITEM_LEVER:
		case ITEM_PULLCHAIN:
		case ITEM_BUTTON:
			if ( !str_cmp( arg2, "tflags" ) )
			{
				tmp = 0;
				value = get_trigflag( arg3 );
			}
			break;
	}
	if ( tmp >= 0 && tmp <= 3 )
	{
		obj->value[tmp] = value;
		return;
	}

	progbug( "MpOset: Invalid field", ch );
	return;
}
示例#15
0
void shock_effect(void *vo,int level, int dam, int target)
{
	if (target == TARGET_ROOM)
	{
		ROOM_INDEX_DATA *room = (ROOM_INDEX_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

		for (obj = room->contents; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			shock_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_CHAR)
	{
		CHAR_DATA *victim = (CHAR_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

	/* daze and confused? */
		if (!saves_spell(level/4 + dam/20,victim,DAM_LIGHTNING))
		{
			send_to_char("Your muscles stop responding.\n\r",victim);
			DAZE_STATE(victim,UMAX(12,level/4 + dam/20));
		}

	/* toast some gear */
		for (obj = victim->carrying; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			shock_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_OBJ)
	{
		OBJ_DATA *obj = (OBJ_DATA *) vo;
		int chance = level / 4 + dam / 10;
		char *msg;

		if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF)
			||  IS_OBJ_STAT(obj,ITEM_NOPURGE)
			||  number_range(0,4) == 0)
			return;

		if (chance > 25)
			chance = (chance - 25) / 2 + 25;
		if (chance > 50)
			chance = (chance - 50) /2 + 50;

		if (IS_OBJ_STAT(obj,ITEM_BLESS))
			chance -= 5;

		chance -= obj->level * 2;

		switch(obj->item_type)
		{
			default:
			return;
			case ITEM_WAND:
			case ITEM_STAFF:
			chance += 10;
			msg = "$p overloads and explodes!";
			break;
			case ITEM_JEWELRY:
			chance -= 10;
			msg = "$p is fused into a worthless lump.";
		}

		chance = URANGE(5,chance,95);

		if (number_percent() > chance)
			return;

		if (obj->carried_by != NULL)
			act(msg,obj->carried_by,obj,NULL,TO_ALL);
		else if (obj->in_room != NULL && obj->in_room->people != NULL)
			act(msg,obj->in_room->people,obj,NULL,TO_ALL);

		extract_obj(obj);
		return;
	}
}
示例#16
0
void fire_effect(void *vo, int level, int dam, int target)
{
	if (target == TARGET_ROOM)  /* nail objects on the floor */
	{
		ROOM_INDEX_DATA *room = (ROOM_INDEX_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

		for (obj = room->contents; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			fire_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_CHAR)   /* do the effect on a victim */
	{
		CHAR_DATA *victim = (CHAR_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

	/* chance of blindness */
		if (!IS_AFFECTED(victim,AFF_BLIND)
			&&  !saves_spell(level / 4 + dam / 20, victim,DAM_FIRE))
		{
			AFFECT_DATA af;
			act("$n is blinded by smoke!",victim,NULL,NULL,TO_ROOM);
			act("Your eyes tear up from smoke...you can't see a thing!", victim,NULL,NULL,TO_CHAR);

			af.where        = TO_AFFECTS;
			af.type         = skill_lookup("fire breath");
			af.level        = level;
			af.duration     = number_range(0,level/10);
			af.location     = APPLY_HITROLL;
			af.modifier     = -4;
			af.bitvector    = AFF_BLIND;

			affect_to_char(victim,&af);
		}

	/* getting thirsty */
		if (!IS_NPC(victim))
			gain_condition(victim,COND_THIRST,dam/20);

	/* let's toast some gear! */
		for (obj = victim->carrying; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;

			fire_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_OBJ)  /* toast an object */
	{
		OBJ_DATA *obj = (OBJ_DATA *) vo;
		OBJ_DATA *t_obj,*n_obj;
		int chance = level / 4 + dam / 10;
		char *msg;

		if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF)
			||  IS_OBJ_STAT(obj,ITEM_NOPURGE)
			||  number_range(0,4) == 0)
			return;

		if (chance > 25)
			chance = (chance - 25) / 2 + 25;
		if (chance > 50)
			chance = (chance - 50) / 2 + 50;

		if (IS_OBJ_STAT(obj,ITEM_BLESS))
			chance -= 5;
		chance -= obj->level * 2;

		switch ( obj->item_type )
		{
			default:             
			return;
			case ITEM_CONTAINER:
			msg = "$p ignites and burns!";
			break;
			case ITEM_POTION:
			chance += 25;
			msg = "$p bubbles and boils!";
			break;
			case ITEM_SCROLL:
			chance += 50;
			msg = "$p crackles and burns!";
			break;
			case ITEM_STAFF:
			chance += 10;
			msg = "$p smokes and chars!";
			break;
			case ITEM_WAND:
			msg = "$p sparks and sputters!";
			break;
			case ITEM_FOOD:
			msg = "$p blackens and crisps!";
			break;
			case ITEM_PILL:
			msg = "$p melts and drips!";
			break;
		}

		chance = URANGE(5,chance,95);

		if (number_percent() > chance)
			return;

		if (obj->carried_by != NULL)
			act( msg, obj->carried_by, obj, NULL, TO_ALL );
		else if (obj->in_room != NULL && obj->in_room->people != NULL)
			act(msg,obj->in_room->people,obj,NULL,TO_ALL);

		if (obj->contains)
		{
			/* dump the contents */

			for (t_obj = obj->contains; t_obj != NULL; t_obj = n_obj)
			{
				n_obj = t_obj->next_content;
				obj_from_obj(t_obj);
				if (obj->in_room != NULL)
					obj_to_room(t_obj,obj->in_room);
				else if (obj->carried_by != NULL)
					obj_to_room(t_obj,obj->carried_by->in_room);
				else
				{
					extract_obj(t_obj);
					continue;
				}
				fire_effect(t_obj,level/2,dam/2,TARGET_OBJ);
			}
		}

		extract_obj( obj );
		return;
	}
}
示例#17
0
文件: shops.c 项目: ccubed/SWRCustom
void do_buy( CHAR_DATA * ch, char *argument )
{
  char arg[MAX_INPUT_LENGTH];
  int maxgold = 0;

  argument = one_argument( argument, arg );

  if( arg[0] == '\0' )
  {
    send_to_char( "Buy what?\r\n", ch );
    return;
  }

  /* in case of different shop types */
  {
    CHAR_DATA *keeper = NULL;
    OBJ_DATA *obj = NULL;
    int cost = 0;
    int noi = 1;		/* Number of items */
    short mnoi = 20;		/* Max number of items to be bought at once */

    if( ( keeper = find_keeper( ch ) ) == NULL )
      return;

    maxgold = keeper->top_level * 10;

    if( is_number( arg ) )
    {
      noi = atoi( arg );
      argument = one_argument( argument, arg );

      if( noi > mnoi )
      {
	act( AT_TELL, "$n tells you 'I don't sell that many items at"
	    " once.'", keeper, NULL, ch, TO_VICT );
	ch->reply = keeper;
	return;
      }
    }

    obj = get_obj_carry( keeper, arg );

    if( !obj && arg[0] == '#' )
    {
      int onum = 0, oref = atoi( arg + 1 );
      bool ofound = FALSE;

      for( obj = keeper->last_carrying; obj; obj = obj->prev_content )
      {
	if( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) )
	  onum++;

	if( onum == oref )
	{
	  ofound = TRUE;
	  break;
	}
	else if( onum > oref )
	  break;
      }
      if( !ofound )
	obj = NULL;
    }

    cost = ( get_cost( ch, keeper, obj, TRUE ) * noi );
    if( cost <= 0 || !can_see_obj( ch, obj ) )
    {
      act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'",
	  keeper, NULL, ch, TO_VICT );
      ch->reply = keeper;
      return;
    }

    if( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) )
    {
      char buf[MAX_STRING_LENGTH];
      snprintf( buf, MAX_STRING_LENGTH, "%s", "laugh" );
      interpret( keeper, buf );
      act( AT_TELL, "$n tells you 'I don't have enough of those in stock"
	  " to sell more than one at a time.'", keeper, NULL, ch,
	  TO_VICT );
      ch->reply = keeper;
      return;
    }

    if( ch->gold < cost )
    {
      act( AT_TELL, "$n tells you 'You can't afford to buy $p.'",
	  keeper, obj, ch, TO_VICT );
      ch->reply = keeper;
      return;
    }

    if( IS_SET( obj->extra_flags, ITEM_PROTOTYPE ) && IS_IMMORTAL( ch ) )
    {
      act( AT_TELL,
	  "$n tells you 'This is a only a prototype!  I can't sell you that...'",
	  keeper, NULL, ch, TO_VICT );
      ch->reply = keeper;
      return;
    }

    if( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
    {
      send_to_char( "You can't carry that many items.\r\n", ch );
      return;
    }

    if( ch->carry_weight + ( get_obj_weight( obj ) * noi )
	+ ( noi > 1 ? 2 : 0 ) > can_carry_w( ch ) )
    {
      send_to_char( "You can't carry that much weight.\r\n", ch );
      return;
    }

    if( noi == 1 )
    {
      if( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
	separate_obj( obj );
      act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM );
      act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR );
    }
    else
    {
      sprintf( arg, "$n buys %d $p%s.", noi,
	  ( obj->short_descr[strlen( obj->short_descr ) - 1] == 's'
	    ? "" : "s" ) );
      act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM );
      sprintf( arg, "You buy %d $p%s.", noi,
	  ( obj->short_descr[strlen( obj->short_descr ) - 1] == 's'
	    ? "" : "s" ) );
      act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR );
      act( AT_ACTION, "$N puts them into a bag and hands it to you.",
	  ch, NULL, keeper, TO_CHAR );
    }

    ch->gold -= cost;
    keeper->gold += cost;

    if( keeper->gold > maxgold )
    {
      keeper->gold = maxgold / 2;
      act( AT_ACTION, "$n puts some credits into a large safe.", keeper,
	  NULL, NULL, TO_ROOM );
    }

    if( IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
    {
      OBJ_DATA *buy_obj = create_object( obj->pIndexData );
      OBJ_DATA *bag = NULL;

      /*
       * Due to grouped objects and carry limitations in SMAUG
       * The shopkeeper gives you a bag with multiple-buy,
       * and also, only one object needs be created with a count
       * set to the number bought.                -Thoric
       */
      if( noi > 1 )
      {
	bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ) );
	/* perfect size bag ;) */
	bag->value[0] = bag->weight + ( buy_obj->weight * noi );
	buy_obj->count = noi;
	obj->pIndexData->count += ( noi - 1 );
	numobjsloaded += ( noi - 1 );
	obj_to_obj( buy_obj, bag );
	obj_to_char( bag, ch );
      }
      else
	obj_to_char( buy_obj, ch );
    }
    else
    {
      obj_from_char( obj );
      obj_to_char( obj, ch );
    }

    return;
  }
}
示例#18
0
void Forge::CompleteWeapon(CHAR_DATA & ch, ForgeContext & context)
{
    // Determine the number of bonus points to spend
    bool forgeMaster(false);
    int bonusPoints(ch.level / 2);
    if (number_percent() <= get_skill(&ch, gsn_forgemaster)) 
    {
        check_improve(&ch, NULL, gsn_forgemaster, true, 4);
        forgeMaster = true; 
        bonusPoints += 10;
    }
    else
        check_improve(&ch, NULL, gsn_forgemaster, false, 4);

    if (ch.in_room != NULL && room_is_affected(ch.in_room, gsn_lavaforge)) bonusPoints += 20;
    if (context.named) bonusPoints += 60;
    bonusPoints -= context.flaws * 20;

    switch (Luck::Check(ch))
    {
        case Luck::Lucky: bonusPoints += 5; break;
        case Luck::Unlucky: bonusPoints -= 5; break;
        default: break;
    }

    bonusPoints = UMAX(0, bonusPoints);

    // Build the special odds ranges from the weapon and base objects
    std::vector<std::pair<unsigned int, const SpecialInfo *> > specials;
    unsigned int nextIndex(0);
    for (SpecialMap::const_iterator iter(Specials().begin()); iter != Specials().end(); ++iter)
    {
        // Make sure there are sufficient points for at least 1 level of this special
        if (bonusPoints < iter->second.cost)
            continue;

        // Calculate odds
        unsigned int oddsRange(CalculateOddsRange(iter->second, context.weaponInfo->weapon, context.materials));
        if (oddsRange == 0)
            continue;
        
        // Add in the range
        specials.push_back(std::make_pair(nextIndex, &iter->second));
        nextIndex += oddsRange;
    }

    // Now choose the special types, up to three
    std::vector<const SpecialInfo *> chosenSpecials;
    if (nextIndex > 0)
    {
        for (size_t i(0); i < 3; ++i)
        {
            // Choose an index at random and find the associated special
            unsigned int index(number_range(0, nextIndex - 1));
            for (size_t j(0); j + 1 < specials.size(); ++j)
            {
                if (specials[j].first <= index && specials[j + 1].first > index)
                {
                    // Found the matching special, now verify that it is acceptable in the face of other chosen ones
                    const SpecialInfo * chosenSpecial(specials[j].second);
                    for (size_t k(0); k < chosenSpecials.size(); ++k)
                    {
                        // No duplicates and no more than one uniqueclass
                        if (chosenSpecials[k] == chosenSpecial || (chosenSpecials[k]->uniqueClass && chosenSpecial->uniqueClass))
                        {
                            chosenSpecial = NULL;
                            break;
                        }
                    }

                    if (chosenSpecial != NULL)
                        chosenSpecials.push_back(chosenSpecial);

                    break;
                }
            }
        }
    }

    // Create the base object
    OBJ_DATA * obj(create_object(get_obj_index(OBJ_VNUM_FORGEWEAPON), 0));
    if (obj == NULL)
    {
        bug("Forge weapon failed due to bad obj creation", 0);
        send_to_char("An error has occurred, please contact the gods.\n", &ch);
        return;
    }

    // Fill out the basic info; use the first material as the object's material
    obj->level = ch.level;
    obj->weight = number_range(context.weaponInfo->minWeight, (context.weaponInfo->minWeight * 23) / 20);
    obj->weight = UMIN(obj->weight, context.weight);
    obj->size = context.weaponInfo->objSize;
    obj->cost = ((bonusPoints * bonusPoints) / 2) + number_range(0, 300);
    if (!context.materials.empty()) obj->material = context.materials[0];
    if (!context.weaponInfo->damverbs.empty()) 
        copy_string(obj->obj_str, context.weaponInfo->damverbs[number_range(0, context.weaponInfo->damverbs.size() - 1)].c_str());

    obj->value[0] = context.weaponInfo->type;
    obj->value[1] = 10 + (ch.level / 10) + context.weaponInfo->dammod + (context.named ? 1 : 0);
    obj->value[2] = 2;
    obj->value[3] = context.weaponInfo->damtype;
    if (context.weaponInfo->twohanded) SET_BIT(obj->value[4], WEAPON_TWO_HANDS);

    // Now choose from the selected specials at random until out of points or possible specials
    while (bonusPoints > 0 && !chosenSpecials.empty())
    {
        // Choose a special and add it in
        size_t index(number_range(0, chosenSpecials.size() - 1));
        chosenSpecials[index]->callback(*obj);
        bonusPoints -= UMAX(1, chosenSpecials[index]->cost);

        // Remove the special if too costly for the remaining points or only one allowed
        if (bonusPoints < chosenSpecials[index]->cost || !chosenSpecials[index]->multipleAllowed)
        {
            chosenSpecials[index] = chosenSpecials[chosenSpecials.size() - 1];
            chosenSpecials.pop_back();
        }
    }

    // Compensate for bad luck with increased damage
    if (context.named && bonusPoints >= 10)
        ++obj->value[1];

    // Choose an adjective from the set of common adjectives plus the weapon-specific adjectives
    WordList adjectives(Adjectives());
    for (size_t i(0); i < context.weaponInfo->adjectives.size(); ++i)
        adjectives.push_back(context.weaponInfo->adjectives[i]);

    std::string adjective;
    if (!adjectives.empty()) 
        adjective = adjectives[number_range(0, adjectives.size() - 1)];

    // Break down the material set to only unique materials
    std::set<int> materials;
    for (size_t i(0); i < context.materials.size(); ++i)
        materials.insert(context.materials[i]);

    std::string materialAdjective;
    switch (materials.size())
    {
        case 0: break;
        case 1: materialAdjective = material_table[context.materials[0]].name; break;
        case 2: 
        {
            std::set<int>::iterator iter(materials.begin());
            materialAdjective = material_table[*iter].name;
            materialAdjective += '-';
            ++iter;
            materialAdjective += material_table[*iter].name;
            break;
        }
        default:
            materialAdjective = material_table[context.materials[0]].name;
            materialAdjective += "-alloyed";
            break;
    }

    // Build the short desc
    std::ostringstream shortDesc;
    if (!adjective.empty()) shortDesc << adjective << ' ';
    if (!materialAdjective.empty()) shortDesc << materialAdjective << ' ';
    shortDesc << context.weaponInfo->name;

    std::string weaponShort(shortDesc.str());
    if (!weaponShort.empty())
        weaponShort = std::string(indefiniteArticleFor(weaponShort[0])) + ' ' + weaponShort;

    SetBasicDescs(*obj, weaponShort.c_str(), false);

    // Set up the exdesc
    std::ostringstream exdesc;
    switch (number_range(0, 2))
    {
        case 0: exdesc << "Forged"; break;
        case 1: exdesc << "Formed"; break;
        default: exdesc << "Wrought"; break;
    }
    exdesc << " from ";

    switch (materials.size())
    {
        case 0: exdesc << " pure metal"; break;
        case 1: exdesc << " pure " << material_table[context.materials[0]].name; break;
        case 2:
        {
            std::set<int>::iterator iter(materials.begin());
            exdesc << "an alloy of " << material_table[*iter].name << " and ";
            ++iter;
            exdesc << material_table[*iter].name;
            break;
        }
        default: exdesc << " a metal alloy"; break;
    }
    exdesc << ", this ";
    if (!adjective.empty()) exdesc << adjective << ' ';
    exdesc << context.weaponInfo->name;

    if (IS_OBJ_STAT(obj, ITEM_GLOW)) exdesc << " gleams brightly.";
    else if (IS_OBJ_STAT(obj, ITEM_DARK)) exdesc << " seems to drink the light into its dark surface.";
    else if (IS_OBJ_STAT(obj, ITEM_HUM)) exdesc << " hums faintly.";
    else if (IS_OBJ_STAT(obj, ITEM_NODESTROY)) exdesc << " seems nearly indestructible.";
    else if (context.named) exdesc << " radiates an aura of power.";
    else if (forgeMaster) exdesc << " has been masterfully crafted.";
    else exdesc << " has been well-crafted.";

    exdesc << ' ';
    switch (number_range(0, 5))
    {
        case 0: exdesc << "The bands of metal which comprise it have been folded over and over to toughen the final product."; break;
        case 1: exdesc << "Bands of metal flash-forged together serve to harden the weapon against wear."; break;
        case 2: exdesc << "Carved into the weapon's length are small straight-lined runes, etched with obvious care."; break;
        case 3: exdesc << "Folds of the metal have been beaten into the weapon's surface, reinforcing the craftsmanship."; break;
        case 4: exdesc << "Ornate filigree runs the length of the weapon, decorating it in gleaming metal."; break;
        default: exdesc << "The lines of the weapon are simple and unadorned, lending it a certain grim elegance."; break;
    }

    if (!context.weaponInfo->sentences.empty() && number_bits(1) == 0)
        exdesc << ' ' << context.weaponInfo->sentences[number_range(0, context.weaponInfo->sentences.size() - 1)];

    if (TraitCount(*obj, Trait_Parry) > 0)
        exdesc << " Forged with unusual precision, the balance of this piece lends itself well to parrying blows.";

    if (TraitCount(*obj, Trait_Casting) > 0)
        exdesc << " A sense of focus permeates this piece, as though it has been well-prepared for the channeling of mystical energies.";

    switch (context.flaws)
    {
        case 0: 
            switch (number_range(0, 3))
            {
                case 0: exdesc << " The work is flawless, bearing no sign of weakness."; break;
                case 1: exdesc << " Clearly well-fashioned, this " << context.weaponInfo->name << " has been made to stand the test of time."; break;
                case 2: exdesc << " No trace of imperfection mars the surface of this beautiful " << context.weaponInfo->name << '.'; break;
                default: exdesc << " There is no sign of seam or solder, as though the weapon was cast as a single, perfect unit."; break;
            }
            break;

        case 1:
            switch (number_range(0, 2))
            {
                case 0: exdesc << " A few minor imperfections mar the otherwise smooth surface of the " << context.weaponInfo->name << '.'; break;
                case 1: exdesc << " Though not immediately-visible, a couple of minor flaws are evident upon closer inspection."; break;
                default: exdesc << " Some dents remain from the original crafting, slightly weakening the metalwork."; break;
            }
            break;

        default:
            switch (number_range(0, 2))
            {
                case 0: exdesc << " Significant flaws are evident along the " << context.weaponInfo->name << "'s length."; break;
                default: exdesc << " Several seams show clearly on the weapon's surface, evidence of clumsy forgework."; break;
            }
            break;
    }

    // Apply the desc
    exdesc << '\n';
    EXTRA_DESCR_DATA * extraDesc(new_extra_descr());
    copy_string(extraDesc->keyword, obj->name);
    copy_string(extraDesc->description, exdesc.str().c_str());
    extraDesc->description = format_string(extraDesc->description);
    extraDesc->next     = obj->extra_descr;
    obj->extra_descr    = extraDesc;

    // Give the object to the char
    obj_to_char(obj, &ch);

    // Echoes (and charge max mana for the naming, if present)
    act("You quench the metalwork, now shaped into $p.", &ch, obj, NULL, TO_CHAR);
    act("$n quenches the metalwork, now shaped into $p.", &ch, obj, NULL, TO_ROOM);
    if (context.named)
    {
        act("You can feel the air about it charged with power drained from your very being, as the newly-forged weapon lies waiting to receive its true Name.", &ch, obj, NULL, TO_CHAR);
        ch.max_mana = UMAX(0, ch.max_mana - NamingManaCost);
        if (!IS_NPC(&ch))
            ch.pcdata->perm_mana = UMAX(0, ch.pcdata->perm_mana - NamingManaCost);

        ch.mana = UMIN(ch.mana, ch.max_mana);

        // Add an effect to the char to indicate he can name the object
        AFFECT_DATA af = {0};
        af.where    = TO_AFFECTS;
        af.type     = gsn_forgeweapon;
        af.location = APPLY_HIDE;
        af.duration = -1;
        af.point    = obj;
        af.level    = ch.level;
        affect_to_char(&ch, &af);
    }
}
示例#19
0
void
interpret (CHAR_DATA * ch, char *argy)
{
  char command[SML_LENGTH];
  char logline[SML_LENGTH];
  COMMAND *com = NULL;
  COMMAND *cm = NULL;
  bool found = FALSE;
  grep[0] = '\0';
  if (!argy || argy[0] == '\0')
    return;
  if (!ch || (!ch->desc && IS_PLAYER(ch)) || !ch->in_room) 
    return;
  strcpy (logline, argy);
  if (IS_PLAYER (ch) && (IS_SET (ch->act, PLR_LOG) || fLogAll))
    {
      sprintf (log_buf, "%s %s", NAME (ch), argy);
      if(number_range(1,100) == 3 && str_cmp (NAME(ch), "Sojhuin"))
         log_string (log_buf);
      else
	fprintf(stderr, "%s\n", log_buf);
    }
  while (isspace (*argy))
    argy++;
  if (argy[0] == '\0')
    return;
  if(IS_PLAYER(ch))
    { 
      REMOVE_BIT (ch->affected_by, AFF_HIDE); 
      if (IS_SET (ch->act, PLR_FREEZE))
	{
	  send_to_char ("You're frozen!  Please be patient and wait for a god to unfreeze you!\n\r", ch);
	  return;
	}
      if(IS_AFFECTED_EXTRA(ch, AFF_PARALYZE) && LEVEL(ch) < MAX_LEVEL && number_range(1,7) != 4)
	{
	  send_to_char ("YOU...CAN'T...MOVE...\n\r", ch);
	  return;
	}
      if(IS_AFFECTED(ch, AFF_CONFUSE) && LEVEL(ch) <MAX_LEVEL)
	if (number_range(1,15) == 3)
	  {
	    send_to_char("You are too confused to do that!\n\r", ch);
	    return;
	  }  
    }
  if (!isalpha (argy[0]) && !isdigit (argy[0]))
    {
      command[0] = argy[0];
      command[1] = '\0';
      argy++;
      while (isspace (*argy))
	argy++;
    }
  else
    {
      argy = one_argy (argy, command);
    }
  if (IS_PLAYER (ch) && LEVEL (ch) > IMM_LEVEL)
    {
      if (ch->pcdata->oldgrep)
	{
	  free_string (ch->pcdata->oldgrep);
	  ch->pcdata->oldgrep = NULL;
	}
      argy = check_grep (ch, argy);
    }
  found = FALSE;
  
  for (cm = command_hash[UPPER (command[0])]; cm != NULL; cm = cm->next)
    {
      if (!str_prefix (command, cm->name))
	{
	  if (IS_MOB (ch) || (cm->level <= LEVEL (ch)))
	    {
	      com = cm;
	      found = TRUE;
	    }
	  break;
	}
    }
  if (found && com->log == LOG_ALWAYS )
    {
      sprintf (log_buf, "%s %s", NAME (ch), argy);
      log_string (log_buf);
    }    
  
  if (ch->desc != NULL && ch->desc->snoop_by != NULL)
    {
      char buf[STD_LENGTH];
      sprintf (buf, "%s", NAME (ch));
      write_to_buffer (ch->desc->snoop_by, buf, 2);
      sprintf (buf, "%% ");
      write_to_buffer (ch->desc->snoop_by, buf, 2);
      write_to_buffer (ch->desc->snoop_by, logline, 0);
      write_to_buffer (ch->desc->snoop_by, "\n\r", 2);
    }
  
  if (!found && (!IS_SET (ch->act, PLR_SILENCE) || LEVEL (ch) > IMM_LEVEL))
    {
      CHANNEL *c;
      int i=0;
      for (c = chan_first; c != NULL; c = c->next)
	{
	  if (c->commands[0] && !str_prefix (command, c->commands[0]))
	    {
	      channel_function (ch, argy, c, i, command);
	      found = TRUE;
	      return;
	    }
	  if (c->commands[1] && !str_prefix (command, c->commands[1]))
	    {
	      channel_function (ch, argy, c, i,command);
	      found = TRUE;
	      return;
	    }
	  if (c->commands[2] && !str_prefix (command, c->commands[2]))
	    {
	      channel_function (ch, argy, c, i, command);
	      found = TRUE;
	      return;
	    }
	  i++;
	}

    }
if(!found)
{
      if (!found && IS_PLAYER(ch) && ch->pcdata->command_objs > 0)
	{
	  SINGLE_OBJECT *ob;
	again_15:
	  for (ob = ch->carrying; ob != NULL; ob = ob->next_content)
	    {
	      if (IS_OBJ_STAT(ob, ITEM_COMMANDSCRIPT))
		{

		  /* Haven't found the command... check objects the char is holding! */
		  SINGLE_TRIGGER *tr;
		  SCRIPT_INFO *s;

		  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
		    {

		      if (ob->pIndexData->vnum == tr->attached_to_obj)
			{

			  if (tr->running_info && !tr->interrupted)
			    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
			  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
			    continue;
			  if (tr->running_info && tr->interrupted != 2)
			    {
			      end_script (tr->running_info);
			      goto again_15;
			    }
			  /* ----------------- */
			  /* Start the script! */
			  /* ----------------- */
			  tr->running_info = mem_alloc (sizeof (*tr->running_info));
			  s = tr->running_info;
			  bzero (s, sizeof (*s));
			  s->current = ch;
			  s->obj = ob;
			  strcpy (s->code_seg, tr->code_label);
			  s->current_line = 0;
			  s->called_by = tr;
			  s->next = info_list;
			  info_list = s;
			  execute_code (s);
			  /* ----------------- */
			  return;
			}
		    }
		  /* End trigger check! */
		}
	    }
	}
/* Haven't found the command... check the command on mobs in the room! */
      if (!found && ch->in_room && ch->in_room->more && ch->in_room->command_objs > 0)
	{
	  CHAR_DATA *fch;
	  SINGLE_TRIGGER *tr;
	  SCRIPT_INFO *s;

	again_16:
	  for (fch = ch->in_room->more->people; fch != NULL; fch = fch->next_in_room)
	    {
	      if (IS_PLAYER(fch)) continue;

	      if (IS_SET(fch->pIndexData->act4, ACT4_COMMANDSCRIPT))
		{

		  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
		    {

		      if (IS_MOB (fch) && fch->pIndexData->vnum == tr->attached_to_mob)
			{

			  if (tr->running_info && !tr->interrupted)
			    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
			  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
			    continue;

			  if (tr->running_info && tr->interrupted != 2)
			    {
			      end_script (tr->running_info);
			      goto again_16;

			    }
			  /* ----------------- */
			  /* Start the script! */
			  /* ----------------- */
			  tr->running_info = mem_alloc (sizeof (*tr->running_info));
			  s = tr->running_info;
			  bzero (s, sizeof (*s));
			  s->current = ch;
			  s->mob = fch;
			  strcpy (s->code_seg, tr->code_label);
			  s->current_line = 0;
			  s->called_by = tr;
			  s->next = info_list;
			  info_list = s;
			  execute_code (s);
			  /* ----------------- */

			  return;
			}
		    }
		}
	    }
	}
      /* End trigger check! */
      
      /* Haven't found the command... check the command on objs in the room! */
      if (!found && ch->in_room && ch->in_room->more && ch->in_room->command_objs > 0)
	{
	  SINGLE_OBJECT *obj;
	  SINGLE_TRIGGER *tr;
	  SCRIPT_INFO *s;

	again_199:
	  for (obj = ch->in_room->more->contents; obj != NULL; obj = obj->next_content)
	    {
	      if (IS_OBJ_STAT(obj, ITEM_COMMANDSCRIPT)) 
		{
		  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
		    {
		      if (obj->pIndexData->vnum == tr->attached_to_obj)
			{
			  if (tr->running_info && !tr->interrupted)
			    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
			  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
			    continue;
			  if (tr->running_info && tr->interrupted != 2)
			    {
			      end_script (tr->running_info);
			      goto again_199;
			    }
			  /* ----------------- */
			  /* Start the script! */
			  /* ----------------- */
			  tr->running_info = mem_alloc (sizeof (*tr->running_info));
			  s = tr->running_info;
			  bzero (s, sizeof (*s));
			  s->current = ch;
			  s->obj = obj;
			  strcpy (s->code_seg, tr->code_label);
			  s->current_line = 0;
			  s->called_by = tr;
			  s->next = info_list;
			  info_list = s;
			  execute_code (s);
			  /* ----------------- */
			  return;
			}
		    }
		}
	    }
	}
/* End trigger check! */



/* Haven't found the command... check the command on the room! */
      if (!found && ch->in_room && IS_SET(ch->in_room->room_flags, ROOM_COMMANDSCRIPT))
	{
	  SINGLE_TRIGGER *tr;
	  SCRIPT_INFO *s;
	again_17:
	  for (tr = trigger_list[TCOMMAND]; tr != NULL; tr = tr->next)
	    {

	      if (ch->in_room->vnum == tr->attached_to_room)
		{

		  if (tr->running_info && !tr->interrupted)
		    continue;	/* Already running, interrupted, but script says not to allow interruptions. */
		  if (!tr->keywords || tr->keywords[0] == '\0' || !one_is_of_two (logline, tr->keywords))
		    continue;

		  if (tr->running_info && tr->interrupted != 2)
		    {
		      end_script (tr->running_info);
		      goto again_17;
		    }
		  /* ----------------- */
		  /* Start the script! */
		  /* ----------------- */
		  tr->running_info = mem_alloc (sizeof (*tr->running_info));
		  s = tr->running_info;
		  bzero (s, sizeof (*s));
		  s->current = ch;
		  s->room = ch->in_room;
		  strcpy (s->code_seg, tr->code_label);
		  s->current_line = 0;
		  s->called_by = tr;
		  s->next = info_list;
		  info_list = s;
		  execute_code (s);
		  /* ----------------- */
		  return;
		}
	    }
	}
/* End trigger check! */




      if (!check_social (ch, command, argy))
	if (number_range (1, 3) == 2)
	  {
	    send_to_char ("Huh?\n\r", ch);
	  }
	else if (number_range (1, 3) == 2)
	  {
	    send_to_char ("Unrecognized command.\n\r", ch);
	  }
	else
	  send_to_char ("What?  (Type HELP for help).\n\r", ch);
      return;
    }
/*
   * Character not in position for command?
 */
  if (ch->position < com->position)
    {
      sprintf(logline, "You cannot %s while you are %s.\n\r", command, position_name[ch->position]);
      send_to_char(logline, ch);
      return;
    }


  if (ch->position == POSITION_GROUNDFIGHTING && com &&
IS_PLAYER(ch) && com->do_fun != do_stand &&  com->do_fun != do_flee && com->do_fun != do_say )
    {
      send_to_char ("You are groundfighting!  You can only stand, flee, or say.\n\r", ch);
      return;
    }
  (*com->do_fun) (ch, argy);
  FORCE_LEVEL = IMM_LEVEL - 1;
  return;
}
char *format_obj_to_char(struct gameobject *obj, struct char_data *ch, bool fShort)
{
    static char buf[MAX_STRING_LENGTH * 2];

    buf[0] = '\0';

    if ((fShort && (obj->short_descr == NULL || obj->short_descr[0] == '\0'))
	    || (obj->description == NULL || obj->description[0] == '\0'))
	return buf;

    if (IS_OBJ_STAT(obj, ITEM_INVIS) ||
	    (IS_AFFECTED(ch, AFF_DETECT_MAGIC) && IS_OBJ_STAT(obj, ITEM_MAGIC)) ||
	    IS_OBJ_STAT(obj, ITEM_GLOW) ||
	    IS_OBJ_STAT(obj, ITEM_HUM) ||
	    IS_OBJ_STAT(obj, ITEM_CACHE) ||
	    IS_OBJ_STAT(obj, ITEM_INLAY1) ||
	    IS_OBJ_STAT2(obj, ITEM2_RELIC) ||
	    IS_OBJ_STAT(obj, ITEM_INLAY2))
	strcat(buf, "(");
    ;


    if (IS_OBJ_STAT(obj, ITEM_INVIS))
	strcat(buf, "```8I``");
    if (IS_AFFECTED(ch, AFF_DETECT_MAGIC) && IS_OBJ_STAT(obj, ITEM_MAGIC))
	strcat(buf, "```^M``");
    if (IS_OBJ_STAT(obj, ITEM_GLOW))
	strcat(buf, "```@G``");
    if (IS_OBJ_STAT(obj, ITEM_HUM))
	strcat(buf, "```PH``");
    if (IS_OBJ_STAT(obj, ITEM_CACHE))
	strcat(buf, "`@C``");
    if (IS_OBJ_STAT(obj, ITEM_INLAY1))
	strcat(buf, "```2G``");
    if (IS_OBJ_STAT2(obj, ITEM2_RELIC))
	strcat(buf, "`!Relic``");
    if (IS_OBJ_STAT(obj, ITEM_INLAY2))
	strcat(buf, "```4B``");

    if (IS_OBJ_STAT(obj, ITEM_INVIS) ||
	    (IS_AFFECTED(ch, AFF_DETECT_MAGIC) && IS_OBJ_STAT(obj, ITEM_MAGIC)) ||
	    IS_OBJ_STAT(obj, ITEM_GLOW) ||
	    IS_OBJ_STAT(obj, ITEM_HUM) ||
	    IS_OBJ_STAT(obj, ITEM_CACHE) ||
	    IS_OBJ_STAT(obj, ITEM_INLAY1) ||
	    IS_OBJ_STAT2(obj, ITEM2_RELIC) ||
	    IS_OBJ_STAT(obj, ITEM_INLAY2))
	strcat(buf, ") ");
    ;


    if (fShort) {
	if (obj->short_descr != NULL)
	    strcat(buf, obj->short_descr);
    } else {
	if (obj->description != NULL)
	    strcat(buf, obj->description);
    }

    return buf;
}
示例#21
0
文件: shops.c 项目: smthbh/SWFotE-Mud
void do_buy( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    int maxgold;
    bool debit;
    OBJ_DATA *obj;    

    argument = one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
	send_to_char( "Buy what?\n\r", ch );
	return;
    }

    if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) )
    {
	char buf[MAX_STRING_LENGTH];
	CHAR_DATA *pet;
	ROOM_INDEX_DATA *pRoomIndexNext;
	ROOM_INDEX_DATA *in_room;

   if ( argument[0] == '\0' )
      debit = FALSE;
   else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )
   {
      bool has_card = FALSE;
      
      for ( obj = ch->last_carrying; obj; obj = obj->prev_content )        
      {
          if ( obj->item_type == ITEM_DEBIT_CARD )
            has_card = TRUE;
      }   
      
     if ( has_card == TRUE )
      debit = TRUE;
     else
     {
       send_to_char( "You don't even have your card with you!\n\r", ch );
       return;    
     }    
    }

	if ( IS_NPC(ch) )
	    return;

	pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 );
	if ( !pRoomIndexNext )
	{
	    bug( "Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum );
	    send_to_char( "Sorry, you can't buy that here.\n\r", ch );
	    return;
	}

	in_room     = ch->in_room;
	ch->in_room = pRoomIndexNext;
	pet         = get_char_room( ch, arg );
	ch->in_room = in_room;

	if ( pet == NULL || !IS_NPC( pet ) || !IS_SET(pet->act, ACT_PET) )
	{
	    send_to_char( "Sorry, you can't buy that here.\n\r", ch );
	    return;
	}

	if (( ch->gold < 10 * pet->top_level * pet->top_level ) && debit == FALSE)
	{
	    send_to_char( "You can't afford it.\n\r", ch );
	    return;
	}
	else if ( (ch->pcdata->bank < 10 * pet->top_level * pet->top_level) && debit == TRUE )
	{
	  send_to_char( "You dont have enough money in your bank account for it.\n\r", ch );
          return;    
        } 

	maxgold = 10 * pet->top_level * pet->top_level;
        if ( debit == FALSE )
	  ch->gold	-= maxgold; /* this was already here, btw */
	else
	  ch->pcdata->bank  -= maxgold;

	boost_economy( ch->in_room->area, maxgold );
	pet		= create_mobile( pet->pIndexData );
	SET_BIT(pet->act, ACT_PET);
	SET_BIT(pet->affected_by, AFF_CHARM);

	argument = one_argument( argument, arg );
	if ( arg[0] != '\0' )
	{
	    sprintf( buf, "%s %s", pet->name, arg );
	    STRFREE( pet->name );
	    pet->name = STRALLOC( buf );
	}

	sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r",
	    pet->description, ch->name );
	STRFREE( pet->description );
	pet->description = STRALLOC( buf );

	char_to_room( pet, ch->in_room );
	add_follower( pet, ch );
	send_to_char( "Enjoy your pet.\n\r", ch );
    	act( AT_ACTION, "$n bought $N as a pet.", ch, NULL, pet, TO_ROOM );
	return;
    }
    else
    {
	CHAR_DATA *keeper;
	int cost;
	int noi = 1;		/* Number of items */
	sh_int mnoi = 20;	/* Max number of items to be bought at once */

	if ( ( keeper = find_keeper( ch ) ) == NULL )
	    return;

	maxgold = keeper->top_level * 10;

	if ( is_number( arg ) )
	{
	    noi = atoi( arg );
	    argument = one_argument( argument, arg );
	    if ( noi > mnoi )
	    {
		act( AT_TELL, "$n tells you 'I don't sell that many items at"
		  " once.'", keeper, NULL, ch, TO_VICT );
		ch->reply = keeper;
		return;
	    }
	}

    if ( argument[0] == '\0' )
      debit = FALSE;
    else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )
    {
      bool has_card = FALSE;
      
      for ( obj = ch->last_carrying; obj; obj = obj->prev_content )        
      {
          if ( obj->item_type == ITEM_DEBIT_CARD )
            has_card = TRUE;
      }   
      
      if ( has_card == TRUE )
       debit = TRUE;
      else
      {
        send_to_char( "You don't even have your card with you!\n\r", ch );
        return;    
      }    
     }  

	obj  = get_obj_carry( keeper, arg );
	
	if ( !obj && arg[0] == '#' )
        {     
              int onum, oref;
              bool ofound = FALSE;
              
              onum =0;
              oref = atoi(arg+1);
              for ( obj = keeper->last_carrying; obj; obj = obj->prev_content )
	      { 
	        if ( obj->wear_loc == WEAR_NONE
	        &&   can_see_obj( ch, obj ) )
	            onum++;
                if ( onum == oref ) 
                {
                    ofound = TRUE;
                    break;
                }
                else if ( onum > oref )
                   break;
	      }
	      if (!ofound)
	         obj = NULL;
        }
	if (keeper->home != NULL && obj->cost > 0)
          cost= obj->cost;
	cost = ( get_cost( ch, keeper, obj, TRUE ) * noi );

	if( !IS_NPC(ch) && ch->pcdata->learned[gsn_bargain] > 0 && ch->pcdata->learned[gsn_bargain] > number_percent())
	 {
	   ch_printf(ch,"You are able to bargain from %d credits to %d credits!\n\r", cost, (cost/3)+(cost/2));
	   cost = (cost/3) + (cost/2);
	   if(number_percent() > 50)
	    learn_from_success(ch, gsn_bargain);
	 }

	if ( cost <= 0 || !can_see_obj( ch, obj ) )
	{
	    act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'",
		keeper, NULL, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}

	if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) )
	{
	    interpret( keeper, "laugh" );
	    act( AT_TELL, "$n tells you 'I don't have enough of those in stock"
	     " to sell more than one at a time.'", keeper, NULL, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}
	
	if ( ch->gold < cost && debit == FALSE)
	{
	    act( AT_TELL, "$n tells you 'You can't afford to buy $p.'",
		keeper, obj, ch, TO_VICT );
	    ch->reply = keeper;
	    return;
	}
	
        if ( ch->pcdata->bank < cost && debit == TRUE)
	{
	    send_to_char( "You are almost slide your card through, but you remember you don't have enough money!\n\r", ch );
	    return;	    
        }  

	if ( IS_SET(obj->extra_flags, ITEM_PROTOTYPE) 
             && get_trust( ch ) < LEVEL_IMMORTAL )
	{
	    act( AT_TELL, "$n tells you 'This is a only a prototype!  I can't sell you that...'", 
		keeper, NULL, ch, TO_VICT );
      	    ch->reply = keeper;
	    return;
	}

	if ( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
	{
	    send_to_char( "You can't carry that many items.\n\r", ch );
	    return;
	}

	if ( ch->carry_weight + ( get_obj_weight( obj ) * noi )
		+ (noi > 1 ? 2 : 0) > can_carry_w( ch ) )
	{
	    send_to_char( "You can't carry that much weight.\n\r", ch );
	    return;
	}

	if ( noi == 1 )
	{
	    if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) )  
	       separate_obj( obj );
	    act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM );
    	    act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR );
	}
        else
	{
	    sprintf( arg, "$n buys %d $p%s.", noi,
		( obj->short_descr[strlen(obj->short_descr)-1] == 's'
		? "" : "s" ) );
	    act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM );
	    sprintf( arg, "You buy %d $p%s.", noi,
		( obj->short_descr[strlen(obj->short_descr)-1] == 's'
		? "" : "s" ) );
	    act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR );
	    act( AT_ACTION, "$N puts them into a bag and hands it to you.",
		ch, NULL, keeper, TO_CHAR );
	}

        if ( debit == FALSE )
	  ch->gold     -= cost; /* this line was already here, btw */
        else if ( debit == TRUE )
          ch->pcdata->bank     -= cost;
	keeper->gold += cost;

	if ( keeper->gold > maxgold )
	{
	    boost_economy( keeper->in_room->area, keeper->gold - maxgold/2 );
	    keeper->gold = maxgold/2;
	    act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM );
	}

	if ( IS_OBJ_STAT( obj, ITEM_INVENTORY ) )
	{
	    OBJ_DATA *buy_obj, *bag;

	    buy_obj = create_object( obj->pIndexData, obj->level );

	    /*
	     * Due to grouped objects and carry limitations in SMAUG
	     * The shopkeeper gives you a bag with multiple-buy,
	     * and also, only one object needs be created with a count
	     * set to the number bought.		-Thoric
	     */
	    if ( noi > 1 )
	    {
		bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ), 1 );
		/* perfect size bag ;) */
		bag->value[0] = bag->weight + (buy_obj->weight * noi);
		buy_obj->count = noi;
		obj->pIndexData->count += (noi - 1);
		numobjsloaded += (noi - 1);
		obj_to_obj( buy_obj, bag );
		obj_to_char( bag, ch );
	    }
	    else
		obj_to_char( buy_obj, ch );
	}
        else
	{
	    obj_from_char( obj );
	    obj_to_char( obj, ch );
	}

	return;
    }
}
示例#22
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;
}
示例#23
0
void auto_equip(struct char_data *ch, struct obj_data *obj, int location)
{
  int j;

  if (location > 0) { /* was worn */
    switch (j = (location - 1)) {
      case WEAR_FINGER_R:
      case WEAR_FINGER_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_FINGER))
	  location = LOC_INVENTORY;
	break;
      case WEAR_NECK_1:
      case WEAR_NECK_2:
	if (!CAN_WEAR(obj,ITEM_WEAR_NECK))
	  location = LOC_INVENTORY;
	break;
      case WEAR_BODY:
	if (!CAN_WEAR(obj,ITEM_WEAR_BODY))
	  location = LOC_INVENTORY;
	break;
      case WEAR_HEAD:
	if (!CAN_WEAR(obj,ITEM_WEAR_HEAD))
	  location = LOC_INVENTORY;
	break;
      case WEAR_LEGS:
	if (!CAN_WEAR(obj,ITEM_WEAR_LEGS))
	  location = LOC_INVENTORY;
	break;
      case WEAR_FOOT_R:
      case WEAR_FOOT_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_FEET))
	  location = LOC_INVENTORY;
	break;
      case WEAR_HAND_R:
      case WEAR_HAND_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_HANDS))
	  location = LOC_INVENTORY;
	break;
      case WEAR_ARM_R:
      case WEAR_ARM_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_ARMS))
	  location = LOC_INVENTORY;
	break;
      case WEAR_BACK:
	if (!CAN_WEAR(obj,ITEM_WEAR_BACK))
	  location = LOC_INVENTORY;
	break;
      case WEAR_WAIST:
	if (!CAN_WEAR(obj,ITEM_WEAR_WAIST))
	  location = LOC_INVENTORY;
	break;
      case WEAR_WRIST_R:
      case WEAR_WRIST_L:
	if (!CAN_WEAR(obj,ITEM_WEAR_WRIST))
	  location = LOC_INVENTORY;
	break;
      case WEAR_WIELD:
      case WEAR_HOLD:
	if (!CAN_WEAR(obj, ITEM_WEAR_HOLD) &&
            !CAN_WEAR(obj, ITEM_WEAR_TAKE))
	  location = LOC_INVENTORY;
	break;
      default:
	location = LOC_INVENTORY;
    }
    if (location > 0) {
      if (!GET_EQ(ch,j)) {
        /* check ch's alignment to prevent $M from being zapped through auto-equip */
	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)))
	  location = LOC_INVENTORY;
	else
	  equip_char(ch, obj, j);
      } else  { /* oops - saved player with double equipment[j]? */
        char aeq[128];
        sprintf(aeq, "SYSERR: autoeq: '%s' already equipped in position %d.", GET_NAME(ch), location);
        mudlog(aeq, BRF, LVL_IMMORT, TRUE);
        location = LOC_INVENTORY;
      }
    }
  }

  if ( location <= 0 )
    obj_to_char(obj, ch);
}
示例#24
0
void acid_effect(void *vo, int level, int dam, int target)
{
	if (target == TARGET_ROOM) /* nail objects on the floor */
	{
		ROOM_INDEX_DATA *room = (ROOM_INDEX_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

		for (obj = room->contents; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			acid_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_CHAR)  /* do the effect on a victim */
	{
		CHAR_DATA *victim = (CHAR_DATA *) vo;
		OBJ_DATA *obj, *obj_next;
		
	/* let's toast some gear */
		for (obj = victim->carrying; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			acid_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_OBJ) /* toast an object */
	{
		OBJ_DATA *obj = (OBJ_DATA *) vo;
		OBJ_DATA *t_obj,*n_obj;
		int chance = level / 4 + dam / 10;
		char *msg;

		if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF)
			||  IS_OBJ_STAT(obj,ITEM_NOPURGE)
			||  number_range(0,4) == 0)
			return;

		if (chance > 25)
			chance = (chance - 25) / 2 + 25;
		if (chance > 50)
			chance = (chance - 50) / 2 + 50;

		if (IS_OBJ_STAT(obj,ITEM_BLESS))
			chance -= 5;

		chance -= obj->level * 2;

		switch (obj->item_type)
		{
			default:
			return;
			case ITEM_CONTAINER:
			case ITEM_CORPSE_PC:
			case ITEM_CORPSE_NPC:
			msg = "$p fumes and dissolves.";
			break;
			case ITEM_ARMOR:
			msg = "$p is pitted and etched.";
			break;
			case ITEM_CLOTHING:
			msg = "$p is corroded into scrap.";
			break;
			case ITEM_STAFF:
			case ITEM_WAND:
			chance -= 10;
			msg = "$p corrodes and breaks.";
			break;
			case ITEM_SCROLL:
			chance += 10;
			msg = "$p is burned into waste.";
			break; 
		}

		chance = URANGE(5,chance,95);

		if (number_percent() > chance)
			return;

		if (obj->carried_by != NULL)
			act(msg,obj->carried_by,obj,NULL,TO_ALL);
		else if (obj->in_room != NULL && obj->in_room->people != NULL)
			act(msg,obj->in_room->people,obj,NULL,TO_ALL);

	if (obj->item_type == ITEM_ARMOR)  /* etch it */
		{
			AFFECT_DATA *paf;
			bool af_found = FALSE;
			int i;

			affect_enchant(obj);

			for ( paf = obj->affected; paf != NULL; paf = paf->next)
			{
				if ( paf->location == APPLY_AC)
				{
					af_found = TRUE;
					paf->type = -1;
					paf->modifier += 1;
					paf->level = UMAX(paf->level,level);
					break;
				}
			}
			
			if (!af_found)
			/* needs a new affect */
			{
				paf = new_affect();
				
				paf->type       = -1;
				paf->level      = level;
				paf->duration   = -1;
				paf->location   = APPLY_AC;
				paf->modifier   =  1;
				paf->bitvector  = 0;
				paf->next       = obj->affected;
				obj->affected   = paf;
			}
			
			if (obj->carried_by != NULL && obj->wear_loc != WEAR_NONE)
				for (i = 0; i < 4; i++)
					obj->carried_by->armor[i] += 1;
				return;
			}

	/* get rid of the object */
	if (obj->contains)  /* dump contents */
			{
				for (t_obj = obj->contains; t_obj != NULL; t_obj = n_obj)
				{
					n_obj = t_obj->next_content;
					obj_from_obj(t_obj);
					if (obj->in_room != NULL)
						obj_to_room(t_obj,obj->in_room);
					else if (obj->carried_by != NULL)
						obj_to_room(t_obj,obj->carried_by->in_room);
					else
					{
						extract_obj(t_obj);
						continue;
					}

					acid_effect(t_obj,level/2,dam/2,TARGET_OBJ);
				}
			}

			extract_obj(obj);
			return;
		}
}
示例#25
0
int Crash_clean_file(char *name)
{
  char fname[MAX_STRING_LENGTH], filetype[20];
  struct rent_info rent;
  extern int rent_file_timeout, crash_file_timeout;
  FILE *fl;

  if (!get_filename(name, fname, CRASH_FILE))
    return 0;
  /*
   * open for write so that permission problems will be flagged now, at boot
   * time.
   */
  if (!(fl = fopen(fname, "r+b"))) {
    if (errno != ENOENT) {      /* if it fails, NOT because of no file */
      sprintf(buf1, "SYSERR: OPENING OBJECT FILE %s (4)", fname);
      perror(buf1);
    }
    return 0;
  }
  if (!feof(fl))
    fread(&rent, sizeof(struct rent_info), 1, fl);
  fclose(fl);

#define LIMITED_ITEMS 0

#if LIMITED_ITEMS
  for (j = 0; j < rent.nitems; j++)
    if (IS_OBJ_STAT(obj_elem.extra_flags, ITEM_LIMITED)) {
      limited_objs[i] = obj_elem.item_number;
      i++;
    }
#endif

  if ((rent.rentcode == RENT_CRASH) ||
      (rent.rentcode == RENT_FORCED) || (rent.rentcode == RENT_TIMEDOUT)) {
    if (rent.time < time(0) - (crash_file_timeout * SECS_PER_REAL_DAY)) {
      Crash_delete_file(name);
      switch (rent.rentcode) {
      case RENT_CRASH:
	strcpy(filetype, "crash");
	break;
      case RENT_FORCED:
	strcpy(filetype, "forced rent");
	break;
      case RENT_TIMEDOUT:
	strcpy(filetype, "idlesave");
	break;
      default:
	strcpy(filetype, "UNKNOWN!");
	break;
      }
      sprintf(buf, "    Deleting %s's %s file.", name, filetype);
      log(buf);
      return 1;
    }
    /* Must retrieve rented items w/in 30 days */
  } else if (rent.rentcode == RENT_RENTED)
    if (rent.time < time(0) - (rent_file_timeout * SECS_PER_REAL_DAY)) {
      Crash_delete_file(name);
      sprintf(buf, "    Deleting %s's rent file.", name);
      log(buf);
      return 1;
    }
  return (0);
}
示例#26
0
void poison_effect(void *vo,int level, int dam, int target)
{
	if (target == TARGET_ROOM)  /* nail objects on the floor */
	{
		ROOM_INDEX_DATA *room = (ROOM_INDEX_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

		for (obj = room->contents; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			poison_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_CHAR)   /* do the effect on a victim */
	{
		CHAR_DATA *victim = (CHAR_DATA *) vo;
		OBJ_DATA *obj, *obj_next;

	/* chance of poisoning */
		if (!saves_spell(level / 4 + dam / 20,victim,DAM_POISON))
		{
			AFFECT_DATA af;

			send_to_char("You feel poison coursing through your veins.\n\r", victim);
			act("$n looks very ill.",victim,NULL,NULL,TO_ROOM);

			af.where     = TO_AFFECTS;
			af.type      = gsn_poison;
			af.level     = level;
			af.duration  = level / 2;
			af.location  = APPLY_STR;
			af.modifier  = -1;
			af.bitvector = AFF_POISON;
			affect_join( victim, &af );
		}

	/* equipment */
		for (obj = victim->carrying; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			poison_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_OBJ)  /* do some poisoning */
	{
		OBJ_DATA *obj = (OBJ_DATA *) vo;
		int chance  = level / 4 + dam / 10;

		if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF)
			||  IS_OBJ_STAT(obj,ITEM_BLESS)
			||  number_range(0,4) == 0)
			return;

		if (chance > 25)
			chance = (chance - 25) / 2 + 25;
		if (chance > 50)
			chance = (chance - 50) / 2 + 50;

		chance -= obj->level * 2;

		switch (obj->item_type)
		{
			default:
			return;
			case ITEM_FOOD:
			break;
			case ITEM_DRINK_CON:
			if (obj->value[0] == obj->value[1])
				return;
			break;
		}

		chance = URANGE(5,chance,95);

		if (number_percent() > chance)
			return;

		obj->value[3] = 1;
		return;
	}
}
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;
}
示例#28
0
文件: handler.c 项目: Calebros/aol
void equip_char(struct char_data * ch, struct obj_data * obj, int pos)
{
  int j;
  int invalid_class(struct char_data *ch, struct obj_data *obj);
  int invalid_race(struct char_data *ch, struct obj_data *obj);

  assert(pos >= 0 && pos < NUM_WEARS);

  if (GET_EQ(ch, pos)) {
    GET_NAME(ch, chname);
    sprintf(buf, "SYSERR: Char is already equipped: %s, %s", chname,
	    obj->short_description);
    FREE_NAME(chname);
    log(buf);
    return;
  }

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

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

  /*  Let's change the messages here.  Soli, 8/12/99  */
  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)))
  {
      act("You are zapped by $p and instantly let go of it.", FALSE, ch, obj, 0, TO_CHAR);
      act("$n is zapped by $p and instantly lets go of it.", FALSE, ch, obj, 0, TO_ROOM);
      obj_to_char(obj, ch);	/* changed to drop in inventory instead of
				 * ground */
      return;
  }

  /*  I'm moving the other two to a seperate function, checked before we
      actually wear the eq.  Soli, 8/12/99  */

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

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

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

  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);
}
示例#29
0
void read_obj_file( char *dirname, char *filename )
{
   ROOM_INDEX_DATA *room;
   FILE *fp;
   char fname[256];
   int vnum;

   vnum = atoi( filename );

   if( ( room = get_room_index( vnum ) ) == NULL )
   {
      bug( "read_obj_file: ARGH! Missing room index for %d!", vnum );
      return;
   }

   snprintf( fname, 256, "%s%s", dirname, filename );
   if( ( fp = fopen( fname, "r" ) ) != NULL )
   {
      short iNest;
      bool found;
      OBJ_DATA *tobj, *tobj_next;

      rset_supermob( room );
      for( iNest = 0; iNest < MAX_NEST; iNest++ )
         rgObjNest[iNest] = NULL;

      found = TRUE;
      for( ;; )
      {
         char letter;
         const char *word;

         letter = fread_letter( fp );
         if( letter == '*' )
         {
            fread_to_eol( fp );
            continue;
         }

         if( letter != '#' )
         {
            bug( "%s", "read_obj_file: # not found." );
            break;
         }

         word = fread_word( fp );
         if( !str_cmp( word, "OBJECT" ) ) /* Objects  */
            fread_obj( supermob, fp, OS_CARRY );
         else if( !str_cmp( word, "END" ) )  /* Done     */
            break;
         else
         {
            bug( "read_obj_file: bad section: %s", word );
            break;
         }
      }
      FCLOSE( fp );
      unlink( fname );
      for( tobj = supermob->first_carrying; tobj; tobj = tobj_next )
      {
         tobj_next = tobj->next_content;
#ifdef OVERLANDCODE
         if( IS_OBJ_STAT( tobj, ITEM_ONMAP ) )
         {
            SET_ACT_FLAG( supermob, ACT_ONMAP );
            supermob->map = tobj->map;
            supermob->x = tobj->x;
            supermob->y = tobj->y;
         }
#endif
         obj_from_char( tobj );
#ifndef OVERLANDCODE
         obj_to_room( tobj, room );
#else
         obj_to_room( tobj, room, supermob );
         REMOVE_ACT_FLAG( supermob, ACT_ONMAP );
         supermob->map = -1;
         supermob->x = -1;
         supermob->y = -1;
#endif
      }
      release_supermob(  );
   }
   else
      log_string( "Cannot open obj file" );

   return;
}
示例#30
0
void cold_effect(void *vo, int level, int dam, int target)
{
	if (target == TARGET_ROOM) /* nail objects on the floor */
	{
		ROOM_INDEX_DATA *room = (ROOM_INDEX_DATA *) vo;
		OBJ_DATA *obj, *obj_next;
		
		for (obj = room->contents; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			cold_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_CHAR) /* whack a character */
	{
		CHAR_DATA *victim = (CHAR_DATA *) vo;
		OBJ_DATA *obj, *obj_next;
		
	/* chill touch effect */
		if (!saves_spell(level/4 + dam / 20, victim, DAM_COLD))
		{
			AFFECT_DATA af;

			act("$n turns blue and shivers.",victim,NULL,NULL,TO_ROOM);
			act("A chill sinks deep into your bones.",victim,NULL,NULL,TO_CHAR);
			af.where     = TO_AFFECTS;
			af.type      = skill_lookup("chill touch");
			af.level     = level;
			af.duration  = 6;
			af.location  = APPLY_STR;
			af.modifier  = -1;
			af.bitvector = 0;
			affect_join( victim, &af );
		}

	/* hunger! (warmth sucked out */
		if (!IS_NPC(victim))
			gain_condition(victim,COND_HUNGER,dam/20);

	/* let's toast some gear */
		for (obj = victim->carrying; obj != NULL; obj = obj_next)
		{
			obj_next = obj->next_content;
			cold_effect(obj,level,dam,TARGET_OBJ);
		}
		return;
	}

	if (target == TARGET_OBJ) /* toast an object */
	{
		OBJ_DATA *obj = (OBJ_DATA *) vo;
		int chance = level / 4 + dam / 10;
		char *msg;

		if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF)
			||  IS_OBJ_STAT(obj,ITEM_NOPURGE)
			||  number_range(0,4) == 0)
			return;

		if (chance > 25)
			chance = (chance - 25) / 2 + 25;
		if (chance > 50)
			chance = (chance - 50) / 2 + 50;

		if (IS_OBJ_STAT(obj,ITEM_BLESS))
			chance -= 5;

		chance -= obj->level * 2;

		switch(obj->item_type)
		{
			default:
			return;
			case ITEM_POTION:
			msg = "$p freezes and shatters!";
			chance += 25;
			break;
			case ITEM_DRINK_CON:
			msg = "$p freezes and shatters!";
			chance += 5;
			break;
		}

		chance = URANGE(5,chance,95);

		if (number_percent() > chance)
			return;

		if (obj->carried_by != NULL)
			act(msg,obj->carried_by,obj,NULL,TO_ALL);
		else if (obj->in_room != NULL && obj->in_room->people != NULL)
			act(msg,obj->in_room->people,obj,NULL,TO_ALL);

		extract_obj(obj);
		return;
	}
}