#!/usr/bin/perl # These are a series of changes to vanilla angband 3.1 series. # They consist of ideas that have not been accepted into V, # may not ever get in, but have considerable support. { # always mark the code as modified # change_version_name(); # comment out if you hate something # squelch_prompt_option(); # no_selling_option(); store_buyout_button(); } sub change_version_name { rename("defines.h", "defines.hold") || die ("cannot rename defines.h to defines.hold"); open(OLD, "defines.hold") || die ("cannot open defines.hold"); open(DEFINESH, ">defines.h") || die ("cannot write to defines.h"); while($_ = ) { if (/(.*VERSION_STRING.*)(\s+)(dev.*)/) { print DEFINESH "$1e$2$3\n"; } else { print DEFINESH $_; } } close(OLD); close(DEFINESH); unlink("defines.hold"); } sub store_buyout_button { rename("store.c", "store.cold") || die ("cannot rename store.c to store.cold"); open(OLD, "store.cold") || die ("cannot open store.cold"); open(STOREC, ">store.c") || die ("cannot write to store.c"); while ($_ = ) { if (/an item from your inventory/) { print STOREC $_; $text = ' if (current_store() != STORE_HOME) { text_out_c(TERM_L_GREEN, "K"); text_out(" restocks the store."); } '; print STOREC $text; } elsif (/store_display_help\(\)/) { print STOREC $_; $text = ' else if (current_store() != STORE_HOME) prt("\'?\' for help, \'K\' restocks store", scr_places_y[LOC_HELP_PROMPT], 1); '; print STOREC $text; } elsif (/Process a command in a store/) { $later = $_; $text = ' * Buy out the store so it will restock */ static bool store_purchase_all(void) { int i; store_type *st_ptr = &store[current_store()]; object_type *o_ptr; s32b price; /* Clear all current messages */ msg_flag = FALSE; prt("", 0, 0); if (current_store() == STORE_HOME) { /* this routine should not have been called from home */ prt("Deleting all items stored at home currently not implemented.", 1, 0); return FALSE; } price = 0; for (i = 0; i < st_ptr->stock_num; i++) { /* Get the existing object */ o_ptr = &st_ptr->stock[i]; price += price_item(o_ptr, FALSE, o_ptr->number); } /* Check if the player can afford it */ if ((u32b)p_ptr->au < (u32b)price) { /* Tell the user */ msg_print("You do not have enough gold to buy out this store."); store_flags |= STORE_KEEP_PROMPT; /* Abort now */ return FALSE; } screen_save(); /* Show price */ prt(format("Total cost: %d", price), 1, 0); /* Confirm purchase */ if (store_get_check("Restock the store? [ESC, any other key to accept]")) screen_load(); else { screen_load(); return FALSE; } /* Spend the money */ p_ptr->au -= price; /* Update the display */ store_flags |= STORE_GOLD_CHANGE; /* Message */ if (one_in_(3)) message(MSG_STORE5, 0, ONE_OF(comment_accept)); msg_format("You restocked the store for %ld gold.", (long)price); store_flags |= STORE_KEEP_PROMPT; /* Handle stuff */ handle_stuff(); /* Buying an object makes you aware of it */ for (i = 0; i < st_ptr->stock_num; i++) { /* Get the existing object */ o_ptr = &st_ptr->stock[i]; object_flavor_aware(o_ptr); } /* in case by buying you the store became aware of flavor in pack */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* Empty the store */ st_ptr->stock_num =0; /* Shuffle */ if (one_in_(STORE_SHUFFLE)) { /* Message */ msg_print("The shopkeeper retires."); /* Shuffle the store */ store_shuffle(current_store()); store_flags |= STORE_INIT_CHANGE; } /* Maintain */ else { /* Message */ msg_print("The shopkeeper brings out some new stock."); } /* New inventory */ for (i = 0; i < 10; ++i) { /* Maintain the store */ store_maint(current_store()); } /* Not kicked out */ return TRUE; } /* '; print STOREC $text; print STOREC $later; } elsif (/switch \(cmd\)/) { print STOREC $_; $_ = ; print STOREC $_; $text = ' /* new command to buy out a store */ case \'K\': { if (store_purchase_all()) return TRUE; break; } '; print STOREC $text; } elsif (/(.*menu.cmd_keys = ")(.*)/) { print STOREC "$1K$2\n"; } else { print STOREC $_; } } close(OLD); close(STOREC); unlink("store.cold"); }