git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3112 c06c8d41-db1a-0410-9941-cceddc491573
66B4FST7OBWPB2T5FZ4RO32G5QSLQSNPAHHLGEVOL6WDS455PABQC -------------------------------------------------------------- pickup.lua:-- Smarter autopickup handling that takes into account the-- item type in combination with your character's race,-- religion, knowledge, and eating habits.---- To use this, add this line to your init.txt:-- lua_file = lua/pickup.lua---- Notes:-- * This script only handles items of classes with-- autopickup on.-- * Any result can still be overridden using-- autopickup_exceptions.------------------------------------------------------------function make_hash(ls)local h = { }for _, i in ipairs(ls) doh[i] = trueendreturn hendfunction you_undead()return you.race() == "Mummy" or you.race() == "Ghoul"or you.race() == "Vampire"end-- not identifiedfunction unknown_potion(type)return type == 0endfunction good_potion(type)return type == 1endfunction bad_potion(type)return type == 2end-- special casesfunction spec_potion(type)return type == 3endfunction ch_autopickup(it)local spells = make_hash( you.spells() )if item.class(it) == "Potions" thenlocal type = item.potion_type(it)-- "bad" potions only for Evaporateif spells["Evaporate"] and bad_potion(type) thenreturn trueend-- no potions for Mummies-- also: no bad potions for anyone elseif you.race() == "Mummy" or bad_potion(type) thenreturn falseend-- pickup "good" and unID'd potionsif good_potion(type) or unknown_potion(type) thenreturn trueend-- special handlingif spec_potion(type) then-- undead cannot use berserk-- or anything involving mutationsif item.subtype(it) == "berserk"or item.subtype(it) == "gain ability"or item.subtype(it) == "cure mutation" thenif you_undead() thenreturn falseelsereturn trueendend-- special cases for blood, water, and porridgeif item.subtype(it) == "blood"or item.subtype(it) == "water"or item.subtype(it) == "porridge" thenreturn food.can_eat(it, false)endend-- anything not handled until here can be picked upreturn trueendif item.class(it) == "Carrion"or item.class(it) == "Comestibles" thenreturn food.can_eat(it, false)endif item.class(it) == "Books" and you.god() == "Trog"then return falseendif item.class(it) == "Jewellery" thenif item.subtype(it) == "hunger"or item.subtype(it) == "inaccuracy" thenreturn falseendif you_undead() and(item.subtype(it) == "regeneration"or item.subtype(it) == "rage"or item.subtype(it) == "sustenance"and you.race() == "Mummy") thenreturn falseendend-- we only get here if class autopickup ONreturn trueend
-------------------------------------------------------------- pickup.lua:-- Smarter autopickup handling that takes into account the-- item type in combination with your character's race,-- religion, knowledge, and eating habits.---- To use this, add this line to your init.txt:-- lua_file = lua/pickup.lua---- Notes:-- * This script only handles items of classes with-- autopickup on.-- * Any result can still be overridden using-- autopickup_exceptions.------------------------------------------------------------function make_hash(ls)local h = { }for _, i in ipairs(ls) doh[i] = trueendreturn hendfunction you_undead()return you.race() == "Mummy" or you.race() == "Ghoul"or you.race() == "Vampire"end-- not identifiedfunction unknown_potion(type)return type == 0endfunction good_potion(type)return type == 1endfunction bad_potion(type)return type == 2end-- special casesfunction spec_potion(type)return type == 3endfunction ch_autopickup(it)local spells = make_hash( you.spells() )if item.class(it) == "Potions" thenlocal type = item.potion_type(it)-- "bad" potions only for Evaporateif spells["Evaporate"] and bad_potion(type) thenreturn trueend-- no potions for Mummies-- also: no bad potions for anyone elseif you.race() == "Mummy" or bad_potion(type) thenreturn falseend-- pickup "good" and unID'd potionsif good_potion(type) or unknown_potion(type) thenreturn trueend-- special handlingif spec_potion(type) then-- undead cannot use berserk-- or anything involving mutationsif item.subtype(it) == "berserk"or item.subtype(it) == "gain ability"or item.subtype(it) == "cure mutation" thenif you_undead() thenreturn falseelsereturn trueendend-- special cases for blood, water, and porridgeif item.subtype(it) == "blood"or item.subtype(it) == "water"or item.subtype(it) == "porridge" thenreturn food.can_eat(it, false)endend-- anything not handled until here can be picked upreturn trueendif item.class(it) == "Carrion"or item.class(it) == "Comestibles" thenreturn food.can_eat(it, false)endif item.class(it) == "Books" and you.god() == "Trog"then return falseendif item.class(it) == "Jewellery" thenif item.subtype(it) == "hunger"or item.subtype(it) == "inaccuracy" thenreturn falseendif you_undead() and(item.subtype(it) == "regeneration"or item.subtype(it) == "rage"or item.subtype(it) == "sustenance"and you.race() == "Mummy") thenreturn falseendend-- we only get here if class autopickup ONreturn trueend