diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/birth.c | 6 | ||||
-rw-r--r-- | src/cmd4.c | 5 | ||||
-rw-r--r-- | src/cmd5.c | 2 | ||||
-rw-r--r-- | src/cmd6.c | 4 | ||||
-rw-r--r-- | src/corrupt.c | 916 | ||||
-rw-r--r-- | src/defines.h | 39 | ||||
-rw-r--r-- | src/externs.h | 53 | ||||
-rw-r--r-- | src/files.c | 6 | ||||
-rw-r--r-- | src/init2.c | 8 | ||||
-rw-r--r-- | src/loadsave.c | 9 | ||||
-rw-r--r-- | src/lua_bind.c | 166 | ||||
-rw-r--r-- | src/melee1.c | 2 | ||||
-rw-r--r-- | src/player.pkg | 78 | ||||
-rw-r--r-- | src/script.c | 3 | ||||
-rw-r--r-- | src/tables.c | 1 | ||||
-rw-r--r-- | src/types.h | 20 | ||||
-rw-r--r-- | src/variable.c | 43 | ||||
-rw-r--r-- | src/wizard2.c | 2 | ||||
-rw-r--r-- | src/xtra2.c | 65 |
20 files changed, 1043 insertions, 387 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2e62644..d610e193 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,7 @@ SET(SRCS object1.c object2.c randart.c squeltch.c traps.c monster1.c monster2.c monster3.c xtra1.c xtra2.c skills.c powers.c gods.c - spells1.c spells2.c + spells1.c spells2.c corrupt.c status.c files.c notes.c loadsave.c cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c help.c diff --git a/src/birth.c b/src/birth.c index 263877fe..f050f9d1 100644 --- a/src/birth.c +++ b/src/birth.c @@ -823,7 +823,6 @@ static void player_wipe(void) int i, j; bool_ *powers; - bool_ *corruptions; /* Wipe special levels */ @@ -831,21 +830,16 @@ static void player_wipe(void) /* Save the powers & corruptions */ powers = p_ptr->powers; - corruptions = p_ptr->corruptions; /* Hack -- zero the struct */ p_ptr = WIPE(p_ptr, player_type); /* Restore the powers & corruptions */ p_ptr->powers = powers; - p_ptr->corruptions = corruptions; /* Not dead yet */ p_ptr->lives = 0; - /* Wipe the corruptions */ - (void)C_WIPE(p_ptr->corruptions, max_corruptions, bool_); - /* Wipe the history */ for (i = 0; i < 4; i++) { @@ -4069,7 +4069,10 @@ void do_cmd_knowledge_corruptions(void) fff = my_fopen(file_name, "w"); /* Dump the corruptions to file */ - if (fff) dump_corruptions(fff, TRUE); + if (fff) + { + dump_corruptions(fff, TRUE, FALSE); + } /* Close the file */ my_fclose(fff); @@ -236,7 +236,7 @@ void do_poly_self(void) /* Polymorph into a less corrupted form */ power -= 10; - lose_corruption(0); + lose_corruption(); } /* @@ -2347,7 +2347,7 @@ static bool_ quaff_potion(int tval, int sval, int pval, int pval2) } msg_print("You feel the dark corruptions of Morgoth coming over you!"); - gain_random_corruption(0); + gain_random_corruption(); ident = TRUE; break; } @@ -7220,7 +7220,7 @@ const char *activation_aux(object_type * o_ptr, bool_ doit, int item) case ACT_MUT: { if (!doit) return "gain corruption every 10 turns"; - gain_random_corruption(0); + gain_random_corruption(); /* Timeout is set before return */ break; diff --git a/src/corrupt.c b/src/corrupt.c new file mode 100644 index 00000000..25570303 --- /dev/null +++ b/src/corrupt.c @@ -0,0 +1,916 @@ +#include "angband.h" +#include <assert.h> + +/** + * Vampire corruption helpers + */ + +static void subrace_add_power(player_race_mod *rmp_ptr, int power) +{ + int i; + + for (i=0; i<4; i++) + { + if (rmp_ptr->powers[i] == -1) + { + rmp_ptr->powers[i] = power; + return; + } + } +} + +static void player_gain_vampire_teeth() +{ + player_race_mod *rmp_ptr = NULL; + + switch_subrace(SUBRACE_SAVE, TRUE); + + rmp_ptr = &race_mod_info[SUBRACE_SAVE]; + subrace_add_power(rmp_ptr, PWR_VAMPIRISM); + rmp_ptr->flags1 = rmp_ptr->flags1 + | PR1_VAMPIRE + | PR1_UNDEAD + | PR1_NO_SUBRACE_CHANGE; +} + +static void player_gain_vampire_strength() +{ + player_race_mod *rmp_ptr = &race_mod_info[SUBRACE_SAVE]; + /* Apply the bonuses/penalities */ + rmp_ptr->r_mhp = rmp_ptr->r_mhp + 1; + rmp_ptr->r_exp = rmp_ptr->r_exp + 100; + + rmp_ptr->r_adj[A_STR + 1] = rmp_ptr->r_adj[A_STR + 1] + 3; + rmp_ptr->r_adj[A_INT + 1] = rmp_ptr->r_adj[A_INT + 1] + 2; + rmp_ptr->r_adj[A_WIS + 1] = rmp_ptr->r_adj[A_WIS + 1] - 3; + rmp_ptr->r_adj[A_DEX + 1] = rmp_ptr->r_adj[A_DEX + 1] - 2; + rmp_ptr->r_adj[A_CON + 1] = rmp_ptr->r_adj[A_CON + 1] + 1; + rmp_ptr->r_adj[A_CHR + 1] = rmp_ptr->r_adj[A_CHR + 1] - 4; + + /* be reborn! */ + do_rebirth(); + cmsg_print(TERM_L_DARK, "You feel death slipping inside."); +} + +static void player_gain_vampire() +{ + player_race_mod *rmp_ptr = &race_mod_info[SUBRACE_SAVE]; + + /* Be a Vampire and be proud of it */ + cptr title = get_subrace_title(SUBRACE_SAVE); + if (streq(title, " ") || streq(title, "Vampire")) + { + title = "Vampire"; + rmp_ptr->place = FALSE; + set_subrace_title(SUBRACE_SAVE, title); + } + else + { + char buf[512]; + sprintf(buf, "Vampire %s", title); + set_subrace_title(SUBRACE_SAVE, buf); + } + + /* Bonus/and .. not bonus :) */ + rmp_ptr->flags1 = rmp_ptr->flags1 | PR1_HURT_LITE; + rmp_ptr->oflags2[2] = rmp_ptr->oflags2[2] + | TR2_RES_POIS + | TR2_RES_NETHER + | TR2_RES_COLD + | TR2_RES_DARK + | TR2_HOLD_LIFE; + rmp_ptr->oflags3[2] = rmp_ptr->oflags3[2] + | TR3_LITE1; +} + +/** + * Corruptions + */ +corruption_type corruptions[CORRUPTIONS_MAX] = +{ + /* + * BALROG corruptions + */ + + { /* 0 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_ORANGE, + NULL /* no group */, + "Balrog Aura", + "A corrupted wall of flames surrounds you.", + "The wall of corrupted flames abandons you.", + " Surrounds you with a fiery aura\n" + " But it can burn scrolls when you read them", + { -1 }, + { -1 }, + NULL, + }, + + { /* 1 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_ORANGE, + NULL /* no group */, + "Balrog Wings", + "Wings of shadow grow in your back.", + "The wings in your back fall apart.", + " Creates ugly, but working, wings allowing you to fly\n" + " But it reduces charisma by 4 and dexterity by 2", + { -1 }, + { -1 }, + NULL, + }, + + { /* 2 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_ORANGE, + NULL /* no group */, + "Balrog Strength", + "Your muscles get unnatural strength.", + "Your muscles get weaker again.", + " Provides 3 strength and 1 constitution\n" + " But it reduces charisma by 1 and dexterity by 3", + { -1 }, + { -1 }, + NULL, + }, + + { /* 3 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_YELLOW, + NULL /* no group */, + "Balrog Form", + "You feel the might of a Balrog inside you.", + "The presence of the Balrog seems to abandon you.", + " Allows you to turn into a Balrog at will\n" + " You need Balrog Wings, Balrog Aura and Balrog Strength to activate it", + { CORRUPT_BALROG_AURA, CORRUPT_BALROG_WINGS, CORRUPT_BALROG_STRENGTH }, + { -1 }, + NULL, + }, + + /* + * DEMON corruptions + */ + { /* 4 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Demon Spirit", + "Your spirit opens to corrupted thoughts.", + "Your spirit closes again to the corrupted thoughts.", + " Increases your intelligence by 1\n" + " But reduce your charisma by 2", + { -1 }, + { -1 }, + NULL, + }, + + { /* 5 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Demon Hide", + "Your skin grows into a thick hide.", + "Your skin returns to a natural state.", + " Increases your armour class by your level\n" + " Provides immunity to fire at level 40\n" + " But reduces speed by your level / 7", + { -1 }, + { -1 }, + NULL, + }, + + { /* 6 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Demon Breath", + "Your breath becomes mephitic.", + "Your breath is once again normal.", + " Provides fire breath\n" + " But gives a small chance to spoil potions when you quaff them", + { -1 }, + { -1 }, + NULL, + }, + + { /* 7 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_L_RED, + NULL /* no group */, + "Demon Realm", + "You feel more attuned to the demon realm.", + "You lose your attunement to the demon realm.", + " Provides access to the demon school skill and the use of demonic equipment\n" + " You need Demon Spirit, Demon Hide and Demon Breath to activate it", + { CORRUPT_DEMON_SPIRIT, CORRUPT_DEMON_HIDE, CORRUPT_DEMON_BREATH }, + { -1 }, + NULL, + }, + + /* + * Teleportation corruptions + */ + + { /* 8 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_GREEN, + NULL /* no group */, + "Random teleportation", + "Space seems to fizzle around you.", + "Space solidify again around you.", + " Randomly teleports you around", + { -1 }, + { CORRUPT_ANTI_TELEPORT, -1 }, + NULL, + }, + + { /* 9 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_GREEN, + NULL /* no group */, + "Anti-teleportation", + "Space continuum freezes around you.", + "Space continuum can once more be altered around you.", + " Prevents all teleportations, be it of you or monsters", + { -1 }, + { CORRUPT_RANDOM_TELEPORT, -1 }, + NULL, + }, + + /* + * Troll blood + */ + + { /* 10 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_GREEN, + NULL /* no group */, + "Troll Blood", + "Your blood thickens, you sense corruption in it.", + "Your blood returns to a normal state.", + " Troll blood flows in your veins, granting increased regeneration\n" + " It also enables you to feel the presence of other troll beings\n" + " But it will make your presence more noticeable and aggravating", + { -1 }, + { -1 }, + NULL, + }, + + /* + * The vampire corruption set + */ + + { /* 11 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_L_DARK, + "Vampire", + "Vampiric Teeth", + "You grow vampiric teeth!", + NULL, /* cannot lose */ + " Your teeth allow you to drain blood to feed yourself\n" + " However your stomach now only accepts blood.", + { -1 }, + { -1 }, + player_gain_vampire_teeth, + }, + + { /* 12 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_L_DARK, + "Vampire", + "Vampiric Strength", + "Your body seems more dead than alive.", + NULL, /* cannot lose */ + " Your body seems somewhat dead\n" + " In this near undead state it has improved strength, constitution and intelligence\n" + " But reduced dexterity, wisdom and charisma.", + { CORRUPT_VAMPIRE_TEETH, -1 }, + { -1 }, + player_gain_vampire_strength, + }, + + { /* 13 */ + { MODULE_TOME, MODULE_THEME, -1 }, + TERM_L_DARK, + "Vampire", + "Vampire", + "You die to be reborn in a Vampire form.", + NULL, /* cannot lose */ + " You are a Vampire. As such you resist cold, poison, darkness and nether.\n" + " Your life is sustained, but you cannot stand the light of the sun.", + { CORRUPT_VAMPIRE_STRENGTH, -1 }, + { -1 }, + player_gain_vampire, + }, + + /* + * Activatable corruptions (mutations) + */ + + { /* 14 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Ancalagon's Breath", + "You gain the ability to spit acid.", + "You lose the ability to spit acid.", + " Fires an acid ball.\n" + " Damage=level Radius 1+(level/30)\n" + " Level=9, Cost=9, Stat=DEX, Difficulty=15", + { -1 }, + { -1 }, + NULL, + }, + + { /* 15 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Smaug's Breath", + "You gain the ability to breathe fire.", + "You lose the ability to breathe fire.", + " Fires a fire ball.\n" + " Damage=2*level Radius 1+(level/20)\n" + " Level=20, Cost=10, Stat=CON, Difficulty=18", + { -1 }, + { -1 }, + NULL, + }, + + { /* 16 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Glaurung's Gaze", + "Your eyes look mesmerizing...", + "Your eyes look uninteresting.", + " Tries to make a monster your pet.\n" + " Power=level\n" + " Level=12, Cost=12, Stat=CHR, Difficulty=18", + { -1 }, + { -1 }, + NULL, + }, + + { /* 17 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Saruman's Power", + "You gain the ability to move objects telekinetically.", + "You lose the ability to move objects telekinetically.", + " Move an object in line of sight to you.\n" + " Max weight equal to (level) pounds\n" + " Level=9, Cost=9, Stat=WIS, Difficulty=14", + { -1 }, + { -1 }, + NULL, + }, + + { /* 18 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Teleport", + "You gain the power of teleportation at will.", + "You lose the power of teleportation at will.", + " Teleports the player at will.\n" + " Distance 10+4*level squares\n" + " Level=7, Cost=7, Stat=WIS, Difficulty=15", + { -1 }, + { -1 }, + NULL, + }, + + { /* 19 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Glaurung's Spell", + "You gain the power of Mind Blast.", + "You lose the power of Mind Blast.", + " Fires a mind blasting bolt (psi damage).\n" + " Psi Damage (3+(level-1)/5)d3\n" + " Level=5, Cost=3, Stat=WIS, Difficulty=15", + { -1 }, + { -1 }, + NULL, + }, + + { /* 20 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Vampiric Drain", + "You become vampiric.", + "You are no longer vampiric.", + " You can drain life from a foe like a vampire.\n" + " Drains (level+1d(level))*(level/10) hitpoints,\n" + " heals you and satiates you. Doesn't work on all monsters\n" + " Level=4, Cost=5, Stat=CON, Difficulty=9", + { -1 }, + { -1 }, + NULL, + }, + + { /* 21 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Carcharoth's Nose", + "You smell a metallic odour.", + "You no longer smell a metallic odour.", + " You can detect nearby precious metal (treasure).\n" + " Radius 25\n" + " Level=3, Cost=2, Stat=INT, Difficulty=12", + { -1 }, + { -1 }, + NULL, + }, + + { /* 22 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Huan's Nose", + "You smell filthy monsters.", + "You no longer smell filthy monsters.", + " You can detect nearby monsters.\n" + " Radius 25\n" + " Level=5, Cost=4, Stat=INT, Difficulty=15", + { -1 }, + { -1 }, + NULL, + }, + + { /* 23 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Blink", + "You gain the power of minor teleportation.", + "You lose the power of minor teleportation.", + " You can teleport yourself short distances (10 squares).\n" + " Level=3, Cost=3, Stat=WIS, Difficulty=12", + { -1 }, + { -1 }, + NULL, + }, + + { /* 24 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Eat Rock", + "The walls look delicious.", + "The walls look unappetizing.", + " You can consume solid rock with food benefit,\n" + " leaving an empty space behind.\n" + " Level=8, Cost=12, Stat=CON, Difficulty=18", + { -1 }, + { -1 }, + NULL, + }, + + { /* 25 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Swap Position", + "You feel like walking a mile in someone else's shoes.", + "You feel like staying in your own shoes.", + " You can switch locations with another being,\n" + " unless it resists teleportation.\n" + " Level=15, Cost=12, Stat=DEX, Difficulty=16", + { -1 }, + { -1 }, + NULL, + }, + + { /* 26 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Shriek", + "Your vocal cords get much tougher.", + "Your vocal cords get much weaker.", + " Fires a sound ball and aggravates monsters.\n" + " Damage=level*4, Radius=8, centered on player\n" + " Level=4, Cost=4, Stat=CON, Difficulty=6", + { -1 }, + { -1 }, + NULL, + }, + + { /* 27 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Illuminate", + "You can light up rooms with your presence.", + "You can no longer light up rooms with your presence.", + " You can emit bright light that illuminates an area.\n" + " Damage=2d(level/2) Radius=(level/10)+1\n" + " Level=3, Cost=2, Stat=INT, Difficulty=10", + { -1 }, + { -1 }, + NULL, + }, + + { /* 28 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Detect Curses", + "You can feel evil magics.", + "You can no longer feel evil magics.", + " You can feel the danger of evil magic.\n" + " It detects cursed items in the inventory\n" + " Level=7, Cost=14, Stat=WIS, Difficulty=14", + { -1 }, + { -1 }, + NULL, + }, + + { /* 29 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Berserk", + "You feel a controlled rage.", + "You no longer feel a controlled rage.", + " You can drive yourself into a berserk frenzy.\n" + " It grants super-heroism. Duration=10+1d(level)\n" + " Level=8, Cost=8, Stat=STR, Difficulty=14", + { -1 }, + { -1 }, + NULL, + }, + + { /* 30 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Midas touch", + "You gain the Midas touch.", + "You lose the Midas touch.", + " You can turn ordinary items to gold.\n" + " Turns a non-artifact object into 1/3 its value in gold\n" + " Level=10, Cost=5, Stat=INT, Difficulty=12", + { -1 }, + { -1 }, + NULL, + }, + + { /* 31 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Grow Mold", + "You feel a sudden affinity for mold.", + "You feel a sudden dislike for mold.", + " You can cause mold to grow near you.\n" + " Summons up to 8 molds around the player\n" + " Level=1, Cost=6, Stat=CON, Difficulty=14", + { -1 }, + { -1 }, + NULL, + }, + + { /* 32 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Resist Elements", + "You feel like you can protect yourself.", + "You feel like you might be vulnerable.", + " You can harden yourself to the ravages of the elements.\n" + " Level-dependent chance of gaining resistances to the four \n" + " elements and poison. Duration=20 + d20\n" + " Level=10, Cost=12, Stat=CON, Difficulty=12", + { -1 }, + { -1 }, + NULL, + }, + + { /* 33 */ + { MODULE_THEME, -1 }, + TERM_RED, + NULL /* no group */, + "Earthquake", + "You gain the ability to wreck the dungeon.", + "You lose the ability to wreck the dungeon.", + " You can bring down the dungeon around your ears.\n" + " Radius=10, center on the player\n" + " Level=12, Cost=12, Stat=STR, Difficulty=16", + { -1 }, + { -1 }, + NULL, + }, + +}; + +/** + * Initialize corruptions + */ +void init_corruptions() +{ + /* Nothing needed currently */ +} + +/* + * Corruptions + */ +bool_ player_has_corruption(int corruption_idx) +{ + if (corruption_idx < 0) + { + return FALSE; + } + + return (p_ptr->corruptions[corruption_idx]); +} + +static bool_ player_can_gain_corruption(int corruption_idx) +{ + cptr r_name = rp_ptr->title + rp_name; + bool_ allowed = TRUE; /* Allowed by default */ + + assert(corruption_idx >= 0); + + if (corruption_idx == CORRUPT_TROLL_BLOOD) + { + /* Ok trolls should not get this one. never. */ + if (streq(r_name, "Troll")) + { + allowed = FALSE; + } + } + + /* Theme module adds additional restrictions for Maiar */ + + if (game_module_idx == MODULE_THEME) + { + if (streq(r_name, "Maia")) + { + /* We use a whitelist of corruptions for Maiar */ + bool_ allow = FALSE; + if ((corruption_idx == CORRUPT_BALROG_AURA) || + (corruption_idx == CORRUPT_BALROG_WINGS) || + (corruption_idx == CORRUPT_BALROG_STRENGTH) || + (corruption_idx == CORRUPT_BALROG_FORM) || + (corruption_idx == CORRUPT_DEMON_BREATH)) + { + allow = TRUE; + }; + + /* Mix result into 'allowed' flag */ + allowed = allowed & allow; + } + } + + /* Result */ + return allowed; +} + +static bool_ player_allow_corruption(int corruption_idx) +{ + int i; + bool_ found = FALSE; + corruption_type *c_ptr = NULL; + + assert(corruption_idx < CORRUPTIONS_MAX); + c_ptr = &corruptions[corruption_idx]; + + /* Must be allowed by module */ + for (i = 0; c_ptr->modules[i] >= 0; i++) + { + if (c_ptr->modules[i] == game_module_idx) + { + found = TRUE; + } + } + + if (!found) + { + return FALSE; + } + + /* Vampire teeth is special */ + if (corruption_idx == CORRUPT_VAMPIRE_TEETH) + { + if (PRACE_FLAG(PR1_NO_SUBRACE_CHANGE)) + { + return TRUE; + } + else + { + return FALSE; + } + } + + return TRUE; +} + +static void player_set_corruption(int c, bool_ set) +{ + p_ptr->corruptions[c] = set; + p_ptr->redraw = p_ptr->redraw | PR_BASIC; + p_ptr->update = p_ptr->update | PU_BONUS | PU_TORCH | PU_BODY | PU_POWERS; + +} + +void player_gain_corruption(int corruption_idx) +{ + corruption_type *c_ptr = NULL; + assert(corruption_idx >= 0); + assert(corruption_idx < CORRUPTIONS_MAX); + c_ptr = &corruptions[corruption_idx]; + + /* Set the player's corruption flag */ + player_set_corruption(corruption_idx, TRUE); + + /* Invoke callback if necessary */ + if (c_ptr->gain_callback) + { + c_ptr->gain_callback(); + } +} + +static void player_lose_corruption(int corruption_idx) +{ + assert(corruption_idx >= 0); + assert(corruption_idx < CORRUPTIONS_MAX); + + player_set_corruption(corruption_idx, FALSE); + + /* Currently no corruptions need any special handling when lost */ +} + +/* + * Test if we have that corruption + * We must: + * 1) have it or be willing to get it + * 2) have all its dependancies + * 3) have none of its opposing corruptions + * 4) pass the possible tests + */ +static bool_ test_depend_corrupt(s16b corrupt_idx, bool_ can_gain) +{ + s16b i; + corruption_type *c_ptr = NULL; + + assert(corrupt_idx >= 0); + assert(corrupt_idx < CORRUPTIONS_MAX); + + c_ptr = &corruptions[corrupt_idx]; + + if (can_gain) + { + if (p_ptr->corruptions[corrupt_idx]) + { + return FALSE; + } + } else { + if (!p_ptr->corruptions[corrupt_idx]) + { + return FALSE; + } + } + + /* Go through all dependencies */ + for (i=0; c_ptr->depends[i] >= 0; i++) + { + if (!test_depend_corrupt(c_ptr->depends[i], FALSE)) + { + return FALSE; + } + } + + /* Go through all opposers */ + for (i=0; c_ptr->opposes[i] >= 0; i++) + { + if (test_depend_corrupt(c_ptr->opposes[i], FALSE)) + { + return FALSE; + } + } + + /* are we even allowed to get it? */ + return player_can_gain_corruption(corrupt_idx); +} + +void gain_random_corruption() +{ + s16b i, max; + s16b pos[CORRUPTIONS_MAX]; + + /* Get the list of all possible ones */ + max = 0; + for (i=0; i < CORRUPTIONS_MAX; i++) + { + if (test_depend_corrupt(i, TRUE) && + player_allow_corruption(i)) + { + pos[max] = i; + max = max + 1; + } + } + + /* Ok now get one of them */ + if (max > 0) + { + s16b ret = rand_int(max); + int c_idx = pos[ret]; + assert(c_idx < CORRUPTIONS_MAX); + + player_gain_corruption(c_idx); + cmsg_print(TERM_L_RED, corruptions[c_idx].get_text); + } +} + +static void remove_corruption(int c_idx) +{ + assert(c_idx >= 0 && c_idx < CORRUPTIONS_MAX); + assert(corruptions[c_idx].lose_text); + + player_lose_corruption(c_idx); + cmsg_print(TERM_L_RED, corruptions[c_idx].lose_text); +} + +void lose_corruption() +{ + s16b i, max; + s16b pos[CORRUPTIONS_MAX]; + + /* Get the list of all possible ones */ + max = 0; + for (i = 0; i < CORRUPTIONS_MAX; i++) + { + bool_ is_removable = (corruptions[i].lose_text != NULL); + if (test_depend_corrupt(i, FALSE) && is_removable) + { + pos[max] = i; + max = max + 1; + } + } + + /* Ok now get one of them */ + if (max > 0) + { + s16b ret = rand_int(max); + int c_idx = pos[ret]; + + /* Remove the corruption */ + remove_corruption(c_idx); + + /* Ok now lets see if it broke some dependencies */ + for (i = 0; i < max - 1; i++) + { + if (p_ptr->corruptions[pos[i]] != test_depend_corrupt(pos[i], FALSE)) + { + remove_corruption(pos[i]); + } + } + } +} + + +/* + * Dump the corruption list + */ +void dump_corruptions(FILE *fff, bool_ color, bool_ header) +{ + int i; + + assert(fff != NULL); + + for (i = 0; i < CORRUPTIONS_MAX; i++) + { + corruption_type *c_ptr = &corruptions[i]; + + if (header) + { + fprintf(fff, "\n Corruption list:\n"); + header = FALSE; + } + + if (p_ptr->corruptions[i]) + { + byte c = c_ptr->color; + + if (color) + { + fprintf(fff, "#####%c%s:\n", conv_color[c], c_ptr->name); + } + else + { + fprintf(fff, "%s:\n", c_ptr->name); + } + + fprintf(fff, "%s\n", c_ptr->desc); + } + } +} + diff --git a/src/defines.h b/src/defines.h index d40e3b90..b590edc5 100644 --- a/src/defines.h +++ b/src/defines.h @@ -4432,6 +4432,45 @@ #define MAX_MODULES 2 /* + * Corruptions + */ +#define CORRUPT_BALROG_AURA 0 +#define CORRUPT_BALROG_WINGS 1 +#define CORRUPT_BALROG_STRENGTH 2 +#define CORRUPT_BALROG_FORM 3 +#define CORRUPT_DEMON_SPIRIT 4 +#define CORRUPT_DEMON_HIDE 5 +#define CORRUPT_DEMON_BREATH 6 +#define CORRUPT_DEMON_REALM 7 +#define CORRUPT_RANDOM_TELEPORT 8 +#define CORRUPT_ANTI_TELEPORT 9 +#define CORRUPT_TROLL_BLOOD 10 +#define CORRUPT_VAMPIRE_TEETH 11 +#define CORRUPT_VAMPIRE_STRENGTH 12 +#define CORRUPT_VAMPIRE_VAMPIRE 13 +#define MUT1_SPIT_ACID 14 +#define MUT1_BR_FIRE 15 +#define MUT1_HYPN_GAZE 16 +#define MUT1_TELEKINES 17 +#define MUT1_VTELEPORT 18 +#define MUT1_MIND_BLST 19 +#define MUT1_VAMPIRISM 20 +#define MUT1_SMELL_MET 21 +#define MUT1_SMELL_MON 22 +#define MUT1_BLINK 23 +#define MUT1_EAT_ROCK 24 +#define MUT1_SWAP_POS 25 +#define MUT1_SHRIEK 26 +#define MUT1_ILLUMINE 27 +#define MUT1_DET_CURSE 28 +#define MUT1_BERSERK 29 +#define MUT1_MIDAS_TCH 30 +#define MUT1_GROW_MOLD 31 +#define MUT1_RESIST 32 +#define MUT1_EARTHQUAKE 33 +#define CORRUPTIONS_MAX 34 + +/* * Hooks */ #define HOOK_MONSTER_DEATH 0 diff --git a/src/externs.h b/src/externs.h index 3f48098c..c82eee41 100644 --- a/src/externs.h +++ b/src/externs.h @@ -583,7 +583,6 @@ extern char gen_skill_modm[MAX_SKILLS]; extern s16b gen_skill_mod[MAX_SKILLS]; extern bool_ linear_stats; extern int max_bact; -extern s16b max_corruptions; extern bool_ option_ingame_help; extern bool_ automatizer_enabled; extern s16b last_teleportation_y; @@ -604,40 +603,6 @@ extern s32b max_gods; extern timer_type *gl_timers; extern s16b tim_precognition; extern const char *get_version_string(); -extern s16b CORRUPT_BALROG_AURA; -extern s16b CORRUPT_BALROG_WINGS; -extern s16b CORRUPT_BALROG_STRENGTH; -extern s16b CORRUPT_BALROG_FORM; -extern s16b CORRUPT_DEMON_SPIRIT; -extern s16b CORRUPT_DEMON_HIDE; -extern s16b CORRUPT_DEMON_BREATH; -extern s16b CORRUPT_DEMON_REALM; -extern s16b CORRUPT_RANDOM_TELEPORT; -extern s16b CORRUPT_ANTI_TELEPORT; -extern s16b CORRUPT_TROLL_BLOOD; -extern s16b CORRUPT_VAMPIRE_TEETH; -extern s16b CORRUPT_VAMPIRE_STRENGTH; -extern s16b CORRUPT_VAMPIRE_VAMPIRE; -extern s16b MUT1_SPIT_ACID; -extern s16b MUT1_BR_FIRE; -extern s16b MUT1_HYPN_GAZE; -extern s16b MUT1_TELEKINES; -extern s16b MUT1_VTELEPORT; -extern s16b MUT1_MIND_BLST; -extern s16b MUT1_VAMPIRISM; -extern s16b MUT1_SMELL_MET; -extern s16b MUT1_SMELL_MON; -extern s16b MUT1_BLINK; -extern s16b MUT1_EAT_ROCK; -extern s16b MUT1_SWAP_POS; -extern s16b MUT1_SHRIEK; -extern s16b MUT1_ILLUMINE; -extern s16b MUT1_DET_CURSE; -extern s16b MUT1_BERSERK; -extern s16b MUT1_MIDAS_TCH; -extern s16b MUT1_GROW_MOLD; -extern s16b MUT1_RESIST; -extern s16b MUT1_EARTHQUAKE; extern s16b POWER_INVISIBILITY; extern s16b POWER_WEB; extern s16b POWER_COR_SPACE_TIME; @@ -907,6 +872,13 @@ extern void do_cmd_symbiotic(void); extern s32b sroot(s32b n); extern int clamp_failure_chance(int chance, int minfail); +/* corrupt.c */ +extern void gain_random_corruption(); +extern void dump_corruptions(FILE *OutFile, bool_ color, bool_ header); +extern void lose_corruption(); +extern bool_ player_has_corruption(int corruption_idx); +extern void player_gain_corruption(int corruption_idx); + /* dungeon.c */ extern byte value_check_aux1(object_type *o_ptr); extern byte value_check_aux1_magic(object_type *o_ptr); @@ -1004,7 +976,7 @@ extern errr init_wf_info_txt(FILE *fp, char *buf); extern errr process_dungeon_file(cptr name, int *yval, int *xval, int ymax, int xmax, bool_ init, bool_ full); /* init2.c */ -extern void init_corruptions(s16b new_size); +extern void init_corruptions(); extern void init_spells(s16b new_size); extern void init_schools(s16b new_size); extern void reinit_gods(s16b new_size); @@ -1670,15 +1642,11 @@ extern bool_ set_shadow(int v); extern bool_ set_tim_esp(int v); extern bool_ tgp_pt(int *x, int * y); extern bool_ tgt_pt (int *x, int *y); -extern bool_ gain_random_corruption(int choose_mut); -extern bool_ got_corruptions(void); -extern void dump_corruptions(FILE *OutFile, bool_ color); extern void do_poly_self(void); extern void do_poly_wounds(void); extern bool_ curse_weapon(void); extern bool_ curse_armor(void); extern void random_resistance(object_type * q_ptr, bool_ is_scroll, int specific); -extern bool_ lose_corruption(int choose_mut); extern void great_side_effect(void); extern void nasty_side_effect(void); extern void deadly_side_effect(bool_ god); @@ -1868,11 +1836,6 @@ extern void lua_delete_list(list_type *, int size); extern void lua_add_to_list(list_type *, int idx, cptr str); extern void lua_display_list(int y, int x, int h, int w, cptr title, list_type *list, int max, int begin, int sel, byte sel_color); -extern bool_ player_has_corruption(int corruption_idx); -extern bool_ player_can_gain_corruption(int corruption_idx); -extern void player_gain_corruption(int corruption_idx); -extern void player_lose_corruption(int corruption_idx); - extern cptr compass(int y, int x, int y2, int x2); extern cptr approximate_distance(int y, int x, int y2, int x2); diff --git a/src/files.c b/src/files.c index 56e57975..96ee66a9 100644 --- a/src/files.c +++ b/src/files.c @@ -2736,11 +2736,7 @@ errr file_character(cptr name, bool_ full) file_character_print_grid(fff, FALSE, FALSE); /* Dump corruptions */ - if (got_corruptions()) - { - fprintf(fff, "\n Corruption list:\n"); - dump_corruptions(fff, FALSE); - } + dump_corruptions(fff, FALSE, TRUE); /* Dump skills */ dump_skills(fff); diff --git a/src/init2.c b/src/init2.c index 222293c4..015a1c0f 100644 --- a/src/init2.c +++ b/src/init2.c @@ -4,6 +4,7 @@ #include "angband.h" +#include <assert.h> /* * This file is used to initialise various variables and arrays for the @@ -2159,13 +2160,6 @@ void init_schools(s16b new_size) max_schools = new_size; } -void init_corruptions(s16b new_size) -{ - /* allocate the extra memory */ - C_MAKE(p_ptr->corruptions, new_size, bool_); - max_corruptions = new_size; -} - /* * Initialise some other arrays */ diff --git a/src/loadsave.c b/src/loadsave.c index 287eabd8..74b5112c 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -577,17 +577,20 @@ static bool_ do_extra(int flag) do_s16b(&p_ptr->chaos_patron, flag); - if (flag == LS_SAVE) tmp16s = max_corruptions; + if ((flag == LS_SAVE)) { tmp16s = CORRUPTIONS_MAX; } do_s16b(&tmp16s, flag); + if (tmp16s > CORRUPTIONS_MAX) { + quit("Too many corruptions"); + } for (i = 0; i < tmp16s; i++) { - if ((flag == LS_SAVE) && (i < max_corruptions)) + if ((flag == LS_SAVE)) tmp8u = p_ptr->corruptions[i]; do_byte(&tmp8u, flag); - if ((flag == LS_LOAD) && (i < max_corruptions)) + if ((flag == LS_LOAD)) p_ptr->corruptions[i] = tmp8u; } diff --git a/src/lua_bind.c b/src/lua_bind.c index 1add61e3..df335dd3 100644 --- a/src/lua_bind.c +++ b/src/lua_bind.c @@ -586,173 +586,7 @@ void lua_display_list(int y, int x, int h, int w, cptr title, list_type* list, i display_list(y, x, h, w, title, list->list, max, begin, sel, sel_color); } -/* - * Corruptions - */ -bool_ player_has_corruption(int corruption_idx) -{ - if (corruption_idx < 0) - { - return FALSE; - } - - - - return (p_ptr->corruptions[corruption_idx]); -} - -bool_ player_can_gain_corruption(int corruption_idx) -{ - cptr r_name = rp_ptr->title + rp_name; - bool_ allowed = TRUE; /* Allowed by default */ - - assert(corruption_idx >= 0); - - if (corruption_idx == CORRUPT_TROLL_BLOOD) - { - /* Ok trolls should not get this one. never. */ - if (streq(r_name, "Troll")) - { - allowed = FALSE; - } - } - - /* Theme module adds additional restrictions for Maiar */ - - if (game_module_idx == MODULE_THEME) - { - if (streq(r_name, "Maia")) - { - /* We use a whitelist of corruptions for Maiar */ - bool_ allow = FALSE; - if ((corruption_idx == CORRUPT_BALROG_AURA) || - (corruption_idx == CORRUPT_BALROG_WINGS) || - (corruption_idx == CORRUPT_BALROG_STRENGTH) || - (corruption_idx == CORRUPT_BALROG_FORM) || - (corruption_idx == CORRUPT_DEMON_BREATH)) - { - allow = TRUE; - }; - - /* Mix result into 'allowed' flag */ - allowed = allowed & allow; - } - } - - /* Result */ - return allowed; -} - -static void subrace_add_power(player_race_mod *rmp_ptr, int power) -{ - int i; - - for (i=0; i<4; i++) - { - if (rmp_ptr->powers[i] == -1) - { - rmp_ptr->powers[i] = power; - return; - } - } -} -static void player_gain_vampire_teeth() -{ - player_race_mod *rmp_ptr = NULL; - - switch_subrace(SUBRACE_SAVE, TRUE); - - rmp_ptr = &race_mod_info[SUBRACE_SAVE]; - subrace_add_power(rmp_ptr, PWR_VAMPIRISM); - rmp_ptr->flags1 = rmp_ptr->flags1 - | PR1_VAMPIRE - | PR1_UNDEAD - | PR1_NO_SUBRACE_CHANGE; -} - -static void player_gain_vampire_strength() -{ - player_race_mod *rmp_ptr = &race_mod_info[SUBRACE_SAVE]; - /* Apply the bonuses/penalities */ - rmp_ptr->r_mhp = rmp_ptr->r_mhp + 1; - rmp_ptr->r_exp = rmp_ptr->r_exp + 100; - - rmp_ptr->r_adj[A_STR + 1] = rmp_ptr->r_adj[A_STR + 1] + 3; - rmp_ptr->r_adj[A_INT + 1] = rmp_ptr->r_adj[A_INT + 1] + 2; - rmp_ptr->r_adj[A_WIS + 1] = rmp_ptr->r_adj[A_WIS + 1] - 3; - rmp_ptr->r_adj[A_DEX + 1] = rmp_ptr->r_adj[A_DEX + 1] - 2; - rmp_ptr->r_adj[A_CON + 1] = rmp_ptr->r_adj[A_CON + 1] + 1; - rmp_ptr->r_adj[A_CHR + 1] = rmp_ptr->r_adj[A_CHR + 1] - 4; - - /* be reborn! */ - do_rebirth(); - cmsg_print(TERM_L_DARK, "You feel death slipping inside."); -} - -static void player_gain_vampire() -{ - player_race_mod *rmp_ptr = &race_mod_info[SUBRACE_SAVE]; - - /* Be a Vampire and be proud of it */ - cptr title = get_subrace_title(SUBRACE_SAVE); - if (streq(title, " ") || streq(title, "Vampire")) - { - title = "Vampire"; - rmp_ptr->place = FALSE; - set_subrace_title(SUBRACE_SAVE, title); - } - else - { - char buf[512]; - sprintf(buf, "Vampire %s", title); - set_subrace_title(SUBRACE_SAVE, buf); - } - - /* Bonus/and .. not bonus :) */ - rmp_ptr->flags1 = rmp_ptr->flags1 | PR1_HURT_LITE; - rmp_ptr->oflags2[2] = rmp_ptr->oflags2[2] - | TR2_RES_POIS - | TR2_RES_NETHER - | TR2_RES_COLD - | TR2_RES_DARK - | TR2_HOLD_LIFE; - rmp_ptr->oflags3[2] = rmp_ptr->oflags3[2] - | TR3_LITE1; -} - -static void player_set_corruption(int c, bool_ set) -{ - p_ptr->corruptions[c] = set; - p_ptr->redraw = p_ptr->redraw | PR_BASIC; - p_ptr->update = p_ptr->update | PU_BONUS | PU_TORCH | PU_BODY | PU_POWERS; - -} - -void player_gain_corruption(int corruption_idx) -{ - player_set_corruption(corruption_idx, TRUE); - - if (corruption_idx == CORRUPT_VAMPIRE_TEETH) - { - player_gain_vampire_teeth(); - } - else if (corruption_idx == CORRUPT_VAMPIRE_STRENGTH) - { - player_gain_vampire_strength(); - } - else if (corruption_idx == CORRUPT_VAMPIRE_VAMPIRE) - { - player_gain_vampire(); - } -} - -void player_lose_corruption(int corruption_idx) -{ - player_set_corruption(corruption_idx, FALSE); - /* Currently no corruptions need - any special handling when lost */ -} /* * Gods diff --git a/src/melee1.c b/src/melee1.c index 4e5d3208..0940f7b4 100644 --- a/src/melee1.c +++ b/src/melee1.c @@ -2877,7 +2877,7 @@ bool_ make_attack_normal(int m_idx, byte divis) { /* Change to resist(but never total protection) */ /* if (magik(3) || (magik(m_ptr->level - (p_ptr->lev / 2)))) - call_lua("gain_corruption", "(s)", "", "Vampire");*/ + gain_corruption("Vampire");*/ } if (explode) diff --git a/src/player.pkg b/src/player.pkg index ad01e9eb..fd7754fc 100644 --- a/src/player.pkg +++ b/src/player.pkg @@ -1793,10 +1793,6 @@ struct player_type byte spellbinder_trigger; /* Corruptions */ - /** @structvar corruptions_aux; - * @brief Boolean - */ - bool corruptions[max_corruptions] @ corruptions_aux; bool corrupt_anti_teleport_stopped; /* Astral */ @@ -1818,44 +1814,44 @@ struct player_type /** * Corruptions */ -extern s16b CORRUPT_BALROG_AURA; -extern s16b CORRUPT_BALROG_WINGS; -extern s16b CORRUPT_BALROG_STRENGTH; -extern s16b CORRUPT_BALROG_FORM; -extern s16b CORRUPT_DEMON_SPIRIT; -extern s16b CORRUPT_DEMON_HIDE; -extern s16b CORRUPT_DEMON_BREATH; -extern s16b CORRUPT_DEMON_REALM; -extern s16b CORRUPT_RANDOM_TELEPORT; -extern s16b CORRUPT_ANTI_TELEPORT; -extern s16b CORRUPT_TROLL_BLOOD; -extern s16b CORRUPT_VAMPIRE_TEETH; -extern s16b CORRUPT_VAMPIRE_STRENGTH; -extern s16b CORRUPT_VAMPIRE_VAMPIRE; -extern s16b MUT1_SPIT_ACID; -extern s16b MUT1_BR_FIRE; -extern s16b MUT1_HYPN_GAZE; -extern s16b MUT1_TELEKINES; -extern s16b MUT1_VTELEPORT; -extern s16b MUT1_MIND_BLST; -extern s16b MUT1_VAMPIRISM; -extern s16b MUT1_SMELL_MET; -extern s16b MUT1_SMELL_MON; -extern s16b MUT1_BLINK; -extern s16b MUT1_EAT_ROCK; -extern s16b MUT1_SWAP_POS; -extern s16b MUT1_SHRIEK; -extern s16b MUT1_ILLUMINE; -extern s16b MUT1_DET_CURSE; -extern s16b MUT1_BERSERK; -extern s16b MUT1_MIDAS_TCH; -extern s16b MUT1_GROW_MOLD; -extern s16b MUT1_RESIST; -extern s16b MUT1_EARTHQUAKE; - -extern bool player_can_gain_corruption(int corruption_idx); +#define CORRUPT_BALROG_AURA 0 +#define CORRUPT_BALROG_WINGS 1 +#define CORRUPT_BALROG_STRENGTH 2 +#define CORRUPT_BALROG_FORM 3 +#define CORRUPT_DEMON_SPIRIT 4 +#define CORRUPT_DEMON_HIDE 5 +#define CORRUPT_DEMON_BREATH 6 +#define CORRUPT_DEMON_REALM 7 +#define CORRUPT_RANDOM_TELEPORT 8 +#define CORRUPT_ANTI_TELEPORT 9 +#define CORRUPT_TROLL_BLOOD 10 +#define CORRUPT_VAMPIRE_TEETH 11 +#define CORRUPT_VAMPIRE_STRENGTH 12 +#define CORRUPT_VAMPIRE_VAMPIRE 13 +#define MUT1_SPIT_ACID 14 +#define MUT1_BR_FIRE 15 +#define MUT1_HYPN_GAZE 16 +#define MUT1_TELEKINES 17 +#define MUT1_VTELEPORT 18 +#define MUT1_MIND_BLST 19 +#define MUT1_VAMPIRISM 20 +#define MUT1_SMELL_MET 21 +#define MUT1_SMELL_MON 22 +#define MUT1_BLINK 23 +#define MUT1_EAT_ROCK 24 +#define MUT1_SWAP_POS 25 +#define MUT1_SHRIEK 26 +#define MUT1_ILLUMINE 27 +#define MUT1_DET_CURSE 28 +#define MUT1_BERSERK 29 +#define MUT1_MIDAS_TCH 30 +#define MUT1_GROW_MOLD 31 +#define MUT1_RESIST 32 +#define MUT1_EARTHQUAKE 33 +#define CORRUPTIONS_MAX 34 + +extern bool player_has_corruption(int corruption_idx); extern void player_gain_corruption(int corruption_idx); -extern void player_lose_corruption(int corruption_idx); /** @name Spellbinder triggers * @{ */ diff --git a/src/script.c b/src/script.c index 89c9ff3b..a5aba3fb 100644 --- a/src/script.c +++ b/src/script.c @@ -245,8 +245,7 @@ void init_lua_init() } /* Finish up the corruptions */ - max = exec_lua("return __corruptions_max"); - init_corruptions(max); + init_corruptions(); } bool_ tome_dofile(char *file) diff --git a/src/tables.c b/src/tables.c index e7a81f11..d0dbb9b7 100644 --- a/src/tables.c +++ b/src/tables.c @@ -4850,3 +4850,4 @@ module_type modules[MAX_MODULES] = } }; + diff --git a/src/types.h b/src/types.h index de90a019..cd08476a 100644 --- a/src/types.h +++ b/src/types.h @@ -1807,7 +1807,7 @@ struct player_type u32b xtra_esp; /* Corruptions */ - bool_ *corruptions; + bool_ corruptions[CORRUPTIONS_MAX]; bool_ corrupt_anti_teleport_stopped; /*** Pet commands ***/ @@ -2583,3 +2583,21 @@ struct module_type } skills; }; + +/** + * Corruptions + */ +typedef struct corruption_type corruption_type; +struct corruption_type +{ + int modules[3]; /* Modules where this corruption is available; terminated with -1 entry */ + byte color; + cptr group; + cptr name; + cptr get_text; + cptr lose_text; /* If NULL, the corruption is NOT removable by any means */ + cptr desc; + s16b depends[5]; /* terminated by a -1 entry */ + s16b opposes[5]; /* terminated by a -1 entry */ + void (*gain_callback)(); /* callback to invoke when gained */ +}; diff --git a/src/variable.c b/src/variable.c index b73a1edf..f775df66 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1542,11 +1542,6 @@ int cli_total = 0; int max_bact = 56; /* - * Max corruptions - */ -s16b max_corruptions = 0; - -/* * Ingame contextual help */ bool_ option_ingame_help = TRUE; @@ -1597,44 +1592,6 @@ timer_type *gl_timers = NULL; */ s16b tim_precognition = 0; -/** - * Corruptions - */ -s16b CORRUPT_BALROG_AURA = -1; -s16b CORRUPT_BALROG_WINGS = -1; -s16b CORRUPT_BALROG_STRENGTH = -1; -s16b CORRUPT_BALROG_FORM = -1; -s16b CORRUPT_DEMON_SPIRIT = -1; -s16b CORRUPT_DEMON_HIDE = -1; -s16b CORRUPT_DEMON_BREATH = -1; -s16b CORRUPT_DEMON_REALM = -1; -s16b CORRUPT_RANDOM_TELEPORT = -1; -s16b CORRUPT_ANTI_TELEPORT = -1; -s16b CORRUPT_TROLL_BLOOD = -1; -s16b CORRUPT_VAMPIRE_TEETH = -1; -s16b CORRUPT_VAMPIRE_STRENGTH = -1; -s16b CORRUPT_VAMPIRE_VAMPIRE = -1; -s16b MUT1_SPIT_ACID = -1; -s16b MUT1_BR_FIRE = -1; -s16b MUT1_HYPN_GAZE = -1; -s16b MUT1_TELEKINES = -1; -s16b MUT1_VTELEPORT = -1; -s16b MUT1_MIND_BLST = -1; -s16b MUT1_VAMPIRISM = -1; -s16b MUT1_SMELL_MET = -1; -s16b MUT1_SMELL_MON = -1; -s16b MUT1_BLINK = -1; -s16b MUT1_EAT_ROCK = -1; -s16b MUT1_SWAP_POS = -1; -s16b MUT1_SHRIEK = -1; -s16b MUT1_ILLUMINE = -1; -s16b MUT1_DET_CURSE = -1; -s16b MUT1_BERSERK = -1; -s16b MUT1_MIDAS_TCH = -1; -s16b MUT1_GROW_MOLD = -1; -s16b MUT1_RESIST = -1; -s16b MUT1_EARTHQUAKE = -1; - /* * Powers diff --git a/src/wizard2.c b/src/wizard2.c index a19b72e0..5e1e38d1 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -1758,7 +1758,7 @@ void do_cmd_debug(void) /* corruption */ case 'M': - (void) gain_random_corruption(command_arg); + gain_random_corruption(); break; /* Specific reward */ diff --git a/src/xtra2.c b/src/xtra2.c index 1a6ec3a0..a3ae9881 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -12,6 +12,7 @@ */ #include "angband.h" +#include <assert.h> /* * Invoke The Rush @@ -5147,7 +5148,7 @@ void gain_level_reward(int chosen_reward) { msg_format("%^s rewards you with a corruption!", chaos_patrons[p_ptr->chaos_patron]); - (void)gain_random_corruption(0); + gain_random_corruption(); return; } @@ -5600,19 +5601,6 @@ bool_ tgt_pt(int *x, int *y) return success; } - -bool_ gain_random_corruption(int choose_mut) -{ - exec_lua("gain_corruption()"); - return (FALSE); -} - -bool_ lose_corruption(int choose_mut) -{ - exec_lua("lose_corruption()"); - return (FALSE); -} - bool_ get_hack_dir(int *dp) { int dir; @@ -5710,51 +5698,6 @@ bool_ get_hack_dir(int *dp) } /* - * Do we have at least one corruption? - */ -bool_ got_corruptions() -{ - int i, max; - - max = exec_lua("return __corruptions_max"); - - for (i = 0; i < max; i++) - { - if (exec_lua(format("if test_depend_corrupt(%d) == TRUE then return TRUE else return FALSE end", i))) - { - return TRUE; - } - } - return FALSE; -} - -/* - * Dump the corruption list - */ -void dump_corruptions(FILE *fff, bool_ color) -{ - int i, max; - - if (!fff) return; - - max = exec_lua("return __corruptions_max"); - - for (i = 0; i < max; i++) - { - if (exec_lua(format("if test_depend_corrupt(%d) == TRUE then return TRUE else return FALSE end", i))) - { - int c = exec_lua(format("return __corruptions[%d].color", i)); - - if (color) - fprintf(fff, "#####%c%s:\n", conv_color[c], string_exec_lua(format("return __corruptions[%d].name", i))); - else - fprintf(fff, "%s:\n", string_exec_lua(format("return __corruptions[%d].name", i))); - fprintf(fff, "%s\n", string_exec_lua(format("return __corruptions[%d].desc", i))); - } - } -} - -/* * Set "p_ptr->grace", notice observable changes */ void set_grace(s32b v) @@ -6048,11 +5991,11 @@ void corrupt_corrupted(void) { if (magik(45)) { - lose_corruption(0); + lose_corruption(); } else { - gain_random_corruption(0); + gain_random_corruption(); } /* We are done. */ |