summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/core/crpt_aux.lua144
-rw-r--r--lib/core/init.lua1
-rw-r--r--lib/mods/theme/core/crpt_aux.lua144
-rw-r--r--lib/mods/theme/core/init.lua1
-rw-r--r--lib/mods/theme/scpt/corrupt.lua526
-rw-r--r--lib/mods/theme/scpt/init.lua3
-rw-r--r--lib/mods/theme/scpt/monsters.lua8
-rw-r--r--lib/scpt/corrupt.lua243
-rw-r--r--lib/scpt/init.lua3
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/birth.c6
-rw-r--r--src/cmd4.c5
-rw-r--r--src/cmd5.c2
-rw-r--r--src/cmd6.c4
-rw-r--r--src/corrupt.c916
-rw-r--r--src/defines.h39
-rw-r--r--src/externs.h53
-rw-r--r--src/files.c6
-rw-r--r--src/init2.c8
-rw-r--r--src/loadsave.c9
-rw-r--r--src/lua_bind.c166
-rw-r--r--src/melee1.c2
-rw-r--r--src/player.pkg78
-rw-r--r--src/script.c3
-rw-r--r--src/tables.c1
-rw-r--r--src/types.h20
-rw-r--r--src/variable.c43
-rw-r--r--src/wizard2.c2
-rw-r--r--src/xtra2.c65
29 files changed, 1047 insertions, 1456 deletions
diff --git a/lib/core/crpt_aux.lua b/lib/core/crpt_aux.lua
deleted file mode 100644
index 24b71860..00000000
--- a/lib/core/crpt_aux.lua
+++ /dev/null
@@ -1,144 +0,0 @@
--- Core functions for corruptions
-
-__corruptions = {}
-__corruptions_max = 0
-__corruptions_callbacks_max = 0
-
--- Get the corruption
-function player.corruption(c)
- return player.corruptions_aux[c + 1]
-end
-
--- 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
-function test_depend_corrupt(corrupt, can_gain)
- local i, c
-
- if not can_gain then can_gain = FALSE end
-
- if can_gain == TRUE then
- if (player.corruption(corrupt) ~= FALSE) then
- return FALSE
- end
- else
- if (player.corruption(corrupt) ~= TRUE) then
- return FALSE
- end
- end
-
- for c, i in __corruptions[corrupt].depends do
- if test_depend_corrupt(c) ~= TRUE then
- return FALSE
- end
- end
-
- for c, i in __corruptions[corrupt].oppose do
- if test_depend_corrupt(c) ~= FALSE then
- return FALSE
- end
- end
-
- -- are we even allowed to get it?
- return player_can_gain_corruption(corrupt)
-end
-
--- Gain a new corruption
-function gain_corruption(group)
- local i, max
- local pos = {}
-
- -- Get the list of all possible ones
- max = 0
- for i = 0, __corruptions_max - 1 do
- if __corruptions[i].group == group and test_depend_corrupt(i, TRUE) == TRUE and __corruptions[i].random == TRUE and __corruptions[i].allow() then
- pos[max] = i
- max = max + 1
- end
- end
-
- -- Ok now get one of them
- if (max > 0) then
- local ret = rand_int(max)
-
- player_gain_corruption(pos[ret])
- cmsg_print(TERM_L_RED, __corruptions[pos[ret]].get_text)
-
- return pos[ret]
- else
- return -1
- end
-end
-
--- Lose an existing corruption
-function lose_corruption()
- local i, max
- local pos = {}
-
- -- Get the list of all possible ones
- max = 0
- for i = 0, __corruptions_max - 1 do
- if test_depend_corrupt(i) == TRUE and __corruptions[i].removable == TRUE then
- pos[max] = i
- max = max + 1
- end
- end
-
- -- Ok now get one of them
- if (max > 0) then
- local ret = rand_int(max)
-
- player_lose_corruption(pos[ret])
- cmsg_print(TERM_L_RED, __corruptions[pos[ret]].lose_text)
-
- -- Ok now lets see if it broke some dependancies
- for i = 0, max - 1 do
- if player.corruption(pos[i]) ~= test_depend_corrupt(pos[i]) then
- player_lose_corruption(pos[i])
- cmsg_print(TERM_L_RED, __corruptions[pos[i]].lose_text)
- end
- end
-
- return pos[ret]
- else
- return -1
- end
-end
-
--- Creates a new corruption
-function add_corruption(c)
- assert(c.color, "No corruption color")
- assert(c.name, "No corruption name")
- assert(c.get_text, "No corruption get_text")
- assert(c.lose_text, "No corruption lose_text")
- assert(c.desc, "No corruption desc")
- if not c.random then c.random = TRUE end
- if not c.removable then c.removable = TRUE end
- if not c.allow then c.allow = function() return not nil end end
-
- if c.depends == nil then c.depends = {} end
- if c.oppose == nil then c.oppose = {} end
-
- -- We must make sure the other ones opposes too
- local o, i
- for o, i in c.oppose do
- __corruptions[o].oppose[__corruptions_max] = TRUE
- end
-
- if type(c.desc) == "table" then
- local new_desc = ""
- local index, h
- for index, h in c.desc do
- new_desc = new_desc..h.."\n"
- end
- c.desc = new_desc
- end
-
- __corruptions[__corruptions_max] = c
- __corruptions_max = __corruptions_max + 1
- return (__corruptions_max - 1)
-end
-
diff --git a/lib/core/init.lua b/lib/core/init.lua
index 11b812d5..3db34076 100644
--- a/lib/core/init.lua
+++ b/lib/core/init.lua
@@ -17,7 +17,6 @@ tome_dofile_anywhere(ANGBAND_DIR_CORE, "monsters.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "building.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "s_aux.lua")
-tome_dofile_anywhere(ANGBAND_DIR_CORE, "crpt_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "mimc_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "quests.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "gods.lua")
diff --git a/lib/mods/theme/core/crpt_aux.lua b/lib/mods/theme/core/crpt_aux.lua
deleted file mode 100644
index 24b71860..00000000
--- a/lib/mods/theme/core/crpt_aux.lua
+++ /dev/null
@@ -1,144 +0,0 @@
--- Core functions for corruptions
-
-__corruptions = {}
-__corruptions_max = 0
-__corruptions_callbacks_max = 0
-
--- Get the corruption
-function player.corruption(c)
- return player.corruptions_aux[c + 1]
-end
-
--- 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
-function test_depend_corrupt(corrupt, can_gain)
- local i, c
-
- if not can_gain then can_gain = FALSE end
-
- if can_gain == TRUE then
- if (player.corruption(corrupt) ~= FALSE) then
- return FALSE
- end
- else
- if (player.corruption(corrupt) ~= TRUE) then
- return FALSE
- end
- end
-
- for c, i in __corruptions[corrupt].depends do
- if test_depend_corrupt(c) ~= TRUE then
- return FALSE
- end
- end
-
- for c, i in __corruptions[corrupt].oppose do
- if test_depend_corrupt(c) ~= FALSE then
- return FALSE
- end
- end
-
- -- are we even allowed to get it?
- return player_can_gain_corruption(corrupt)
-end
-
--- Gain a new corruption
-function gain_corruption(group)
- local i, max
- local pos = {}
-
- -- Get the list of all possible ones
- max = 0
- for i = 0, __corruptions_max - 1 do
- if __corruptions[i].group == group and test_depend_corrupt(i, TRUE) == TRUE and __corruptions[i].random == TRUE and __corruptions[i].allow() then
- pos[max] = i
- max = max + 1
- end
- end
-
- -- Ok now get one of them
- if (max > 0) then
- local ret = rand_int(max)
-
- player_gain_corruption(pos[ret])
- cmsg_print(TERM_L_RED, __corruptions[pos[ret]].get_text)
-
- return pos[ret]
- else
- return -1
- end
-end
-
--- Lose an existing corruption
-function lose_corruption()
- local i, max
- local pos = {}
-
- -- Get the list of all possible ones
- max = 0
- for i = 0, __corruptions_max - 1 do
- if test_depend_corrupt(i) == TRUE and __corruptions[i].removable == TRUE then
- pos[max] = i
- max = max + 1
- end
- end
-
- -- Ok now get one of them
- if (max > 0) then
- local ret = rand_int(max)
-
- player_lose_corruption(pos[ret])
- cmsg_print(TERM_L_RED, __corruptions[pos[ret]].lose_text)
-
- -- Ok now lets see if it broke some dependancies
- for i = 0, max - 1 do
- if player.corruption(pos[i]) ~= test_depend_corrupt(pos[i]) then
- player_lose_corruption(pos[i])
- cmsg_print(TERM_L_RED, __corruptions[pos[i]].lose_text)
- end
- end
-
- return pos[ret]
- else
- return -1
- end
-end
-
--- Creates a new corruption
-function add_corruption(c)
- assert(c.color, "No corruption color")
- assert(c.name, "No corruption name")
- assert(c.get_text, "No corruption get_text")
- assert(c.lose_text, "No corruption lose_text")
- assert(c.desc, "No corruption desc")
- if not c.random then c.random = TRUE end
- if not c.removable then c.removable = TRUE end
- if not c.allow then c.allow = function() return not nil end end
-
- if c.depends == nil then c.depends = {} end
- if c.oppose == nil then c.oppose = {} end
-
- -- We must make sure the other ones opposes too
- local o, i
- for o, i in c.oppose do
- __corruptions[o].oppose[__corruptions_max] = TRUE
- end
-
- if type(c.desc) == "table" then
- local new_desc = ""
- local index, h
- for index, h in c.desc do
- new_desc = new_desc..h.."\n"
- end
- c.desc = new_desc
- end
-
- __corruptions[__corruptions_max] = c
- __corruptions_max = __corruptions_max + 1
- return (__corruptions_max - 1)
-end
-
diff --git a/lib/mods/theme/core/init.lua b/lib/mods/theme/core/init.lua
index 11b812d5..3db34076 100644
--- a/lib/mods/theme/core/init.lua
+++ b/lib/mods/theme/core/init.lua
@@ -17,7 +17,6 @@ tome_dofile_anywhere(ANGBAND_DIR_CORE, "monsters.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "building.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "s_aux.lua")
-tome_dofile_anywhere(ANGBAND_DIR_CORE, "crpt_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "mimc_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "quests.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "gods.lua")
diff --git a/lib/mods/theme/scpt/corrupt.lua b/lib/mods/theme/scpt/corrupt.lua
deleted file mode 100644
index e303803b..00000000
--- a/lib/mods/theme/scpt/corrupt.lua
+++ /dev/null
@@ -1,526 +0,0 @@
--- Definition of the corruptions
--- Theme adds the restriction T-Plus has for Maiar: they may only gain the Balrog corruptions.
-
--- The Balrog corruptions
-CORRUPT_BALROG_AURA = add_corruption
-{
- ["color"] = TERM_ORANGE,
- ["name"] = "Balrog Aura",
- ["get_text"] = "A corrupted wall of flames surrounds you.",
- ["lose_text"] = "The wall of corrupted flames abandons you.",
- ["desc"] =
- {
- " Surrounds you with a fiery aura",
- " But it can burn scrolls when you read them"
- },
-}
-
-CORRUPT_BALROG_WINGS = add_corruption
-{
- ["color"] = TERM_ORANGE,
- ["name"] = "Balrog Wings",
- ["get_text"] = "Wings of shadow grow in your back.",
- ["lose_text"] = "The wings in your back fall apart.",
- ["desc"] =
- {
- " Creates ugly, but working, wings allowing you to fly",
- " But it reduces charisma by 4 and dexterity by 2"
- },
-}
-
-CORRUPT_BALROG_STRENGTH = add_corruption
-{
- ["color"] = TERM_ORANGE,
- ["name"] = "Balrog Strength",
- ["get_text"] = "Your muscles get unnatural strength.",
- ["lose_text"] = "Your muscles get weaker again.",
- ["desc"] =
- {
- " Provides 3 strength and 1 constitution",
- " But it reduces charisma by 1 and dexterity by 3"
- },
-}
-
-CORRUPT_BALROG_FORM = add_corruption
-{
- ["color"] = TERM_YELLOW,
- ["name"] = "Balrog Form",
- ["get_text"] = "You feel the might of a Balrog inside you.",
- ["lose_text"] = "The presence of the Balrog seems to abandon you.",
- ["desc"] =
- {
- " Allows you to turn into a Balrog at will",
- " You need Balrog Wings, Balrog Aura and Balrog Strength to activate it"
- },
- ["depends"] =
- {
- [CORRUPT_BALROG_AURA] = TRUE,
- [CORRUPT_BALROG_WINGS] = TRUE,
- [CORRUPT_BALROG_STRENGTH] = TRUE
- },
-}
-
-
--- The Demon corruptions
-CORRUPT_DEMON_SPIRIT = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Demon Spirit",
- ["get_text"] = "Your spirit opens to corrupted thoughts.",
- ["lose_text"] = "Your spirit closes again to the corrupted thoughts.",
- ["desc"] =
- {
- " Increases your intelligence by 1",
- " But reduce your charisma by 2",
- },
-}
-
-CORRUPT_DEMON_HIDE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Demon Hide",
- ["get_text"] = "Your skin grows into a thick hide.",
- ["lose_text"] = "Your skin returns to a natural state.",
- ["desc"] =
- {
- " Increases your armour class by your level",
- " Provides immunity to fire at level 40",
- " But reduces speed by your level / 7",
- },
-}
-
-CORRUPT_DEMON_BREATH = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Demon Breath",
- ["get_text"] = "Your breath becomes mephitic.",
- ["lose_text"] = "Your breath is once again normal.",
- ["desc"] =
- {
- " Provides fire breath",
- " But gives a small chance to spoil potions when you quaff them",
- },
-}
-
-CORRUPT_DEMON_REALM = add_corruption
-{
- ["color"] = TERM_L_RED,
- ["name"] = "Demon Realm",
- ["get_text"] = "You feel more attuned to the demon realm.",
- ["lose_text"] = "You lose your attunement to the demon realm.",
- ["desc"] =
- {
- " Provides access to the demon school skill and the use of demonic equipment",
- " You need Demon Spirit, Demon Hide and Demon Breath to activate it"
- },
- ["depends"] =
- {
- [CORRUPT_DEMON_SPIRIT] = TRUE,
- [CORRUPT_DEMON_HIDE] = TRUE,
- [CORRUPT_DEMON_BREATH] = TRUE
- },
-}
-
-
--- Teleportation corruptions
-
--- Random teleportation will ask for confirmation 70% of the time
--- But 30% of the time it will teleport, without asking
-CORRUPT_RANDOM_TELEPORT = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "Random teleportation",
- ["get_text"] = "Space seems to fizzle around you.",
- ["lose_text"] = "Space solidify again around you.",
- ["desc"] =
- {
- " Randomly teleports you around",
- },
- -- No oppose field, it will be automatically set when we declare the anti-telep corruption to oppose us
-}
-
--- Anti-teleportation corruption, can be stopped with this power
-CORRUPT_ANTI_TELEPORT = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "Anti-teleportation",
- ["get_text"] = "Space continuum freezes around you.",
- ["lose_text"] = "Space continuum can once more be altered around you.",
- ["desc"] =
- {
- " Prevents all teleportations, be it of you or monsters",
- },
- ["oppose"] =
- {
- [CORRUPT_RANDOM_TELEPORT] = TRUE
- },
-}
-
-
--- Troll blood
-CORRUPT_TROLL_BLOOD = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "Troll Blood",
- ["get_text"] = "Your blood thickens, you sense corruption in it.",
- ["lose_text"] = "Your blood returns to a normal state.",
- ["desc"] =
- {
- " Troll blood flows in your veins, granting increased regeneration",
- " It also enables you to feel the presence of other troll beings",
- " But it will make your presence more noticeable and aggravating",
- },
-}
-
--- The vampire corruption set
-CORRUPT_VAMPIRE_TEETH = add_corruption
-{
- ["group"] = "Vampire",
- ["removable"] = FALSE,
- ["color"] = TERM_L_DARK,
- ["name"] = "Vampiric Teeth",
- ["get_text"] = "You grow vampiric teeth!",
- ["lose_text"] = "BUG! this should not happen",
- ["desc"] =
- {
- " Your teeth allow you to drain blood to feed yourself",
- " However your stomach now only accepts blood.",
- },
- ["allow"] = function()
- if test_race_flags(1, PR1_NO_SUBRACE_CHANGE) == FALSE then return not nil else return nil end
- end,
-}
-CORRUPT_VAMPIRE_STRENGTH = add_corruption
-{
- ["group"] = "Vampire",
- ["removable"] = FALSE,
- ["color"] = TERM_L_DARK,
- ["name"] = "Vampiric Strength",
- ["get_text"] = "Your body seems more dead than alive.",
- ["lose_text"] = "BUG! this should not happen",
- ["desc"] =
- {
- " Your body seems somewhat dead",
- " In this near undead state it has improved strength, constitution and intelligence",
- " But reduced dexterity, wisdom and charisma.",
- },
- ["depends"] =
- {
- [CORRUPT_VAMPIRE_TEETH] = TRUE,
- },
-}
-CORRUPT_VAMPIRE_VAMPIRE = add_corruption
-{
- ["group"] = "Vampire",
- ["removable"] = FALSE,
- ["color"] = TERM_L_DARK,
- ["name"] = "Vampire",
- ["get_text"] = "You die to be reborn in a Vampire form.",
- ["lose_text"] = "BUG! this should not happen",
- ["desc"] =
- {
- " You are a Vampire. As such you resist cold, poison, darkness and nether.",
- " Your life is sustained, but you cannot stand the light of the sun."
- },
- ["depends"] =
- {
- [CORRUPT_VAMPIRE_STRENGTH] = TRUE,
- },
-}
-
--- The old activable corruptions / mutations
-
-MUT1_SPIT_ACID = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Ancalagon's Breath",
- ["get_text"] = "You gain the ability to spit acid.",
- ["lose_text"] = "You lose the ability to spit acid.",
- ["desc"] =
- {
- " Fires an acid ball.",
- " Damage=level Radius 1+(level/30)",
- " Level=9, Cost=9, Stat=DEX, Difficulty=15",
- },
-}
-
-MUT1_BR_FIRE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Smaug's Breath",
- ["get_text"] = "You gain the ability to breathe fire.",
- ["lose_text"] = "You lose the ability to breathe fire.",
- ["desc"] =
- {
- " Fires a fire ball.",
- " Damage=2*level Radius 1+(level/20)",
- " Level=20, Cost=10, Stat=CON, Difficulty=18",
- },
-}
-
-MUT1_HYPN_GAZE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Glaurung's Gaze",
- ["get_text"] = "Your eyes look mesmerizing...",
- ["lose_text"] = "Your eyes look uninteresting.",
- ["desc"] =
- {
- " Tries to make a monster your pet.",
- " Power=level",
- " Level=12, Cost=12, Stat=CHR, Difficulty=18",
- },
-}
-
-MUT1_TELEKINES = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Saruman's Power",
- ["get_text"] = "You gain the ability to move objects telekinetically.",
- ["lose_text"] = "You lose the ability to move objects telekinetically.",
- ["desc"] =
- {
- " Move an object in line of sight to you.",
- " Max weight equal to (level) pounds",
- " Level=9, Cost=9, Stat=WIS, Difficulty=14",
- },
-}
-
-MUT1_VTELEPORT = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Teleport",
- ["get_text"] = "You gain the power of teleportation at will.",
- ["lose_text"] = "You lose the power of teleportation at will.",
- ["desc"] =
- {
- " Teleports the player at will.",
- " Distance 10+4*level squares",
- " Level=7, Cost=7, Stat=WIS, Difficulty=15",
- },
-}
-
-MUT1_MIND_BLST = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Glaurung's Spell",
- ["get_text"] = "You gain the power of Mind Blast.",
- ["lose_text"] = "You lose the power of Mind Blast.",
- ["desc"] =
- {
- " Fires a mind blasting bolt (psi damage).",
- " Psi Damage (3+(level-1)/5)d3",
- " Level=5, Cost=3, Stat=WIS, Difficulty=15",
- },
-}
-
-MUT1_VAMPIRISM = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Vampiric Drain",
- ["get_text"] = "You become vampiric.",
- ["lose_text"] = "You are no longer vampiric.",
- ["desc"] =
- {
- " You can drain life from a foe like a vampire.",
- " Drains (level+1d(level))*(level/10) hitpoints,",
- " heals you and satiates you. Doesn't work on all monsters",
- " Level=4, Cost=5, Stat=CON, Difficulty=9",
- },
-}
-
-MUT1_SMELL_MET = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Carcharoth's Nose",
- ["get_text"] = "You smell a metallic odour.",
- ["lose_text"] = "You no longer smell a metallic odour.",
- ["desc"] =
- {
- " You can detect nearby precious metal (treasure).",
- " Radius 25",
- " Level=3, Cost=2, Stat=INT, Difficulty=12",
- },
-}
-
-MUT1_SMELL_MON = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Huan's Nose",
- ["get_text"] = "You smell filthy monsters.",
- ["lose_text"] = "You no longer smell filthy monsters.",
- ["desc"] =
- {
- " You can detect nearby monsters.",
- " Radius 25",
- " Level=5, Cost=4, Stat=INT, Difficulty=15",
- },
-}
-
-MUT1_BLINK = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Blink",
- ["get_text"] = "You gain the power of minor teleportation.",
- ["lose_text"] = "You lose the power of minor teleportation.",
- ["desc"] =
- {
- " You can teleport yourself short distances (10 squares).",
- " Level=3, Cost=3, Stat=WIS, Difficulty=12",
- },
-}
-
-MUT1_EAT_ROCK = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Eat Rock",
- ["get_text"] = "The walls look delicious.",
- ["lose_text"] = "The walls look unappetizing.",
- ["desc"] =
- {
- " You can consume solid rock with food benefit,",
- " leaving an empty space behind.",
- " Level=8, Cost=12, Stat=CON, Difficulty=18",
- },
-}
-
-MUT1_SWAP_POS = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Swap Position",
- ["get_text"] = "You feel like walking a mile in someone else's shoes.",
- ["lose_text"] = "You feel like staying in your own shoes.",
- ["desc"] =
- {
- " You can switch locations with another being,",
- " unless it resists teleportation.",
- " Level=15, Cost=12, Stat=DEX, Difficulty=16",
- },
-}
-
-MUT1_SHRIEK = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Shriek",
- ["get_text"] = "Your vocal cords get much tougher.",
- ["lose_text"] = "Your vocal cords get much weaker.",
- ["desc"] =
- {
- " Fires a sound ball and aggravates monsters.",
- " Damage=level*4, Radius=8, centered on player",
- " Level=4, Cost=4, Stat=CON, Difficulty=6",
- },
-}
-
-MUT1_ILLUMINE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Illuminate",
- ["get_text"] = "You can light up rooms with your presence.",
- ["lose_text"] = "You can no longer light up rooms with your presence.",
- ["desc"] =
- {
- " You can emit bright light that illuminates an area.",
- " Damage=2d(level/2) Radius=(level/10)+1",
- " Level=3, Cost=2, Stat=INT, Difficulty=10",
- },
-}
-
-MUT1_DET_CURSE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Detect Curses",
- ["get_text"] = "You can feel evil magics.",
- ["lose_text"] = "You can no longer feel evil magics.",
- ["desc"] =
- {
- " You can feel the danger of evil magic.",
- " It detects cursed items in the inventory",
- " Level=7, Cost=14, Stat=WIS, Difficulty=14",
- },
-}
-
-MUT1_BERSERK = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Berserk",
- ["get_text"] = "You feel a controlled rage.",
- ["lose_text"] = "You no longer feel a controlled rage.",
- ["desc"] =
- {
- " You can drive yourself into a berserk frenzy.",
- " It grants super-heroism. Duration=10+1d(level)",
- " Level=8, Cost=8, Stat=STR, Difficulty=14",
- },
-}
-
-
-MUT1_MIDAS_TCH = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Midas touch",
- ["get_text"] = "You gain the Midas touch.",
- ["lose_text"] = "You lose the Midas touch.",
- ["desc"] =
- {
- " You can turn ordinary items to gold.",
- " Turns a non-artifact object into 1/3 its value in gold",
- " Level=10, Cost=5, Stat=INT, Difficulty=12",
- },
-}
-
-MUT1_GROW_MOLD = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Grow Mold",
- ["get_text"] = "You feel a sudden affinity for mold.",
- ["lose_text"] = "You feel a sudden dislike for mold.",
- ["desc"] =
- {
- " You can cause mold to grow near you.",
- " Summons up to 8 molds around the player",
- " Level=1, Cost=6, Stat=CON, Difficulty=14",
- },
-}
-
-MUT1_RESIST = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Resist Elements",
- ["get_text"] = "You feel like you can protect yourself.",
- ["lose_text"] = "You feel like you might be vulnerable.",
- ["desc"] =
- {
- " You can harden yourself to the ravages of the elements.",
- " Level-dependent chance of gaining resistances to the four ",
- " elements and poison. Duration=20 + d20",
- " Level=10, Cost=12, Stat=CON, Difficulty=12",
- },
-}
-
-MUT1_EARTHQUAKE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Earthquake",
- ["get_text"] = "You gain the ability to wreck the dungeon.",
- ["lose_text"] = "You lose the ability to wreck the dungeon.",
- ["desc"] =
- {
- " You can bring down the dungeon around your ears.",
- " Radius=10, center on the player",
- " Level=12, Cost=12, Stat=STR, Difficulty=16",
- },
-}
---[[
-CORRUPT_ = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "",
- ["get_text"] = "",
- ["lose_text"] = "",
- ["desc"] =
- {
- " ",
- },
-}
-]]
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua
index 19649da7..b70fb773 100644
--- a/lib/mods/theme/scpt/init.lua
+++ b/lib/mods/theme/scpt/init.lua
@@ -17,9 +17,6 @@ tome_dofile("powers.lua")
-- Add the mimic shapes
tome_dofile("mimic.lua")
--- Add the corruptions
-tome_dofile("corrupt.lua")
-
-- Add the mkey activations
tome_dofile("mkeys.lua")
diff --git a/lib/mods/theme/scpt/monsters.lua b/lib/mods/theme/scpt/monsters.lua
index ad3a5628..cbadf1d6 100644
--- a/lib/mods/theme/scpt/monsters.lua
+++ b/lib/mods/theme/scpt/monsters.lua
@@ -75,10 +75,10 @@ add_hooks{
[HOOK_GAME_START] = function()
if ((get_race_name() == "Maia") and
- (player.corruption(CORRUPT_BALROG_AURA) ~= TRUE) and
- (player.corruption(CORRUPT_BALROG_WINGS) ~= TRUE) and
- (player.corruption(CORRUPT_BALROG_STRENGTH) ~= TRUE) and
- (player.corruption(CORRUPT_BALROG_FORM) ~= TRUE)) then
+ (player_has_corruption(CORRUPT_BALROG_AURA) ~= TRUE) and
+ (player_has_corruption(CORRUPT_BALROG_WINGS) ~= TRUE) and
+ (player_has_corruption(CORRUPT_BALROG_STRENGTH) ~= TRUE) and
+ (player_has_corruption(CORRUPT_BALROG_FORM) ~= TRUE)) then
-- "Proper" Maiar aggravate evil beings
TIMER_AGGRAVATE_EVIL.enabled = TRUE
-- Good beings (except swans, GWoPs, Wyrm Spirits, and some joke uniques) are coaligned with Maiar
diff --git a/lib/scpt/corrupt.lua b/lib/scpt/corrupt.lua
deleted file mode 100644
index 19957668..00000000
--- a/lib/scpt/corrupt.lua
+++ /dev/null
@@ -1,243 +0,0 @@
--- Definition of the corruptions
-
--- The Balrog corruptions
-CORRUPT_BALROG_AURA = add_corruption
-{
- ["color"] = TERM_ORANGE,
- ["name"] = "Balrog Aura",
- ["get_text"] = "A corrupted wall of flames surrounds you.",
- ["lose_text"] = "The wall of corrupted flames abandons you.",
- ["desc"] =
- {
- " Surrounds you with a fiery aura",
- " But it can burn scrolls when you read them"
- },
-}
-
-CORRUPT_BALROG_WINGS = add_corruption
-{
- ["color"] = TERM_ORANGE,
- ["name"] = "Balrog Wings",
- ["get_text"] = "Wings of shadow grow in your back.",
- ["lose_text"] = "The wings in your back fall apart.",
- ["desc"] =
- {
- " Creates ugly, but working, wings allowing you to fly",
- " But it reduces charisma by 4 and dexterity by 2"
- },
-}
-
-CORRUPT_BALROG_STRENGTH = add_corruption
-{
- ["color"] = TERM_ORANGE,
- ["name"] = "Balrog Strength",
- ["get_text"] = "Your muscles get unnatural strength.",
- ["lose_text"] = "Your muscles get weaker again.",
- ["desc"] =
- {
- " Provides 3 strength and 1 constitution",
- " But it reduces charisma by 1 and dexterity by 3"
- },
-}
-
-CORRUPT_BALROG_FORM = add_corruption
-{
- ["color"] = TERM_YELLOW,
- ["name"] = "Balrog Form",
- ["get_text"] = "You feel the might of a Balrog inside you.",
- ["lose_text"] = "The presence of the Balrog seems to abandon you.",
- ["desc"] =
- {
- " Allows you to turn into a Balrog at will",
- " You need Balrog Wings, Balrog Aura and Balrog Strength to activate it"
- },
- ["depends"] =
- {
- [CORRUPT_BALROG_AURA] = TRUE,
- [CORRUPT_BALROG_WINGS] = TRUE,
- [CORRUPT_BALROG_STRENGTH] = TRUE
- },
-}
-
-
--- The Demon corruptions
-CORRUPT_DEMON_SPIRIT = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Demon Spirit",
- ["get_text"] = "Your spirit opens to corrupted thoughts.",
- ["lose_text"] = "Your spirit closes again to the corrupted thoughts.",
- ["desc"] =
- {
- " Increases your intelligence by 1",
- " But reduce your charisma by 2",
- },
-}
-
-CORRUPT_DEMON_HIDE = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Demon Hide",
- ["get_text"] = "Your skin grows into a thick hide.",
- ["lose_text"] = "Your skin returns to a natural state.",
- ["desc"] =
- {
- " Increases your armour class by your level",
- " Provides immunity to fire at level 40",
- " But reduces speed by your level / 7",
- },
-}
-
-CORRUPT_DEMON_BREATH = add_corruption
-{
- ["color"] = TERM_RED,
- ["name"] = "Demon Breath",
- ["get_text"] = "Your breath becomes mephitic.",
- ["lose_text"] = "Your breath is once again normal.",
- ["desc"] =
- {
- " Provides fire breath",
- " But gives a small chance to spoil potions when you quaff them",
- },
-}
-
-CORRUPT_DEMON_REALM = add_corruption
-{
- ["color"] = TERM_L_RED,
- ["name"] = "Demon Realm",
- ["get_text"] = "You feel more attuned to the demon realm.",
- ["lose_text"] = "You lose your attunement to the demon realm.",
- ["desc"] =
- {
- " Provides access to the demon school skill and the use of demonic equipment",
- " You need Demon Spirit, Demon Hide and Demon Breath to activate it"
- },
- ["depends"] =
- {
- [CORRUPT_DEMON_SPIRIT] = TRUE,
- [CORRUPT_DEMON_HIDE] = TRUE,
- [CORRUPT_DEMON_BREATH] = TRUE
- },
-}
-
-
--- Teleportation corruptions
-
--- Random teleportation will ask for confirmation 70% of the time
--- But 30% of the time it will teleport, without asking
-CORRUPT_RANDOM_TELEPORT = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "Random teleportation",
- ["get_text"] = "Space seems to fizzle around you.",
- ["lose_text"] = "Space solidify again around you.",
- ["desc"] =
- {
- " Randomly teleports you around",
- },
- -- No oppose field, it will be automatically set when we declare the anti-telep corruption to oppose us
-}
-
--- Anti-teleportation corruption, can be stopped with this power
-CORRUPT_ANTI_TELEPORT = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "Anti-teleportation",
- ["get_text"] = "Space continuum freezes around you.",
- ["lose_text"] = "Space continuum can once more be altered around you.",
- ["desc"] =
- {
- " Prevents all teleportations, be it of you or monsters",
- },
- ["oppose"] =
- {
- [CORRUPT_RANDOM_TELEPORT] = TRUE
- },
-}
-
-
--- Troll blood
-CORRUPT_TROLL_BLOOD = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "Troll Blood",
- ["get_text"] = "Your blood thickens, you sense corruption in it.",
- ["lose_text"] = "Your blood returns to a normal state.",
- ["desc"] =
- {
- " Troll blood flows in your veins, granting increased regeneration",
- " It also enables you to feel the presence of other troll beings",
- " But it will make your presence more noticeable and aggravating",
- },
-}
-
--- The vampire corruption set
-CORRUPT_VAMPIRE_TEETH = add_corruption
-{
- ["group"] = "Vampire",
- ["removable"] = FALSE,
- ["color"] = TERM_L_DARK,
- ["name"] = "Vampiric Teeth",
- ["get_text"] = "You grow vampiric teeth!",
- ["lose_text"] = "BUG! this should not happen",
- ["desc"] =
- {
- " Your teeth allow you to drain blood to feed yourself",
- " However your stomach now only accepts blood.",
- },
- ["allow"] = function()
- if test_race_flags(1, PR1_NO_SUBRACE_CHANGE) == FALSE then return not nil else return nil end
- end,
-}
-CORRUPT_VAMPIRE_STRENGTH = add_corruption
-{
- ["group"] = "Vampire",
- ["removable"] = FALSE,
- ["color"] = TERM_L_DARK,
- ["name"] = "Vampiric Strength",
- ["get_text"] = "Your body seems more dead than alive.",
- ["lose_text"] = "BUG! this should not happen",
- ["desc"] =
- {
- " Your body seems somewhat dead",
- " In this near undead state it has improved strength, constitution and intelligence",
- " But reduced dexterity, wisdom and charisma.",
- },
- ["depends"] =
- {
- [CORRUPT_VAMPIRE_TEETH] = TRUE,
- },
-}
-CORRUPT_VAMPIRE_VAMPIRE = add_corruption
-{
- ["group"] = "Vampire",
- ["removable"] = FALSE,
- ["color"] = TERM_L_DARK,
- ["name"] = "Vampire",
- ["get_text"] = "You die to be reborn in a Vampire form.",
- ["lose_text"] = "BUG! this should not happen",
- ["desc"] =
- {
- " You are a Vampire. As such you resist cold, poison, darkness and nether.",
- " Your life is sustained, but you cannot stand the light of the sun."
- },
- ["depends"] =
- {
- [CORRUPT_VAMPIRE_STRENGTH] = TRUE,
- },
-}
-
-
---[[
-CORRUPT_ = add_corruption
-{
- ["color"] = TERM_GREEN,
- ["name"] = "",
- ["get_text"] = "",
- ["lose_text"] = "",
- ["desc"] =
- {
- " ",
- },
-}
-]]
diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua
index 8b288f17..ea42f927 100644
--- a/lib/scpt/init.lua
+++ b/lib/scpt/init.lua
@@ -17,9 +17,6 @@ tome_dofile("powers.lua")
-- Add the mimic shapes
tome_dofile("mimic.lua")
--- Add the corruptions
-tome_dofile("corrupt.lua")
-
-- Add the mkey activations
tome_dofile("mkeys.lua")
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++)
{
diff --git a/src/cmd4.c b/src/cmd4.c
index e9125d3d..29d01c73 100644
--- a/src/cmd4.c
+++ b/src/cmd4.c
@@ -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);
diff --git a/src/cmd5.c b/src/cmd5.c
index 847c279b..57746ca0 100644
--- a/src/cmd5.c
+++ b/src/cmd5.c
@@ -236,7 +236,7 @@ void do_poly_self(void)
/* Polymorph into a less corrupted form */
power -= 10;
- lose_corruption(0);
+ lose_corruption();
}
/*
diff --git a/src/cmd6.c b/src/cmd6.c
index 48d56125..67fad8e2 100644
--- a/src/cmd6.c
+++ b/src/cmd6.c
@@ -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. */