void shopping_value(char *arg, struct char_data * ch, struct char_data * keeper, int shop_nr) { char buf[MAX_STRING_LENGTH]; struct obj_data *obj; char name[MAX_INPUT_LENGTH]; if (!(is_ok(keeper, ch, shop_nr))) return; if (!(*arg)) { sprintf(buf, "%s What do you want me to valuate??", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } one_argument(arg, name); if (!(obj = get_selling_obj(ch, name, keeper, shop_nr, TRUE))) return; sprintf(buf, "%s I'll give you %d gold coins for that!", GET_NAME(ch), sell_price(ch, obj, shop_nr)); do_tell(keeper, buf, cmd_tell, 0); return; }
int is_ok_char(struct char_data * keeper, struct char_data * ch, int shop_nr) { char buf[200]; if (!(CAN_SEE(keeper, ch))) { do_say(keeper, MSG_NO_SEE_CHAR, cmd_say, 0); return (FALSE); } if (IS_GOD(ch)) return (TRUE); if ((IS_GOOD(ch) && NOTRADE_GOOD(shop_nr)) || (IS_EVIL(ch) && NOTRADE_EVIL(shop_nr)) || (IS_NEUTRAL(ch) && NOTRADE_NEUTRAL(shop_nr))) { sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_SELL_ALIGN); do_tell(keeper, buf, cmd_tell, 0); return (FALSE); } if (IS_NPC(ch)) return (TRUE); if ((IS_MAGIC_USER(ch) && NOTRADE_MAGIC_USER(shop_nr)) || (IS_CLERIC(ch) && NOTRADE_CLERIC(shop_nr)) || (IS_THIEF(ch) && NOTRADE_THIEF(shop_nr)) || (IS_WARRIOR(ch) && NOTRADE_WARRIOR(shop_nr))) { sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_SELL_CLASS); do_tell(keeper, buf, cmd_tell, 0); return (FALSE); } return (TRUE); }
void shopping_value( const char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH]; 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 me to evaluate??", GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) { sprintf(buf,shop_index[shop_nr].no_such_item2, GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(!(trade_with(temp1,shop_nr))) { sprintf(buf, shop_index[shop_nr].do_not_buy, GET_NAME(ch)); do_tell(keeper,buf,19); return; } sprintf(buf,"%s I'll give you %d gold coins for that!", GET_NAME(ch),(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))); do_tell(keeper,buf,19); return; }
void quest_join(struct char_data *ch, struct char_data *qm, char argument[MAX_INPUT_LENGTH]) { qst_vnum vnum; qst_rnum rnum; char buf[MAX_INPUT_LENGTH]; if (!*argument) snprintf(buf, sizeof(buf), "%s What quest did you wish to join?", GET_NAME(ch)); else if (GET_QUEST(ch) != NOTHING) snprintf(buf, sizeof(buf), "%s But you are already part of a quest!", GET_NAME(ch)); else if((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING) snprintf(buf, sizeof(buf), "%s I don't know of such a quest!", GET_NAME(ch)); else if ((rnum = real_quest(vnum)) == NOTHING) snprintf(buf, sizeof(buf), "%s I don't know of such a quest!", GET_NAME(ch)); else if (GET_LEVEL(ch) < QST_MINLEVEL(rnum)) snprintf(buf, sizeof(buf), "%s You are not experienced enough for that quest!", GET_NAME(ch)); else if (GET_LEVEL(ch) > QST_MAXLEVEL(rnum)) snprintf(buf, sizeof(buf), "%s You are too experienced for that quest!", GET_NAME(ch)); else if (is_complete(ch, vnum)) snprintf(buf, sizeof(buf), "%s You have already completed that quest!", GET_NAME(ch)); else if ((QST_PREV(rnum) != NOTHING) && !is_complete(ch, QST_PREV(rnum))) snprintf(buf, sizeof(buf), "%s That quest is not available to you yet!", GET_NAME(ch)); else if ((QST_PREREQ(rnum) != NOTHING) && (real_object(QST_PREREQ(rnum)) != NOTHING) && (get_obj_in_list_num(real_object(QST_PREREQ(rnum)), ch->carrying) == NULL)) snprintf(buf, sizeof(buf), "%s You need to have %s first!", GET_NAME(ch), obj_proto[real_object(QST_PREREQ(rnum))].short_description); else { act("You join the quest.", TRUE, ch, NULL, NULL, TO_CHAR); act("$n has joined a quest.", TRUE, ch, NULL, NULL, TO_ROOM); snprintf(buf, sizeof(buf), "%s Listen carefully to the instructions.", GET_NAME(ch)); do_tell(qm, buf, cmd_tell, 0); set_quest(ch, rnum); send_to_char(ch, "%s", QST_INFO(rnum)); if (QST_TIME(rnum) != -1) snprintf(buf, sizeof(buf), "%s You have a time limit of %d turn%s to complete the quest.", GET_NAME(ch), QST_TIME(rnum), QST_TIME(rnum) == 1 ? "" : "s"); else snprintf(buf, sizeof(buf), "%s You can take however long you want to complete the quest.", GET_NAME(ch)); } do_tell(qm, buf, cmd_tell, 0); save_char(ch); }
struct obj_data * get_purchase_obj(struct char_data * ch, char *arg, struct char_data * keeper, int shop_nr, int msg) { char buf[MAX_STRING_LENGTH], name[MAX_INPUT_LENGTH]; struct obj_data *obj; one_argument(arg, name); do { if (*name == '#') obj = get_hash_obj_vis(ch, name, keeper->carrying); else obj = get_slide_obj_vis(ch, name, keeper->carrying); if (!obj) { if (msg) { sprintf(buf, shop_index[shop_nr].no_such_item1, GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); } return (0); } if (GET_OBJ_COST(obj) <= 0) { extract_obj(obj); obj = 0; } } while (!obj); return (obj); }
void ccp_tell(int cn,int co,char *text) { #ifdef REAL_CCP if (ch[co].flags&CF_CCP) return; do_tell(cn,ch[co].name,"Sorry, I'm just a robot, I cannot really talk back."); #endif }
void shopping_value( char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH]; struct obj_data *temp1; if(!(is_ok(keeper,ch,shop_nr))) return; one_argument(arg, argm); if(!(*argm)) { sprintf(buf,"%s What do you want me to valuate??", GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) { sprintf(buf,shop_index[shop_nr].no_such_item2, GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(!(trade_with(temp1,shop_nr))) { sprintf(buf, shop_index[shop_nr].do_not_buy, GET_NAME(ch)); do_tell(keeper,buf,19); return; } sprintf(buf,"%s I'll give you %d gold coins for that!", GET_NAME(ch),(int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell)); do_tell(keeper,buf,19); return; }
struct obj_data * get_selling_obj(struct char_data * ch, char *name, struct char_data * keeper, int shop_nr, int msg) { char buf[MAX_STRING_LENGTH]; struct obj_data *obj; int result; if (!(obj = get_obj_in_list_vis(ch, name, ch->carrying))) { if (msg) { sprintf(buf, shop_index[shop_nr].no_such_item2, GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); } return (0); } if ((result = trade_with(obj, shop_nr)) == OBJECT_OK) return (obj); switch (result) { case OBJECT_NOTOK: sprintf(buf, shop_index[shop_nr].do_not_buy, GET_NAME(ch)); break; case OBJECT_DEAD: sprintf(buf, "%s %s", GET_NAME(ch), MSG_NO_USED_WANDSTAFF); break; default: sprintf(buf, "Illegal return value of %d from trade_with() (shop.c)", result); log("%s", buf); sprintf(buf, "%s An error has occurred.", GET_NAME(ch)); break; } if (msg) do_tell(keeper, buf, cmd_tell, 0); return (0); }
void shopping_kill( const char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char buf[100]; switch(shop_index[shop_nr].temper2){ case 0: sprintf(buf,"%s Don't ever try that again!", GET_NAME(ch)); do_tell(keeper,buf,19); return; case 1: sprintf(buf,"%s Scram - midget!", GET_NAME(ch)); do_tell(keeper,buf,19); return; default : return; } }
void Crash_rent_deadline(struct char_data * ch, struct char_data * recep, long cost) { long rent_deadline; if (!cost) return; rent_deadline = ((GET_GOLD(ch) + GET_BANK_GOLD(ch)) / cost); sprintf(buf, "%s You can rent for %ld day%s with the gold you have\r\n" "on hand and in the bank.\r\n", GET_NAME(ch), rent_deadline, (rent_deadline > 1) ? "s" : ""); do_tell(recep, buf, 0, 0); }
int Crash_report_unrentables(struct char_data * ch, struct char_data * recep, struct obj_data * obj) { char buf[128]; int has_norents = 0; if (obj) { if (Crash_is_unrentable(obj)) { has_norents = 1; sprintf(buf, "%s You cannot store %s.", GET_NAME(ch), OBJS(obj, ch)); do_tell(recep, buf, 0, 0); } has_norents += Crash_report_unrentables(ch, recep, obj->contains); has_norents += Crash_report_unrentables(ch, recep, obj->next_content); } return (has_norents); }
int Crash_offer_rent(struct char_data * ch, struct char_data * receptionist, int display, int factor) { char buf[MAX_INPUT_LENGTH]; int i; long totalcost = 0, numitems = 0, norent = 0; norent = Crash_report_unrentables(ch, receptionist, ch->carrying); for (i = 0; i < NUM_WEARS; i++) norent += Crash_report_unrentables(ch, receptionist, GET_EQ(ch, i)); if (norent) return 0; totalcost = min_rent_cost * factor; Crash_report_rent(ch, receptionist, ch->carrying, &totalcost, &numitems, display, factor); for (i = 0; i < NUM_WEARS; i++) Crash_report_rent(ch, receptionist, GET_EQ(ch, i), &totalcost, &numitems, display, factor); if (!numitems) { sprintf(buf, "%s But you are not carrying anything! Just quit!", GET_NAME(ch)); do_tell(receptionist, buf, 0, 0); return (0); } if (numitems > max_obj_save) { sprintf(buf, "%s Sorry, but I cannot store more than %d items.", GET_NAME(ch), max_obj_save); do_tell(receptionist, buf, 0, 0); return (0); } if (display) { sprintf(buf, "%s Plus, my %d coin fee..", GET_NAME(ch), min_rent_cost * factor); do_tell(receptionist, buf, 0, 0); sprintf(buf, "%s Totalling %ld, minus your rent credit of %ld...", GET_NAME(ch), totalcost, (long)(GET_LEVEL(ch) * 800)); do_tell(receptionist, buf, 0, 0); totalcost = MAX(0, (int)(totalcost - (GET_LEVEL(ch) * 800))); sprintf(buf, "%s That will be %ld coin%s%s.", GET_NAME(ch), totalcost, (totalcost == 1 ? "" : "s"), (factor == RENT_FACTOR ? " per day" : "")); do_tell(receptionist, buf, 0, 0); if (totalcost > GET_GOLD(ch)) { sprintf(buf, "%s ...which I see you can't afford.", GET_NAME(ch)); do_tell(receptionist, buf, 0, 0); return (0); } else if (factor == RENT_FACTOR) Crash_rent_deadline(ch, receptionist, totalcost); } return (totalcost); }
void Crash_report_rent(struct char_data * ch, struct char_data * recep, struct obj_data * obj, long *cost, long *nitems, int display, int factor) { static char buf[256]; if (obj) { if (!Crash_is_unrentable(obj)) { (*nitems)++; *cost += MAX(0, (int)(GET_OBJ_RENT(obj) * factor)); if (display) { sprintf(buf, "%s %5d coins for %s..", GET_NAME(ch), (GET_OBJ_RENT(obj) * factor), OBJS(obj, ch)); do_tell(recep, buf, 0, 0); } } Crash_report_rent(ch, recep, obj->contains, cost, nitems, display, factor); Crash_report_rent(ch, recep, obj->next_content, cost, nitems, display, factor); } }
int ok_damage_shopkeeper(struct char_data * ch, struct char_data * victim) { char buf[200]; int index; if (IS_NPC(victim) && (mob_index[GET_MOB_RNUM(victim)].func == shop_keeper)) for (index = 0; index < top_shop; index++) if ((GET_MOB_RNUM(victim) == SHOP_KEEPER(index)) && !SHOP_KILL_CHARS(index)) { do_action(victim, GET_NAME(ch), cmd_slap, 0); sprintf(buf, "%s %s", GET_NAME(ch), MSG_CANT_KILL_KEEPER); do_tell(victim, buf, cmd_tell, 0); if (GET_RACE(ch)==RACE_KENDER) do_gen_comm(victim, "Stinkin' Kender scum!", 0, SCMD_SHOUT); return (FALSE); } return (TRUE); }
int process_line(ai::PL::KnowledgeBase &kb, int interactive, char *buf, std::istream &in, std::ostream &out) { if(strncmp(buf, "tell", 4) == 0) { do_tell(kb, interactive, buf, in, out); } else if(strncmp(buf, "ask2", 4) == 0) { do_ask(kb, interactive, buf, in, out, "ask2"); } else if(strncmp(buf, "dpll", 4) == 0) { do_ask(kb, interactive, buf, in, out, "dpll"); } else if(strncmp(buf, "ask", 3) == 0) { do_ask(kb, interactive, buf, in, out, "ask"); } else if(strncmp(buf, "list", 4) == 0) { do_list(kb, interactive, buf, in, out); } else if(strncmp(buf, "cnf", 3) == 0) { do_cnf(kb, interactive, buf, in, out); } else if(strncmp(buf, "quit", 4) == 0) { return 1; } else if(strncmp(buf, "load", 4) == 0) { do_load(kb, interactive, buf, in, out); } else if(strncmp(buf, "help", 4) == 0) { out << "known commands" << std::endl << "help - this message" << std::endl << "tell - prompt for new statement" << std::endl << "ask - prompt for statement to check for entailment" << std::endl << "ask2 - prompt for statement to check for entailment (pruned)" << std::endl << "dpll - prompt for statement to check for entailment (dpll)" << std::endl << "list - display known statements" << std::endl << "cnf - display known statements in CNF" << std::endl << "load - load statements from file" << std::endl << "quit - end session" << std::endl; } else if(strncmp(buf, "#", 1) == 0) { // comment, skip it } else if(strlen(buf) == 0) { // empty line, skip it } else { out << "unknown command. use help to list known commands." << std::endl; out << buf << std::endl; } return 0; }
void do_transfer( CHAR_DATA * ch, char *argument ) { CHAR_DATA *banker; CHAR_DATA *victim; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; bool isgold = FALSE; bool issilver = FALSE; bool iscopper = FALSE; char buf[MAX_STRING_LENGTH]; long int amount; long int thebalance; if( !( banker = find_banker( ch ) ) ) { send_to_char( "&WYou're not in a bank!&w\r\n", ch ); return; } if( IS_NPC( ch ) ) { sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr ); do_say( banker, buf ); return; } if( argument[0] == '\0' ) { do_say( banker, "If you need help, see HELP BANK." ); return; } argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if( arg1 == '\0' || arg2 == '\0' || arg3 == '\0' ) { sprintf( buf, "%s How much do you wish to send to who?", ch->name ); do_tell( banker, buf ); return; } if( str_cmp( arg1, "all" ) && !is_number( arg1 ) ) { sprintf( buf, "%s How much do you wish to send to who?", ch->name ); do_tell( banker, buf ); return; } if( !str_cmp( arg2, "gold" ) ) { isgold = TRUE; thebalance = ch->pcdata->gbalance; } else if( !str_cmp( arg2, "silver" ) ) { issilver = TRUE; thebalance = ch->pcdata->sbalance; } else if( !str_cmp( arg2, "copper" ) ) { iscopper = TRUE; thebalance = ch->pcdata->balance; } else { sprintf( buf, "%s I don't trade in that currency.", ch->name ); do_tell( banker, buf ); return; } if( !( victim = get_char_world( ch, arg3 ) ) ) { sprintf( buf, "%s %s could not be located.", ch->name, capitalize( arg2 ) ); do_tell( banker, buf ); return; } if( IS_NPC( victim ) ) { sprintf( buf, "%s We do not do business with mobiles...", ch->name ); do_tell( banker, buf ); return; } if( !str_cmp( arg1, "all" ) ) isgold ? ( amount = ch->pcdata->gbalance ) : issilver ? ( amount = ch->pcdata->sbalance ) : ( amount = ch->pcdata->balance ); else amount = atoi( arg1 ); if( amount > thebalance ) { sprintf( buf, "%s You are very generous, but you don't have that much %s!", ch->name, isgold ? "gold" : issilver ? "silver" : "copper" ); do_tell( banker, buf ); return; } if( amount <= 0 ) { sprintf( buf, "%s Oh I see.. I didn't know I was doing business with a comedian.", ch->name ); do_tell( banker, buf ); return; } if( isgold ) { ch->pcdata->gbalance -= amount; victim->pcdata->gbalance += amount; } else if( issilver ) { ch->pcdata->sbalance -= amount; victim->pcdata->sbalance += amount; } else if( iscopper ) { ch->pcdata->balance -= amount; victim->pcdata->balance += amount; } else { bug( "Invalid money type in banks. Error code: Er21303 Please report this code to Garinan." ); return; } sprintf( buf, "You transfer %ld %s coin%s to %s's bank account.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "", victim->name ); set_char_color( AT_WHITE, ch ); send_to_char( buf, ch ); sprintf( buf, "%s just transferred %ld %s coin%s to your bank account.\r\n", ch->name, amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "" ); set_char_color( AT_WHITE, victim ); send_to_char( buf, victim ); return; }
/* Deposit, withdraw, balance and transfer commands */ void do_deposit( CHAR_DATA * ch, char *argument ) { CHAR_DATA *banker; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; bool isgold = FALSE; bool issilver = FALSE; bool iscopper = FALSE; long int amount; if( !( banker = find_banker( ch ) ) ) { send_to_char( "&WYou're not in a bank!&w\r\n", ch ); return; } if( IS_NPC( ch ) ) { sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr ); do_say( banker, buf ); return; } if( argument[0] == '\0' ) { do_say( banker, "If you need help, see HELP BANK." ); return; } argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if( arg1 == '\0' ) { sprintf( buf, "%s How much do you wish to deposit?", ch->name ); do_tell( banker, buf ); return; } if( str_cmp( arg1, "all" ) && !is_number( arg1 ) ) { sprintf( buf, "%s How much do you wish to deposit?", ch->name ); do_tell( banker, buf ); return; } /* * New Money System -Garinan */ if( arg2 == '\0' ) { sprintf( buf, "%s You must specify gold, silver, or copper.", ch->name ); do_tell( banker, buf ); return; } if( !str_cmp( arg2, "gold" ) ) isgold = TRUE; else if( !str_cmp( arg2, "silver" ) ) issilver = TRUE; else if( !str_cmp( arg2, "copper" ) ) iscopper = TRUE; else { sprintf( buf, "%s I don't trade in that currency.", ch->name ); do_tell( banker, buf ); return; } if( !str_cmp( arg1, "all" ) ) isgold ? ( amount = ch->gold ) : issilver ? ( amount = ch->silver ) : ( amount = ch->copper ); else amount = atoi( arg1 ); if( ( amount > ch->gold && isgold ) || ( amount > ch->silver && issilver ) || ( amount > ch->copper && iscopper ) ) { sprintf( buf, "%s Sorry, but you don't have that much %s to deposit.", ch->name, isgold ? "gold" : issilver ? "silver" : "copper" ); do_tell( banker, buf ); return; } if( amount <= 0 ) { sprintf( buf, "%s Oh, I see.. I didn't know i was doing business with a comedian.", ch->name ); do_tell( banker, buf ); return; } /* if( !IS_IMMORTAL( ch ) ) { if( isgold ) { if( ch->pcdata->gbalance == 500 ) { do_tell( banker, "You can't deposit more than 500 gold coins!" ); return; } if( ch->pcdata->gbalance + amount > 500 ) amount = 500 - ch->pcdata->gbalance; } if( issilver ) { if( ch->pcdata->sbalance == 50000 ) { do_tell( banker, "You can't deposit more than 50,000 silver coins!" ); return; } if( ch->pcdata->sbalance + amount > 50000 ) amount = 50000 - ch->pcdata->sbalance; } if( iscopper ) { if( ch->pcdata->balance == 5000000 ) { do_tell( banker, "You can't deposit more than 5,000,000 copper coins!" ); return; } if( ch->pcdata->balance + amount > 5000000 ) amount = 5000000 - ch->pcdata->balance; } } */ if( isgold ) { ch->gold -= amount; ch->pcdata->gbalance += amount; } else if( issilver ) { ch->silver -= amount; ch->pcdata->sbalance += amount; } else if( iscopper ) { ch->copper -= amount; ch->pcdata->balance += amount; } else { bug( "Invalid money type in banks. Error code: Er21301 Please report this code to Garinan." ); return; } sprintf( buf, "You deposit %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "" ); set_char_color( AT_WHITE, ch ); send_to_char( buf, ch ); sprintf( buf, "$n deposits %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "" ); act( AT_WHITE, buf, ch, NULL, NULL, TO_ROOM ); return; }
int gen_receptionist(struct char_data * ch, struct char_data * recep, int cmd, char *arg, int mode) { int cost = 0; extern int free_rent; sh_int save_room; char *action_table[] = {"smile", "dance", "sigh", "blush", "burp", "cough", "giggle", "twiddle", "yawn"}; if (!ch->desc || IS_NPC(ch)) return FALSE; if (!cmd && !number(0, 5)) { do_action(recep, "", find_command(action_table[number(0, 8)]), 0); return FALSE; } if (!CMD_IS("offer") && !CMD_IS("rent")) return FALSE; if (!AWAKE(recep)) { send_to_char("She is unable to talk to you...\r\n", ch); return TRUE; } if (!CAN_SEE(recep, ch)) { act("$n says, 'I don't deal with people I can't see!'", FALSE, recep, 0, 0, TO_ROOM); return TRUE; } if (free_rent) { act("$n tells you, 'Rent is free here. Just quit, and your objects will be saved!'", FALSE, recep, 0, ch, TO_VICT); return 1; } if (CMD_IS("rent")) { if (mode == RENT_FACTOR) sprintf(buf, "%s Rent will cost you %d gold coins per day.", GET_NAME(ch), cost); else if (mode == CRYO_FACTOR) sprintf(buf, "%s It will cost you %d gold coins to be frozen.", GET_NAME(ch), cost); do_tell(recep, buf, 0, 0); if (cost > GET_GOLD(ch)) { sprintf(buf, "%s ...which I see you can't afford.", GET_NAME(ch)); do_tell(recep, buf, 0, 0); return TRUE; } if (mode == RENT_FACTOR) Crash_rent_deadline(ch, recep, cost); if (mode == RENT_FACTOR) { act("$n stores your belongings and helps you into your private chamber.", FALSE, recep, 0, ch, TO_VICT); Crash_rentsave(ch, cost); sprintf(buf, "%s has rented (%d/day, %ld tot.)", GET_NAME(ch), cost, GET_GOLD(ch) + GET_BANK_GOLD(ch)); } else { /* cryo */ act("$n stores your belongings and helps you into your private chamber.\r\n" "A white mist appears in the room, chilling you to the bone...\r\n" "You begin to lose consciousness...", FALSE, recep, 0, ch, TO_VICT); Crash_cryosave(ch, cost); sprintf(buf, "%s has cryo-rented.", GET_NAME(ch)); SET_BIT(PLR_FLAGS(ch), PLR_CRYO); } mudlog(buf, NRM, MAX((int)LVL_IMMORT, (int)GET_INVIS_LEV(ch)), TRUE); act("$n helps $N into $S private chamber.", FALSE, recep, 0, ch, TO_NOTVICT); save_room = ch->in_room; extract_char(ch); save_char(ch, save_room); } else { Crash_offer_rent(ch, recep, TRUE, mode); act("$N gives $n an offer.", FALSE, ch, 0, recep, TO_ROOM); } return TRUE; }
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; }
void shopping_sell( char *arg, struct char_data *ch, struct char_data *keeper,int shop_nr) { char argm[100], buf[MAX_STRING_LENGTH]; struct obj_data *temp1; struct char_data *temp_char; if(!(is_ok(keeper,ch,shop_nr))) return; one_argument(arg, argm); if(!(*argm)) { sprintf(buf, "%s What do you want to sell??" ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(!( temp1 = get_obj_in_list_vis(ch,argm,ch->carrying))) { sprintf(buf, shop_index[shop_nr].no_such_item2 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } if(!(trade_with(temp1,shop_nr))||(temp1->obj_flags.cost<1)) { sprintf(buf, shop_index[shop_nr].do_not_buy, GET_NAME(ch)); do_tell(keeper,buf,19); return; } if (GET_GOLD(keeper)<(int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell)) { sprintf(buf,shop_index[shop_nr].missing_cash1 ,GET_NAME(ch)); do_tell(keeper,buf,19); return; } act("$n sells $p.", FALSE, ch, temp1, 0, TO_ROOM); sprintf(buf,shop_index[shop_nr].message_sell, GET_NAME(ch),(int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell)); do_tell(keeper,buf,19); sprintf(buf,"The shopkeeper now has %s.\n\r", temp1->short_description); send_to_char(buf,ch); GET_GOLD(ch) += (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell); GET_GOLD(keeper) -= (int) (temp1->obj_flags.cost* shop_index[shop_nr].profit_sell); if((get_obj_in_list(argm,keeper->carrying)) || (GET_ITEM_TYPE(temp1) == ITEM_TRASH)) extract_obj(temp1); else { obj_from_char(temp1); obj_to_char(temp1,keeper); } return; }
void shopping_sell(char *arg, struct char_data * ch, struct char_data * keeper, int shop_nr) { char tempstr[200], buf[MAX_STRING_LENGTH], name[200]; char shortd[MAX_STRING_LENGTH]; struct obj_data *obj, *tag = 0; int sellnum, sold = 0, goldamt = 0; if (!(is_ok(keeper, ch, shop_nr))) return; if ((sellnum = transaction_amt(arg)) < 0) { sprintf(buf, "%s A negative amount? Try buying something.", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } if (!(*arg) || !(sellnum)) { sprintf(buf, "%s What do you want to sell??", GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } one_argument(arg, name); if (!(obj = get_selling_obj(ch, name, keeper, shop_nr, TRUE))) return; strcpy(shortd, obj->short_description); if (GET_GOLD(keeper) + SHOP_BANK(shop_nr) < sell_price(ch, obj, shop_nr)) { sprintf(buf, shop_index[shop_nr].missing_cash1, GET_NAME(ch)); do_tell(keeper, buf, cmd_tell, 0); return; } while ((obj) && (GET_GOLD(keeper) + SHOP_BANK(shop_nr) >= sell_price(ch, obj, shop_nr)) && (sold < sellnum)) { sold++; goldamt += sell_price(ch, obj, shop_nr); GET_GOLD(keeper) -= sell_price(ch, obj, shop_nr); obj_from_char(obj); tag = slide_obj(obj, keeper, shop_nr); obj = get_selling_obj(ch, name, keeper, shop_nr, FALSE); } if (sold < sellnum) { if (!obj) sprintf(buf, "%s You only have %d of those.", GET_NAME(ch), sold); else if (GET_GOLD(keeper) + SHOP_BANK(shop_nr) < sell_price(ch, obj, shop_nr)) sprintf(buf, "%s I can only afford to buy %d of those.", GET_NAME(ch), sold); else sprintf(buf, "%s Something really screwy made me buy %d.", GET_NAME(ch), sold); do_tell(keeper, buf, cmd_tell, 0); } GET_GOLD(ch) += goldamt; strcpy(tempstr, times_message(0, shortd, sold)); sprintf(buf, "$n sells %s.", tempstr); act(buf, FALSE, ch, obj, 0, TO_ROOM); sprintf(buf, shop_index[shop_nr].message_sell, GET_NAME(ch), goldamt); do_tell(keeper, buf, cmd_tell, 0); sprintf(buf, "The shopkeeper now has %s.\n\r", tempstr); send_to_char(buf, ch); if (GET_GOLD(keeper) < MIN_OUTSIDE_BANK) { goldamt = MIN(MAX_OUTSIDE_BANK - GET_GOLD(keeper), SHOP_BANK(shop_nr)); SHOP_BANK(shop_nr) -= goldamt; GET_GOLD(keeper) += goldamt; } }
void select_target( CHAR_DATA * ch ) { /* * Find a new target for the group to go after */ int average_level; // int tmp = 0; CHAR_DATA *vch; CHAR_DATA *victim = NULL; list<CHAR_DATA *>::iterator li; char buf[MAX_STRING_LENGTH]; int force_index = 0; bool alone = TRUE; bool mob_is_leader = FALSE; short attempts; /* * mobs were doing ethereal travel too much... i've now lowered it to * * 15% of the time and only if they are not hunting */ mob_is_leader = is_group_leader( ch ); if ( ( number_percent( ) < 15 ) && ( ch->hunting == NULL ) && ( ch->in_room->vnum != ROOM_VNUM_ETHEREAL_PLANE ) ) /* was victim == NULL, that's always true at this point.. Zen */ { if ( mob_is_leader == TRUE ) { for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room ) { if ( ( is_same_group( ch, vch ) ) == TRUE ) { if ( vch->mana < mana_cost( vch, skill_lookup( "ethereal travel" ) ) ) { return; } } } } if ( ch->mana < mana_cost( ch, skill_lookup( "ethereal travel" ) ) ) return; do_say( ch, "This place is boring! I am gonna go somewhere else!" ); for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room ) { if ( ( is_same_group( vch, ch ) ) && ( ch != vch ) ) { do_say( vch, "Yeah, it is--we're outta here!" ); do_cast( vch, "ethereal" ); } } do_cast( ch, "ethereal" ); } else { /* * keeps checking until you've found a valid target */ attempts = 0; while ( ( victim == NULL ) && ( attempts < 15 ) ) { // ZEN FIX set average level based on level of ngroup attempts++; average_level = ch->get_level("psuedo"); force_index = number_range( 1, mob_index_list.size() ); for ( li = char_list.begin(); li != char_list.end(); li++ ) { vch = *li; if ( victim != NULL ) break; force_index--; if ( force_index > 0 ) continue; if ( valid_target( ch, vch, average_level ) ) { /* * Trick used in something else... */ if ( number_range( 0, 1 ) == 0 ) { victim = vch; } if ( victim == NULL ) /* screwed up somehow */ { continue; } if ( !IS_NPC( victim ) ) { for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room ) { if ( is_same_group( ch, vch ) ) { alone = FALSE; break; } } if ( alone == FALSE ) { snprintf( buf, MSL, "%s We're coming for you!", victim->name.c_str() ); do_tell( ch, buf ); } else { snprintf( buf, MSL, "%s I'm coming for you!", victim->name.c_str() ); do_tell( ch, buf ); } } } } } if ( set_hunt( ch, NULL, victim, NULL, HUNT_WORLD | HUNT_PICKDOOR | HUNT_CR, HUNT_MERC ) ) { snprintf( buf, MSL, "Right! %s is our new target!!", victim->get_name() ); do_say( ch, buf ); } return; } return; }
void do_send( CHAR_DATA *ch, char *argument ) { BANK_DATA *bank; BANK_DATA *victim_bank; CHAR_DATA *banker; char buf[MAX_STRING_LENGTH]; int type = DEFAULT_CURR; int amount = 0; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; if ( !( banker = find_banker( ch ) ) ) { send_to_char( "You're not in a bank!\r\n", ch ); return; } if ( IS_NPC( ch ) ) { snprintf( buf, MSL, "say Sorry, %s, we don't do business with mobs.", ch->name ); interpret( banker, buf ); return; } if ( argument[0] == '\0' ) { send_to_char( "Syntax: send [amount] [currency] [destination account]\r\n\r\n", ch ); interpret( banker, ( char * ) "say if you need help type &WHELP BANK&D." ); return; } if ( ch->pcdata->bank == NULL ) { send_to_char( "You don't have any bank account open now.\r\n", ch ); return; } /* * Just to make sure that we are retrieving the latest bank info,not relying on the * stale bank info in pcdata struct */ bank = find_bank( ch->pcdata->bank->name ); if ( !bank ) { send_to_char( "There is no account by that name!\r\n", ch ); return; } argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if ( !str_cmp( arg1, "all" ) ) { amount = -1; } else if ( !is_number( arg1 ) ) { send_to_char( "You can only withdraw coins.\r\n", ch ); return; } else { amount = atoi( arg1 ); } if ( arg1 && arg2 ) type = get_currency_type( arg2 ); if ( type == CURR_NONE ) { send_to_char( "You don't have any of that kind of coin.\r\n", ch ); return; } if ( amount <= 0 ) { send_to_char( "You can't do that.\r\n", ch ); return; } victim_bank = find_bank( arg3 ); if ( !victim_bank ) { sprintf( buf, "%s There is no account by that name here.", ch->name ); do_tell( banker, buf ); return; } if ( type == CURR_BRONZE ) { if ( amount > bank->bronze ) { ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] ); return; } bank->bronze -= amount; victim_bank->bronze += amount; } else if ( type == CURR_COPPER ) { if ( amount > bank->copper ) { ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] ); return; } bank->copper -= amount; victim_bank->copper += amount; } else if ( type == CURR_GOLD ) { if ( amount > bank->gold ) { ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] ); return; } bank->gold -= amount; victim_bank->gold += amount; } else if ( type == CURR_SILVER ) { if ( amount > bank->silver ) { ch_printf( ch, "You don't have that much %s in the bank.\r\n", curr_types[type] ); return; } bank->silver -= amount; victim_bank->silver += amount; } ch_printf( ch, "You send %d %s coins from your account to theirs.\r\n", amount, curr_types[type] ); bank->lastused = current_time; save_bank( ); return; }
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_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; }
void do_withdraw( CHAR_DATA * ch, char *argument ) { CHAR_DATA *banker; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; bool isgold = FALSE; bool issilver = FALSE; bool iscopper = FALSE; long int amount; long int thebalance; if( !( banker = find_banker( ch ) ) ) { send_to_char( "&WYou're not in a bank!&w\r\n", ch ); return; } if( IS_NPC( ch ) ) { sprintf( buf, "Sorry, %s, we don't do business with mobs.", ch->short_descr ); do_say( banker, buf ); return; } if( argument[0] == '\0' ) { do_say( banker, "If you need help, see HELP BANK." ); return; } argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if( arg1 == '\0' ) { sprintf( buf, "%s How much do you wish to withdraw?", ch->name ); do_tell( banker, buf ); return; } if( str_cmp( arg1, "all" ) && !is_number( arg1 ) ) { sprintf( buf, "%s How much do you wish to withdraw?", ch->name ); do_tell( banker, buf ); return; } if( arg2 == '\0' || ( str_cmp( arg2, "gold" ) && str_cmp( arg2, "silver" ) && str_cmp( arg2, "copper" ) ) ) { sprintf( buf, "%s You must specify gold, silver, or copper.", ch->name ); do_tell( banker, buf ); return; } if( !str_cmp( arg2, "gold" ) ) { isgold = TRUE; thebalance = ch->pcdata->gbalance; } else if( !str_cmp( arg2, "silver" ) ) { issilver = TRUE; thebalance = ch->pcdata->sbalance; } else if( !str_cmp( arg2, "copper" ) ) { iscopper = TRUE; thebalance = ch->pcdata->balance; } else { bug( "Invalid money type in banks. Error code: Er21302 Please report this code to Garinan." ); return; } if( !str_cmp( arg1, "all" ) ) isgold ? ( amount = ch->pcdata->gbalance ) : issilver ? ( amount = ch->pcdata->sbalance ) : ( amount = ch->pcdata->balance ); else amount = atoi( arg1 ); if( amount > thebalance ) { sprintf( buf, "%s But you do not have that much %s in your account!", ch->name, isgold ? "gold" : issilver ? "silver" : "copper" ); do_tell( banker, buf ); return; } if( amount <= 0 ) { sprintf( buf, "%s Oh I see.. I didn't know i was doing business with a comedian.", ch->name ); do_tell( banker, buf ); return; } if( iscopper ) { ch->pcdata->balance -= amount; ch->copper += amount; } else if( isgold ) { ch->pcdata->gbalance -= amount; ch->gold += amount; } else if( issilver ) { ch->pcdata->sbalance -= amount; ch->silver += amount; } else { bug( "Invalid money type in banks. Error code: Er21303 Please report this code to Garinan." ); return; } sprintf( buf, "You withdraw %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "" ); set_char_color( AT_WHITE, ch ); send_to_char( buf, ch ); sprintf( buf, "$n withdraws %ld %s coin%s.\r\n", amount, isgold ? "gold" : issilver ? "silver" : "copper", ( amount != 1 ) ? "s" : "" ); act( AT_WHITE, buf, ch, NULL, NULL, TO_ROOM ); return; }