From 77fa8ec7c240813906737b9750743bc9c19fb88c Mon Sep 17 00:00:00 2001 From: Matthew Tadd Date: Fri, 22 Feb 2013 16:06:51 -0500 Subject: [PATCH] viking patch --- src/defines.h | 8 ++-- src/object2.c | 151 ++++++++++++++++++++++++++++++++++++++++++++-------------- src/tables.c | 13 ++--- 3 files changed, 126 insertions(+), 46 deletions(-) diff --git a/src/defines.h b/src/defines.h index f03cce0..fe2f04b 100644 --- a/src/defines.h +++ b/src/defines.h @@ -2534,7 +2534,7 @@ // xxx birth_preserve #define OPT_birth_discon_stair (OPT_BIRTH+3) #define OPT_birth_ironman (OPT_BIRTH+4) -// xxx birth_no_stores +#define OPT_birth_no_magic_items (OPT_BIRTH+5) #define OPT_birth_no_artefacts (OPT_BIRTH+6) // xxx birth_rand_artefacts // xxx birth_no_stacking @@ -2566,7 +2566,7 @@ // xxx adult_preserve #define OPT_adult_discon_stair (OPT_ADULT+3) #define OPT_adult_ironman (OPT_ADULT+4) -// xxx adult_no_stores +#define OPT_adult_no_magic_items (OPT_ADULT+5) #define OPT_adult_no_artefacts (OPT_ADULT+6) // xxx adult_rand_artefacts // xxx adult_no_stacking @@ -2678,7 +2678,7 @@ // xxx birth_preserve #define birth_discon_stair op_ptr->opt[OPT_birth_discon_stair] #define birth_ironman op_ptr->opt[OPT_birth_ironman] -// xxx birth_no_stores +#define birth_no_magic_items op_ptr->opt[OPT_birth_no_magic_items] #define birth_no_artefacts op_ptr->opt[OPT_birth_no_artefacts] // xxx birth_rand_artefacts @@ -2714,7 +2714,7 @@ // xxx adult_preserve #define adult_discon_stair op_ptr->opt[OPT_adult_discon_stair] #define adult_ironman op_ptr->opt[OPT_adult_ironman] -// xxx adult_no_stores +#define adult_no_magic_items op_ptr->opt[OPT_adult_no_magic_items] #define adult_no_artefacts op_ptr->opt[OPT_adult_no_artefacts] // Sil: set directly to false at the moment, as they are currently incompatible with Sil diff --git a/src/object2.c b/src/object2.c index f44af1a..d8c1106 100644 --- a/src/object2.c +++ b/src/object2.c @@ -1909,6 +1909,7 @@ static void charge_staff(object_type *o_ptr) } } + /* * * Determines the theme of a chest. This function is called @@ -1918,22 +1919,39 @@ static void charge_staff(object_type *o_ptr) static int choose_chest_contents(void) { /* - * chest theme # 1 is potions (+ herbs of restoring) - * chest theme # 2 is staffs - * chest theme # 3 is shields - * chest theme # 4 is weapons - * chest theme # 5 is armor - * chest theme # 6 is boots - * chest theme # 7 is bow - * chest theme # 8 is cloak - * chest theme # 9 is gloves - * chest theme #10 is edged weapons - * chest theme #11 is polearms - * chest theme #12 is helms and crowns - * chest theme #13 is jewelry + * Note that the table entries can be in any order, and/or + * include duplicates to get non-uniform theme distribution. */ - - return (dieroll(13)); + static byte theme_table[] = { + DROP_TYPE_POTION, /* + herbs of restoring */ + DROP_TYPE_STAFF, + DROP_TYPE_SHIELD, + DROP_TYPE_WEAPON, + DROP_TYPE_ARMOR, + DROP_TYPE_BOOTS, + DROP_TYPE_BOW, + DROP_TYPE_CLOAK, + DROP_TYPE_GLOVES, + DROP_TYPE_EDGED, + DROP_TYPE_POLEARM, + DROP_TYPE_HEADGEAR, + DROP_TYPE_JEWELRY, + }; + static int table_size = (sizeof(theme_table))/sizeof(byte); + + + int theme = theme_table[rand_int(table_size)]; + + // Hack - dis-allow certain drop types for certain challenges + if (adult_no_magic_items) { + if ((DROP_TYPE_STAFF == theme) || (DROP_TYPE_JEWELRY == theme)) { + theme = DROP_TYPE_NOT_USELESS; + } + // Note: DROP_TYPE_TRUMPET currently doesn't exist, but if it + // ever does, it will need to be dis-allowed here as well. + } + + return theme; } /* @@ -2525,6 +2543,17 @@ void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great, /* Get no rolls if not allowed */ if (!okay || o_ptr->name1) artefact_rolls = 0; + /* Check for challenge restrictions */ + if (adult_no_artefacts) artefact_rolls = 0; + if (adult_no_magic_items) { + // Change "special" items to be merely "fine" + if (special) { + special = FALSE; + fine = TRUE; + } + } + + /* Roll for artefacts if allowed */ for (i = 0; i < artefact_rolls; i++) { @@ -2796,24 +2825,66 @@ static bool kind_is_great(int k_idx) static bool kind_is_not_useless(int k_idx) { object_kind *k_ptr = &k_info[k_idx]; - + /* Analyze the item type */ switch (k_ptr->tval) { - + /* Useless -- Bad */ case TV_USELESS: { return (FALSE); } - + } - + + /* Assume good */ + return (TRUE); +} + + +/* + * Hack -- determine if a template is not a magic item + * + */ +static bool kind_is_not_magic(int k_idx) +{ + object_kind *k_ptr = &k_info[k_idx]; + + /* Analyze the item type */ + switch (k_ptr->tval) + { + case TV_RING: + case TV_AMULET: + case TV_STAFF: + case TV_TRUMPET: + { + return (FALSE); + } + + case TV_LIGHT: + { + if (SV_LIGHT_FEANORIAN == k_ptr->sval) return (FALSE); + if (SV_LIGHT_LESSER_JEWEL == k_ptr->sval) return (FALSE); + } + + case TV_CLOAK: + { + if (SV_SHADOW_CLOAK == k_ptr->sval) return (FALSE); + } + } + /* Assume good */ return (TRUE); } +static bool kind_is_not_magic_and_not_useless(int k_idx) +{ + return (kind_is_not_magic(k_idx) && kind_is_not_useless(k_idx)); +} + + /* * Hack -- determine if a template is a chest. * @@ -3311,7 +3382,15 @@ bool make_object(object_type *j_ptr, bool good, bool great, int objecttype) int k_idx; // unlike the others, this type can be overridden by 'great' and 'good' - if (objecttype == DROP_TYPE_NOT_USELESS) get_obj_num_hook = kind_is_not_useless; + if (objecttype == DROP_TYPE_NOT_USELESS) get_obj_num_hook = kind_is_not_useless; + + /* Hack - special handling for the "no magic items" challenge */ + if (adult_no_magic_items) { + if (objecttype == DROP_TYPE_UNTHEMED) get_obj_num_hook = kind_is_not_magic; + if (objecttype == DROP_TYPE_NOT_USELESS) { + get_obj_num_hook = kind_is_not_magic_and_not_useless; + } + } /* * Next check if it is a themed drop, and @@ -3321,20 +3400,20 @@ bool make_object(object_type *j_ptr, bool good, bool great, int objecttype) */ if ((good) || (great) || (objecttype > DROP_TYPE_NOT_USELESS)) { - if (objecttype == DROP_TYPE_POTION) get_obj_num_hook = kind_is_potion; - else if (objecttype == DROP_TYPE_STAFF) get_obj_num_hook = kind_is_staff; - else if (objecttype == DROP_TYPE_SHIELD) get_obj_num_hook = kind_is_shield; - else if (objecttype == DROP_TYPE_WEAPON) get_obj_num_hook = kind_is_weapon; - else if (objecttype == DROP_TYPE_ARMOR) get_obj_num_hook = kind_is_armor; - else if (objecttype == DROP_TYPE_BOOTS) get_obj_num_hook = kind_is_boots; - else if (objecttype == DROP_TYPE_BOW) get_obj_num_hook = kind_is_bow; - else if (objecttype == DROP_TYPE_CLOAK) get_obj_num_hook = kind_is_cloak; - else if (objecttype == DROP_TYPE_GLOVES) get_obj_num_hook = kind_is_gloves; - else if (objecttype == DROP_TYPE_EDGED) get_obj_num_hook = kind_is_edged; - else if (objecttype == DROP_TYPE_POLEARM) get_obj_num_hook = kind_is_polearm; - else if (objecttype == DROP_TYPE_HEADGEAR) get_obj_num_hook = kind_is_headgear; - else if (objecttype == DROP_TYPE_JEWELRY) get_obj_num_hook = kind_is_jewelry; - else if (objecttype == DROP_TYPE_CHEST) get_obj_num_hook = kind_is_chest; + if (objecttype == DROP_TYPE_POTION) get_obj_num_hook = kind_is_potion; + else if (objecttype == DROP_TYPE_STAFF) get_obj_num_hook = kind_is_staff; + else if (objecttype == DROP_TYPE_SHIELD) get_obj_num_hook = kind_is_shield; + else if (objecttype == DROP_TYPE_WEAPON) get_obj_num_hook = kind_is_weapon; + else if (objecttype == DROP_TYPE_ARMOR) get_obj_num_hook = kind_is_armor; + else if (objecttype == DROP_TYPE_BOOTS) get_obj_num_hook = kind_is_boots; + else if (objecttype == DROP_TYPE_BOW) get_obj_num_hook = kind_is_bow; + else if (objecttype == DROP_TYPE_CLOAK) get_obj_num_hook = kind_is_cloak; + else if (objecttype == DROP_TYPE_GLOVES) get_obj_num_hook = kind_is_gloves; + else if (objecttype == DROP_TYPE_EDGED) get_obj_num_hook = kind_is_edged; + else if (objecttype == DROP_TYPE_POLEARM) get_obj_num_hook = kind_is_polearm; + else if (objecttype == DROP_TYPE_HEADGEAR) get_obj_num_hook = kind_is_headgear; + else if (objecttype == DROP_TYPE_JEWELRY) get_obj_num_hook = kind_is_jewelry; + else if (objecttype == DROP_TYPE_CHEST) get_obj_num_hook = kind_is_chest; /* * If it isn't a chest, check good and great flags. @@ -3345,7 +3424,7 @@ bool make_object(object_type *j_ptr, bool good, bool great, int objecttype) } /* Prepare allocation table if needed*/ - if ((objecttype) || (good) || (great)) + if ((objecttype) || (good) || (great) || (adult_no_magic_items)) { get_obj_num_prep(); } @@ -3354,7 +3433,7 @@ bool make_object(object_type *j_ptr, bool good, bool great, int objecttype) k_idx = get_obj_num(base); /* Clear the objects template*/ - if ((objecttype) || (good) || (great)) + if ((objecttype) || (good) || (great) || (adult_no_magic_items)) { /* Clear restriction */ get_obj_num_hook = NULL; diff --git a/src/tables.c b/src/tables.c index bf8b14c..db4b5f1 100644 --- a/src/tables.c +++ b/src/tables.c @@ -399,7 +399,7 @@ cptr option_text[OPT_MAX] = NULL, /* xxx birth_maximize */ "birth_discon_stair", /* OPT_birth_discon_stair */ "birth_ironman", /* OPT_birth_ironman */ - NULL, /* xxx birth_no_stores */ + "birth_no_magic_items", /* OPT_birth_no_magic_items */ "birth_no_artefacts", /* OPT_birth_no_artefacts */ NULL, /* xxx birth_rand_artefacts */ NULL, /* xxx birth_no_stacking */ @@ -463,7 +463,7 @@ cptr option_text[OPT_MAX] = NULL, /* xxx adult_maximize */ "adult_discon_stair", /* OPT_adult_discon_stair */ "adult_ironman", /* OPT_adult_ironman */ - NULL, /* xxx adult_no_stores */ + "adult_no_magic_items", /* OPT_adult_no_magic_items */ "adult_no_artefacts", /* OPT_adult_no_artefacts */ NULL, /* xxx adult_rand_artefacts */ NULL, /* xxx adult_no_stacking */ @@ -663,7 +663,7 @@ cptr option_desc[OPT_MAX] = NULL, /* xxx birth_maximize */ "Disconnected stairs", /* OPT_birth_discon_stair */ "Straight down (no up stairs until endgame)",/* OPT_birth_ironman */ - NULL, /* xxx birth_no_stores */ + "No magic items", /* OPT_birth_no_magic_items */ "No artefacts", /* OPT_birth_no_artefacts */ NULL, /* xxx birth_rand_artefacts */ NULL, /* xxx birth_no_stacking */ @@ -727,7 +727,7 @@ cptr option_desc[OPT_MAX] = NULL, /* xxx adult_maximize */ "Disconnected stairs", /* OPT_adult_discon_stair */ "Straight down (no up stairs until endgame)",/* OPT_adult_ironman */ - NULL, /* xxx adult_no_stores */ + "No magic items", /* OPT_adult_no_magic_items */ "No artefacts", /* OPT_adult_no_artefacts */ NULL, /* xxx adult_rand_artefacts */ NULL, /* xxx adult_adult_no_stacking */ @@ -928,7 +928,7 @@ const bool option_norm[OPT_MAX] = FALSE, /* xxx birth_maximize */ FALSE, /* OPT_birth_discon_stair */ FALSE, /* OPT_birth_ironman */ - FALSE, /* xxx birth_no_stores */ + FALSE, /* OPT_birth_no_magic_items */ FALSE, /* OPT_birth_no_artefacts */ FALSE, /* xxx birth_rand_artefacts */ FALSE, /* xxx birth_no_stacking */ @@ -992,7 +992,7 @@ const bool option_norm[OPT_MAX] = FALSE, /* xxx adult_maximize */ FALSE, /* OPT_adult_discon_stair */ FALSE, /* OPT_adult_ironman */ - FALSE, /* xxx adult_no_stores */ + FALSE, /* OPT_adult_no_magic_items */ FALSE, /* OPT_adult_no_artefacts */ FALSE, /* xxx adult_rand_artefacts */ FALSE, /* xxx adult_no_stacking */ @@ -1189,6 +1189,7 @@ const byte option_page[OPT_PAGE_MAX][OPT_PAGE_PER] = OPT_birth_discon_stair, OPT_birth_ironman, OPT_birth_no_artefacts, + OPT_birth_no_magic_items, OPT_NONE, OPT_NONE, OPT_NONE, -- 1.8.1.3