void do_remove(struct char_data *ch, char *argument, int cmd) { char arg1[MAX_STRING_LENGTH]; char buffer[MAX_STRING_LENGTH]; char buffer1[MAX_STRING_LENGTH]; struct obj_data *obj_object; struct char_data *tmp_char; int i, j; one_argument(argument, arg1); if (*arg1) { obj_object = get_object_in_equip_vis(ch, arg1, ch->equipment, &j); if (obj_object) { if (CAN_CARRY_N(ch) != IS_CARRYING_N(ch)) { obj_to_char(unequip_char(ch, j), ch); if (obj_object->obj_flags.type_flag == ITEM_LIGHT) if (obj_object->obj_flags.value[2]) world[ch->in_room].light--; act("You stop using $p.",FALSE,ch,obj_object,0,TO_CHAR); act("$n stops using $p.",TRUE,ch,obj_object,0,TO_ROOM); } else { send_to_char("You can't carry that many items.\n\r", ch); } } else { send_to_char("You are not using it.\n\r", ch); } } else { send_to_char("Remove what?\n\r", ch); } }
void shopping_buy(char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char tempstr[200], buf[MAX_STRING_LENGTH]; struct obj_data *obj, *last_obj = NULL; int goldamt = 0, buynum, bought = 0; if (!(is_ok(keeper, ch, shop_nr))) return; if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper)) sort_keeper_objs(keeper, shop_nr); if ((buynum = transaction_amt(arg)) < 0) { sprintf(buf, "%s A negative amount? Try selling me something.", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } if (!(*arg) || !(buynum)) { sprintf(buf, "%s What do you want to buy??", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } if (!(obj = get_purchase_obj(ch, arg, keeper, shop_nr, TRUE))) return; if ((buy_price(ch, obj, shop_nr) > GET_GOLD(ch)) && !IS_GOD(ch)) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); switch (SHOP_BROKE_TEMPER(shop_nr)) { case 0: do_action(keeper, GET_NAME(ch), cmd_puke, 0); return; case 1: do_echo(keeper, "smokes on his joint.", cmd_emote, SCMD_EMOTE); return; default: return; } } if ((IS_CARRYING_N(ch) + 1 > CAN_CARRY_N(ch))) { sprintf(buf, "%s: You can't carry any more items.\n\r", fname(obj->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj)) > CAN_CARRY_W(ch)) { sprintf(buf, "%s: You can't carry that much weight.\n\r", fname(obj->name)); send_to_char(buf, ch); return; } while ((obj) && ((GET_GOLD(ch) >= buy_price(ch, obj, shop_nr)) || IS_GOD(ch)) && (IS_CARRYING_N(ch) < CAN_CARRY_N(ch)) && (bought < buynum) && (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) <= CAN_CARRY_W(ch))) { bought++; /* Test if producing shop ! */ if (shop_producing(obj, shop_nr)) obj = read_object(GET_OBJ_RNUM(obj), REAL); else { obj_from_char(obj); SHOP_SORT(shop_nr)--; } obj_to_char(obj, ch); goldamt += buy_price(ch, obj, shop_nr); if (!IS_GOD(ch)) GET_GOLD(ch) -= buy_price(ch, obj, shop_nr); last_obj = obj; obj = get_purchase_obj(ch, arg, keeper, shop_nr, FALSE); if (!same_obj(obj, last_obj)) break; } if (bought < buynum) { if (!obj || !same_obj(last_obj, obj)) sprintf(buf, "%s I only have %d to sell you.", GET_NAME(ch), bought); else if (GET_GOLD(ch) < buy_price(ch, obj, shop_nr)) sprintf(buf, "%s You can only afford %d.", GET_NAME(ch), bought); else if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)) sprintf(buf, "%s You can only hold %d.", GET_NAME(ch), bought); else if (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) > CAN_CARRY_W(ch)) sprintf(buf, "%s You can only carry %d.", GET_NAME(ch), bought); else sprintf(buf, "%s Something screwy only gave you %d.", GET_NAME(ch), bought); do_tell(keeper, buf, cmd_tell, 0); } if (!IS_GOD(ch)) GET_GOLD(keeper) += goldamt; sprintf(tempstr, "%s", times_message(ch->carrying, 0, bought)); sprintf(buf, "$n buys %s.", tempstr); act(buf, FALSE, ch, obj, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), goldamt); do_tell(keeper, buf, cmd_tell, 0); sprintf(buf, "You now have %s.\n\r", tempstr); send_to_char(buf, ch); if (SHOP_USES_BANK(shop_nr)) if (GET_GOLD(keeper) > MAX_OUTSIDE_BANK) { SHOP_BANK(shop_nr) += (GET_GOLD(keeper) - MAX_OUTSIDE_BANK); GET_GOLD(keeper) = MAX_OUTSIDE_BANK; } }
void shopping_buy( const char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH], newarg[100]; int num = 1; struct obj_data *temp1; int i; 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 buy??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; }; if( ( num = getabunch( argm, newarg ) ) != 0 ) { strcpy(argm,newarg); } if (num == 0) num = 1; if(!( temp1 = get_obj_in_list_vis(ch,argm,keeper->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(temp1->obj_flags.cost <= 0) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); extract_obj(temp1); return; } if( GET_GOLD(ch) < (int) (num*(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))) && GetMaxLevel(ch)<DEMIGOD) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper,buf,19); switch(shop_index[shop_nr].temper1) { case 0: do_action(keeper,GET_NAME(ch),30); return; case 1: do_emote(keeper,"grins happily",36); return; default: return; } } if ((IS_CARRYING_N(ch) + num) > (CAN_CARRY_N(ch))) { sprintf(buf,"%s : You can't carry that many items.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + (num * temp1->obj_flags.weight)) > CAN_CARRY_W(ch)) { sprintf(buf,"%s : You can't carry that much weight.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), (int) (num * (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost)))); do_tell(keeper,buf,19); sprintf(buf,"You now have %s (*%d).\n\r", temp1->short_description,num); send_to_char(buf,ch); while (num-- > 0) { if (GetMaxLevel(ch)<DEMIGOD) GET_GOLD(ch) -= (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); GET_GOLD(keeper) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[(int)GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); /* Test if producing shop ! */ if (shop_producing(temp1,shop_nr)) temp1 = read_object(temp1->item_number, REAL); else { obj_from_char(temp1); if (temp1 == NULL) { send_to_char("Sorry, I just ran out of those.\n\r",ch); GET_GOLD(ch) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy - ((chr_apply[ (int)GET_CHR(ch) ].reaction * temp1->obj_flags.cost)/100)+ (mult * temp1->obj_flags.cost)); return; } } obj_to_char(temp1,ch); } return; }
void shopping_buy( char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH]; struct obj_data *temp1; struct char_data *temp_char; if(!(is_ok(keeper,ch,shop_nr))) return; one_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s what do you want to buy??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; }; if(!( temp1 = get_obj_in_list_vis(ch,argm,keeper->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(temp1->obj_flags.cost <= 0) { sprintf(buf, shop_index[shop_nr].no_such_item1 ,GET_NAME(ch)); do_tell(keeper,buf,19); extract_obj(temp1); return; } if(GET_GOLD(ch) < (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy) && GET_LEVEL(ch)<22) { sprintf(buf, shop_index[shop_nr].missing_cash2, GET_NAME(ch)); do_tell(keeper,buf,19); switch(shop_index[shop_nr].temper1) { case 0: do_action(keeper,GET_NAME(ch),30); return; case 1: do_emote(keeper,"smokes on his joint",36); return; default: return; } } if ((IS_CARRYING_N(ch) + 1 > CAN_CARRY_N(ch))) { sprintf(buf,"%s : You can't carry that many items.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } if ((IS_CARRYING_W(ch) + temp1->obj_flags.weight) > CAN_CARRY_W(ch)) { sprintf(buf,"%s : You can't carry that much weight.\n\r", fname(temp1->name)); send_to_char(buf, ch); return; } act("$n buys $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_buy, GET_NAME(ch), (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_buy)); do_tell(keeper,buf,19); sprintf(buf,"You now have %s.\n\r", temp1->short_description); send_to_char(buf,ch); if(GET_LEVEL(ch)<22) GET_GOLD(ch) -= (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy); GET_GOLD(keeper) += (int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy); /* Test if producing shop ! */ if(shop_producing(temp1,shop_nr)) temp1 = read_object(temp1->item_number, REAL); else obj_from_char(temp1); obj_to_char(temp1,ch); return; }