Blindfold removal fix
[slashemextended.git] / src / mkobj.c
blobd3a3315b90e7fcded52f2ae49a0cfb525700c363
1 /* SCCS Id: @(#)mkobj.c 3.4 2002/10/07 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #include "hack.h"
6 #include "prop.h"
9 STATIC_DCL void mkbox_cnts(struct obj *);
10 STATIC_DCL void obj_timer_checks(struct obj *, XCHAR_P, XCHAR_P, int);
11 #ifdef OVL1
12 STATIC_DCL void container_weight(struct obj *);
13 STATIC_DCL struct obj *save_mtraits(struct obj *, struct monst *);
14 #ifdef WIZARD
15 STATIC_DCL const char *where_name(int);
16 STATIC_DCL void check_contained(struct obj *,const char *);
17 #endif
18 #endif /* OVL1 */
19 STATIC_DCL int makeobject_core(int);
20 STATIC_DCL boolean artigenechance(int);
22 extern struct obj *thrownobj; /* defined in dothrow.c */
24 /*#define DEBUG_EFFECTS*/ /* show some messages for debugging */
26 struct icp {
27 int iprob; /* probability of an item type */
28 char iclass; /* item class */
31 /* faux artifacts to fool the player --Amy */
32 static const char * const fauxartinames[] = {
34 "Pus Spitter", "Excalibat", "Moonbite", "Steelgleam", "Spellstealer", "Ironward", "Crashbug Preventer", "Segfault Breath", "Server Operator", "Mindflayer's Best", "The Burninator", "Ascension Kit Part", "DYWYPI", "Identificator", "Frost Barrier", "Zombiekiller", "Litchbane", "Gnomerist", "Vorpal Element", "Silverswandir", "Electric Brand", "Mojo", "Mirrorblack", "Eluder", "Barrowtooth", "Icy Flame", "Spider's Tongue", "Thunderbringer", "White Death", "Coldfire", "Polar Sphere", "Mind Maw", "Hidden Potato", "Queeb Butt", "Total Nonsense", "Spewbrewer", "Lasercross", "Hotel Thirst", "Ultimate Artifact", "Anti-YASD Insurance", "Invulnerability Dummy", "Priced Bauble", "Hunter of Shiva", "Sharp Bender", "Itchalaquaakque", "Saintly Seduction", "Nymph Bait", "Magicbreath", "Team Nastytrap Medal", "Team Ant's Friend", "Hatefulpresident", "Snyder's Killer", "Universa Exit", "Marike's Farting Noise Generator", "Solvejg's Protector", "Josefine's Girly Fun", "Beeper Tag", "Larissa's Hugger", "Relic of AmyBSOD", "Slashem Slasher", "Deslexifier", "Soviet Russia Special", "Sexy Hexy", "Pinobot", "Kenault's Cantrip Generator", "The Deck of Wild Magic", "Baalzebub's Tormented Box", "Baalzebub's All-seeing Servant", "Boccob's Unfinished Works", "The Devil's Pentagram", "Mordekainen's Sneaking Eye", "Tenser's Alteration Manual", "The Pendulum of Orcus", "Mordekainen's Pocket Magician", "Benetar's Death Ray Experiment", "Valdarbon's Automatic Alchemist", "Demigods and their Uses", "Magic for the Layman", "Benetar's Mana Battery", "Benetar's Portable Plague", "Gamenlon's Summoning Manual", "The Lost Works of Kenault", "Planar Travel Made Easy", "The Wand Construction Kit", "The Clay Tablets of Antiquity", "Raal's Tormented Spirits", "Tenser's Mechanical Magician", "Boccob's Magical Mish-mash", "The Grail of Kenault", "Household Magic", "Tenser's Last Words", "Secrets of the Gnomish Wizards", "The Cunning Plan of Zog", "Immortality For Dummies", "Raistlin's Ready Ranger", "Mordenkainen's Mysterious Mind-Masher", "Famous Last Words", "Jor's Compendium of Strange Behaviour", "Agannazar's Antique Acorn", "Cathal's Corrupting Cymbal", "Pytar's Portable Pandemonium", "Finer Points of Munchkinism", "Agannazar's Altruistic Assassin", "Olive's Omnipotent Ostrich", "Cathal's Collapsible Crutch", "Nauglamir", "The Anchor of Space-Time", "Razorback", "Bladeturner", "Soulkeeper", "Belegennon", "Thalkettoth", "Holhenneth", "Colluin", "Holcolleth", "Colannon", "Cambeleg", "Cammithrim", "Paurhach", "Paurnimmen", "Pauraegen", "Paurnen", "Camlost", "Dal-i-thalion", "Angrist", "Narthanc", "Nimthanc", "Dethanc", "Belangil", "Calris", "Aranruth", "Glamourdring", "Aeglin", "Gurthang", "Zarcuthra", "Mormegil", "Gondricam", "Crisdurian", "Aglarang", "Ringil", "Anduril", "Anguirel", "Elvagil", "Forasgil", "Careth Asdriag", "Haradekket", "Gilettar", "Doomcaller", "Osondir", "Til-i-arc", "Aeglos", "Nimloth", "Lotharang", "Mundwine", "Barukkheled", "Avavir", "Grond", "Totila", "Thudunderfist", "Bloodspike", "Firestar", "Taratol", "Nar-i-vagil", "Eriril", "Deathwreaker", "Turmil", "Belthronding", "Cubragol", "Glimdrir", "Lasher", "Bullseye", "Travak", "Limbslicer", "Orchast", "Naturebane", "Hanisbroner's Surprise", "Merlion Karc's Demonbane", "Narsil", "Lebohaum", "Mediator", "Hithlomir", "Skullcleaver", "Durandil", "Toris Mejistos", "Elessar", "Evenstar", "Balefire", "Stonebiter", "Heart's Blood", "Scale-piercer", "Garachoth", "Skycleaver", "Photic Illuminator", "Captain Nemo's Nautilus", "Le Loup Blanc", "The Eye of Ra", "The Pectoral of the Kheper", "War of the Worlds", "The Time Machine", "20000 Leagues Under the Sea", "Journey to the Centre of the Earth", "Treasure Island", "Les Miserables", "Hunchback of Notre Dame", "The Count of Monte Cristo", "The Three Musketeers", "The Invisible Man", "Around the World in 80 Days", "Wuthering Heights", "The Adventures of Sherlock Holmes", "The Hound of the Baskervilles", "The Return of Sherlock Holmes", "The Lost World", "The Sign of the Four", "A Christmas Carol", "Great Expectations", "A Tale of Two Cities", "Little Women", "Alice's Adventures in Wonderland", "Through the Looking Glass", "The Adventures of Huckleberry Finn", "The Adventures of Tom Sawyer", "A Connecticut Yankee in King Arthur's Court", "The Prince and the Pauper", "Life on the Mississippi", "On the Origin of Species", "Tenant of Wildfell Hall", "Sense and Sensibility", "Pride and Prejudice", "Northanger Abbey", "Persuasion", "Confessions of an English Opium Eater", "The System of the Heavens", "Lord Rosse's Telescope", "On Murder Considered as One of the Fine Arts", "The Arts of Cheating, Swindling and Murder", "The Man Who Would Be King", "The Mark of the Beast", "Captains Courageous", "The Hunting of the Snark", "The Picture of Dorian Gray", "The Turn of the Screw", "King Solomon's Mines", "Legend of Sleepy Hollow", "Crime and Punishment", "Last of the Mohicans", "From the Earth to the Moon", "Round the Moon", "War and Peace", "The Man in the Iron Mask", "The Jungle Book", "Principles of Political Economy", "The Narrative of Arthur Gordon Pym", "Tales of the Grotesque and Arabesque", "The Tomb and Other Tales", "Dagon and Other Macabre Tales", "The Dream-Quest of the Unknown Kadath", "Mysteries of the Depths of the Seas", "The Life and Adventures of Santa Claus", "Red Nail", "Deathspade", "Mindrend", "Rakescar", "The Chieftan", "The Humongous", "Maelstromwrath", "Gravenspine", "Umes Lament", "Felloak", "Knell Striker", "Rusthandle", "Stoutnail", "Bloodrise", "The Generals Tan Do Li Blabla", "Bonesob", "Steeldriver", "Rixots Keen", "Azurewrath", "Hellplague", "Kinemils Awl", "The Patriarch", "Gull", "Irices Shard", "The Dragon Chang", "Razortine", "Steelgoad", "Bane Ash", "The Iron Jang Bong", "Witherstring", "Rimeraven", "Piercerib", "Pullspite", "Wizendraw", "Hellclap", "Blastbark", "Leadcrow", "Ichorstring", "Hellcast", "Doomspittle", "Duskdeep", "Greyform", "Blinkbats Form", "The Centurion", "Twitchthroe", "Darkglow", "Venomsward", "Iceblink", "Boneflesh", "Pelta Lunata", "Stormguild", "Steelclash", "Chance Guards", "Frostburn", "Hotspur", "Tearhaunch", "Nightsmoke", "Nokozan Relic", "The Eye of Etlich", "The Mahim-Oak Curio", "Manald Heal", "Gorgethroat", "The Stone of Jordan", "Crissaegrim", "Force Field", "Mother of Universe", "The Ungodly Slayer of Hitpoints", "The Randomizer", "Creeping Death", "Anthrax", "Tranquilizer", "Ezerataneous", "Blood Omen", "Blizzard of Oz", "Spectral Avoider", "Heretic Saprophyte", "Nature Is Hell", "The Energy Reaver", "Glory of Suffering", "Da Grip", "Terminus Est", "World Champion", "Elysdeon", "Datura", "Talula", "Nativity in Black", "A Twist of Ugliness", "Ass Kickers", "Visionary", "Impact Splatter", "A Woman's Scorn", "Saint Ankh", "Mystery Ankh", "Shining Freedom", "Juarez", "Hide in Shadows", "Stalking Ambush", "Resident Evil", "Celestial Seasons", "Flame Visit", "Spread Needle", "Heaven's Punisher", "Holy Ray", "Enchanted Revenge", "Chain of Conductors", "Soul of Support", "Vagyu Darkness", "Spiritual Cleansing", "Crushing Divinity", "Sightseeker", "Gospel of Peace", "Word of Truth", "Eternal Sphere", "Tri-Emblem", "Star Guard", "Valkerie Guard", "Missing Score", "Rolling Thunder", "Conformer", "Death Penalty", "Army of Me", "Varista", "Orotiagito", "Reactor Fragment", "Energy Core", "Thermal Nuclear Chamber", "Crystalis", "Carved Perfection", "Gold Digger", "The Memory of Lady Mia", "Kaladgolg", "Scorched Trail", "Intercontinental", "Di Immortales", "Til Death do Us Part", "Wrath of Cardice", "Penetrators", "MP3 Player", "Coldkill", "Islestrike", "Warlord's Trust", "Spellsteel", "Suicide Branch", "Cairn Shard", "Drulan's Tongue", "The Fetid Sprinkler", "Sureshrill Frost", "Moonfall", "Baezils Vortex", "Earthshaker", "Coldsteal Eye", "Hexfire", "Riftslash", "The Atlantien", "Crainte Vomir", "Bing Sz Wang", "Cloudcrack", "Todesfaelle Flamme", "Kelpie Snare", "Hone Sundan", "Athena's Wrath", "Pierre Tombale Couant", "Husoldal Evo", "Grim's Burning Dead", "Chromatic Ire", "Skullcollector", "Skystrike", "Kuko Shakaku", "Endlesshail", "Langer Briser", "Buriza-Do Kyanon", "Vampiregaze", "String of Ears", "Gorerider", "Lavagout", "Venom Grip", "Visceratuant", "Guardian Angle", "Shaftstop", "Valkiry Wing", "Demon Machine", "Cliffkiller", "Razorswitch", "Meatscrape", "Pitblood Thirst", "Ondal's Wisdom", "Geronimo's Fury", "Charsi's Favor", "Doppleganger's Shadow", "Deathbit", "Warshrike", "Gutsiphon", "Stonerattle", "Marrowgrinder", "Steelshade", "Death's Web", "Gaia's Wrath", "Khalim's Vengance", "Angel's Song", "The Reedeemer", "Fleshbone", "Odium", "Blood Comet", "Bul-Kathos' Might", "Arioc's Needle", "Shadowdancer", "Indiego's Fancy", "Tyrael's Mercy", "Souldrain", "Runemaster", "Executioner's Justice", "Wallace's Tear", "Leviathan", "Qual'Kek's Enforcer", "Dawnbringer", "Wisp Projector", "Gargoyle's Bite", "Lacerator", "Mang Song's Lesson", "El Espiritu", "The Ensanguinator", "The Reaper's Toll", "Spiritkeeper", "Hellrack", "Alma Negra", "Darkforge Spawn", "Sankenkur's Resurrection", "The Archon Magus", "Widow maker", "Catgut", "Ghostflame", "Bling Bling", "Nebucaneezer's Storm", "Griffon's Eye", "Eaglewind", "Windhammer", "Thunderstroke", "Bloodmoon", "Cranebeak", "Iansang's Frenzy", "Warhound", "Gulletwound", "Headhunter's Glory", "Mordoc's marauder", "Talberd's Law", "Amodeus's Manipulator", "Darksoul", "The Black Adder", "Nature's Peace", "Seraph's Hymn", "Zakarum's Salvation", "Blood Rain", "Horizon's Tornado", "Wrath of Cain", "Siren's call", "Archangel's Deliverance", "Fuego Del Sol", "El Infierno", "Moonrend", "Larzuk's Champion", "Nightsummon", "Kang's Virtue", "Lifechoke", "Palo Grande", "Ghostleach", "Samual's Caretaker", "Hell's Whisper", "The TreeEnt", "Stormwillow", "Moonshadow", "Strongoak", "Demonweb", "Bloodraven's Charge", "Shadefalcon", "Robin's Yolk", "Glimmershred", "Wraithflight", "Lestron's Mark", "Banshee's Wail", "Medusa's Gaze", "Hadeshorn", "Rockstopper", "Crow Caw", "Skullder's Ire", "Toothrow", "Atma's Wail", "Black Hades", "Corpsemourn", "Que-hegan's Wisdom", "Moser's Blessed Circle", "Stormchaser", "Tiamat's Rebuke", "Gerke's Sanctuary", "Radimant's Sphere", "Gravepalm", "Hellmouth", "Infernostride", "Silkweave", "Wartraveler", "Razortail", "Gloomstrap", "Snowclash", "Thudergod's Vigor", "Lanceguard", "Squire's Cover", "Boneflame", "Steelpillar", "Nightwing's Veil", "Hightower's Watch", "Darkfear", "Ashrera's Wired Frame", "Rainbow Facet", "Ravenlore", "Boneshade", "Nethercrow", "Flamebellow", "Fathom", "Wolfhowl", "Gheed's Fortune", "The Vicar", "Halaberd's Reign", "Parkersor's Calm", "Frostwind", "Templar's Might", "Eschuta's temper", "Sandstorm Trek", "Marrowwalk", "Heaven's Light", "Merman's Speed", "Arachnid Mesh", "Sigurd's Staunch", "Carrion Wind", "Gillian's Brazier", "Drakeflame", "Dust Storm", "Skulltred", "Alma's Reflection", "Sacred Charge", "Saracen's Chance", "Highlord's Wrath", "Raven Frost", "Dwarf Star", "Atma's Scarab", "Mara's Kaleidoscope", "The Rising Sun", "The Cat's Eye", "Metalgrid", "Titan's Revenge", "Shakabra's Crux", "Lycander's Aim", "Shadow's Touch", "The Prowler", "Sarmichian Justice", "Annihilus", "The Harbinger", "Doomseer", "Apothecary's Tote", "Apocrypha", "Foci of Visjerei", "Aurora's Guard", "Herald of Zakarum", "Ancient Eye", "Xenos", "Sister of the Water", "Flanker Loop", "Bet Notice", "Mafia City", "Flanker Intro", "Pinball Ingame", "Mafia Water", "Pin of the 11B potatoes", "The Dictator of France", "Short Wave Hiding", "Lock Defendant", "Solved Puzzle", "The Torture Master", "Diablo 2's Eddy Wind", "DHG-Search Play Prize", "Brasilia's Rain Forrest", "Artifical Accomplishment", "Amusing Ivo's Fury", "Elnaz's Blood Rush", "Sizzle's Card Stand", "G-cheater's Fucking Rockstar", "Gigantic Double-deck Airplane", "Holland's World Master Team", "GTS Champion Elbow", "Lily's Puncturer", "Laura and her sisters and their force", "A.Ha's Revenant", "Shakira's Beautiful Dance", "Gerlindchen's Flower Pot", "Ruth's resouding laughter", "Jane's embrace-worthiness", "Steel Beetle's Victory", "Invisible Maker", "H.'s Giant Tank", "Course of Kastor-Transport", "Ludgera's Deception", "Upper Perfect Kunzite", "CD of Britney Spears", "Gettoblaster 2.0++", "Awake Sleep Tower Sign", "Iceforce", "The Boss of the Errors", "Teacher Police's Cheating", "Property Completion", "Urbaldi's Last Salvation", "Nest of the Black Raptors", "Ruth's Case Sign", "World's Burden", "Tyrant's Power", "Magma Shooting Bird", "Dracula's Wish", "Zephyros", "Course Point's Glacial Spike", "Reflection Cover", "Barkbite", "Error Biter", "Breakwound Impacter", "Bulldog Gaurd", "Dark Corner", "Computer Mouse", "The Mould Defiler", "Port Output", "Apocalypse", "Frostfoil", "Ascaron", "Laurefindelo Umbar", "Scaleron", "Cosomoco Pelecco", "Cosomoco Vaitando", "Aiglos", "Winter's Bite", "Tempest", "Scorchwind", "Withering Finger", "Oblivion's Enbrace", "Crushing Grip", "Cruel Spur", "Fold of Sorrow", "Crimson Steel", "Spineridge", "Diabolic Wrap", "Spider Strand", "Battlelock", "Threshold Insurmountable", "Diabolic Casing", "Astral Dream", "Enspelled Talisman", "Charm of Holding", "Broach of Eternal Life", "Vizier's Charm", "Circle of Life and Death", "Cryptic Glyph", "Scion of Numenor", "Diabolic Gifts", "Vampire's Immortality", "Star of Tar-Ancalime", "Vilisse", "Ancalquon Morramaloce", "Cosomot Valaraucatur", "Relics of the Third Age", "Rule of Eldarion", "Boromir's Gift", "Scourge of Fire", "Battlecry of Lammoth", "Darkness of Moria", "Sacred Bottle Spirit", "Clay Tone Band", "Measure-hit a corner", "Leo's secret hiding place", "Jutta flax's OHP", "Total Sun Darkness", "The Gravegraver", "The Secret Car", "Silver-cutting 1E-coin", "The Queue's Destruction", "Diablo II's Great Hatred", "Stalin's Secret Refuge", "Clockold Blackwhite TV", "A Green Prostitute", "Marc's Battlestandard", "TI-83 Pocket Calculator", "Plague Error Impacter", "Spleendrain", "Ametyhstmaster", "Irriant Darkness", "Cage Rattler", "Hobbes's Rectifier", "Elsa's Champion", "Corner to sport-resounded", "Punching Bag", "Lesson with DJ Leutkak", "Internal Clan Area", "Cristi's Greener Pin", "The Challenging Fence", "A Christmas Present", "Star Wars - Episode 2", "Gorbatschov's Talisman", "The Tarrif Cashier", "Door to the space 314", "Saddam Has Fallen", "The Toilet Brush's Shard", "Bull Mode", "Lock Entrance Cashier", "King of Porn", "Marianne's Measurer", "Red Lit Combat Arena", "Mars-resound's Disguise", "The Horse's Giant Engine", "Fear Forwards The Light", "Hiding Place of Urbaldi", "Inability of Reziarfg", "Kastor-Transport's Accellerotor", "Aee's Steel Sign", "Gunnhild's General Store", "Heaven For Everyone", "Braight Meteor", "Homicidal Tendancies", "Master Thief", "Drogman's Fortune", "Nebucaneezer's Reign", "Prick Rat Nest", "Nosferatu's Grasp", "Hibernal Wind", "Sentinal Angle", "Most Wanted", "Giant Air Elemental", "Volcano Walk", "Insidiarious", "Slowing Down Spider Net", "Granitegrid", "Large Feries", "Sigurd's Impact", "Carrion Beetle", "Bonusroomward", "Secret Order", "Larissa's Requiem", "Larissa's Repose", "Larissa's Marker", "Larissa's Stride", "Larissa's Decorum", "Larissa's Mourning", "Operating Charm", "Blood Rose", "Frost Orchid", "Stinging Vine", "Falling Thunder", "Marc's Sprint", "Larissa's Windsong", "Call of Odin", "Herald of the Dead Potatoes", "Censor of the Dead Potatoes", "Black Flame", "SpeeArrow", "Leon's Rage", "Invisible Bane", "Andariel's Bane", "Sarthan Fang", "Larissa's Embrace", "Unknown Quantity", "Harathnar", "Vigilante", "Grand Final", "Alphabet Soup", "Streetrace", "Great ski the jungle", "Buggards Greatness", "Grave Theft", "The Cheater", "Super Long Eddy Wind", "Weather Control", "Sky High Fire", "Prison Lattice", "Super Grandpa", "World Fall", "Dumoto", "Firecracker", "Impossible Dream", "Reduction Jet", "Upper World Killer", "Berrytown Disco", "Porsche Carrera GT", "Errland's Salvation", "Germany's Liberator", "Arrest Jet", "Cave Bear's Revenge", "Giant Pencil Sharpener", "Car Hostage", "End of a bridge", "God's Allmight", "The Annihilating Plague", "McDonalds Cheat", "Radio Wave", "Taxi Central", "Lower Level", "Sky Collapse", "Useless Rubber", "Nefarius's Sucking", "Phrozenkeep's Insanity", "Accelerator Button", "Money Printing Machine", "Blessed Aim Bug", "Great Boredom", "Greener Branch", "Reuniting of the Elements", "Error Generator", "Perma-red Traffic Light", "Beer Drinker's Trick", "Lit Room", "Buriza-Do Astron", "Duskhigh", "Water Course", "Andrials Fake", "Missing Light", "Statue Room", "Yet Another Defense Part", "Upper Convictor", "Difficult Start", "Double Order", "Start Absorber", "Still More Difficult End", "Multiple Character", "Attack Guard", "Phil's Heroism", "Cop Skilltab", "Upper Giant UFO", "Crash Bonus 1 Million", "Thornwalk", "Cold Animation", "Fire Spire", "Allied Agora", "High Calculation", "Preemptive Calculation", "False Tal Rasha's Tomb", "Sky Explosion", "Bonus Speed", "Giant Attic Spider", "Too bad!", "Course Reflector", "Super Spray Box 3.1", "Super Spray Box 3.BAR++", "Crusaders Justice", "Shining Light", "Cursed Begining", "Worldstone Collapse", "Wildheart", "The Onslaught", "Shard of Heaven", "Ancients Peak", "Elements Vortex", "The Worldstone Hold", "Zues' Holy Shards", "Gustforce", "Chieftans Shrine", "Immortal One", "Theifs Prowess", "Elements Bane", "Colossal Bones", "The Wounding Noose", "Phases of Time", "Riamens Savour", "Cold Maidens Woods", "The Spirit Within", "Cruel Prod", "The Jester Tear", "Enspirited Soul", "The Maidens Cursed Touch", "Ogre's Crossing", "The Tribute", "Enslaver", "Worldstone Shard", "Deaths Dancer", "Heart's Content", "Mind and Soul", "Rampage", "The Zodiac", "Enhancer", "The Elmentalist", "The Weathers", "Green Unweather", "Blue Unweather", "Plague Stealer", "Bomb off-throw", "Bomber of the Monsters", "Stopping Target Far Tube", "Not Ending Thunder", "Boat Torch Flare", "Iron Vortex", "The Top Secret Course", "Ethereal Fighter", "Greater Controversy Code", "Cursed Worth", "Great Potato Iron", "Flash Spirit", "Wide Level", "Dynamic Right Library", "Course Thief", "The Dictator Of CD Rome", "Mummy Loading", "Saddam Hussein's Bomb Notice", "Green Space", "Unclear Link Curve", "Legal Situation", "Hell-Light Source", "Dark Wonderer", "Trophy Trap", "Larger Poison New Facts", "Pins Without Soul", "The Amazon's Last Chance", "Poison Fighter's Alternation", "Really Impossible Crash Bug", "Altered Save Method", "Fast Reload", "Group Meeting", "Newest Terror Notice", "Shot Series", "Insane Contractor", "Gate Shot", "Gang Shot", "Post Shot", "Endless Wave", "Hotel Burner", "Outgoing Heap", "Cheating Contractor", "Giant Shooting Range", "ds will only run in Protect mode", "Stolen from Duke", "Only Newly Added", "Already Outcheated", "Swift Flight Body", "The All-maker", "The Vault Master", "Thunder Curse", "Call of Loki", "Stalingrad Liberator", "Cooling Shot", "Incinerating Shot", "Tschaeauwieauw!", "Tschiuwiu!", "Hollywood Holocaust", "Low Level PK", "Impossible to find", "Additional Learning Achievement", "Leutkak's Special", "Gorden's Frenzy", "Golem Bar", "First Siegecrafter", "Mexico's Secret Agency", "Guantanamo's Discovery", "Pseudo Grandpa", "Dwelling Case", "Cheater Stinger", "Marlboro Light", "End of the year", "Steel Runeword", "Copilot Wanted Level 6", "Nuke MiG", "Connections", "Perfect Set", "Urbaldi's New Invention", "2k Raid", "Upward Course", "Burning Spaceship", "Overcharge", "God's Annihilator", "Cop Activator", "747 Attack", "Demon Portal", "Horizons Alternative", "Undead Portal", "Gift of the Golden Gates", "Devil Warder", "The North Star", "Pack Caller", "Nighttime Birds", "Pandemonium", "Avalanche Strike", "Insight of the Ancients", "Beating Disk", "Repenter of Mage Corruption", "Serendipity", "On Most Surfaces", "Oakheart", "Gruntface", "Stand Up And Shout", "Me Smash", "Elemental Ignorance", "Blessing of the Dawn", "Angel's Grace", "Nupraptor's Madness", "Morte", "Passive Horror", "Nightwish", "Ancients' Epiphany", "Survival of the Fittest", "Don't Break the Oath", "White Tiger", "These Precious Illusions", "The Road of Good Intentions", "Beware the Heavens", "Tamara's Youth", "In My Cross Hairs", "Nerad's Attunuation", "Violence Has Arrived", "Diversity is Our Strength", "Scarlet's Walk", "A Thousand Kisses Deep", "Eclipse", "Marumana", "Little Earthquakes", "Bloody Ballerina", "Grade-A Nirvana", "Focus Shifter", "Typhoon", "Lead Us to War", "Never is a Promise", "Pillum of Marius", "Twinrova's Essence", "Dark Shadow", "Holy Avenger", "The Only Fantasy is Reality", "We've Come For Your Daughter", "One Hitpoint Wonder", "Pokey Pokey", "Paragons of Innocence", "Fear of the Dark", "Gold Moon Dragon", "The Mob Rules", "Midnight Madness", "Shadow Feet", "Rakashi's Tempest", "Murder God Lasher", "Gravesinger", "Bleed the Freak", "Blegh", "Zero Drive Illusion", "Smokestack", "Bless the Child", "Whore of the Abattoir", "Haven's Work", "Heirloom of the Shara Goddess", "All is Full of Love", "Stormsplitter", "Volcaetus", "Claimh Saolias", "Evanescence", "The King's Devotion", "Melufa", "Gimmie a Hand", "Vanquisher", "Silence Breaker", "Lich Hunter", "Euros", "Tomb Chill", "I Spit on Your Grave", "We Are Nine", "Persona", "Andrea's World", "Can I Play With Madness", "Hidden Place", "Akara's Thanks", "Skidbladnir", "The Devil's Orchid", "Curse Tips", "Azalin's Wish", "Hangman's Smile", "Morrenbane", "Infinite Fury", "Wizard Away Spray", "Planar Edge", "Terra's Enchantment", "Prox", "Ocean's Embrace", "Terminator", "The Last in Line", "Electric Funeral", "Turn Up the Night", "Silver Spark", "Angry Machines", "Tidal Master", "Longicolnis", "Spirit of Servents", "Powerslave", "D.N.R.", "From the Other Side", "Atheist Champion", "Horror Show", "Dusk", "van Gough's Gift", "Hail Storm", "Brotherhood", "Eat Your Entrails", "Straferiffic", "Poets and Madmen", "Immortal Corruptor", "Cvalda", "The Amnesty of Night", "Running Free", "Soul Hunter Medallion", "Reinventing the Steel", "Dehumanizer", "Sky Scorcher", "Cain's Support", "Wolfsbane Bloom", "Lobelia", "Biledriver", "Variant Reader's Codex", "Lost Orb of Phantastacoria", "The Colour of Magic", "The Light Fantastic", "Equal Rites", "Mort", "Sourcery", "Wyrd Sisters", "Pyramids", "Guards! Guards!", "Moving Pictures", "Reaper Man", "Witches Abroad", "Small Gods", "Lords and Ladies", "Men at Arms", "Soul Music", "Interesting Times", "Maskerade", "Feet of Clay", "Hogfather", "Jingo", "The Last Continent", "Carpe Jugulum", "The Fifth Elephant", "The Truth", "Thief of Time", "The Last Hero", "The Amazing Maurice and His Educated Rodents", "Night Watch", "The Wee Free Men", "Monstrous Regiment", "A Hat Full of Sky", "Going Postal", "Thud!", "Wintersmith", "Making Money", "Unseen Academicals", "I Shall Wear Midnight", "Snuff", "Raising Steam", "The Shepherd's Crown", "Restful Cage For Sorcerors", "Amaxoflandir",
38 #ifdef OVL1
40 /* STEPHEN WHITE'S NEW CODE */
41 /* [Tom] tried to fix this back up a little... */
42 /* KMH, balance patch -- changed again */
43 const struct icp mkobjprobs[] = {
44 {149, WEAPON_CLASS},
45 {105, ARMOR_CLASS},
46 {160, FOOD_CLASS},
47 { 75, TOOL_CLASS},
48 { 30, GEM_CLASS},
49 {120, POTION_CLASS},
50 {120, SCROLL_CLASS},
51 { 40, SPBOOK_CLASS},
52 { 70, WAND_CLASS},
53 { 20, RING_CLASS},
54 { 15, AMULET_CLASS},
55 { 78, COIN_CLASS},
56 { 5, VENOM_CLASS},
57 { 10, ROCK_CLASS},
58 { 1, BALL_CLASS},
59 { 1, CHAIN_CLASS},
60 { 1, IMPLANT_CLASS}
62 /* KMH -- amulets now appear later in the game */
63 /*{ 0, AMULET_CLASS}*/
66 const struct icp boxiprobs[] = {
67 {114, WEAPON_CLASS},
68 {105, ARMOR_CLASS},
69 { 20, GEM_CLASS},
70 { 75, TOOL_CLASS},
71 {160, FOOD_CLASS},
72 {120, POTION_CLASS},
73 {120, SCROLL_CLASS},
74 { 60, SPBOOK_CLASS},
75 { 34, COIN_CLASS},
76 { 65, WAND_CLASS},
77 { 40, RING_CLASS},
78 { 20, AMULET_CLASS},
79 { 50, VENOM_CLASS},
80 { 10, ROCK_CLASS},
81 { 1, BALL_CLASS},
82 { 1, CHAIN_CLASS},
83 { 5, IMPLANT_CLASS}
86 const struct icp tchestprobs[] = {
87 {160, WEAPON_CLASS},
88 {150, ARMOR_CLASS},
89 { 74, GEM_CLASS},
90 { 70, TOOL_CLASS},
91 { 90, FOOD_CLASS},
92 { 90, POTION_CLASS},
93 { 90, SCROLL_CLASS},
94 { 60, SPBOOK_CLASS},
95 { 4, COIN_CLASS},
96 { 45, WAND_CLASS},
97 { 55, RING_CLASS},
98 { 45, AMULET_CLASS},
99 { 50, VENOM_CLASS},
100 { 10, ROCK_CLASS},
101 { 1, BALL_CLASS},
102 { 1, CHAIN_CLASS},
103 { 5, IMPLANT_CLASS}
106 #ifdef REINCARNATION
107 const struct icp rogueprobs[] = {
108 {150, WEAPON_CLASS},
109 {130, ARMOR_CLASS},
110 {220, FOOD_CLASS},
111 {200, POTION_CLASS},
112 {200, SCROLL_CLASS},
113 { 50, WAND_CLASS},
114 { 50, RING_CLASS}
116 #endif
118 const struct icp hellprobs[] = {
119 {129, WEAPON_CLASS},
120 {100, ARMOR_CLASS},
121 {160, FOOD_CLASS},
122 { 80, TOOL_CLASS},
123 { 50, GEM_CLASS},
124 { 90, POTION_CLASS},
125 { 90, SCROLL_CLASS},
126 { 50, WAND_CLASS},
127 { 30, RING_CLASS},
128 { 20, AMULET_CLASS},
129 { 35, SPBOOK_CLASS},
130 {133, COIN_CLASS},
131 { 20, VENOM_CLASS},
132 { 10, ROCK_CLASS},
133 { 1, BALL_CLASS},
134 { 1, CHAIN_CLASS},
135 { 1, IMPLANT_CLASS}
138 /* chance that an item is made into an artifact, by Amy, includes multipliers for the chance
139 * returns TRUE if the artifact can be made */
140 STATIC_OVL boolean
141 artigenechance(artichance)
142 int artichance;
144 if (uarm && uarm->oartifact == ART_AMMY_S_RETRIBUTION) return FALSE;
146 if (Race_if(PM_LISTENER)) artichance *= 2;
148 if (MagicFindBonus) {
149 artichance *= 9;
150 artichance /= 10;
152 if (StrongMagicFindBonus) {
153 artichance *= 9;
154 artichance /= 10;
156 if (Race_if(PM_STARTSCUMMER)) {
157 artichance *= 9;
158 artichance /= 10;
160 if (uarms && uarms->oartifact == ART_DNETHACKC_NOONISHNESS) {
161 artichance *= 9;
162 artichance /= 10;
164 if (achieve.get_amulet) {
165 artichance *= 9;
166 artichance /= 10;
168 if (artichance < 1) artichance = 1; /* fail safe */
170 if (!rn2(artichance)) return TRUE;
172 return FALSE;
175 struct obj *
176 mkobj_at(let, x, y, artif, shopinit)
177 char let;
178 int x, y;
179 int artif;
180 boolean shopinit;
182 struct obj *otmp;
184 otmp = mkobj(let, artif, shopinit);
185 if (!otmp) return (struct obj *)0; /* fail safe added by Amy */
186 place_object(otmp, x, y);
187 return(otmp);
190 struct obj *
191 mksobj_at(otyp, x, y, init, artif, shopinit)
192 int otyp, x, y;
193 boolean init;
194 int artif;
195 boolean shopinit;
197 struct obj *otmp;
199 otmp = mksobj(otyp, init, artif, shopinit);
200 if (!otmp) return (struct obj *)0;
201 place_object(otmp, x, y);
202 return(otmp);
205 /* mkobj change by Amy: "artif" used to be a boolean and is now an int.
206 * 0 = usually don't make item into an artifact, but retain a very low chance
207 * 1 = normal chance of making the item into an artifact
208 * 2 = absolutely never make the item into an artifact, and also don't make contents if it's a container
209 * 3 = absolutely never make the item into an artifact, don't make contents if it's a container, and don't run some other code
213 makeobject_core(oclass)
214 int oclass;
216 int prob = rnd(100000);
217 int i;
218 int levscalediff;
220 i = bases[(int)oclass];
221 while((prob -= objects[i].oc_prob) > 0) i++;
223 if(objects[i].oc_class != oclass)
224 panic("probtype error, oclass=%d i=%d", (int) oclass, i);
225 if(!OBJ_NAME(objects[i]))
226 panic("probtype no object name error, oclass=%d i=%d", (int) oclass, i);
228 /* Levelscaler race: very unlikely to get "out of depth items" --Amy */
229 if (islevelscaler && (i != GOLD_PIECE) && (objects[i].oc_minlvl > 1)) {
231 levscalediff = level_difficulty();
232 if (levscalediff < 1) levscalediff = 1; /* fail safe */
234 /*pline("trying to make item %d with level %d (level difficulty is %d)", i, objects[i].oc_minlvl, levscalediff);*/
236 while ((levscalediff >= 1) && (objects[i].oc_minlvl > levscalediff)) {
238 /*pline("item %d has level %d but scale is %d", i, objects[i].oc_minlvl, levscalediff);*/
240 if (!rn2(3)) {
242 /* somehow there's a weird potential for infinite loops... let's prevent them --Amy */
243 if (!rn2(50)) {
244 i = GOLD_PIECE;
245 goto levscalerollpast;
248 prob = rnd(100000);
249 i = bases[(int)oclass];
250 while((prob -= objects[i].oc_prob) > 0) i++;
252 if(objects[i].oc_class != oclass)
253 panic("probtype error, oclass=%d i=%d", (int) oclass, i);
254 if(!OBJ_NAME(objects[i]))
255 panic("probtype no object name error, oclass=%d i=%d", (int) oclass, i);
258 levscalediff += 1;
262 levscalerollpast:
264 /* inspired by ais523, higher base level items shouldn't appear constantly on early dlvls --Amy
265 * they should still have a chance of spawning, so that exploring the levels is worthwile, but we don't want them
266 * to have the full spawn chance; level_difficulty() is actually slightly random so it can take quite a while until
267 * a high base level item reaches its full spawn chance
268 * late into the game (Gehennom and beyond), everything should have its full spawn chance */
269 if ((i != GOLD_PIECE) && !In_lategame(&u.uz) && (objects[i].oc_minlvl > 1) ) {
270 levscalediff = rnd(100 + level_difficulty());
271 if (!rn2(100)) levscalediff += 100;
272 int attempts = 50000;
274 while (attempts && (levscalediff < objects[i].oc_minlvl)) {
275 attempts--;
277 /*pline("item %d has level %d but scale is %d", i, objects[i].oc_minlvl, levscalediff);*/
279 prob = rnd(100000);
280 i = bases[(int)oclass];
281 while((prob -= objects[i].oc_prob) > 0) i++;
283 if(objects[i].oc_class != oclass)
284 panic("probtype error, oclass=%d i=%d", (int) oclass, i);
285 if(!OBJ_NAME(objects[i]))
286 panic("probtype no object name error, oclass=%d i=%d", (int) oclass, i);
292 return i;
295 struct obj *
296 mkobj(oclass, artif, shopinit)
297 char oclass;
298 int artif;
299 boolean shopinit;
301 int tprob, i, j, prob = rnd(100000);
303 int debugvar = 0;
304 if (Is_rogue_level(&u.uz)) debugvar = 1;
305 else if (Inhell) debugvar = 2;
306 boolean wildcard = 0;
307 if (oclass == WILDCARD_CLASS) { /* RANDOM_CLASS, but timebasedlowerchance is not in effect --Amy */
308 oclass = RANDOM_CLASS;
309 wildcard = TRUE;
312 register int levscalediff;
314 if (oclass >= MAXOCLASSES) { /* failsafe --Amy */
316 impossible("Error: mkobj() called with invalid object class %d", (int) oclass);
317 oclass = RANDOM_CLASS;
321 if(oclass == RANDOM_CLASS) {
322 const struct icp *iprobs =
323 #ifdef REINCARNATION
324 (Is_rogue_level(&u.uz)) ?
325 (const struct icp *)rogueprobs :
326 #endif
327 Inhell ? (const struct icp *)hellprobs :
328 (const struct icp *)mkobjprobs;
330 for(tprob = rnd(1000);
331 (tprob -= iprobs->iprob) > 0;
332 iprobs++);
333 oclass = iprobs->iclass;
335 if ((u.veryobtainclass1 > 0) && (rn2(10000) < u.veryobtainclass1boost)) {
336 oclass = u.veryobtainclass1;
338 else if ((u.veryobtainclass2 > 0) && (rn2(10000) < u.veryobtainclass2boost)) {
339 oclass = u.veryobtainclass2;
341 else if ((u.veryobtainclass3 > 0) && (rn2(10000) < u.veryobtainclass3boost)) {
342 oclass = u.veryobtainclass3;
345 if (uarm && uarm->oartifact == ART_CHEST_IN_THE_BANDIT_S_LAIR && !rn2(40))
346 oclass = ARMOR_CLASS;
348 if ((oclass == SCROLL_CLASS) && (rn2(100) < u.scrollspawnchance)) {
349 oclass = COIN_CLASS;
351 if ((oclass == POTION_CLASS) && (rn2(100) < u.potionspawnchance)) {
352 oclass = COIN_CLASS;
354 if ((oclass == SPBOOK_CLASS) && (rn2(100) < u.bookspawnchance)) {
355 oclass = COIN_CLASS;
357 if ((oclass == WAND_CLASS) && (rn2(100) < u.wandspawnchance)) {
358 oclass = COIN_CLASS;
360 if ((oclass == AMULET_CLASS) && (rn2(100) < u.amuletspawnchance)) {
361 oclass = COIN_CLASS;
363 if ((oclass == IMPLANT_CLASS) && (rn2(100) < u.implantspawnchance)) {
364 oclass = COIN_CLASS;
366 if ((oclass == RING_CLASS) && (rn2(100) < u.ringspawnchance)) {
367 oclass = COIN_CLASS;
369 if ((oclass == WEAPON_CLASS) && (rn2(100) < u.weaponspawnchance)) {
370 oclass = COIN_CLASS;
372 if ((oclass == ARMOR_CLASS) && (rn2(100) < u.armorspawnchance)) {
373 oclass = COIN_CLASS;
375 if ((oclass == TOOL_CLASS) && (rn2(100) < u.toolspawnchance)) {
376 oclass = COIN_CLASS;
378 if ((oclass == FOOD_CLASS) && (rn2(100) < u.foodspawnchance)) {
379 oclass = COIN_CLASS;
382 if ((oclass == SCROLL_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() ) {
383 oclass = COIN_CLASS;
386 if ((oclass == WEAPON_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() ) {
387 oclass = COIN_CLASS;
390 if ((oclass == ARMOR_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() ) {
391 oclass = COIN_CLASS;
394 if ((oclass == TOOL_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() ) {
395 oclass = COIN_CLASS;
398 if ((oclass == POTION_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() ) {
399 oclass = COIN_CLASS;
402 if ((oclass == WAND_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() ) {
403 oclass = COIN_CLASS;
406 if ((oclass == AMULET_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() ) {
407 oclass = COIN_CLASS;
410 if ((oclass == SPBOOK_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() && !timebasedlowerchance() ) {
411 oclass = COIN_CLASS;
414 if ((oclass == FOOD_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && !timebasedlowerchance() && !timebasedlowerchance() ) {
415 oclass = COIN_CLASS;
418 if ((oclass == GEM_CLASS) && !wildcard && evilfriday && !timebasedlowerchance() && (!timebasedlowerchance() || !timebasedlowerchance() ) ) {
419 oclass = COIN_CLASS;
422 if ((oclass == RING_CLASS) && !wildcard && evilfriday && ( (!timebasedlowerchance() && !timebasedlowerchance() ) || (!timebasedlowerchance() && !timebasedlowerchance() ) ) ) {
423 oclass = COIN_CLASS;
426 if (oclass >= MAXOCLASSES) {
427 impossible("Error: mkobj() random class object returned invalid object class %d. Please tell Amy about this bug. Debug variable: %d", (int) oclass, debugvar);
428 oclass = COIN_CLASS;
434 i = makeobject_core(oclass);
436 if (oclass == SPBOOK_CLASS) {
438 if (u.spellbookbias1 >= 0 && (rnd(100) <= u.spellbookchance1) && (spell_skilltype(i) != u.spellbookbias1)) {
440 int spattempts = 0;
441 while (spattempts++ < 50000 && (spell_skilltype(i) != u.spellbookbias1)) {
443 i = makeobject_core(oclass);
446 } else if (u.spellbookbias2 >= 0 && (rnd(100) <= u.spellbookchance2) && (spell_skilltype(i) != u.spellbookbias2)) {
447 int spattempts = 0;
448 while (spattempts++ < 50000 && (spell_skilltype(i) != u.spellbookbias2)) {
450 i = makeobject_core(oclass);
453 } else if (u.spellbookbias3 >= 0 && (rnd(100) <= u.spellbookchance3) && (spell_skilltype(i) != u.spellbookbias3)) {
454 int spattempts = 0;
455 while (spattempts++ < 50000 && (spell_skilltype(i) != u.spellbookbias3)) {
457 i = makeobject_core(oclass);
464 if (Role_if(PM_TOSSER) && oclass == WEAPON_CLASS) {
466 if (!rn2(20) && objects[i].oc_skill != P_JAVELIN) {
467 int spattempts = 0;
468 while (spattempts++ < 50000 && (objects[i].oc_skill != P_JAVELIN)) {
470 i = makeobject_core(oclass);
476 if (uwep && uwep->oartifact == ART_WHY_DOES_THE_GAME_GENERATE && oclass == WEAPON_CLASS) {
478 if (!rn2(50) && objects[i].oc_skill != P_CROSSBOW) {
479 int spattempts = 0;
480 while (spattempts++ < 50000 && (objects[i].oc_skill != P_CROSSBOW)) {
482 i = makeobject_core(oclass);
488 if (ismusablenumber(i) && (u.antimusablebias > rn2(100) ) ) {
490 i = makeobject_core(oclass);
493 /* Gray stones are too common; have a chance to reroll them at least once --Amy */
494 if (i >= RIGHT_MOUSE_BUTTON_STONE && i <= NASTY_STONE && rn2(5)) {
496 i = makeobject_core(oclass);
499 if (i >= ELIF_S_JEWEL && i <= DORA_S_JEWEL && rn2(5)) {
501 i = makeobject_core(oclass);
504 if (i == SCR_RAGNAROK && rn2(64)) {
505 i = makeobject_core(oclass);
509 /* you get way too much useful armor... let's limit the amount by changing some into mundane ones --Amy
510 * but if you've obtained the amulet already, that should no longer be the case */
511 if (oclass == ARMOR_CLASS && !achieve.get_amulet && !isvanillaarmor(i) && rn2(2)) {
513 int armortries = 0;
515 while (!isvanillaarmor(i) && (armortries < 5000)) {
516 armortries++;
517 i = makeobject_core(oclass);
522 /* the rnd value is 10000 here, this is not an error --Amy */
524 if ((objects[u.veryobtainable].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost) ) return(mksobj(u.veryobtainable, TRUE, artif, shopinit));
526 else if ((objects[u.veryobtainable2].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost2) ) return(mksobj(u.veryobtainable2, TRUE, artif, shopinit));
528 else if ((objects[u.veryobtainable3].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost3) ) return(mksobj(u.veryobtainable3, TRUE, artif, shopinit));
530 else if ((objects[u.veryobtainable4].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost4) ) return(mksobj(u.veryobtainable4, TRUE, artif, shopinit));
532 else if ((objects[u.veryobtainable5].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost5) ) return(mksobj(u.veryobtainable5, TRUE, artif, shopinit));
534 else if ((objects[u.veryobtainable6].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost6) ) return(mksobj(u.veryobtainable6, TRUE, artif, shopinit));
536 else if ((objects[u.veryobtainable7].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost7) ) return(mksobj(u.veryobtainable7, TRUE, artif, shopinit));
538 else if ((objects[u.veryobtainable8].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost8) ) return(mksobj(u.veryobtainable8, TRUE, artif, shopinit));
540 else if ((objects[u.veryobtainable9].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost9) ) return(mksobj(u.veryobtainable9, TRUE, artif, shopinit));
542 else if ((objects[u.veryobtainable10].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost10) ) return(mksobj(u.veryobtainable10, TRUE, artif, shopinit));
544 else if ((objects[u.veryobtainable11].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost11) ) return(mksobj(u.veryobtainable11, TRUE, artif, shopinit));
546 else if ((objects[u.veryobtainable12].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost12) ) return(mksobj(u.veryobtainable12, TRUE, artif, shopinit));
548 else if ((objects[u.veryobtainable13].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost13) ) return(mksobj(u.veryobtainable13, TRUE, artif, shopinit));
550 else if ((objects[u.veryobtainable14].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost14) ) return(mksobj(u.veryobtainable14, TRUE, artif, shopinit));
552 else if ((objects[u.veryobtainable15].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost15) ) return(mksobj(u.veryobtainable15, TRUE, artif, shopinit));
554 else if ((objects[u.veryobtainable16].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost16) ) return(mksobj(u.veryobtainable16, TRUE, artif, shopinit));
556 else if ((objects[u.veryobtainable17].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost17) ) return(mksobj(u.veryobtainable17, TRUE, artif, shopinit));
558 else if ((objects[u.veryobtainable18].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost18) ) return(mksobj(u.veryobtainable18, TRUE, artif, shopinit));
560 else if ((objects[u.veryobtainable19].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost19) ) return(mksobj(u.veryobtainable19, TRUE, artif, shopinit));
562 else if ((objects[u.veryobtainable20].oc_class == oclass) && (rnd(10000) < u.veryobtainableboost20) ) return(mksobj(u.veryobtainable20, TRUE, artif, shopinit));
564 else if (!rn2(100) && oclass == ARMOR_CLASS) {
566 int freqhelmet = find_frequent_helmet();
567 if (freqhelmet != -1 && freqhelmet < NUM_OBJECTS) {
568 return(mksobj(freqhelmet, TRUE, artif, shopinit));
569 } else {
570 return(mksobj(i, TRUE, artif, shopinit));
575 else if (!rn2(100) && issoviet && oclass == WAND_CLASS) {
577 return(mksobj(WAN_DESLEXIFICATION, TRUE, artif, shopinit));
581 else return(mksobj(i, TRUE, artif, shopinit));
584 STATIC_OVL void
585 mkbox_cnts(box)
586 struct obj *box;
588 register int n, minn = 0;
589 register struct obj *otmp, *otmpX;
591 box->cobj = (struct obj *) 0;
593 switch (box->otyp) {
594 case POTATO_BAG:
596 otmp = mksobj(makemusableitem(), TRUE, TRUE, FALSE);
597 if (otmp) {
598 otmp->owt = weight(otmp);
599 (void) add_to_container(box, otmp, TRUE);
601 if (timebasedlowerchance() && !rn2(5)) {
602 otmp = mksobj(REPLICA_UNICORN_HORN, TRUE, TRUE, FALSE);
603 if (otmp) {
604 otmp->owt = weight(otmp);
605 (void) add_to_container(box, otmp, TRUE);
609 if (depth(&u.uz) >= 1 && depth(&u.uz) <= 5 && !issoviet) {
610 if (!rn2(2)) {
611 otmp = mkobj(WEAPON_CLASS, TRUE, FALSE);
612 if (otmp) {
613 otmp->owt = weight(otmp);
614 (void) add_to_container(box, otmp, TRUE);
617 if (!rn2(2)) {
618 otmp = mkobj(ARMOR_CLASS, TRUE, FALSE);
619 if (otmp) {
620 otmp->owt = weight(otmp);
621 (void) add_to_container(box, otmp, TRUE);
625 if (iszapem && In_spacebase(&u.uz) && dunlev(&u.uz) <= 5 && !issoviet) {
626 if (!rn2(2)) {
627 otmp = mkobj(WEAPON_CLASS, TRUE, FALSE);
628 if (otmp) {
629 otmp->owt = weight(otmp);
630 (void) add_to_container(box, otmp, TRUE);
633 if (!rn2(2)) {
634 otmp = mkobj(ARMOR_CLASS, TRUE, FALSE);
635 if (otmp) {
636 otmp->owt = weight(otmp);
637 (void) add_to_container(box, otmp, TRUE);
641 if (u.preversionmode && In_greencross(&u.uz) && dunlev(&u.uz) <= 5 && !issoviet) {
642 if (!rn2(2)) {
643 otmp = mkobj(WEAPON_CLASS, TRUE, FALSE);
644 if (otmp) {
645 otmp->owt = weight(otmp);
646 (void) add_to_container(box, otmp, TRUE);
649 if (!rn2(2)) {
650 otmp = mkobj(ARMOR_CLASS, TRUE, FALSE);
651 if (otmp) {
652 otmp->owt = weight(otmp);
653 (void) add_to_container(box, otmp, TRUE);
658 n = (ishaxor ? rnd(2) : rn2(2)); break;
659 break;
661 case RUGGED_SACK:
663 /* any random class from WEAPON_CLASS to VENOM_CLASS */
664 otmp = mkobj(WEAPON_CLASS + rn2(17), TRUE, FALSE);
665 if (otmp) {
666 otmp->owt = weight(otmp);
667 (void) add_to_container(box, otmp, TRUE);
669 if (rn2(3)) {
670 otmp = mkobj(WEAPON_CLASS + rn2(17), TRUE, FALSE);
671 if (otmp) {
672 otmp->owt = weight(otmp);
673 (void) add_to_container(box, otmp, TRUE);
675 if (rn2(2)) {
676 otmp = mkobj(WEAPON_CLASS + rn2(17), TRUE, FALSE);
677 if (otmp) {
678 otmp->owt = weight(otmp);
679 (void) add_to_container(box, otmp, TRUE);
684 n = (ishaxor ? rnd(2) : rn2(2)); break;
685 break;
687 case MEDICAL_KIT:
688 n = (ishaxor ? 120 : 60);
689 /* Initial inventory, no empty medical kits */
690 if (moves <= 1 && !in_mklev) minn = 1;
691 break;
692 case TREASURE_CHEST:
693 n = (ishaxor ? rnd(100) : rnd(50));
694 if (!rn2(5)) {
695 otmp = mksobj(SCR_RETURN, TRUE, FALSE, FALSE);
696 if (otmp) {
697 otmp->owt = weight(otmp);
698 (void) add_to_container(box, otmp, TRUE);
701 break; /* used to be rno but the rn1 BS below... --Amy */
702 case LOOT_CHEST:
703 n = (ishaxor ? rnd(12) : rnd(6));
704 break;
705 case ICE_BOX_OF_HOLDING:
706 case ICE_BOX_OF_WATERPROOFING:
707 case DISPERSION_BOX:
708 case ICE_BOX:
709 n = (ishaxor ? 40 : 20);
710 break;
711 case CHEST_OF_HOLDING:
712 case NANO_CHEST:
713 n = (ishaxor ? rnd(10) : rnd(5));
714 break;
716 case CHEST:
717 n = (ishaxor ? rnd(10) : rnd(5));
718 if (depth(&u.uz) >= 1 && depth(&u.uz) <= 5 && !issoviet) n += rn2(6);
719 if (iszapem && In_spacebase(&u.uz) && dunlev(&u.uz) <= 5 && !issoviet) n += rn2(6);
720 if (u.preversionmode && In_greencross(&u.uz) && dunlev(&u.uz) <= 5 && !issoviet) n += rn2(6);
722 if (uarm && uarm->oartifact == ART_CHEST_IN_THE_BANDIT_S_LAIR) { /* only applies to regular chests --Amy */
724 int armorxtras = rnd(3);
725 while (armorxtras > 0) {
726 armorxtras--;
727 otmp = mkobj(ARMOR_CLASS, TRUE, FALSE);
728 if (otmp) {
729 otmp->owt = weight(otmp);
730 (void) add_to_container(box, otmp, TRUE);
736 break;
738 case LARGE_BOX:
739 n = (ishaxor ? rnd(6) : rnd(3));
740 break;
741 case LEAD_BOX:
742 n = (ishaxor ? rnd(6) : rnd(3));
743 break;
744 case TOP_BOX:
745 n = (ishaxor ? rnd(6) : rnd(3));
746 break;
747 case SACK:
748 case HANDYBAG:
749 case OILSKIN_SACK:
750 case TITAN_SACK:
751 /* initial inventory: sack starts out empty */
752 if (moves <= 1 && !in_mklev) {
753 n = 0; break;
755 /*else FALLTHRU*/
756 case BAG_OF_HOLDING:
757 n = (ishaxor ? rnd(2) : rn2(2));
758 break;
759 case LARGE_BOX_OF_DIGESTION:
760 case ICE_BOX_OF_DIGESTION:
761 case BAG_OF_DIGESTION: /* makes sense, doesn't it ? */
762 default:
763 n = 0;
764 break;
767 /* it is soooooooo stOOOOOOOOOOOpid that 9 out of 10 containers are empty even if a nonzero number for n was rolled!
768 * and therefore, I decided to unfuck that a bit so that you get more containers with at least one item --Amy */
769 if (n > 0 && rn2(10) && !issoviet && !minn) {
770 minn = 1;
772 if (n > 1 && rn2(2) && (minn < 2)) {
773 minn++; n++;
776 if (box->otyp == TREASURE_CHEST) {
777 minn++; n++; /* no empty treasure chests, also happened waaaaaaaay too often --Amy */
779 if (box->otyp == LOOT_CHEST) {
780 minn++; n++;
783 for (n = rn1(n+1 - minn, minn); n > 0; n--) {
785 if (box->otyp == MEDICAL_KIT) {
786 int supplies[] = { PHIAL, BANDAGE, PILL };
788 if (!(otmp = mksobj(supplies[rn2(SIZE(supplies))], TRUE, TRUE, FALSE)))
789 continue;
790 else
791 otmp->oinvis = otmp->oinvisreal = FALSE;
792 } else
793 if (box->otyp == ICE_BOX || box->otyp == DISPERSION_BOX || box->otyp == ICE_BOX_OF_HOLDING || box->otyp == ICE_BOX_OF_WATERPROOFING || box->otyp == ICE_BOX_OF_DIGESTION) {
794 if (!timebasedlowerchance() && !timebasedlowerchance() && (rn2(2) || !timebasedlowerchance() ) ) continue;
795 if (!(otmp = mksobj(CORPSE, TRUE, FALSE, FALSE))) continue;
796 /* Note: setting age to 0 is correct. Age has a different
797 * from usual meaning for objects stored in ice boxes. -KAA
798 * Amy note: very low chance for artifacts, mainly because of shops
800 otmp->age = 0L;
801 otmp->icedobject = TRUE;
802 if (otmp->timed) {
803 (void) stop_timer(ROT_CORPSE, (void *)otmp);
804 (void) stop_timer(MOLDY_CORPSE, (void *)otmp);
805 (void) stop_timer(REVIVE_MON, (void *)otmp);
807 } else if (box->otyp == TREASURE_CHEST || box->otyp == LOOT_CHEST) {
808 register int tprob;
809 const struct icp *iprobs = tchestprobs;
811 for (tprob = rnd(1000); (tprob -= iprobs->iprob) > 0; iprobs++)
813 if (!timebasedlowerchance() && !timebasedlowerchance() && (rn2(2) || !timebasedlowerchance() ) ) continue;
814 if (!(otmp = mkobj(iprobs->iclass, TRUE, FALSE))) continue;
816 /* handle a couple of special cases */
817 if (otmp->oclass == COIN_CLASS) {
818 /* 2.5 x level's usual amount; weight adjusted below */
819 otmp->quan = (long)(rnd(level_difficulty()+5) * rnd(10));
821 if (Race_if(PM_VENTURE_CAPITALIST)) { /* they get extra money, idea by deepy */
823 if (rn2(2)) otmp->quan *= 2;
824 if (!rn2(5)) otmp->quan *= 3;
825 if (!rn2(20)) otmp->quan *= 5;
826 if (!rn2(200)) otmp->quan *= 10;
827 if (!rn2(1000)) otmp->quan *= 20;
828 if (!rn2(5000)) otmp->quan *= 50;
829 if (!rn2(25000)) otmp->quan *= 100;
833 if (uimplant && uimplant->oartifact == ART_SCROOGE_S_MONEY_MEMORY) {
834 otmp->quan *= 2;
835 if (powerfulimplants()) otmp->quan *= 2;
838 if (have_trippingjewel()) {
839 otmp->quan *= 3; otmp->quan /= 2;
841 if (uarmh && uarmh->oartifact == ART_GOLD_STANDARD) otmp->quan *= 2;
842 if (uarmg && uarmg->oartifact == ART_ROBBERY_GONE_RIGHT) otmp->quan *= 3;
843 if (uarmf && uarmf->oartifact == ART_SPARKLING_GOLD) otmp->quan *= 2;
844 if (uleft && uleft->oartifact == ART_WELLTRAVEL) {
845 otmp->quan *= 3; otmp->quan /= 2;
847 if (uright && uright->oartifact == ART_WELLTRAVEL) {
848 otmp->quan *= 3; otmp->quan /= 2;
851 otmp->owt = weight(otmp);
853 } else {
854 register int tprob;
855 const struct icp *iprobs = boxiprobs;
857 for (tprob = rnd(1000); (tprob -= iprobs->iprob) > 0; iprobs++)
859 if (!timebasedlowerchance() && !timebasedlowerchance() && (rn2(2) || !timebasedlowerchance() ) ) continue;
860 if (!(otmp = mkobj(iprobs->iclass, TRUE, FALSE))) continue;
862 /* handle a couple of special cases */
863 if (otmp->oclass == COIN_CLASS) {
864 /* 2.5 x level's usual amount; weight adjusted below */
865 otmp->quan = (long)(rnd(level_difficulty()+5) * rnd(10));
867 if (Race_if(PM_VENTURE_CAPITALIST)) { /* they get extra money, idea by deepy */
869 if (rn2(2)) otmp->quan *= 2;
870 if (!rn2(5)) otmp->quan *= 3;
871 if (!rn2(20)) otmp->quan *= 5;
872 if (!rn2(200)) otmp->quan *= 10;
873 if (!rn2(1000)) otmp->quan *= 20;
874 if (!rn2(5000)) otmp->quan *= 50;
875 if (!rn2(25000)) otmp->quan *= 100;
879 if (uarmh && uarmh->oartifact == ART_GOLD_STANDARD) otmp->quan *= 2;
880 if (uarmg && uarmg->oartifact == ART_ROBBERY_GONE_RIGHT) otmp->quan *= 3;
881 if (uarmf && uarmf->oartifact == ART_SPARKLING_GOLD) otmp->quan *= 2;
883 otmp->owt = weight(otmp);
885 /* no reason not to allow stones... but in Soviet Russia, everything is a weird mix of special cases
886 * held together by special cases, and woe to you if you remove any of them because that will make the entire
887 * house of cards that is communism come down in a mighty crash. --Amy */
888 } else while (issoviet && otmp->otyp == ROCK) {
889 otmp->otyp = rnd_class(DILITHIUM_CRYSTAL, FLINT);
890 if (otmp->quan > 2L) otmp->quan = 1L;
891 otmp->owt = weight(otmp);
893 if (box->otyp == BAG_OF_HOLDING || box->otyp == ICE_BOX_OF_HOLDING || box->otyp == CHEST_OF_HOLDING || box->oartifact == ART_SACK_OF_HOLDING) {
894 if (Is_mbag(otmp)) {
895 otmp->otyp = SACK;
896 otmp->spe = 0;
897 otmp->owt = weight(otmp);
898 } else while (otmp->otyp == WAN_CANCELLATION)
899 otmp->otyp = rnd_class(WAN_LIGHT, WAN_FIREBALL);
902 (void) add_to_container(box, otmp, TRUE);
907 rndmonnum() /* select a random, common monster type */
909 register struct permonst *ptr;
910 register int i;
912 /* Plan A: get a level-appropriate common monster */
913 ptr = rndmonst();
914 if (ptr) return(monsndx(ptr));
916 /* Plan B: get any common monster */
917 do {
918 i = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
919 ptr = &mons[i];
920 } while((ptr->geno & G_NOGEN) /*|| (!Inhell && (ptr->geno & G_HELL))*/);
922 return(i);
926 usefulitem() /* select the ID number of an item that may be useful for the player --Amy */
929 switch (rnd(168)) {
931 case 1:
932 return ATHAME;
933 case 2:
934 return WORM_TOOTH;
935 case 3:
936 return AMULET_OF_LIFE_SAVING;
937 case 4:
938 return AMULET_VERSUS_STONE;
939 case 5:
940 return ICE_BOX;
941 case 6:
942 return MAGIC_WHISTLE;
943 case 7:
944 case 8:
945 return FROST_HORN;
946 case 9:
947 case 10:
948 return FIRE_HORN;
949 case 11:
950 case 12:
951 case 13:
952 case 14:
953 case 15:
954 return UNICORN_HORN;
955 case 16:
956 return STETHOSCOPE;
957 case 17:
958 return TINNING_KIT;
959 case 18:
960 return CAN_OF_GREASE;
961 case 19:
962 return MAGIC_MARKER;
963 case 20:
964 case 21:
965 case 22:
966 case 23:
967 case 24:
968 case 25:
969 case 26:
970 case 27:
971 case 28:
972 case 29:
973 return CHEMISTRY_SET;
974 case 30:
975 return HUGE_CHUNK_OF_MEAT;
976 case 31:
977 return KELP_FROND;
978 case 32:
979 case 33:
980 return EUCALYPTUS_LEAF;
981 case 34:
982 case 35:
983 return LUMP_OF_ROYAL_JELLY;
984 case 36:
985 case 37:
986 return HACKER_S_FOOD;
987 case 38:
988 case 39:
989 return POT_RESTORE_ABILITY;
990 case 40:
991 case 41:
992 case 42:
993 case 43:
994 case 44:
995 return POT_GAIN_ENERGY;
996 case 45:
997 case 46:
998 case 47:
999 return POT_GAIN_HEALTH;
1000 case 48:
1001 case 49:
1002 case 50:
1003 case 51:
1004 case 52:
1005 return POT_FULL_HEALING;
1006 case 53:
1007 case 54:
1008 case 55:
1009 case 56:
1010 case 57:
1011 return POT_GAIN_ABILITY;
1012 case 58:
1013 case 59:
1014 case 60:
1015 case 61:
1016 case 62:
1017 return POT_GAIN_LEVEL;
1018 case 63:
1019 case 64:
1020 case 65:
1021 return POT_WATER;
1022 case 66:
1023 case 67:
1024 return SCR_CREATE_FAMILIAR;
1025 case 68:
1026 return SCR_TAMING;
1027 case 69:
1028 return SCR_INVENTORY_ID;
1029 case 70:
1030 case 71:
1031 case 72:
1032 case 73:
1033 case 74:
1034 return SCR_GAIN_MANA;
1035 case 75:
1036 case 76:
1037 case 77:
1038 return SCR_ENCHANT_WEAPON;
1039 case 78:
1040 case 79:
1041 return SCR_ENCHANT_ARMOR;
1042 case 80:
1043 case 81:
1044 case 82:
1045 case 83:
1046 case 84:
1047 return SCR_RANDOM_ENCHANTMENT;
1048 case 85:
1049 case 86:
1050 return SCR_REMOVE_CURSE;
1051 case 87:
1052 case 88:
1053 case 89:
1054 case 90:
1055 case 91:
1056 return SCR_TELEPORTATION;
1057 case 92:
1058 case 93:
1059 return SCR_TELE_LEVEL;
1060 case 94:
1061 return SCR_CURE;
1062 case 95:
1063 return SCR_TRAP_DISARMING;
1064 case 96:
1065 case 97:
1066 case 98:
1067 return SCR_CHARGING;
1068 case 99:
1069 case 100:
1070 return SCR_GENOCIDE;
1071 case 101:
1072 case 102:
1073 return SCR_TRAP_DETECTION;
1074 case 103:
1075 return SCR_ACQUIREMENT;
1076 case 104:
1077 return SCR_CONSECRATION;
1078 case 105:
1079 return SCR_ENTHRONIZATION;
1080 case 106:
1081 return SPE_CURE_HALLUCINATION;
1082 case 107:
1083 return SPE_EXTRA_HEALING;
1084 case 108:
1085 return SPE_FULL_HEALING;
1086 case 109:
1087 return SPE_RESTORE_ABILITY;
1088 case 110:
1089 return SPE_CREATE_FAMILIAR;
1090 case 111:
1091 return SPE_IDENTIFY;
1092 case 112:
1093 case 113:
1094 case 114:
1095 case 115:
1096 case 116:
1097 return SPE_CHEMISTRY;
1098 case 117:
1099 return SPE_REMOVE_CURSE;
1100 case 118:
1101 return SPE_LEVITATION;
1102 case 119:
1103 case 120:
1104 return SPE_REPAIR_ARMOR;
1105 case 121:
1106 return SPE_MAGIC_MISSILE;
1107 case 122:
1108 return SPE_FORCE_BOLT;
1109 case 123:
1110 return WAN_MANA;
1111 case 124:
1112 return WAN_GAIN_LEVEL;
1113 case 125:
1114 case 126:
1115 case 127:
1116 return WAN_HEALING;
1117 case 128:
1118 return WAN_IDENTIFY;
1119 case 129:
1120 return WAN_REMOVE_CURSE;
1121 case 130:
1122 return WAN_TRAP_DISARMING;
1123 case 131:
1124 return WAN_ENTRAPPING;
1125 case 132:
1126 return WAN_INCREASE_MAX_HITPOINTS;
1127 case 133:
1128 return WAN_CREATE_FAMILIAR;
1129 case 134:
1130 case 135:
1131 return WAN_TELEPORTATION;
1132 case 136:
1133 return WAN_EXTRA_HEALING;
1134 case 137:
1135 return WAN_FULL_HEALING;
1136 case 138:
1137 return WAN_ACQUIREMENT;
1138 case 139:
1139 return WAN_CHARGING;
1140 case 140:
1141 case 141:
1142 return WAN_MAGIC_MISSILE;
1143 case 142:
1144 return WAN_FIRE;
1145 case 143:
1146 return WAN_SLEEP;
1147 case 144:
1148 return WAN_DEATH;
1149 case 145:
1150 case 146:
1151 return WAN_COLD;
1152 case 147:
1153 return WAN_LIGHTNING;
1154 case 148:
1155 return WAN_ACID;
1156 case 149:
1157 return WAN_SOLAR_BEAM;
1158 case 150:
1159 return SPE_REPAIR_WEAPON;
1160 case 151:
1161 return SCR_MAKE_PENTAGRAM;
1162 case 152:
1163 return WAN_RESTORATION;
1164 case 153:
1165 return HONEYCOMB;
1166 case 154:
1167 return INFUSION;
1168 case 155:
1169 return SCR_PROOF_ACCESSORY;
1170 case 156:
1171 return SCR_PROOF_TOOL;
1172 case 157:
1173 return AMULET_OF_SYMBIOTE_SAVING;
1174 case 158:
1175 return RAD_X;
1176 case 159:
1177 return RADAWAY;
1178 case 160:
1179 case 161:
1180 case 162:
1181 return CASINO_CHIP;
1182 case 163:
1183 return CLOAK_OF_MYSTERY;
1184 case 164:
1185 return GAUNTLETS_OF_MYSTERY_RESISTANC;
1186 case 165:
1187 return RIN_MYSTERY_RESISTANCE;
1188 case 166:
1189 return WAN_STRONG_HEALING;
1190 case 167:
1191 return WAN_TELEPORT_SELF;
1192 case 168:
1193 return ACID_SYRINGE;
1194 default: /* fail safe */
1195 return POT_FULL_HEALING;
1201 nastymusableitem() /* select the ID number of an item that the monsters may use against you --Amy */
1204 switch (rnd(210)) {
1206 case 1:
1207 case 2:
1208 case 3:
1209 return WAN_CREATE_MONSTER;
1210 case 4:
1211 case 5:
1212 case 6:
1213 case 7:
1214 case 8:
1215 case 9:
1216 case 10:
1217 return SCR_CREATE_MONSTER;
1218 case 11:
1219 case 12:
1220 case 13:
1221 return SCR_CREATE_VICTIM;
1222 case 14:
1223 case 15:
1224 return WAN_CREATE_HORDE;
1225 case 16:
1226 case 17:
1227 case 18:
1228 return RIN_TIMELY_BACKUP;
1229 case 19:
1230 case 20:
1231 case 21:
1232 return SCR_ROOT_PASSWORD_DETECTION;
1233 case 22:
1234 case 23:
1235 case 24:
1236 case 25:
1237 case 26:
1238 case 27:
1239 case 28:
1240 return SCR_SUMMON_UNDEAD;
1241 case 29:
1242 case 30:
1243 case 31:
1244 return WAN_SUMMON_UNDEAD;
1245 case 32:
1246 return SCR_WARPING;
1247 case 33:
1248 return WAN_REDUCE_MAX_HITPOINTS;
1249 case 34:
1250 return WAN_INCREASE_MAX_HITPOINTS;
1251 case 35:
1252 case 36:
1253 return POT_AMNESIA;
1254 case 37:
1255 return POT_CYANIDE;
1256 case 38:
1257 return POT_RADIUM;
1258 case 39:
1259 case 40:
1260 case 41:
1261 case 42:
1262 return SCR_TRAP_CREATION;
1263 case 43:
1264 case 44:
1265 return SCR_CREATE_TRAP;
1266 case 45:
1267 case 46:
1268 return WAN_TRAP_CREATION;
1269 case 47:
1270 return SCR_FLOOD;
1271 case 48:
1272 return SCR_LAVA;
1273 case 49:
1274 return SCR_GROWTH;
1275 case 50:
1276 return SCR_BARRHING;
1277 case 51:
1278 return SCR_LOCKOUT;
1279 case 52:
1280 return (rn2(10) ? WAN_TELEPORTATION : WAN_BANISHMENT);
1281 case 53:
1282 case 54:
1283 case 55:
1284 case 56:
1285 case 57:
1286 case 58:
1287 case 59:
1288 return POT_HALLUCINATION;
1289 case 60:
1290 case 61:
1291 case 62:
1292 return POT_ICE;
1293 case 63:
1294 case 64:
1295 case 65:
1296 case 66:
1297 case 67:
1298 case 68:
1299 case 69:
1300 return POT_STUNNING;
1301 case 70:
1302 case 71:
1303 case 72:
1304 case 73:
1305 case 74:
1306 case 75:
1307 case 76:
1308 return POT_NUMBNESS;
1309 case 77:
1310 return POT_URINE;
1311 case 78:
1312 return POT_CANCELLATION;
1313 case 79:
1314 return POT_SLIME;
1315 case 80:
1316 case 81:
1317 case 82:
1318 case 83:
1319 case 84:
1320 case 85:
1321 return SCR_BAD_EFFECT;
1322 case 86:
1323 return WAN_BAD_EFFECT;
1324 case 87:
1325 case 88:
1326 case 89:
1327 case 90:
1328 case 91:
1329 case 92:
1330 case 93:
1331 return POT_FIRE;
1332 case 94:
1333 return WAN_GAIN_LEVEL;
1334 case 95:
1335 return WAN_MUTATION;
1336 case 96:
1337 return WAN_CLONE_MONSTER;
1338 case 97:
1339 return SCR_DESTROY_ARMOR;
1340 case 98:
1341 return SCR_DESTROY_WEAPON;
1342 case 99:
1343 return SCR_STONING;
1344 case 100:
1345 return SCR_AMNESIA;
1346 case 101:
1347 case 102:
1348 return BAG_OF_TRICKS;
1349 case 103:
1350 return WAN_STONING;
1351 case 104:
1352 return WAN_DISINTEGRATION;
1353 case 105:
1354 return WAN_PARALYSIS;
1355 case 106:
1356 return WAN_CURSE_ITEMS;
1357 case 107:
1358 return WAN_AMNESIA;
1359 case 108:
1360 return WAN_BAD_LUCK;
1361 case 109:
1362 return WAN_REMOVE_RESISTANCE;
1363 case 110:
1364 return WAN_CORROSION;
1365 case 111:
1366 return WAN_STARVATION;
1367 case 112:
1368 return WAN_CONFUSION;
1369 case 113:
1370 return WAN_SLIMING;
1371 case 114:
1372 return WAN_LYCANTHROPY;
1373 case 115:
1374 return WAN_FUMBLING;
1375 case 116:
1376 return WAN_PUNISHMENT;
1377 case 117:
1378 case 118:
1379 return SCR_PUNISHMENT;
1380 case 119:
1381 case 120:
1382 case 121:
1383 case 122:
1384 case 123:
1385 return SCR_SUMMON_BOSS;
1386 case 124:
1387 case 125:
1388 case 126:
1389 case 127:
1390 case 128:
1391 case 129:
1392 case 130:
1393 return SCR_WOUNDS;
1394 case 131:
1395 case 132:
1396 return SCR_BULLSHIT;
1397 case 133:
1398 return SCR_CHAOS_TERRAIN;
1399 case 134:
1400 return SCR_NASTINESS;
1401 case 135:
1402 return SCR_DEMONOLOGY;
1403 case 136:
1404 return SCR_ELEMENTALISM;
1405 case 137:
1406 return SCR_GIRLINESS;
1407 case 138:
1408 return WAN_SUMMON_SEXY_GIRL;
1409 case 139:
1410 case 140:
1411 case 141:
1412 case 142:
1413 case 143:
1414 return SCR_GROUP_SUMMONING;
1415 case 144:
1416 case 145:
1417 case 146:
1418 return WAN_STUN_MONSTER;
1419 case 147:
1420 return SCR_SUMMON_GHOST;
1421 case 148:
1422 return SCR_MEGALOAD;
1423 case 149:
1424 return SCR_ENRAGE;
1425 case 150:
1426 return WAN_TIDAL_WAVE;
1427 case 151:
1428 return SCR_ANTIMATTER;
1429 case 152:
1430 case 153:
1431 return SCR_SUMMON_ELM;
1432 case 154:
1433 return WAN_SUMMON_ELM;
1434 case 155:
1435 return WAN_DRAIN_MANA;
1436 case 156:
1437 return WAN_FINGER_BENDING;
1438 case 157:
1439 case 158:
1440 case 159:
1441 return SCR_IMMOBILITY;
1442 case 160:
1443 return WAN_IMMOBILITY;
1444 case 161:
1445 return SCR_FLOODING;
1446 case 162:
1447 case 163:
1448 case 164:
1449 return SCR_EGOISM;
1450 case 165:
1451 return WAN_EGOISM;
1452 case 166:
1453 return SCR_SIN;
1454 case 167:
1455 return WAN_SIN;
1456 case 168:
1457 return WAN_INERTIA;
1458 case 169:
1459 return WAN_TIME;
1460 case 170:
1461 return WAN_LEVITATION;
1462 case 171:
1463 return SCR_VILENESS;
1464 case 172:
1465 case 173:
1466 case 174:
1467 case 175:
1468 case 176:
1469 case 177:
1470 case 178:
1471 return POT_DIMNESS;
1472 case 179:
1473 return SCR_OFFLEVEL_ITEM;
1474 case 180:
1475 return SCR_NASTY_CURSE;
1476 case 181:
1477 return WAN_FLEECY_TERRAIN;
1478 case 182:
1479 return WAN_DISENCHANTMENT;
1480 case 183:
1481 return WAN_CONTAMINATION;
1482 case 184:
1483 return WAN_TREMBLING;
1484 case 185:
1485 return SCR_GRAVE;
1486 case 186:
1487 return SCR_TUNNELS;
1488 case 187:
1489 return SCR_FARMING;
1490 case 188:
1491 return SCR_MOUNTAINS;
1492 case 189:
1493 return SCR_DIVING;
1494 case 190:
1495 return SCR_CRYSTALLIZATION;
1496 case 191:
1497 return SCR_MOORLAND;
1498 case 192:
1499 return SCR_URINE;
1500 case 193:
1501 return SCR_QUICKSAND;
1502 case 194:
1503 return SCR_STYX;
1504 case 195:
1505 return SCR_SNOW;
1506 case 196:
1507 return SCR_ASH;
1508 case 197:
1509 return SCR_SAND;
1510 case 198:
1511 return SCR_PAVING;
1512 case 199:
1513 return SCR_HIGHWAY;
1514 case 200:
1515 return SCR_GRASSLAND;
1516 case 201:
1517 return SCR_NETHER;
1518 case 202:
1519 return SCR_STALACTITE;
1520 case 203:
1521 return SCR_CRYPT;
1522 case 204:
1523 return SCR_BUBBLE_BOBBLE;
1524 case 205:
1525 return SCR_RAIN;
1526 case 206:
1527 return WAN_CHAOS_TERRAIN;
1528 case 207:
1529 return SCR_EVIL_VARIANT;
1530 case 208:
1531 return WAN_STAT_REDUCTION;
1532 case 209:
1533 return SCR_COURSE_TRAVELING;
1534 case 210:
1535 return POT_GREASE;
1536 default: /* fail safe */
1537 return WAN_CREATE_HORDE;
1543 makemusableitem() /* select the ID number of a musable item --Amy */
1545 switch (rnd(325)) {
1547 case 1: return WAN_SLEEP;
1548 case 2: return WAN_FIREBALL;
1549 case 3: return WAN_FIRE;
1550 case 4: return WAN_COLD;
1551 case 5: return WAN_LIGHTNING;
1552 case 6: return WAN_MAGIC_MISSILE;
1553 case 7: return WAN_STRIKING;
1554 case 8: return SCR_FIRE;
1555 case 9: return POT_PARALYSIS;
1556 case 10: return POT_BLINDNESS;
1557 case 11: return POT_CONFUSION;
1558 case 12: return POT_SLEEPING;
1559 case 13: return POT_ACID;
1560 case 14: return FROST_HORN;
1561 case 15: return FIRE_HORN;
1562 case 16: return WAN_DRAINING;
1563 case 17: return SCR_EARTH;
1564 case 18: return POT_AMNESIA;
1565 case 19: return WAN_CANCELLATION;
1566 case 20: return POT_CYANIDE;
1567 case 21: return POT_RADIUM;
1568 case 22: return WAN_ACID;
1569 case 23: return SCR_TRAP_CREATION;
1570 case 24: return WAN_TRAP_CREATION;
1571 case 25: return SCR_FLOOD;
1572 case 26: return SCR_LAVA;
1573 case 27: return SCR_GROWTH;
1574 case 28: return SCR_ICE;
1575 case 29: return SCR_CLOUDS;
1576 case 30: return SCR_BARRHING;
1577 case 31: return WAN_SOLAR_BEAM;
1578 case 32: return SCR_LOCKOUT;
1579 case 33: return (rn2(10) ? WAN_TELEPORTATION : WAN_BANISHMENT);
1580 case 34: return POT_HALLUCINATION;
1581 case 35: return POT_NUMBNESS;
1582 case 36: return POT_ICE;
1583 case 37: return POT_STUNNING;
1584 case 38: return SCR_BAD_EFFECT;
1585 case 39: return WAN_BAD_EFFECT;
1586 case 40: return POT_FIRE;
1587 case 41: return WAN_SLOW_MONSTER;
1588 case 42: return WAN_FEAR;
1589 case 43: return POT_FEAR;
1590 case 44: return SCR_DESTROY_ARMOR;
1591 case 45: return SCR_STONING;
1592 case 46: return POT_URINE;
1593 case 47: return POT_SLIME;
1594 case 48: return POT_CANCELLATION;
1595 case 49: return WAN_STONING;
1596 case 50: return WAN_DISINTEGRATION;
1597 case 51: return WAN_PARALYSIS;
1598 case 52: return WAN_CURSE_ITEMS;
1599 case 53: return WAN_AMNESIA;
1600 case 54: return WAN_BAD_LUCK;
1601 case 55: return WAN_REMOVE_RESISTANCE;
1602 case 56: return WAN_CORROSION;
1603 case 57: return WAN_FUMBLING;
1604 case 58: return WAN_STARVATION;
1605 case 59: return WAN_PUNISHMENT;
1606 case 60: return SCR_PUNISHMENT;
1607 case 61: return WAN_MAKE_VISIBLE;
1608 case 62: return WAN_REDUCE_MAX_HITPOINTS;
1609 case 63: return WAN_CONFUSION;
1610 case 64: return WAN_SLIMING;
1611 case 65: return WAN_LYCANTHROPY;
1612 case 66: return SCR_CHAOS_TERRAIN;
1613 case 67: return SCR_WOUNDS;
1614 case 68: return SCR_BULLSHIT;
1615 case 69: return SCR_AMNESIA;
1616 case 70: return WAN_SUMMON_SEXY_GIRL;
1617 case 71: return SCR_DEMONOLOGY;
1618 case 72: return SCR_NASTINESS;
1619 case 73: return SCR_GIRLINESS;
1620 case 74: return SCR_ELEMENTALISM;
1621 case 75: return TEMPEST_HORN;
1622 case 76: return WAN_POISON;
1623 case 77: return SCR_DESTROY_WEAPON;
1624 case 78: return WAN_DISINTEGRATION_BEAM;
1625 case 79: return WAN_CHROMATIC_BEAM;
1626 case 80: return WAN_STUN_MONSTER;
1627 case 81: return SCR_MEGALOAD;
1628 case 82: return SCR_ENRAGE;
1629 case 83: return WAN_TIDAL_WAVE;
1630 case 84: return SCR_ANTIMATTER;
1631 case 85: return WAN_DRAIN_MANA;
1632 case 86: return WAN_FINGER_BENDING;
1633 case 87: return SCR_IMMOBILITY;
1634 case 88: return WAN_IMMOBILITY;
1635 case 89: return SCR_FLOODING;
1636 case 90: return SCR_EGOISM;
1637 case 91: return WAN_EGOISM;
1638 case 92: return SCR_RUMOR;
1639 case 93: return SCR_MESSAGE;
1640 case 94: return SCR_SIN;
1641 case 95: return WAN_SIN;
1642 case 96: return WAN_INERTIA;
1643 case 97: return WAN_TIME;
1644 case 98: return WAN_LEVITATION;
1645 case 99: return WAN_PSYBEAM;
1646 case 100: return WAN_HYPER_BEAM;
1647 case 101: return WAN_STRIKING;
1648 case 102: return POT_ACID;
1649 case 103: return POT_CONFUSION;
1650 case 104: return POT_BLINDNESS;
1651 case 105: return POT_SLEEPING;
1652 case 106: return POT_PARALYSIS;
1653 case 107: return WAN_MAGIC_MISSILE;
1654 case 108: return WAN_SLEEP;
1655 case 109: return WAN_FIRE;
1656 case 110: return WAN_COLD;
1657 case 111: return WAN_STRIKING;
1658 case 112: return POT_ACID;
1659 case 113: return POT_CONFUSION;
1660 case 114: return POT_BLINDNESS;
1661 case 115: return POT_SLEEPING;
1662 case 116: return POT_PARALYSIS;
1663 case 117: return WAN_MAGIC_MISSILE;
1664 case 118: return WAN_SLEEP;
1665 case 119: return WAN_FIRE;
1666 case 120: return WAN_COLD;
1667 case 121: return WAN_STRIKING;
1668 case 122: return POT_ACID;
1669 case 123: return POT_CONFUSION;
1670 case 124: return POT_BLINDNESS;
1671 case 125: return POT_SLEEPING;
1672 case 126: return POT_PARALYSIS;
1673 case 127: return WAN_MAGIC_MISSILE;
1674 case 128: return WAN_SLEEP;
1675 case 129: return WAN_FIRE;
1676 case 130: return WAN_COLD;
1677 case 131: return WAN_STRIKING;
1678 case 132: return POT_ACID;
1679 case 133: return POT_CONFUSION;
1680 case 134: return POT_BLINDNESS;
1681 case 135: return POT_SLEEPING;
1682 case 136: return POT_PARALYSIS;
1683 case 137: return WAN_MAGIC_MISSILE;
1684 case 138: return WAN_SLEEP;
1685 case 139: return WAN_FIRE;
1686 case 140: return WAN_COLD;
1687 case 141: return WAN_STRIKING;
1688 case 142: return POT_ACID;
1689 case 143: return POT_CONFUSION;
1690 case 144: return POT_BLINDNESS;
1691 case 145: return POT_SLEEPING;
1692 case 146: return POT_PARALYSIS;
1693 case 147: return WAN_MAGIC_MISSILE;
1694 case 148: return WAN_SLEEP;
1695 case 149: return WAN_FIRE;
1696 case 150: return WAN_COLD;
1697 case 151: return WAN_LIGHTNING;
1698 case 152: return WAN_LIGHTNING;
1699 case 153: return WAN_LIGHTNING;
1700 case 154: return WAN_LIGHTNING;
1701 case 155: return WAN_LIGHTNING;
1702 case 156: return POT_HALLUCINATION;
1703 case 157: return POT_NUMBNESS;
1704 case 158: return POT_ICE;
1705 case 159: return POT_STUNNING;
1706 case 160: return SCR_BAD_EFFECT;
1707 case 161: return POT_FIRE;
1708 case 162: return POT_FEAR;
1709 case 163: return POT_HALLUCINATION;
1710 case 164: return POT_NUMBNESS;
1711 case 165: return POT_ICE;
1712 case 166: return POT_STUNNING;
1713 case 167: return SCR_BAD_EFFECT;
1714 case 168: return POT_FIRE;
1715 case 169: return POT_FEAR;
1716 case 170: return POT_HALLUCINATION;
1717 case 171: return POT_NUMBNESS;
1718 case 172: return POT_ICE;
1719 case 173: return POT_STUNNING;
1720 case 174: return SCR_BAD_EFFECT;
1721 case 175: return POT_FIRE;
1722 case 176: return POT_FEAR;
1723 case 177: return POT_HALLUCINATION;
1724 case 178: return POT_NUMBNESS;
1725 case 179: return POT_ICE;
1726 case 180: return POT_STUNNING;
1727 case 181: return SCR_BAD_EFFECT;
1728 case 182: return POT_FIRE;
1729 case 183: return POT_FEAR;
1730 case 184: return POT_HALLUCINATION;
1731 case 185: return POT_NUMBNESS;
1732 case 186: return POT_ICE;
1733 case 187: return POT_STUNNING;
1734 case 188: return SCR_BAD_EFFECT;
1735 case 189: return POT_FIRE;
1736 case 190: return POT_FEAR;
1737 case 191: return WAN_STRIKING;
1738 case 192: return POT_ACID;
1739 case 193: return POT_CONFUSION;
1740 case 194: return POT_BLINDNESS;
1741 case 195: return POT_SLEEPING;
1742 case 196: return POT_PARALYSIS;
1743 case 197: return WAN_MAGIC_MISSILE;
1744 case 198: return WAN_SLEEP;
1745 case 199: return WAN_FIRE;
1746 case 200: return WAN_COLD;
1747 case 201: return WAN_LIGHTNING;
1748 case 202: return WAN_INFERNO;
1749 case 203: return WAN_ICE_BEAM;
1750 case 204: return WAN_THUNDER;
1751 case 205: return WAN_SLUDGE;
1752 case 206: return WAN_TOXIC;
1753 case 207: return WAN_NETHER_BEAM;
1754 case 208: return WAN_AURORA_BEAM;
1755 case 209: return WAN_GRAVITY_BEAM;
1756 case 210: return WAN_CHLOROFORM;
1757 case 211: return WAN_DREAM_EATER;
1758 case 212: return WAN_BUBBLEBEAM;
1759 case 213: return WAN_GOOD_NIGHT;
1760 case 214: return SCR_VILENESS;
1761 case 215: return POT_DIMNESS;
1762 case 216: return POT_DIMNESS;
1763 case 217: return POT_DIMNESS;
1764 case 218: return POT_DIMNESS;
1765 case 219: return POT_DIMNESS;
1766 case 220: return POT_DIMNESS;
1767 case 221: return POT_DIMNESS;
1768 case 222: return SCR_OFFLEVEL_ITEM;
1769 case 223: return POT_SANITY;
1770 case 224: return POT_SANITY;
1771 case 225: return POT_SANITY;
1772 case 226: return POT_SANITY;
1773 case 227: return SCR_BAD_EQUIPMENT;
1774 case 228: return WAN_INSANITY;
1775 case 229: return WAN_BAD_EQUIPMENT;
1776 case 230: return SCR_NASTY_CURSE;
1777 case 231: return SCR_HYBRIDIZATION;
1778 case 232: return WAN_DISENCHANTMENT;
1779 case 233: return WAN_TREMBLING;
1780 case 234: return WAN_CONTAMINATION;
1781 case 235: return SCR_GRAVE;
1782 case 236: return SCR_TUNNELS;
1783 case 237: return SCR_FARMING;
1784 case 238: return SCR_MOUNTAINS;
1785 case 239: return SCR_DIVING;
1786 case 240: return SCR_CRYSTALLIZATION;
1787 case 241: return SCR_MOORLAND;
1788 case 242: return SCR_URINE;
1789 case 243: return SCR_QUICKSAND;
1790 case 244: return SCR_STYX;
1791 case 245: return SCR_SNOW;
1792 case 246: return SCR_ASH;
1793 case 247: return SCR_SAND;
1794 case 248: return SCR_PAVING;
1795 case 249: return SCR_HIGHWAY;
1796 case 250: return SCR_GRASSLAND;
1797 case 251: return SCR_NETHER;
1798 case 252: return SCR_STALACTITE;
1799 case 253: return SCR_CRYPT;
1800 case 254: return SCR_BUBBLE_BOBBLE;
1801 case 255: return SCR_RAIN;
1802 case 256: return WAN_CHAOS_TERRAIN;
1803 case 257: return WAN_FLEECY_TERRAIN;
1804 case 258: return ETHER_HORN;
1805 case 259: return SHADOW_HORN;
1806 case 260: return CHROME_HORN;
1807 case 261: return SCR_ILLUSION;
1808 case 262: return SCR_EVIL_VARIANT;
1809 case 263: return SCR_FEMINISM;
1810 case 264: return WAN_BLEEDING;
1811 case 265: return WAN_UNDRESSING;
1812 case 266: return WAN_STAT_REDUCTION;
1813 case 267: return SCR_VISIBLE_ITEM;
1814 case 268: return WAN_DEATH;
1815 case 269: return SCR_TELEPORTATION;
1816 case 270: return POT_HEALING;
1817 case 271: return POT_EXTRA_HEALING;
1818 case 272: return WAN_DIGGING;
1819 case 273: return WAN_CREATE_MONSTER;
1820 case 274: return SCR_CREATE_MONSTER;
1821 case 275: return WAN_TELEPORTATION;
1822 case 276: return BUGLE;
1823 case 277: return UNICORN_HORN;
1824 case 278: return POT_FULL_HEALING;
1825 case 279: return SCR_SUMMON_UNDEAD;
1826 case 280: return WAN_HEALING;
1827 case 281: return WAN_EXTRA_HEALING;
1828 case 282: return WAN_CREATE_HORDE;
1829 case 283: return POT_VAMPIRE_BLOOD;
1830 case 284: return WAN_FULL_HEALING;
1831 case 285: return SCR_TELE_LEVEL;
1832 case 286: return SCR_ROOT_PASSWORD_DETECTION;
1833 case 287: return RIN_TIMELY_BACKUP;
1834 case 288: return WAN_SUMMON_UNDEAD;
1835 case 289: return SCR_HEALING;
1836 case 290: return SCR_WARPING;
1837 case 291: return BAG_OF_TRICKS;
1838 case 292: return WAN_TELE_LEVEL;
1839 case 293: return SCR_SUMMON_BOSS;
1840 case 294: return POT_CURE_WOUNDS;
1841 case 295: return POT_CURE_SERIOUS_WOUNDS;
1842 case 296: return POT_CURE_CRITICAL_WOUNDS;
1843 case 297: return SCR_POWER_HEALING;
1844 case 298: return SCR_CREATE_VICTIM;
1845 case 299: return SCR_GROUP_SUMMONING;
1846 case 300: return SCR_SUMMON_GHOST;
1847 case 301: return SCR_SUMMON_ELM;
1848 case 302: return WAN_SUMMON_ELM;
1849 case 303: return SCR_RELOCATION;
1850 case 304: return SCR_EXTRA_HEALING;
1851 case 305: return POT_BLOOD;
1852 case 306: return POT_GAIN_LEVEL;
1853 case 307: return WAN_MAKE_INVISIBLE;
1854 case 308: return POT_INVISIBILITY;
1855 case 309: return WAN_POLYMORPH;
1856 case 310: return POT_SPEED;
1857 case 311: return WAN_SPEED_MONSTER;
1858 case 312: return BULLWHIP;
1859 case 313: return POT_POLYMORPH;
1860 case 314: return WAN_CLONE_MONSTER;
1861 case 315: return WAN_HASTE_MONSTER;
1862 case 316: return POT_MUTATION;
1863 case 317: return WAN_MUTATION;
1864 case 318: return WAN_GAIN_LEVEL;
1865 case 319: return WAN_INCREASE_MAX_HITPOINTS;
1866 case 320: return SCR_COURSE_TRAVELING;
1867 case 321: return WAN_MEDIUM_HEALING;
1868 case 322: return WAN_STRONG_HEALING;
1869 case 323: return WAN_SUPER_HEALING;
1870 case 324: return WAN_TELEPORT_SELF;
1871 case 325: return POT_GREASE;
1872 default: return WAN_MAGIC_MISSILE;
1876 return WAN_MAGIC_MISSILE; /* to appease the compiler */
1881 makegreatitem() /* select the ID number of an item that might be very useful for you --Amy */
1884 switch (rnd(183)) {
1885 case 1:
1886 return TOOTH_OF_AN_ALGOLIAN_SUNTIGER;
1887 case 2:
1888 return DWARVISH_BATTLE_AXE;
1889 case 3:
1890 return ELECTRIC_SWORD;
1891 case 4:
1892 return BASTERD_SWORD;
1893 case 5:
1894 return HUGE_CLUB;
1895 case 6:
1896 return LOG;
1897 case 7:
1898 return INSECT_SQUASHER;
1899 case 8:
1900 return BOAT_OAR;
1901 case 9:
1902 return REINFORCED_MACE;
1903 case 10:
1904 return DEVIL_STAR;
1905 case 11:
1906 return OBSID;
1907 case 12:
1908 return SLEDGE_HAMMER;
1909 case 13:
1910 return MALLET;
1911 case 14:
1912 return BATTLE_STAFF;
1913 case 15:
1914 return TORPEDO;
1915 case 16:
1916 return MANCATCHER;
1917 case 17:
1918 return HYDRA_BOW;
1919 case 18:
1920 return CATAPULT;
1921 case 19:
1922 return BFG;
1923 case 20:
1924 return DEMON_CROSSBOW;
1925 case 21:
1926 return BODYGLOVE;
1927 case 22:
1928 return KYRT_SHIRT;
1929 case 23:
1930 return FULL_PLATE_MAIL;
1931 case 24:
1932 return ROBE_OF_MAGIC_RESISTANCE;
1933 case 25:
1934 return GRAY_DRAGON_SCALE_MAIL;
1935 case 26:
1936 return SILVER_DRAGON_SCALE_MAIL;
1937 case 27:
1938 return MERCURIAL_DRAGON_SCALE_MAIL;
1939 case 28:
1940 return DEEP_DRAGON_SCALE_MAIL;
1941 case 29:
1942 return BLACK_DRAGON_SCALE_MAIL;
1943 case 30:
1944 return GOLDEN_DRAGON_SCALE_MAIL;
1945 case 31:
1946 return STONE_DRAGON_SCALE_MAIL;
1947 case 32:
1948 return SKY_DRAGON_SCALE_MAIL;
1949 case 33:
1950 return CLOAK_OF_MAGIC_RESISTANCE;
1951 case 34:
1952 return CLOAK_OF_DRAIN_RESISTANCE;
1953 case 35:
1954 return CLOAK_OF_REFLECTION;
1955 case 36:
1956 return WING_CLOAK;
1957 case 37:
1958 return CLOAK_OF_STABILITY;
1959 case 38:
1960 return COCLOAK;
1961 case 39:
1962 return CLOAK_OF_SHIFTING;
1963 case 40:
1964 return SENSOR_CLOAK;
1965 case 41:
1966 return CLOAK_OF_SPEED;
1967 case 42:
1968 return OPERATION_CLOAK;
1969 case 43:
1970 return CLOAK_OF_FREEDOM;
1971 case 44:
1972 return CLOAK_OF_CURSE_CATCHING;
1973 case 45:
1974 return HELM_OF_DRAIN_RESISTANCE;
1975 case 46:
1976 return HELM_OF_SPEED;
1977 case 47:
1978 return HELM_OF_DETOXIFICATION;
1979 case 48:
1980 return HELM_OF_TELEPATHY;
1981 case 49:
1982 return ORIHALCYON_GAUNTLETS;
1983 case 50:
1984 return GAUNTLETS_OF_REFLECTION;
1985 case 51:
1986 return GAUNTLETS_OF_FREE_ACTION;
1987 case 52:
1988 return SHIELD_OF_MOBILITY;
1989 case 53:
1990 return GRAY_DRAGON_SCALE_SHIELD;
1991 case 54:
1992 return SILVER_DRAGON_SCALE_SHIELD;
1993 case 55:
1994 return MERCURIAL_DRAGON_SCALE_SHIELD;
1995 case 56:
1996 return DEEP_DRAGON_SCALE_SHIELD;
1997 case 57:
1998 return BLACK_DRAGON_SCALE_SHIELD;
1999 case 58:
2000 return GOLDEN_DRAGON_SCALE_SHIELD;
2001 case 59:
2002 return STONE_DRAGON_SCALE_SHIELD;
2003 case 60:
2004 return SKY_DRAGON_SCALE_SHIELD;
2005 case 61:
2006 return SPEED_BOOTS;
2007 case 62:
2008 return FLYING_BOOTS;
2009 case 63:
2010 return BOOTS_OF_FREEDOM;
2011 case 64:
2012 return BOOTS_OF_TOTAL_STABILITY;
2013 case 65:
2014 return RIN_DRAIN_RESISTANCE;
2015 case 66:
2016 return RIN_MAGIC_RESISTANCE;
2017 case 67:
2018 return RIN_MATERIAL_STABILITY;
2019 case 68:
2020 return RIN_SICKNESS_RESISTANCE;
2021 case 69:
2022 return RIN_ALACRITY;
2023 case 70:
2024 return RIN_FREE_ACTION;
2025 case 71:
2026 return RIN_POLYMORPH_CONTROL;
2027 case 72:
2028 return AMULET_OF_DRAIN_RESISTANCE;
2029 case 73:
2030 return AMULET_OF_ESP;
2031 case 74:
2032 return AMULET_OF_FLYING;
2033 case 75:
2034 return AMULET_OF_LIFE_SAVING;
2035 case 76:
2036 return AMULET_OF_REFLECTION;
2037 case 77:
2038 return AMULET_OF_DEPETRIFY;
2039 case 78:
2040 return AMULET_OF_MAGIC_RESISTANCE;
2041 case 79:
2042 return AMULET_OF_SICKNESS_RESISTANCE;
2043 case 80:
2044 return AMULET_OF_DISINTEGRATION_RESIS;
2045 case 81:
2046 return AMULET_OF_SPEED;
2047 case 82:
2048 return AMULET_OF_POLYMORPH_CONTROL;
2049 case 83:
2050 return AMULET_OF_PRISM;
2051 case 84:
2052 return AMULET_OF_WARP_DIMENSION;
2053 case 85:
2054 return AMULET_VERSUS_CURSES;
2055 case 86:
2056 return CHEST_OF_HOLDING;
2057 case 87:
2058 return ICE_BOX_OF_HOLDING;
2059 case 88:
2060 return ICE_BOX_OF_WATERPROOFING;
2061 case 89:
2062 return BAG_OF_HOLDING;
2063 case 90:
2064 return MAGIC_CANDLE;
2065 case 91:
2066 return MAGIC_WHISTLE;
2067 case 92:
2068 return MAGIC_HARP;
2069 case 93:
2070 return RED_DOUBLE_LIGHTSABER;
2071 case 94:
2072 return MAGIC_MARKER;
2073 case 95:
2074 return SWITCHER;
2075 case 96:
2076 return GOD_O_METER;
2077 case 97:
2078 return CHEMISTRY_SET;
2079 case 98:
2080 return POT_GAIN_HEALTH;
2081 case 99:
2082 return POT_FULL_HEALING;
2083 case 100:
2084 return POT_GAIN_LEVEL;
2085 case 101:
2086 return POT_INVULNERABILITY;
2087 case 102:
2088 return POT_RECOVERY;
2089 case 103:
2090 return POT_HEROISM;
2091 case 104:
2092 return SCR_CREATE_FAMILIAR;
2093 case 105:
2094 return SCR_SECURE_IDENTIFY;
2095 case 106:
2096 return SCR_INVENTORY_ID;
2097 case 107:
2098 return SCR_ARMOR_SPECIALIZATION;
2099 case 108:
2100 return SCR_ARTIFACT_CREATION;
2101 case 109:
2102 return SCR_GENOCIDE;
2103 case 110:
2104 return SCR_ACQUIREMENT;
2105 case 111:
2106 return SCR_REVERSE_IDENTIFY;
2107 case 112:
2108 return SCR_ALTER_REALITY;
2109 case 113:
2110 return SCR_ERASURE;
2111 case 114:
2112 return SCR_POWER_HEALING;
2113 case 115:
2114 return SCR_SKILL_UP;
2115 case 116:
2116 return SCR_CREATE_ALTAR;
2117 case 117:
2118 return SCR_WORLD_FALL;
2119 case 118:
2120 return SCR_RESURRECTION;
2121 case 119:
2122 return SCR_CONSECRATION;
2123 case 120:
2124 return SCR_REPAIR_ITEM;
2125 case 121:
2126 return SCR_ITEM_GENOCIDE;
2127 case 122:
2128 return SPE_TIME;
2129 case 123:
2130 return SPE_DISINTEGRATION;
2131 case 124:
2132 return SPE_DISINTEGRATION_BEAM;
2133 case 125:
2134 return SPE_FIXING;
2135 case 126:
2136 return SPE_MAP_LEVEL;
2137 case 127:
2138 return SPE_INERTIA;
2139 case 128:
2140 return SPE_REMOVE_CURSE;
2141 case 129:
2142 return SPE_TIME_STOP;
2143 case 130:
2144 return SPE_LEVELPORT;
2145 case 131:
2146 return SPE_PARALYSIS;
2147 case 132:
2148 return SPE_PETRIFY;
2149 case 133:
2150 return SPE_GRAVITY_BEAM;
2151 case 134:
2152 return SPE_GOOD_NIGHT;
2153 case 135:
2154 return SPE_INFERNO;
2155 case 136:
2156 return SPE_ICE_BEAM;
2157 case 137:
2158 return SPE_THUNDER;
2159 case 138:
2160 return SPE_SLUDGE;
2161 case 139:
2162 return SPE_TOXIC;
2163 case 140:
2164 return SPE_NETHER_BEAM;
2165 case 141:
2166 return SPE_AURORA_BEAM;
2167 case 142:
2168 return SPE_CHLOROFORM;
2169 case 143:
2170 return SPE_FINGER_OF_DEATH;
2171 case 144:
2172 return WAN_GAIN_LEVEL;
2173 case 145:
2174 return WAN_TIME_STOP;
2175 case 146:
2176 return WAN_TELE_LEVEL;
2177 case 147:
2178 return WAN_GENOCIDE;
2179 case 148:
2180 return WAN_ENTRAPPING;
2181 case 149:
2182 return WAN_PARALYSIS;
2183 case 150:
2184 return WAN_DISINTEGRATION;
2185 case 151:
2186 return WAN_STONING;
2187 case 152:
2188 return WAN_INCREASE_MAX_HITPOINTS;
2189 case 153:
2190 return WAN_CREATE_FAMILIAR;
2191 case 154:
2192 return WAN_DISINTEGRATION_BEAM;
2193 case 155:
2194 return WAN_ACQUIREMENT;
2195 case 156:
2196 return WAN_CHARGING;
2197 case 157:
2198 return WAN_GRAVITY_BEAM;
2199 case 158:
2200 return WAN_GOOD_NIGHT;
2201 case 159:
2202 return WAN_INFERNO;
2203 case 160:
2204 return WAN_ICE_BEAM;
2205 case 161:
2206 return WAN_THUNDER;
2207 case 162:
2208 return WAN_SLUDGE;
2209 case 163:
2210 return WAN_TOXIC;
2211 case 164:
2212 return WAN_NETHER_BEAM;
2213 case 165:
2214 return WAN_AURORA_BEAM;
2215 case 166:
2216 return WAN_DEATH;
2217 case 167:
2218 return CHARGER;
2219 case 168:
2220 return MATERIAL_KIT;
2221 case 169:
2222 return INTELLIGENCE_PACK;
2223 case 170:
2224 return SYMBIOTE;
2225 case 171:
2226 return SCR_SUPERIOR_MATERIAL;
2227 case 172:
2228 return SCR_GREATER_ENCHANT_WEAPON;
2229 case 173:
2230 return SCR_GREATER_ENCHANT_ARMOR;
2231 case 174:
2232 return SCR_POWER_CHARGING;
2233 case 175:
2234 return BITCHER;
2235 case 176:
2236 return POT_TECH_LEVEL_UP;
2237 case 177:
2238 return SCR_BRANCH_TELEPORT;
2239 case 178:
2240 return BLESSER;
2241 case 179:
2242 return BEAUTY_PACK;
2243 case 180:
2244 return INFUSION;
2245 case 181:
2246 return SCR_EXTRA_SKILL_POINT;
2247 case 182:
2248 return COMBINATION_CLOAK;
2249 case 183:
2250 return WAN_SUPER_HEALING;
2251 default: /* fail safe */
2252 return SCR_IDENTIFY;
2256 /* appease the compiler --Amy */
2257 return SCR_IDENTIFY;
2262 * Split obj so that it gets size gets reduced by num. The quantity num is
2263 * put in the object structure delivered by this call. The returned object
2264 * has its wornmask cleared and is positioned just following the original
2265 * in the nobj chain (and nexthere chain when on the floor).
2267 struct obj *
2268 splitobj(obj, num)
2269 struct obj *obj;
2270 long num;
2272 struct obj *otmp;
2274 if (obj->cobj || num <= 0L || obj->quan <= num)
2275 panic("splitobj"); /* can't split containers */
2276 otmp = newobj(obj->oxlth + obj->onamelth);
2277 *otmp = *obj; /* copies whole structure */
2278 otmp->o_id = flags.ident++;
2279 if (!otmp->o_id) otmp->o_id = flags.ident++; /* ident overflowed */
2280 otmp->timed = 0; /* not timed, yet */
2281 otmp->lamplit = 0; /* ditto */
2282 otmp->owornmask = 0L; /* new object isn't worn */
2283 obj->quan -= num;
2284 obj->owt = weight(obj);
2285 otmp->quan = num;
2286 otmp->owt = weight(otmp); /* -= obj->owt ? */
2287 obj->nobj = otmp;
2288 /* Only set nexthere when on the floor, nexthere is also used */
2289 /* as a back pointer to the container object when contained. */
2290 if (obj->where == OBJ_FLOOR)
2291 obj->nexthere = otmp;
2292 if (obj->oxlth)
2293 (void)memcpy((void *)otmp->oextra, (void *)obj->oextra,
2294 obj->oxlth);
2295 if (obj->onamelth)
2296 (void)strncpy(ONAME(otmp), ONAME(obj), (int)obj->onamelth);
2297 if (obj->unpaid) splitbill(obj,otmp);
2298 if (obj->timed) obj_split_timers(obj, otmp);
2299 if (obj_sheds_light(obj)) obj_split_light_source(obj, otmp);
2300 return otmp;
2304 * Insert otmp right after obj in whatever chain(s) it is on. Then extract
2305 * obj from the chain(s). This function does a literal swap. It is up to
2306 * the caller to provide a valid context for the swap. When done, obj will
2307 * still exist, but not on any chain.
2309 * Note: Don't use use obj_extract_self() -- we are doing an in-place swap,
2310 * not actually moving something.
2312 void
2313 replace_object(obj, otmp)
2314 struct obj *obj;
2315 struct obj *otmp;
2317 otmp->where = obj->where;
2318 switch (obj->where) {
2319 case OBJ_FREE:
2320 /* do nothing */
2321 break;
2322 case OBJ_INVENT:
2323 otmp->nobj = obj->nobj;
2324 obj->nobj = otmp;
2325 extract_nobj(obj, &invent);
2326 break;
2327 case OBJ_CONTAINED:
2328 otmp->nobj = obj->nobj;
2329 otmp->ocontainer = obj->ocontainer;
2330 obj->nobj = otmp;
2331 extract_nobj(obj, &obj->ocontainer->cobj);
2332 break;
2333 case OBJ_MINVENT:
2334 otmp->nobj = obj->nobj;
2335 otmp->ocarry = obj->ocarry;
2336 obj->nobj = otmp;
2337 extract_nobj(obj, &obj->ocarry->minvent);
2338 break;
2339 case OBJ_FLOOR:
2340 otmp->nobj = obj->nobj;
2341 otmp->nexthere = obj->nexthere;
2342 otmp->ox = obj->ox;
2343 otmp->oy = obj->oy;
2344 obj->nobj = otmp;
2345 obj->nexthere = otmp;
2346 extract_nobj(obj, &fobj);
2347 extract_nexthere(obj, &level.objects[obj->ox][obj->oy]);
2348 break;
2349 case OBJ_MIGRATING:
2350 otmp->nobj = obj->nobj;
2351 obj->nobj = otmp;
2352 extract_nobj(obj, &migrating_objs);
2353 break;
2354 case OBJ_BURIED:
2355 otmp->nobj = obj->nobj;
2356 obj->nobj = otmp;
2357 extract_nobj(obj, &level.buriedobjlist);
2358 break;
2359 case OBJ_ONBILL:
2360 otmp->nobj = obj->nobj;
2361 obj->nobj = otmp;
2362 extract_nobj(obj, &billobjs);
2363 break;
2364 default:
2365 panic("replace_object: obj position");
2366 break;
2371 * Create a dummy duplicate to put on shop bill. The duplicate exists
2372 * only in the billobjs chain. This function is used when a shop object
2373 * is being altered, and a copy of the original is needed for billing
2374 * purposes. For example, when eating, where an interruption will yield
2375 * an object which is different from what it started out as; the "I x"
2376 * command needs to display the original object.
2378 * The caller is responsible for checking otmp->unpaid and
2379 * costly_spot(u.ux, u.uy). This function will make otmp no charge.
2381 * Note that check_unpaid_usage() should be used instead for partial
2382 * usage of an object.
2384 void
2385 bill_dummy_object(otmp)
2386 register struct obj *otmp;
2388 register struct obj *dummy, *obj;
2390 if (otmp->unpaid)
2391 subfrombill(otmp, shop_keeper(*u.ushops));
2392 dummy = newobj(otmp->oxlth + otmp->onamelth);
2393 *dummy = *otmp;
2394 if (Has_contents(otmp)) {
2395 for(obj = otmp->cobj; obj; obj = obj->nobj)
2396 bill_dummy_object(obj);
2397 dummy->cobj = NULL;
2399 dummy->where = OBJ_FREE;
2400 dummy->o_id = flags.ident++;
2401 if (!dummy->o_id) dummy->o_id = flags.ident++; /* ident overflowed */
2402 dummy->timed = 0;
2403 if (otmp->oxlth)
2404 (void)memcpy((void *)dummy->oextra,
2405 (void *)otmp->oextra, otmp->oxlth);
2406 if (otmp->onamelth)
2407 (void)strncpy(ONAME(dummy), ONAME(otmp), (int)otmp->onamelth);
2408 if (Is_candle(dummy)) dummy->lamplit = 0;
2409 addtobill(dummy, FALSE, TRUE, TRUE);
2410 if (otmp->where != OBJ_INVENT)
2411 otmp->no_charge = 1;
2412 otmp->unpaid = 0;
2413 return;
2416 #endif /* OVL1 */
2417 #ifdef OVLB
2419 static const char dknowns[] = {
2420 WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, AMULET_CLASS, IMPLANT_CLASS,
2421 GEM_CLASS, SPBOOK_CLASS, WEAPON_CLASS, TOOL_CLASS, 0
2424 struct obj *
2425 mksobj(otyp, init, artif, shopinit)
2426 int otyp;
2427 boolean init;
2428 int artif;
2429 boolean shopinit;
2431 int mndx, tryct;
2432 struct obj *otmp;
2434 if (otyp >= NUM_OBJECTS) {
2435 impossible("Error: mksobj() called with invalid object type %d! Debug info for Amy: %d, %d, %d", otyp, (int) init, artif, (int) shopinit);
2436 otyp = GOLD_PIECE;
2439 if (objects[otyp].oc_class >= MAXOCLASSES) {
2440 impossible("Error: mksobj() called with invalid object class! Debug info for Amy: %d, %d, %d, %d", otyp, (int) init, artif, (int) shopinit);
2441 otyp = GOLD_PIECE;
2444 if (otyp == u.unobtainable && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2445 otyp = GOLD_PIECE;
2448 if (otyp == u.unobtainable2 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2449 otyp = GOLD_PIECE;
2452 if (otyp == u.unobtainable3 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2453 otyp = GOLD_PIECE;
2456 if (otyp == u.unobtainable4 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2457 otyp = GOLD_PIECE;
2460 if (otyp == u.unobtainable5 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2461 otyp = GOLD_PIECE;
2464 if (otyp == u.unobtainable6 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2465 otyp = GOLD_PIECE;
2468 if (otyp == u.unobtainable7 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2469 otyp = GOLD_PIECE;
2472 if (otyp == u.unobtainable8 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2473 otyp = GOLD_PIECE;
2476 if (otyp == u.unobtainable9 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2477 otyp = GOLD_PIECE;
2480 if (otyp == u.unobtainable10 && !(u.riderhack && otyp == CORPSE) && !(issokosolver && otyp == BOULDER)) {
2481 otyp = GOLD_PIECE;
2484 if (otyp == u.unobtainablegeno && !(u.riderhack && otyp == CORPSE)) { /* your fault for genociding them. No sokosolver specialties! --Amy */
2485 otyp = GOLD_PIECE;
2488 if (u.minimalism && isminimalist && rn2(u.minimalism) && !(issokosolver && otyp == BOULDER)) {
2489 if (otyp != GOLD_PIECE && otyp != STRANGE_OBJECT && otyp != AMULET_OF_YENDOR && otyp != CANDELABRUM_OF_INVOCATION
2490 #ifdef MAIL
2491 && otyp != SCR_MAIL
2492 #endif
2493 && otyp != BELL_OF_OPENING && otyp != SPE_BOOK_OF_THE_DEAD)
2494 otyp = GOLD_PIECE;
2497 char let = objects[otyp].oc_class;
2498 if (objects[otyp].oc_class >= MAXOCLASSES) {
2499 impossible("Error! mkobj oc_class invalid. Debug info for Amy: %d, %d, %d, %d, let %c", otyp, (int) init, artif, (int) shopinit, let);
2502 otmp = newobj(0);
2503 *otmp = zeroobj;
2504 otmp->age = monstermoves;
2505 otmp->invoketimer = monstermoves;
2506 otmp->o_id = flags.ident++;
2507 if (!otmp->o_id) otmp->o_id = flags.ident++; /* ident overflowed */
2508 otmp->quan = 1L;
2509 otmp->oclass = let;
2510 otmp->otyp = otyp;
2511 otmp->where = OBJ_FREE;
2512 otmp->dknown = index(dknowns, let) ? 0 : 1;
2513 otmp->selfmade = FALSE;
2514 otmp->oinvis = 0;
2515 otmp->oinvisreal = 0;
2516 otmp->petmarked = 0;
2517 otmp->obrittle = 0;
2518 otmp->obrittle2 = 0;
2519 otmp->olocked = FALSE; /* ->recharged */
2520 otmp->altmode = WP_MODE_AUTO;
2521 otmp->fakeartifact = 0;
2522 otmp->enchantment = 0;
2523 otmp->finalcancel = 0;
2524 otmp->nemtrident = 0;
2525 otmp->objwassold = (shopinit ? 1 : 0);
2526 otmp->icedobject = 0;
2528 if (init && (artif == 0) && !rn2(50)) artif = 1;
2530 /* each aspect that can be identified has a 4 in 5 chance of being possible to reveal by using the ID spell --Amy */
2531 otmp->ident_bst = rn2(5);
2532 otmp->ident_knw = rn2(5);
2533 otmp->ident_dkn = rn2(5);
2534 otmp->ident_bkn = rn2(5);
2535 otmp->ident_rkn = rn2(5);
2537 otmp->stackmarked = FALSE;
2538 otmp->shirtmessage = rnd(1000000);
2539 /* for use in read.c (shirts only) - since items can be polymorphed, set it for everything, including non-shirts */
2541 if ((otmp->otyp >= ELVEN_SHIELD && otmp->otyp <= ORCISH_SHIELD) ||
2542 otmp->otyp == SHIELD_OF_REFLECTION)
2543 otmp->dknown = 0;
2544 if (!objects[otmp->otyp].oc_uses_known)
2545 otmp->known = 1;
2546 otmp->oinvis = !always_visible(otmp) && \
2547 /*(otmp->otyp != BOULDER || !In_sokoban(&u.uz)) && */ !rn2(1250);
2548 if (otmp->otyp == BOULDER && In_sokoban(&u.uz) && !((moves + u.monstertimefinish) % 1317) ) otmp->oinvis = 1;
2550 /* 1 in 10000 random boulders are Wendyhole; use onameX to make sure it can generate several times --Amy */
2551 if (otmp->otyp == BOULDER && !rn2(10000) && !otmp->oartifact) {
2552 otmp = onameX(otmp, artiname(ART_WENDYHOLE));
2555 if (otmp->oinvis && !rn2(!(u.monstertimefinish % 13333) ? 3 : !(u.monstertimefinish % 1333) ? 10 : !(u.monstertimefinish % 133) ? 30 : 100) ) otmp->oinvisreal = 1;
2557 if (init && (let >= MAXOCLASSES)) {
2558 impossible("Error: mksobj() let value is invalid! Debug info for Amy: %d, %d, %d, %d, let %c", otyp, (int) init, artif, (int) shopinit, let);
2561 /* failsafe by Amy to make sure that all "aged" objects are still getting their correct age even if the item is being
2562 * created without initialization, so that they don't miraculously have an age of 100k if generated at T:100k
2563 * we're using fixed, not randomized values here; all we care about is that these items aren't bugged */
2564 if (!init) {
2566 switch (otmp->otyp) {
2568 case POT_OIL:
2569 otmp->age = MAX_OIL_IN_FLASK; /* amount of oil */
2570 break;
2571 case STICK_OF_DYNAMITE:
2572 otmp->age = rn2(10) + 10;
2573 break;
2574 case TALLOW_CANDLE:
2575 case WAX_CANDLE:
2576 case JAPAN_WAX_CANDLE:
2577 case OIL_CANDLE:
2578 case UNSPECIFIED_CANDLE:
2579 case SPECIFIC_CANDLE:
2580 case __CANDLE:
2581 case NATURAL_CANDLE:
2582 case UNAFFECTED_CANDLE:
2583 case GENERAL_CANDLE:
2584 otmp->age = 2000;
2585 break;
2586 case TORCH:
2587 otmp->age = (long) rn1(300,600);
2588 break;
2589 case BRASS_LANTERN:
2590 case OIL_LAMP:
2591 otmp->age = (long) rn1(500,1000);
2592 break;
2593 case DIM_LANTERN:
2594 otmp->age = (long) rn1(2500,5000);
2595 break;
2596 case RED_DOUBLE_LIGHTSABER:
2597 case CYAN_DOUBLE_LIGHTSABER:
2598 case LASERDENT:
2599 case LASER_FLYAXE:
2600 case PINK_DOUBLE_LIGHTSWORD:
2601 case LASERXBOW:
2602 case SITH_STAFF:
2603 case LASER_POLE:
2604 case WHITE_DOUBLE_LIGHTSABER:
2605 case STARWARS_MACE:
2606 case KLIUSLING:
2607 case LASER_SWORD:
2608 case LIGHTTORCH:
2609 case PINK_LIGHTSWORD:
2610 case BEAMSWORD:
2611 case GREEN_LIGHTSABER:
2612 case ORANGE_LIGHTSABER:
2613 case BLACK_LIGHTSABER:
2614 case BLUE_LIGHTSABER:
2615 case DARK_LIGHTSABER:
2616 case LASERFIST:
2617 case LASER_TIN_OPENER:
2618 case MYSTERY_LIGHTSABER:
2619 case VIOLET_LIGHTSABER:
2620 case WHITE_LIGHTSABER:
2621 case YELLOW_LIGHTSABER:
2622 case RAINBOW_LIGHTSABER:
2623 case RED_LIGHTSABER:
2624 case LASER_SWATTER:
2625 case NANO_HAMMER:
2626 case LIGHTWHIP:
2627 case ELECTRIC_CIGARETTE:
2628 otmp->age = (long) rn1(1000,1000);
2629 break;
2630 case HEAVY_LASER_BALL:
2631 case LASER_CHAIN:
2632 otmp->age = (long) rn1(500,1000);
2633 break;
2638 if (init) switch (let) {
2639 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
2640 case WEAPON_CLASS:
2641 /* KMH, balance patch -- new macros */
2642 otmp->quan = is_multigen(otmp) ? (long) rn1(12,12) : 1L;
2643 if (otmp->otyp == PISTOL_BULLET) otmp->quan += rnd(50);
2644 if (otmp->otyp == LEAD_PISTOL_BULLET) otmp->quan += rnd(50);
2645 if (otmp->otyp == SILVER_PISTOL_BULLET) otmp->quan += rnd(75);
2646 if (otmp->otyp == ANTIMATTER_PISTOL_BULLET) otmp->quan += rnd(75);
2647 if (otmp->otyp == FIVE_SEVEN_BULLET) otmp->quan += rnd(80);
2648 if (otmp->otyp == LEAD_FIVE_SEVEN_BULLET) otmp->quan += rnd(80);
2649 if (otmp->otyp == SHADOW_FIVE_SEVEN_BULLET) otmp->quan += rnd(200);
2650 if (otmp->otyp == ANTIMATTER_FIVE_SEVEN_BULLET) otmp->quan += rnd(160);
2651 if (otmp->otyp == SMG_BULLET) otmp->quan += rnd(50);
2652 if (otmp->otyp == BRONZE_SMG_BULLET) otmp->quan += rnd(50);
2653 if (otmp->otyp == LEAD_SMG_BULLET) otmp->quan += rnd(50);
2654 if (otmp->otyp == ANTIMATTER_SMG_BULLET) otmp->quan += rnd(50);
2655 if (otmp->otyp == MG_BULLET) otmp->quan += rnd(100);
2656 if (otmp->otyp == LEAD_MG_BULLET) otmp->quan += rnd(100);
2657 if (otmp->otyp == HOLLOW_POINT_MG_BULLET) otmp->quan += rnd(100);
2658 if (otmp->otyp == ANTIMATTER_MG_BULLET) otmp->quan += rnd(100);
2659 if (otmp->otyp == RIFLE_BULLET) otmp->quan += rnd(50);
2660 if (otmp->otyp == COPPER_RIFLE_BULLET) otmp->quan += rnd(50);
2661 if (otmp->otyp == LEAD_RIFLE_BULLET) otmp->quan += rnd(50);
2662 if (otmp->otyp == ANTIMATTER_RIFLE_BULLET) otmp->quan += rnd(50);
2663 if (otmp->otyp == SNIPER_BULLET) otmp->quan += rnd(50);
2664 if (otmp->otyp == LEAD_SNIPER_BULLET) otmp->quan += rnd(50);
2665 if (otmp->otyp == ANTIMATTER_SNIPER_BULLET) otmp->quan += rnd(50);
2666 if (otmp->otyp == PLATINUM_SNIPER_BULLET) otmp->quan += rnd(50);
2667 if (otmp->otyp == ASSAULT_RIFLE_BULLET) otmp->quan += rnd(75);
2668 if (otmp->otyp == LOWRATE_ASSAULT_RIFLE_BULLET) otmp->quan += rnd(160);
2669 if (otmp->otyp == LEAD_ASSAULT_RIFLE_BULLET) otmp->quan += rnd(75);
2670 if (otmp->otyp == ANTIMATTER_ASSAULT_RIFLE_BULLE) otmp->quan += rnd(75);
2671 if (otmp->otyp == BLASTER_BOLT) otmp->quan += rnd(30);
2672 if (otmp->otyp == CARCOSAN_BOLT) otmp->quan += rnd(100);
2673 if (otmp->otyp == RADIO) otmp->quan += rnd(30);
2674 if (otmp->otyp == RAYGUN_BOLT) otmp->quan += rnd(40);
2675 if (otmp->otyp == HEAVY_BLASTER_BOLT) otmp->quan += rnd(40);
2676 if (otmp->otyp == LASER_BEAM) otmp->quan += rnd(50);
2677 if (otmp->otyp == SHOTGUN_SHELL) otmp->quan += rnd(20);
2678 if (otmp->otyp == AUTO_SHOTGUN_SHELL) otmp->quan += rnd(30);
2679 if (otmp->otyp == LEAD_SHOT) otmp->quan += rnd(20);
2680 if (otmp->otyp == CHROME_PELLET) otmp->quan += rnd(20);
2681 if (otmp->otyp == AUTO_LEAD_SHOT) otmp->quan += rnd(30);
2682 if (otmp->otyp == COATED_AUTO_SHELL) otmp->quan += rnd(30);
2683 if (otmp->otyp == ROCKET) otmp->quan += rnd(5);
2684 if (otmp->otyp == CROSSBOW_BOLT) otmp->quan += rnd(25);
2685 if (otmp->otyp == DROVEN_BOLT) otmp->quan += rnd(75);
2686 if (otmp->otyp == DROVEN_ARROW) otmp->quan += rnd(75);
2687 if (otmp->otyp == INFERIOR_BOLT) otmp->quan += rnd(55);
2688 if (otmp->otyp == KOKKEN || otmp->otyp == MINERAL_BOLT || otmp->otyp == POISON_BOLT || otmp->otyp == HEAVY_CROSSBOW_BOLT || otmp->otyp == ETHER_BOLT || otmp->otyp == MATERIAL_BOLT || otmp->otyp == FLEECE_BOLT || otmp->otyp == PIN_BOLT || otmp->otyp == SPIKY_BOLT || otmp->otyp == HARDENED_BOLT) otmp->quan += rnd(50);
2689 if (otmp->otyp == PAPER_ARROW || otmp->otyp == FORBIDDEN_ARROW || otmp->otyp == GOLDEN_ARROW || otmp->otyp == ANCIENT_ARROW || otmp->otyp == BRONZE_ARROW) otmp->quan += rnd(15);
2690 if (otmp->otyp == YA) otmp->quan += rnd(20);
2691 if (otmp->otyp == FAR_EAST_ARROW) otmp->quan += rnd(20);
2692 if (otmp->otyp == FLIMSY_DART) otmp->quan += rnd(30);
2693 if (otmp->otyp == SAND_DART) otmp->quan += rnd(50);
2694 if (otmp->otyp == INKA_STINGER || otmp->otyp == SPIKE) otmp->quan += rnd(30);
2695 if (otmp->otyp == SHURIKEN) otmp->quan += rnd(100);
2696 if (otmp->otyp == MYSTERY_SHURIKEN) otmp->quan += rnd(100);
2697 if (otmp->otyp == TAR_STAR) otmp->quan += rnd(100);
2698 if (otmp->otyp == LIGHT_STAR) otmp->quan += rnd(100);
2699 if (otmp->otyp == NINJA_STAR) otmp->quan += rnd(60);
2700 if (otmp->otyp == NANO_SHURIKEN) otmp->quan += rnd(100);
2701 if (otmp->otyp == CUBIC_STAR) otmp->quan += rnd(100);
2702 if (otmp->otyp == WINDMILL_BLADE) otmp->quan += rnd(100);
2703 if (otmp->otyp == JUMPING_FLAMER) otmp->quan += rnd(100);
2704 if (otmp->otyp == NEEDLE) otmp->quan += rnd(100);
2705 if (otmp->otyp == SOFT_STAR) otmp->quan += rnd(200);
2706 if (otmp->otyp == CALTROP) otmp->quan += rnd(400);
2707 if (otmp->otyp == FLAMETHROWER) {
2708 otmp->quan += rnd(20);
2709 if (!rn2(5)) otmp->quan += rnd(30);
2711 if (otmp->otyp == BFG_AMMO) {
2712 otmp->quan = 40;
2713 if (!rn2(5)) otmp->quan *= (1 + rnd(4));
2715 if (is_lower_multigen(otmp) && !is_multigen(otmp) && !issoviet && !rn2(50) ) otmp->quan += rn2(6);
2716 if (is_lower_multigen(otmp) && !is_multigen(otmp) && !issoviet && !rn2(10) ) otmp->quan += rn2(2);
2718 /* occasionally make bigger stacks of stackable weapons --Amy */
2719 if (!issoviet && !rn2(is_multigen(otmp) ? 20 : is_lower_multigen(otmp) ? 100 : 1000) ) {
2720 otmp->quan += rnd(otmp->quan);
2721 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
2722 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
2724 if (In_lategame(&u.uz) && !issoviet && !rn2(is_multigen(otmp) ? 6 : is_lower_multigen(otmp) ? 20 : 1000) ) {
2725 otmp->quan += rnd(otmp->quan);
2726 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
2727 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
2730 if (uarmc && itemhasappearance(uarmc, APP_QUANTITY_CLOAK) && !rn2(3) && is_multigen(otmp)) {
2731 otmp->quan += rnd(otmp->quan);
2733 if (uarmc && itemhasappearance(uarmc, APP_QUANTITY_CLOAK) && !rn2(20) && is_lower_multigen(otmp)) {
2734 otmp->quan += rnd(otmp->quan);
2737 if (Race_if(PM_JAVA) && (otmp->otyp == JAVELIN || otmp->otyp == ASBESTOS_JAVELIN || otmp->otyp == STACK_JAVELIN || otmp->otyp == SPIRIT_THROWER || otmp->otyp == COURSE_JAVELIN || otmp->otyp == PUNCTURING_JAVELIN || otmp->otyp == UNDERWORLD_JAVELIN || otmp->otyp == TRANSPARENCE_THROWER || otmp->otyp == BRICK_MISSILE || otmp->otyp == TORPEDO || otmp->otyp == HOMING_TORPEDO)) {
2738 otmp->quan += rnd(5);
2740 if (Role_if(PM_TOSSER) && (otmp->otyp == JAVELIN || otmp->otyp == ASBESTOS_JAVELIN || otmp->otyp == STACK_JAVELIN || otmp->otyp == SPIRIT_THROWER || otmp->otyp == COURSE_JAVELIN || otmp->otyp == PUNCTURING_JAVELIN || otmp->otyp == UNDERWORLD_JAVELIN || otmp->otyp == TRANSPARENCE_THROWER || otmp->otyp == BRICK_MISSILE || otmp->otyp == TORPEDO || otmp->otyp == HOMING_TORPEDO)) {
2741 otmp->quan += rnd(5);
2744 if (otmp->otyp == MINI_NUKE) otmp->quan = 1;
2746 if (uarmc && uarmc->oartifact == ART_ARABELLA_S_WEAPON_STORAGE && (is_ammo(otmp) || is_missile(otmp) || is_grenade(otmp)) ) otmp->quan *= 2;
2748 /* In Soviet Russia, it's completely unthinkable to find a stack of more than the standard rn1(12,12) arrows.
2749 * Or darts or whatever other ranged weapon it is. Because it's not allowed to luck into a huge stack of
2750 * 100 +8 arrows or something. The standard amount must be sufficient for everyone in communism! --Amy */
2752 if(!rn2(ishaxor ? 3 : 6)) {
2753 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
2754 if (rn2(2)) otmp->blessed = rn2(2);
2755 else blessorcurse_on_creation(otmp, 3);
2756 } else if(!rn2(ishaxor ? 4 : 8)) {
2757 if (rn2(10)) curse_on_creation(otmp);
2758 else blessorcurse_on_creation(otmp, 3);
2759 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
2760 } else blessorcurse_on_creation(otmp, 10);
2762 if (MagicFindBonus && !rn2(6) && otmp->spe == 0) {
2763 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
2764 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
2766 if (StrongMagicFindBonus && !rn2(6) && otmp->spe == 0) {
2767 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
2768 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
2770 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
2771 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
2772 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
2774 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
2775 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
2778 /* lategame (Gehennom and beyond) should spawn highly enchanted gear slightly more often --Amy
2779 * idea from Nethack Fourk but implementation is my own */
2780 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
2781 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
2782 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
2785 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
2787 if (is_poisonable(otmp) && !rn2(100)) {
2788 otmp->opoisoned = 1;
2789 if (!rn2(100)) otmp->superpoison = 1;
2791 if (!rn2(achieve.get_amulet ? 100 : 400)) otmp->oerodeproof = 1;
2792 if (!rn2(400)) {
2793 if (!rn2(3)) otmp->oeroded = rnd(3);
2794 if (!rn2(3)) otmp->oeroded2 = rnd(3);
2796 if (!rn2(achieve.get_amulet ? 50 : 200)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
2798 if (artif && (artif != 2) && artigenechance(20)) {
2799 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
2800 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
2802 else if ((artif || otmp->spe) && !rn2((abs(otmp->spe) > 9) ? 2 : (abs(otmp->spe) > 7) ? 3 : (abs(otmp->spe) > 5) ? 4 : (abs(otmp->spe) > 4) ? 5 : (abs(otmp->spe) > 3) ? 6 : (abs(otmp->spe) > 2) ? 7 : (abs(otmp->spe) > 1) ? 8 : (abs(otmp->spe) > 0) ? 10 : 50)) {
2803 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
2804 otmp->fakeartifact = 1;
2805 if (artif != 2) u.fakeartifacts++;
2807 if (otmp->otyp == STICK_OF_DYNAMITE) {
2808 otmp->age = (otmp->cursed ? rn2(15) + 2 :
2809 (otmp->blessed ? 15 : rn2(10) + 10));
2812 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
2814 break;
2815 case FOOD_CLASS:
2816 otmp->odrained = 0;
2817 otmp->oeaten = 0;
2818 switch(otmp->otyp) {
2819 case CORPSE:
2820 /* possibly overridden by mkcorpstat() */
2821 tryct = 50;
2822 do otmp->corpsenm = undead_to_corpse(rndmonnum());
2823 while ((mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) && (--tryct > 0));
2824 if (tryct == 0) {
2825 /* perhaps rndmonnum() only wants to make G_NOCORPSE monsters on
2826 this level; let's create an adventurer's corpse instead, then */
2827 otmp->corpsenm = PM_HUMAN;
2829 /* timer set below */
2830 blessorcurse_on_creation(otmp, 8);
2831 break;
2832 case EGG:
2833 otmp->corpsenm = NON_PM; /* generic egg */
2834 if (rn2(3)) for (tryct = 500; tryct > 0; --tryct) { /* Uncommon egg types may be possible. --Amy */
2835 mndx = (rn2(100) ? can_be_hatched(rndmonnum()) : rndmonnum() );
2836 if (mndx != NON_PM && !dead_species(mndx, TRUE)) {
2837 otmp->corpsenm = mndx; /* typed egg */
2838 attach_egg_hatch_timeout(otmp);
2839 break;
2842 if (!rn2(200)) otmp->spe = 2;
2843 blessorcurse_on_creation(otmp, 8);
2844 break;
2845 case TIN:
2846 otmp->corpsenm = NON_PM; /* empty (so far) */
2847 if (!rn2(10)) /* more rare now --Amy */
2848 otmp->spe = rnd(4); /* spinach, beans, peaches or fish */
2849 else for (tryct = 200; tryct > 0; --tryct) {
2850 mndx = undead_to_corpse(rndmonnum());
2851 if (mons[mndx].cnutrit &&
2852 !(mvitals[mndx].mvflags & G_NOCORPSE)) {
2853 otmp->corpsenm = mndx;
2854 break;
2857 blessorcurse_on_creation(otmp, 10);
2858 break;
2859 case SLIME_MOLD:
2860 otmp->spe = current_fruit;
2861 otmp->quan = (long) rnd(15);
2862 if (!issoviet && !rn2(20) ) {
2863 otmp->quan += rnd(otmp->quan);
2864 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
2865 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
2867 if (In_lategame(&u.uz) && !issoviet && !rn2(6) ) {
2868 otmp->quan += rnd(otmp->quan);
2869 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
2870 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
2873 if (uarmc && uarmc->oartifact == ART_GOODFOOD && !rn2(3) ) {
2874 otmp->quan += rnd(otmp->quan);
2877 blessorcurse_on_creation(otmp, 10);
2878 break;
2879 case APPLE:
2880 case CARROT:
2881 case PEAR:
2882 case CHERRY:
2883 case ASIAN_PEAR:
2884 case BANANA:
2885 case WATER_HYACINTH:
2886 case LEMON:
2887 case ORANGE:
2888 case MELON:
2889 case KELP_FROND:
2890 otmp->quan = (long) rnd(5);
2891 if (!issoviet && !rn2(20) ) {
2892 otmp->quan += rnd(otmp->quan);
2893 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
2894 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
2896 if (In_lategame(&u.uz) && !issoviet && !rn2(6) ) {
2897 otmp->quan += rnd(otmp->quan);
2898 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
2899 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
2902 if (uarmc && uarmc->oartifact == ART_GOODFOOD && !rn2(3) ) {
2903 otmp->quan += rnd(otmp->quan);
2906 blessorcurse_on_creation(otmp, 10);
2907 break;
2908 } /* end switch statement */
2909 blessorcurse_on_creation(otmp, 10);
2910 if (!rn2(achieve.get_amulet ? 1000 : 4000)) otmp->oerodeproof = 1;
2911 if (!rn2(4000)) {
2912 if (!rn2(3)) otmp->oeroded = rnd(3);
2913 if (!rn2(3)) otmp->oeroded2 = rnd(3);
2915 if (!rn2(achieve.get_amulet ? 500 : 2000)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
2916 if (artif && (artif != 2) && artigenechance(200)) {
2917 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
2918 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
2920 else if (artif && !rn2(500)) {
2921 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
2922 otmp->fakeartifact = 1;
2923 if (artif != 2) u.fakeartifacts++;
2925 break;
2926 /* no longer fall into next case --Amy */
2928 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
2929 case GEM_CLASS:
2931 if (otmp->otyp == WONDER_STONE) otmp->oinvis = 1;
2933 /* KMH, balance patch -- healthstone replaces rotting/health */
2934 if (otmp->otyp == LOADSTONE || otmp->otyp == HEALTHSTONE || otmp->otyp == MANASTONE || otmp->otyp == SLEEPSTONE || otmp->otyp == LOADBOULDER || otmp->otyp == STARLIGHTSTONE) {
2935 curse_on_creation(otmp);
2936 if (!rn2(6)) otmp->quan = rn2(5) ? 2L : rn2(4) ? rn1(5,5) : rn1(10,10);
2937 else otmp->quan = 1L;
2939 if (!rn2(achieve.get_amulet ? 250 : 1000)) otmp->oerodeproof = 1;
2940 if (!rn2(1000)) {
2941 if (!rn2(3)) otmp->oeroded = rnd(3);
2942 if (!rn2(3)) otmp->oeroded2 = rnd(3);
2944 if (!rn2(achieve.get_amulet ? 125 : 500)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
2946 if (artif && (artif != 2) && artigenechance(50)) {
2947 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
2948 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
2950 else if ((artif || otmp->spe) && !rn2((abs(otmp->spe) > 9) ? 2 : (abs(otmp->spe) > 7) ? 3 : (abs(otmp->spe) > 5) ? 4 : (abs(otmp->spe) > 4) ? 5 : (abs(otmp->spe) > 3) ? 6 : (abs(otmp->spe) > 2) ? 7 : (abs(otmp->spe) > 1) ? 8 : (abs(otmp->spe) > 0) ? 10 : 150)) {
2951 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
2952 otmp->fakeartifact = 1;
2953 if (artif != 2) u.fakeartifacts++;
2956 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
2958 break;
2960 else if (otmp->otyp == ROCK) otmp->quan = (long) rn1(6,6);
2961 /* Finding single flint stones is just useless. Let sling users have some fun! --Amy */
2962 else if (otmp->otyp == FLINT && rn2(2) ) {
2963 otmp->quan = (long) rn1(5,5);
2964 if (!rn2(10)) otmp->quan *= 2;
2966 else if (otmp->otyp == SMALL_PIECE_OF_UNREFINED_MITHR && rn2(2) ) {
2967 otmp->quan = (long) rn1(6,6);
2968 if (!rn2(10)) otmp->quan *= 2;
2970 else if (otmp->otyp == COBALT_CHUNK && rn2(2) ) {
2971 otmp->quan = (long) rn1(7,7);
2972 if (!rn2(10)) otmp->quan *= 2;
2974 else if (otmp->otyp == BRONZE_NUGGET && rn2(2) ) {
2975 otmp->quan = (long) rn1(7,7);
2976 if (!rn2(10)) otmp->quan *= 2;
2978 else if (otmp->otyp == SLING_AMMO && rn2(2) ) {
2979 otmp->quan = (long) rn1(7,7);
2980 if (!rn2(10)) otmp->quan *= 2;
2982 else if (otmp->otyp == LEAD_CLUMP && rn2(2) ) {
2983 otmp->quan = (long) rn1(6,6);
2984 if (!rn2(10)) otmp->quan *= 2;
2986 else if (otmp->otyp == STEEL_SLUG && rn2(2) ) {
2987 otmp->quan = (long) rn1(6,6);
2988 if (!rn2(10)) otmp->quan *= 2;
2990 else if (otmp->otyp == BONE_FRAGMENT && rn2(2) ) {
2991 otmp->quan = (long) rn1(8,8);
2992 if (!rn2(10)) otmp->quan *= 2;
2994 else if (otmp->otyp == JUNK_METAL && rn2(2) ) {
2995 otmp->quan = (long) rn1(15,15);
2996 if (!rn2(10)) otmp->quan *= 2;
2998 else if (otmp->otyp == SILVER_SLINGSTONE && rn2(2) ) {
2999 otmp->quan = (long) rn1(10,10);
3000 if (!rn2(10)) otmp->quan *= 2;
3002 else if (otmp->otyp == METEOR_FRAGMENT && rn2(2) ) {
3003 otmp->quan = (long) rn1(13,13);
3004 if (!rn2(10)) otmp->quan *= 2;
3006 else if (otmp->otyp == CONUNDRUM_NUGGET && rn2(2) ) {
3007 otmp->quan = (long) rn1(9,9);
3008 if (!rn2(10)) otmp->quan *= 2;
3011 /* it's too easy to tell flint etc. apart from dangerous gray stones, so let's allow the latter to spawn
3012 * in bigger stacks occasionally just to troll players who expect stacks to always be flint. --Amy */
3013 else if (!rn2(6)) otmp->quan = rn2(5) ? 2L : rn2(4) ? rn1(5,5) : rn1(10,10);
3014 else otmp->quan = 1L;
3016 /* random chance of getting a bigger stack --Amy */
3017 if (!issoviet && !rn2(50) ) otmp->quan += rn2(6);
3018 if (!issoviet && !rn2(10) ) otmp->quan += rn2(2);
3019 if (!issoviet && !rn2(20) ) {
3020 otmp->quan += rnd(otmp->quan);
3021 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
3022 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3024 if (In_lategame(&u.uz) && !issoviet && !rn2(6) ) {
3025 otmp->quan += rnd(otmp->quan);
3026 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
3027 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3030 if (uarmc && itemhasappearance(uarmc, APP_QUANTITY_CLOAK) && !rn2(3)) {
3031 otmp->quan += rnd(otmp->quan);
3034 if(!rn2(ishaxor ? 4 : 8)) {
3035 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3036 if (rn2(2)) otmp->blessed = rn2(2);
3037 else blessorcurse_on_creation(otmp, 3);
3038 } else if(!rn2(ishaxor ? 5 : 10)) {
3039 if (rn2(10)) curse_on_creation(otmp);
3040 else blessorcurse_on_creation(otmp, 3);
3041 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3042 } else blessorcurse_on_creation(otmp, 10);
3044 if (MagicFindBonus && !rn2(8) && otmp->spe == 0) {
3045 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3046 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3048 if (StrongMagicFindBonus && !rn2(8) && otmp->spe == 0) {
3049 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3050 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3052 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
3053 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3054 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3056 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
3057 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3060 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
3061 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
3062 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
3065 if (!rn2(achieve.get_amulet ? 250 : 1000)) otmp->oerodeproof = 1;
3066 if (!rn2(1000)) {
3067 if (!rn2(3)) otmp->oeroded = rnd(3);
3068 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3070 if (!rn2(achieve.get_amulet ? 125 : 500)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3072 /* Amy edit: regular rocks are so common, and we might be adding more artifact versions of those in future
3073 * versions, so we want to make sure they don't spawn literally everywhere - make them 20x less common */
3074 if (artif && (artif != 2) && (!rn2(20) || (otmp->otyp != ROCK) ) && artigenechance(50)) {
3075 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3076 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3078 else if ((artif || otmp->spe) && !rn2((abs(otmp->spe) > 9) ? 2 : (abs(otmp->spe) > 7) ? 3 : (abs(otmp->spe) > 5) ? 4 : (abs(otmp->spe) > 4) ? 5 : (abs(otmp->spe) > 3) ? 6 : (abs(otmp->spe) > 2) ? 7 : (abs(otmp->spe) > 1) ? 8 : (abs(otmp->spe) > 0) ? 10 : 150)) {
3079 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3080 otmp->fakeartifact = 1;
3081 if (artif != 2) u.fakeartifacts++;
3084 /* "Disable enchantable rocks. The racial + stregnth + sling enchantment bonus is more than enough." In Soviet Russia, people never use slings anyway so they never noticed that those retarded things never do enough damage. They also completely disregard the fact that higher enchantment means a lower chance for the projectiles to disappear too. Guess they never used a stack of blessed +7 rocks in their life, otherwise they'd know the benefits of having them. --Amy */
3085 if (issoviet) otmp->spe = 0;
3087 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3089 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3091 break;
3092 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
3093 case TOOL_CLASS:
3094 switch(otmp->otyp) {
3095 case TALLOW_CANDLE:
3096 case WAX_CANDLE:
3097 case JAPAN_WAX_CANDLE:
3098 case OIL_CANDLE:
3099 case UNSPECIFIED_CANDLE:
3100 case SPECIFIC_CANDLE:
3101 case __CANDLE:
3102 case NATURAL_CANDLE:
3103 case UNAFFECTED_CANDLE:
3104 case GENERAL_CANDLE:
3105 otmp->spe = 1;
3106 otmp->age = 2000L; /* used to depend on cost but that's BS --Amy */
3108 if (!rn2(20)) {
3109 otmp->age += (rnd(10) * 500);
3110 } else if (!rn2(20)) {
3111 otmp->age -= (rnd(9) * 200);
3114 if (ishaxor) otmp->age *= 2;
3116 if (!rn2(6) && In_lategame(&u.uz)) {
3117 otmp->age += rnd(otmp->age);
3120 otmp->lamplit = 0;
3121 otmp->quan = 1L +
3122 (long)(rn2(2) ? rn2(7) : 0);
3123 if (!issoviet && !rn2(20) ) {
3124 otmp->quan += rnd(otmp->quan);
3125 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
3126 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3128 if (In_lategame(&u.uz) && !issoviet && !rn2(6) ) {
3129 otmp->quan += rnd(otmp->quan);
3130 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
3131 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3133 blessorcurse_on_creation(otmp, 5);
3134 break;
3135 case TORCH: otmp->spe = 0;
3136 otmp->age = (long) rn1(300,600);
3138 if (!rn2(20)) {
3139 otmp->age += rnz(1000);
3140 } else if (!rn2(20)) {
3141 otmp->age = rnz(600);
3144 if (ishaxor) otmp->age *= 2;
3146 if (!rn2(6) && In_lategame(&u.uz)) {
3147 otmp->age += rnd(otmp->age);
3150 otmp->lamplit = 0;
3151 otmp->quan = rnd(3);
3152 if (!issoviet && !rn2(20) ) {
3153 otmp->quan += rnd(otmp->quan);
3154 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
3155 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3157 if (In_lategame(&u.uz) && !issoviet && !rn2(6) ) {
3158 otmp->quan += rnd(otmp->quan);
3159 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
3160 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3162 blessorcurse_on_creation(otmp, 5);
3163 break;
3164 case BRASS_LANTERN:
3165 case OIL_LAMP:
3166 otmp->recharged = 0;
3167 if(!rn2(5)) otmp->recharged = rnd(7);
3168 otmp->spe = 1;
3169 otmp->age = (long) rn1(500,1000);
3170 if (!rn2(20)) {
3171 otmp->age += rnz(2000);
3172 } else if (!rn2(20)) {
3173 otmp->age = rnz(1000);
3175 if (ishaxor) otmp->age *= 2;
3177 if (!rn2(6) && In_lategame(&u.uz)) {
3178 otmp->age += rnd(otmp->age);
3181 otmp->lamplit = 0;
3182 blessorcurse_on_creation(otmp, 5);
3183 break;
3184 case DIM_LANTERN:
3185 otmp->recharged = 0;
3186 if(!rn2(5)) otmp->recharged = rnd(7);
3187 otmp->spe = 1;
3188 otmp->age = (long) rn1(2500,5000);
3189 if (!rn2(20)) {
3190 otmp->age += rnz(10000);
3191 } else if (!rn2(20)) {
3192 otmp->age = rnz(1000);
3194 if (ishaxor) otmp->age *= 2;
3196 if (!rn2(6) && In_lategame(&u.uz)) {
3197 otmp->age += rnd(otmp->age);
3200 otmp->lamplit = 0;
3201 blessorcurse_on_creation(otmp, 5);
3202 break;
3203 case MAGIC_CANDLE:
3204 case MAGIC_LAMP:
3205 otmp->spe = 1;
3206 otmp->lamplit = 0;
3207 blessorcurse_on_creation(otmp, 2);
3208 break;
3209 case RED_DOUBLE_LIGHTSABER:
3210 case CYAN_DOUBLE_LIGHTSABER:
3211 case LASERDENT:
3212 case LASER_FLYAXE:
3213 case PINK_DOUBLE_LIGHTSWORD:
3214 case LASERXBOW:
3215 case SITH_STAFF:
3216 case LASER_POLE:
3217 case WHITE_DOUBLE_LIGHTSABER:
3218 otmp->altmode = FALSE;
3219 case STARWARS_MACE:
3220 case KLIUSLING:
3221 case LASER_SWORD:
3222 case LIGHTTORCH:
3223 case PINK_LIGHTSWORD:
3224 case BEAMSWORD:
3225 case GREEN_LIGHTSABER:
3226 case ORANGE_LIGHTSABER:
3227 case BLACK_LIGHTSABER:
3228 case BLUE_LIGHTSABER:
3229 case DARK_LIGHTSABER:
3230 case LASERFIST:
3231 case LASER_TIN_OPENER:
3232 case MYSTERY_LIGHTSABER:
3233 case VIOLET_LIGHTSABER:
3234 case WHITE_LIGHTSABER:
3235 case YELLOW_LIGHTSABER:
3236 case RAINBOW_LIGHTSABER:
3237 case RED_LIGHTSABER:
3238 case LASER_SWATTER:
3239 case NANO_HAMMER:
3240 case LIGHTWHIP:
3241 case ELECTRIC_CIGARETTE:
3242 otmp->recharged = 0;
3243 if(!rn2(5)) otmp->recharged = rnd(7);
3244 otmp->lamplit = 0;
3245 otmp->age = (long) rn1(1000,1000);
3246 if (!rn2(20)) {
3247 otmp->age += rnz(1000);
3248 } else if (!rn2(20)) {
3249 otmp->age = rnz(500);
3252 if (otmp->otyp == BLACK_LIGHTSABER) otmp->age += rnz(5000);
3253 if (otmp->otyp == LASER_TIN_OPENER) otmp->age += rnz(5000);
3255 if (ishaxor) otmp->age *= 2;
3257 if (!rn2(6) && In_lategame(&u.uz)) {
3258 otmp->age += rnd(otmp->age);
3261 if(!rn2(ishaxor ? 3 : 6)) {
3262 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3263 if (rn2(2)) otmp->blessed = rn2(2);
3264 else blessorcurse_on_creation(otmp, 3);
3265 } else if(!rn2(ishaxor ? 4 : 8)) {
3266 if (rn2(10)) curse_on_creation(otmp);
3267 else blessorcurse_on_creation(otmp, 3);
3268 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3269 } else blessorcurse_on_creation(otmp, 10);
3271 if (MagicFindBonus && !rn2(6) && otmp->spe == 0) {
3272 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3273 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3275 if (StrongMagicFindBonus && !rn2(6) && otmp->spe == 0) {
3276 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3277 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3279 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
3280 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3281 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3283 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
3284 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3287 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
3288 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
3289 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
3292 if (bimanual(otmp)) { /* double lightsabers should last at least a bit longer --Amy */
3293 otmp->age *= 11;
3294 otmp->age /= 10;
3297 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3298 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3300 break;
3301 case TREASURE_CHEST:
3302 otmp->olocked = TRUE;
3303 otmp->otrapped = rn2(5);
3304 if (artif != 2) mkbox_cnts(otmp);
3305 blessorcurse_on_creation(otmp, 8);
3306 break;
3307 case LOOT_CHEST:
3308 otmp->olocked = rn2(2) ? TRUE : FALSE;
3309 otmp->otrapped = rn2(2);
3310 if (artif != 2) mkbox_cnts(otmp);
3311 blessorcurse_on_creation(otmp, 8);
3312 break;
3314 case CHEST:
3315 case NANO_CHEST:
3316 case CHEST_OF_HOLDING:
3317 case LARGE_BOX:
3318 case LEAD_BOX:
3319 case TOP_BOX:
3320 otmp->olocked = !!(rn2(5));
3321 otmp->otrapped = !(rn2(10));
3322 case ICE_BOX:
3323 case DISPERSION_BOX:
3324 case ICE_BOX_OF_HOLDING:
3325 case ICE_BOX_OF_WATERPROOFING:
3326 case SACK:
3327 case OILSKIN_SACK:
3328 case TITAN_SACK:
3329 case POTATO_BAG:
3330 case RUGGED_SACK:
3331 case HANDYBAG:
3332 case BAG_OF_HOLDING:
3333 case MEDICAL_KIT:
3334 if (artif != 2) mkbox_cnts(otmp);
3335 blessorcurse_on_creation(otmp, 8);
3336 break;
3337 case EXPENSIVE_CAMERA:
3338 case FELT_TIP_MARKER:
3339 otmp->recharged = 0;
3340 if(!rn2(5)) otmp->recharged = rnd(7);
3341 otmp->spe = rnd(ishaxor ? 120 : 100);
3342 otmp->spe -= rn2(3);
3343 blessorcurse_on_creation(otmp, 5);
3344 break;
3345 case TINNING_KIT:
3346 case BINNING_KIT:
3347 otmp->recharged = 0;
3348 if(!rn2(5)) otmp->recharged = rnd(7);
3349 otmp->spe = rnd(ishaxor ? 120 : 100);
3350 if (rn2(10)) otmp->spe = rnd(ishaxor ? 100 : 50);
3351 if (!rn2(3)) otmp->spe = rnd(ishaxor ? 60 : 30);
3352 if (!rn2(5)) otmp->spe = rnd(ishaxor ? 40 : 20);
3353 otmp->spe -= rn2(3);
3354 blessorcurse_on_creation(otmp, 5);
3355 break;
3356 break;
3357 case MAGIC_MARKER:
3358 otmp->recharged = 0;
3359 if(!rn2(2)) otmp->recharged = 1;
3360 otmp->spe = rnd(ishaxor ? 120 : 100);
3361 otmp->spe -= rn2(3);
3362 blessorcurse_on_creation(otmp, 5);
3363 break;
3364 case CAN_OF_GREASE:
3365 case LUBRICANT_CAN:
3366 otmp->recharged = 0;
3367 if(!rn2(5)) otmp->recharged = rnd(7);
3368 otmp->spe = rnd(ishaxor ? 70 : 35);
3369 otmp->spe -= rn2(3);
3370 blessorcurse_on_creation(otmp, 10);
3371 break;
3372 /* KMH, balance patch -- removed to prevent abuse, but added back in by Amy because the OPness can be fixed */
3373 case ORB_OF_DESTRUCTION:
3374 otmp->recharged = 0;
3375 if(!rn2(5)) otmp->recharged = rnd(7);
3376 blessorcurse_on_creation(otmp, 2);
3377 break;
3378 case ORB_OF_CHARGING:
3379 otmp->recharged = 0;
3380 if(rn2(5)) otmp->recharged = rnd(7);
3381 otmp->spe = rnd(3) + 1; /* wtf that was way too high a value! no wonder KMH thought it was overpowered */
3382 otmp->spe -= rn2(3);
3383 blessorcurse_on_creation(otmp, 2);
3384 break;
3385 case ORB_OF_ENCHANTMENT:
3386 otmp->spe = rnd(3) + 1;
3387 otmp->spe -= rn2(3);
3388 blessorcurse_on_creation(otmp, 2);
3389 break;
3390 case CRYSTAL_BALL:
3391 otmp->recharged = 0;
3392 if(!rn2(5)) otmp->recharged = rnd(7);
3393 otmp->spe = rn1(10,3);
3394 otmp->spe -= rn2(3);
3395 blessorcurse_on_creation(otmp, 2);
3396 break;
3397 case HORN_OF_PLENTY:
3398 case BAG_OF_TRICKS:
3399 otmp->recharged = 0;
3400 if(!rn2(5)) otmp->recharged = rnd(7);
3401 otmp->spe = rnd(30);
3402 otmp->spe -= rn2(3);
3403 blessorcurse_on_creation(otmp, 5);
3404 break;
3405 case CHEMISTRY_SET:
3406 otmp->recharged = 0;
3407 if(!rn2(5)) otmp->recharged = rnd(7);
3408 otmp->spe = rnd(ishaxor ? 80 : 40);
3409 otmp->spe -= rn2(3);
3410 blessorcurse_on_creation(otmp,4);
3411 break;
3412 case FIGURINE: {
3413 int tryct2 = 0;
3415 otmp->corpsenm = rndmonnum();
3416 while(is_human(&mons[otmp->corpsenm]) && !rn2(5)
3417 && tryct2++ < 30); /* come on, human figurines should be possible! --Amy */
3418 blessorcurse_on_creation(otmp, 4);
3419 break;
3421 case ENERGY_SAP:
3423 int tryct2 = 0;
3424 do otmp->corpsenm = rndmonnum();
3425 while(is_human(&mons[otmp->corpsenm]) && !rn2(5) && tryct2++ < 30);
3426 blessorcurse_on_creation(otmp, 4);
3427 break;
3429 case BELL_OF_OPENING:
3430 otmp->spe = (ishaxor ? 60 : 30);
3431 break;
3432 case MAGIC_FLUTE:
3433 case MAGIC_HARP:
3434 case FROST_HORN:
3435 case TEMPEST_HORN:
3436 case ETHER_HORN:
3437 case SHADOW_HORN:
3438 case CHROME_HORN:
3439 case FIRE_HORN:
3440 case DRUM_OF_EARTHQUAKE:
3441 /* KMH, balance patch -- removed, but re-inserted by Amy */
3442 case PAN_PIPE_OF_SUMMONING:
3443 case PAN_PIPE_OF_THE_SEWERS:
3444 otmp->recharged = 0;
3445 if(!rn2(5)) otmp->recharged = rnd(7);
3446 otmp->spe = rnd(ishaxor ? 30 : 15);
3447 otmp->spe -= rn2(3);
3448 blessorcurse_on_creation(otmp, 10);
3449 break;
3450 default: /* all the other tools --Amy */
3451 if(!rn2(ishaxor ? 3 : 6)) {
3452 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3453 if (rn2(2)) otmp->blessed = rn2(2);
3454 else blessorcurse_on_creation(otmp, 3);
3455 } else if(!rn2(ishaxor ? 4 : 8)) {
3456 if (rn2(10)) curse_on_creation(otmp);
3457 else blessorcurse_on_creation(otmp, 3);
3458 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3459 } else {
3460 blessorcurse_on_creation(otmp, 10);
3462 if (MagicFindBonus && !rn2(6) && otmp->spe == 0) {
3463 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3464 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3466 if (StrongMagicFindBonus && !rn2(6) && otmp->spe == 0) {
3467 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3468 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3470 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
3471 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3472 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3474 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
3475 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3478 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
3479 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
3480 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
3483 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3485 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3487 break;
3490 if (!rn2(achieve.get_amulet ? 200 : 800)) otmp->oerodeproof = 1;
3491 if (!rn2(800)) {
3492 if (!rn2(3)) otmp->oeroded = rnd(3);
3493 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3495 if (!rn2(achieve.get_amulet ? 100 : 400)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3497 if (artif && (artif != 2) && artigenechance(40)) {
3498 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3499 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3501 else if ((artif && !rn2(100)) || (otmp->spe && is_weptool(otmp) && !rn2((abs(otmp->spe) > 9) ? 2 : (abs(otmp->spe) > 7) ? 3 : (abs(otmp->spe) > 5) ? 4 : (abs(otmp->spe) > 4) ? 5 : (abs(otmp->spe) > 3) ? 6 : (abs(otmp->spe) > 2) ? 7 : (abs(otmp->spe) > 1) ? 8 : (abs(otmp->spe) > 0) ? 10 : 20)) ) {
3502 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3503 otmp->fakeartifact = 1;
3504 if (artif != 2) u.fakeartifacts++;
3507 break;
3508 case AMULET_CLASS:
3509 if (otmp->otyp == AMULET_OF_YENDOR) flags.made_amulet = TRUE;
3510 if(rn2(10) && (otmp->otyp == AMULET_OF_STRANGULATION ||
3511 otmp->otyp == AMULET_OF_CHANGE ||
3512 otmp->otyp == AMULET_OF_FUMBLING ||
3513 otmp->otyp == AMULET_OF_HUNGER ||
3514 otmp->otyp == AMULET_OF_BLINDNESS ||
3515 otmp->otyp == AMULET_OF_FUCKING ||
3516 otmp->otyp == AMULET_OF_BURDEN ||
3517 otmp->otyp == AMULET_OF_RESTFUL_SLEEP)) {
3518 curse_on_creation(otmp);
3519 } else {
3520 blessorcurse_on_creation(otmp, 10);
3522 if (!rn2(achieve.get_amulet ? 300 : 1200)) otmp->oerodeproof = 1;
3523 if (!rn2(1200)) {
3524 if (!rn2(3)) otmp->oeroded = rnd(3);
3525 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3527 if (!rn2(achieve.get_amulet ? 150 : 600)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3529 if (artif && (artif != 2) && artigenechance(60)) {
3530 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3531 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3533 else if (artif && !rn2(140)) {
3534 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3535 otmp->fakeartifact = 1;
3536 if (artif != 2) u.fakeartifacts++;
3539 break;
3540 case IMPLANT_CLASS:
3542 if(objects[otmp->otyp].oc_charged) {
3543 blessorcurse_on_creation(otmp, 5);
3544 if(rn2(10)) {
3545 if(rn2(10) && bcsign(otmp))
3546 otmp->spe = bcsign(otmp) * rne(Race_if(PM_LISTENER) ? 3 : 2);
3547 else otmp->spe = rn2(2) ? rne(Race_if(PM_LISTENER) ? 3 : 2) : -rne(Race_if(PM_LISTENER) ? 3 : 2);
3549 /* make useless +0 implants much less common */
3550 if (otmp->spe == 0) {
3551 /* otmp->spe = rn2(4) - rn2(3); */
3552 /* wow! +8! */
3553 if (rn2(3)) otmp->spe = rne(2)+1;
3554 else otmp->spe = -(rne(2)+1);
3557 if ((otmp->spe > 0) && !rn2(6) && In_lategame(&u.uz)) {
3558 otmp->spe += rnd(otmp->spe);
3560 if ((otmp->spe < 0) && !rn2(6) && In_lategame(&u.uz)) {
3561 otmp->spe -= rnd(abs(otmp->spe));
3564 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3566 /* negative implants are usually cursed */
3567 if (otmp->spe < 0 && rn2(5)) curse_on_creation(otmp);
3568 } else blessorcurse_on_creation(otmp, 5);
3570 if (!rn2(achieve.get_amulet ? 300 : 1200)) otmp->oerodeproof = 1;
3571 if (!rn2(1200)) {
3572 if (!rn2(3)) otmp->oeroded = rnd(3);
3573 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3575 if (!rn2(achieve.get_amulet ? 150 : 600)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3577 if (artif && (artif != 2) && artigenechance(60)) {
3578 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3579 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3581 else if (artif && !rn2(140)) {
3582 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3583 otmp->fakeartifact = 1;
3584 if (artif != 2) u.fakeartifacts++;
3587 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3589 break;
3590 case VENOM_CLASS:
3591 blessorcurse_on_creation(otmp, 10);
3593 if(!rn2(ishaxor ? 3 : 6)) {
3594 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3595 if (rn2(2)) otmp->blessed = rn2(2);
3596 else blessorcurse_on_creation(otmp, 3);
3597 } else if(!rn2(ishaxor ? 4 : 8)) {
3598 if (rn2(10)) curse_on_creation(otmp);
3599 else blessorcurse_on_creation(otmp, 3);
3600 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3601 } else blessorcurse_on_creation(otmp, 10);
3603 if (MagicFindBonus && !rn2(6) && otmp->spe == 0) {
3604 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3605 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3607 if (StrongMagicFindBonus && !rn2(6) && otmp->spe == 0) {
3608 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3609 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3611 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
3612 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3613 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3615 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
3616 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3619 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
3620 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
3621 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
3624 if (issoviet) otmp->spe = 0;
3626 if (!issoviet) otmp->quan = rnd(100);
3627 if (!issoviet && !rn2(20) ) {
3628 otmp->quan += rnd(otmp->quan);
3629 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
3630 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3632 if (In_lategame(&u.uz) && !issoviet && !rn2(6) ) {
3633 otmp->quan += rnd(otmp->quan);
3634 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
3635 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3638 if (uarmc && itemhasappearance(uarmc, APP_QUANTITY_CLOAK) && !rn2(3) && is_lower_multigen(otmp)) {
3639 otmp->quan += rnd(otmp->quan);
3642 if (!rn2(achieve.get_amulet ? 100 : 400)) otmp->oerodeproof = 1;
3643 if (!rn2(400)) {
3644 if (!rn2(3)) otmp->oeroded = rnd(3);
3645 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3647 if (!rn2(achieve.get_amulet ? 50 : 200)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3649 if (artif && (artif != 2) && artigenechance(100)) {
3650 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3651 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3653 else if (artif && !rn2(250)) {
3654 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3655 otmp->fakeartifact = 1;
3656 if (artif != 2) u.fakeartifacts++;
3659 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3661 if (otmp->oartifact == ART_BUS_ERROR || otmp->oartifact == ART_MYSTERIOUS_SPIKES) otmp->quan = 1;
3663 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3665 break;
3666 case CHAIN_CLASS:
3667 case BALL_CLASS:
3669 switch (otmp->otyp) {
3670 case HEAVY_LASER_BALL:
3671 case LASER_CHAIN:
3672 otmp->recharged = 0;
3673 if(!rn2(5)) otmp->recharged = rnd(7);
3674 otmp->lamplit = 0;
3675 otmp->age = (long) rn1(500,1000);
3676 if (!rn2(20)) {
3677 otmp->age += rnz(1000);
3678 } else if (!rn2(20)) {
3679 otmp->age = rnz(500);
3682 if (otmp->otyp == BLACK_LIGHTSABER) otmp->age += rnz(5000);
3684 if (ishaxor) otmp->age *= 2;
3686 if (!rn2(6) && In_lategame(&u.uz)) {
3687 otmp->age += rnd(otmp->age);
3690 break;
3693 if(!rn2(ishaxor ? 3 : 6)) {
3694 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3695 if (rn2(2)) otmp->blessed = rn2(2);
3696 else blessorcurse_on_creation(otmp, 3);
3697 } else if(!rn2(ishaxor ? 4 : 8)) {
3698 if (rn2(10)) curse_on_creation(otmp);
3699 else blessorcurse_on_creation(otmp, 3);
3700 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3701 } else blessorcurse_on_creation(otmp, 10);
3703 if (MagicFindBonus && !rn2(6) && otmp->spe == 0) {
3704 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3705 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3707 if (StrongMagicFindBonus && !rn2(6) && otmp->spe == 0) {
3708 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3709 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3711 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
3712 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3713 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3715 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
3716 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3719 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
3720 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
3721 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
3724 if (issoviet) otmp->spe = 0;
3726 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3728 if (!rn2(achieve.get_amulet ? 250 : 1000)) otmp->oerodeproof = 1;
3729 if (!rn2(1000)) {
3730 if (!rn2(3)) otmp->oeroded = rnd(3);
3731 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3733 if (!rn2(achieve.get_amulet ? 125 : 500)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3735 if (artif && (artif != 2) && artigenechance(50)) {
3736 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3737 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3739 else if ((artif || otmp->spe) && !rn2((abs(otmp->spe) > 9) ? 2 : (abs(otmp->spe) > 7) ? 3 : (abs(otmp->spe) > 5) ? 4 : (abs(otmp->spe) > 4) ? 5 : (abs(otmp->spe) > 3) ? 6 : (abs(otmp->spe) > 2) ? 7 : (abs(otmp->spe) > 1) ? 8 : (abs(otmp->spe) > 0) ? 10 : 150)) {
3740 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3741 otmp->fakeartifact = 1;
3742 if (artif != 2) u.fakeartifacts++;
3745 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3747 break;
3748 case POTION_CLASS:
3749 if (otmp->otyp == POT_OIL)
3750 otmp->age = MAX_OIL_IN_FLASK; /* amount of oil */
3751 /* fall through */
3752 case SCROLL_CLASS:
3753 #ifdef MAIL
3754 if (otmp->otyp != SCR_MAIL)
3755 #endif
3756 blessorcurse_on_creation(otmp, 4);
3758 if (!rn2(achieve.get_amulet ? 80 : 320)) otmp->oerodeproof = 1;
3759 if (!rn2(320)) {
3760 if (!rn2(3)) otmp->oeroded = rnd(3);
3761 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3763 if (!rn2(achieve.get_amulet ? 40 : 160)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3765 if (artif && (artif != 2) && artigenechance(160)) {
3766 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3767 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3769 else if (artif && !rn2(400)) {
3770 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3771 otmp->fakeartifact = 1;
3772 if (artif != 2) u.fakeartifacts++;
3774 if (!rn2(3) && !(otmp->otyp == SCR_HEALING || otmp->otyp == SCR_EXTRA_HEALING || otmp->otyp == SCR_HEAL_OTHER || otmp->otyp == SCR_STANDARD_ID || otmp->otyp == SCR_MANA || otmp->otyp == SCR_GREATER_MANA_RESTORATION
3775 #ifdef MAIL
3776 || otmp->otyp == SCR_MAIL
3777 #endif
3778 || otmp->otyp == SCR_CURE || otmp->otyp == SCR_PHASE_DOOR) ) otmp->finalcancel = TRUE;
3780 if (!issoviet && !rn2(500) && otmp->otyp != SCR_CREATE_CREATE_SCROLL ) {
3781 otmp->quan += rnd(4);
3782 if (!rn2(50)) otmp->quan += rnz(otmp->quan + 3);
3783 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3785 if (In_lategame(&u.uz) && !issoviet && !rn2(100) && otmp->otyp != SCR_CREATE_CREATE_SCROLL ) {
3786 otmp->quan += rnd(4);
3787 if (!rn2(20)) otmp->quan += rnz(otmp->quan + 3);
3788 if (!rn2(50)) otmp->quan += rnz( rnd( (otmp->quan * 2) + 3) );
3791 break;
3792 case SPBOOK_CLASS:
3793 /* WAC charged books are easier to read */
3794 if (otmp->otyp != SPE_BOOK_OF_THE_DEAD) {
3795 if (!rn2(2)) otmp->spe = rnd(ishaxor ? 10 : 5);
3796 else if (rn2(8)) otmp->spe = rnd(ishaxor ? 6 : 3);
3797 else otmp->spe = rnd(ishaxor ? 4 : 2);
3798 if (!rn2(10)) {
3799 otmp->spe -= rnd(4);
3800 if (otmp->spe < 0 && rn2(10)) otmp->spe = 0;
3804 if ((otmp->spe > 0) && !rn2(6) && In_lategame(&u.uz)) {
3805 otmp->spe += rnd(otmp->spe);
3808 otmp->recharged = 0;
3809 if(!rn2(5)) otmp->recharged = rnd(7);
3810 blessorcurse_on_creation(otmp, 17);
3812 if (!rn2(achieve.get_amulet ? 50 : 200)) otmp->oerodeproof = 1;
3813 if (!rn2(200)) {
3814 if (!rn2(3)) otmp->oeroded = rnd(3);
3815 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3817 if (!rn2(achieve.get_amulet ? 25 : 100)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3819 if (artif && (artif != 2) && artigenechance(100)) {
3820 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3821 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3823 else if (artif && !rn2(250)) {
3824 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3825 otmp->fakeartifact = 1;
3826 if (artif != 2) u.fakeartifacts++;
3828 if (!rn2(4)) otmp->finalcancel = TRUE;
3830 break;
3831 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
3832 case ARMOR_CLASS:
3833 if(rn2(10) && (otmp->otyp == FUMBLE_BOOTS ||
3834 otmp->otyp == LEVITATION_BOOTS ||
3835 otmp->otyp == ZIPPER_BOOTS ||
3836 otmp->otyp == FIRE_BOOTS ||
3837 otmp->otyp == BOOTS_OF_MOLASSES ||
3838 otmp->otyp == HIPPIE_HEELS ||
3839 otmp->otyp == CLOAK_OF_CONFUSION ||
3840 otmp->otyp == CLOAK_OF_FUCKING ||
3841 otmp->otyp == CLOAK_OF_FUMBLING ||
3842 otmp->otyp == CLOAK_OF_DIMNESS ||
3843 otmp->otyp == CLOAK_OF_BURDEN ||
3844 otmp->otyp == CLOAK_OF_VACUUM ||
3845 otmp->otyp == CLOAK_OF_TRANSFORMATION ||
3846 otmp->otyp == CLOAK_OF_AGGRAVATION ||
3847 otmp->otyp == CLOAK_OF_CONFLICT ||
3848 otmp->otyp == CLOAK_OF_STAT_LOCK ||
3849 otmp->otyp == HELM_OF_OPPOSITE_ALIGNMENT ||
3850 otmp->otyp == HELM_OF_FEAR ||
3851 otmp->otyp == HELM_OF_MADNESS ||
3852 otmp->otyp == VACUUM_HELMET ||
3853 otmp->otyp == BOOGEYMAN_HELMET ||
3854 otmp->otyp == HELM_OF_SENSORY_DEPRIVATION ||
3855 otmp->otyp == HELM_OF_HUNGER ||
3856 otmp->otyp == HELM_OF_STORMS ||
3857 otmp->otyp == HELM_OF_TELEPORTATION ||
3858 otmp->otyp == HELM_OF_DETECT_MONSTERS ||
3859 otmp->otyp == GAUNTLETS_OF_FUMBLING ||
3860 otmp->otyp == GAUNTLETS_OF_PANIC ||
3861 otmp->otyp == GAUNTLETS_OF_SLOWING ||
3862 otmp->otyp == ROBE_OF_WEAKNESS ||
3863 otmp->otyp == OILSKIN_GLOVES ||
3864 !rn2(ishaxor ? 5 : 11))) {
3865 if (rn2(10)) curse_on_creation(otmp);
3866 else blessorcurse_on_creation(otmp, 3);
3867 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3868 } else if(!rn2(ishaxor ? 5 : 8)) {
3869 if (rn2(2)) otmp->blessed = rn2(2);
3870 else blessorcurse_on_creation(otmp, 3);
3871 otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3872 } else blessorcurse_on_creation(otmp, 10);
3874 if (MagicFindBonus && !rn2(5) && otmp->spe == 0) {
3875 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3876 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3878 if (StrongMagicFindBonus && !rn2(5) && otmp->spe == 0) {
3879 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3880 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3882 if (uwep && uwep->oartifact == ART_MR__OF_HIGH_HEELS && !flags.female && otmp->spe == 0 && !rn2(10)) {
3883 if (rn2(2)) otmp->spe = rne(Race_if(PM_LISTENER) ? 3 : 2);
3884 else otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3886 if (uarmc && uarmc->oartifact == ART_FINDEET && otmp->spe == 0 && rn2(2)) {
3887 otmp->spe = -rne(Race_if(PM_LISTENER) ? 3 : 2);
3890 if (otmp->spe && !rn2(6) && In_lategame(&u.uz)) {
3891 if (otmp->spe > 0) otmp->spe += rne(Race_if(PM_LISTENER) ? 3 : 2);
3892 else otmp->spe -= rne(Race_if(PM_LISTENER) ? 3 : 2);
3895 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
3897 if (!rn2(achieve.get_amulet ? 20 : 80)) otmp->oerodeproof = 1;
3898 if (!rn2(80)) {
3899 if (!rn2(3)) otmp->oeroded = rnd(3);
3900 if (!rn2(3)) otmp->oeroded2 = rnd(3);
3902 if (!rn2(achieve.get_amulet ? 10 : 40)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
3904 if (itemhasappearance(otmp, APP_ANTISUCK_HELMET)) otmp->greased = rnd(3);
3906 if (artif && (artif != 2) && artigenechance(40)) {
3907 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
3908 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
3910 else if ((artif || otmp->spe) && !rn2((abs(otmp->spe) > 9) ? 2 : (abs(otmp->spe) > 7) ? 3 : (abs(otmp->spe) > 5) ? 4 : (abs(otmp->spe) > 4) ? 5 : (abs(otmp->spe) > 3) ? 6 : (abs(otmp->spe) > 2) ? 7 : (abs(otmp->spe) > 1) ? 8 : (abs(otmp->spe) > 0) ? 10 : 100)) {
3911 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3912 otmp->fakeartifact = 1;
3913 if (artif != 2) u.fakeartifacts++;
3914 } else if (!otmp->fakeartifact && !otmp->oartifact && itemhasappearance(otmp, APP_NAMED_BOOTS)) {
3915 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
3916 otmp->fakeartifact = 1;
3917 if (artif != 2) u.fakeartifacts++;
3920 /* simulate lacquered armor for samurai */
3921 if ( ( Role_if(PM_SAMURAI) && otmp->otyp == SPLINT_MAIL) || (Role_if(PM_ERDRICK) && otmp->otyp == STANDARD_HELMET) ) {
3922 #ifdef UNIXPC
3923 /* optimizer bitfield bug */
3924 otmp->oerodeproof = 1;
3925 otmp->rknown = 1;
3926 #else
3927 otmp->oerodeproof = otmp->rknown = 1;
3928 #endif
3931 if (!rn2(100) || (In_lategame(&u.uz) && !rn2(100)) || (achieve.get_amulet && !rn2(50)) || (uarmh && uarmh->oartifact == ART_WHY_NOT_DO_THE_REAL_THING && !rn2(20)) ||
3932 ( (is_shirt(otmp) || otmp->otyp == WHISPERING_HELMET || otmp->otyp == MOMHAT || otmp->otyp == CAPTCHA_HELM || otmp->otyp == QUIZ_HELM || otmp->otyp == LONG_POINTY_HEELS || otmp->otyp == METER_GAUNTLETS || otmp->otyp == WEIGHTING_GAUNTLETS || otmp->otyp == BIGSCRIPT_HELM ) && !rn2(15) ) ||
3933 ( (otmp->otyp == WEDGE_SANDALS || otmp->otyp == REPEATABLE_BOOTS || otmp->otyp == DANCING_SHOES || otmp->otyp == ANGER_HELM || otmp->otyp == SCRIPTED_HELMET || otmp->otyp == GAUNTLETS_OF_RAINBOW_MOUD || otmp->otyp == POKELIE_GLOVES || otmp->otyp == ASS_KICKER_BOOTS || otmp->otyp == TOP_HELMET || otmp->otyp == ABCDE_HELMET || otmp->otyp == COSTLY_FAILURE_HELMET || otmp->otyp == COLOR_CHANGING_CONE || otmp->otyp == SWEET_MOCASSINS || otmp->otyp == SOFT_SNEAKERS || otmp->otyp == CLOGS ) && !rn2(10) ) ||
3934 ( (otmp->otyp == CLOAK_OF_UNSPELLING || otmp->otyp == ANTI_CASTER_CLOAK || otmp->otyp == HEAVY_STATUS_CLOAK || otmp->otyp == CLOAK_OF_LUCK_NEGATION || otmp->otyp == YELLOW_SPELL_CLOAK || otmp->otyp == VULNERABILITY_CLOAK || otmp->otyp == CLOAK_OF_INVENTORYLESSNESS || otmp->otyp == CLOAK_OF_NULLIFICATION || otmp->otyp == HELM_OF_LOSE_IDENTIFICATION || otmp->otyp == HELM_OF_OBSCURED_DISPLAY || otmp->otyp == COVETED_BOOTS || otmp->otyp == LIGHTLESS_BOOTS || otmp->otyp == SELF_WILLED_HEELS || otmp->otyp == SOIL_CLINGING_BOOTS || otmp->otyp == PERMANENTLY_BLACK_SHOES || otmp->otyp == AUTOSCOOTER_HEELS || otmp->otyp == FORCEFUL_BOOTS || otmp->otyp == BUM_BUM_BOOTS || otmp->otyp == SADISTIC_BOOTS || otmp->otyp == FLUCKERING_BOOTS || otmp->otyp == SPRAP_BOOTS || otmp->otyp == FAILED_ATTEMPT_BOOTS || otmp->otyp == TECH_LOSS_HELMET || otmp->otyp == BRIGHT_CYAN_BEAUTIES || otmp->otyp == SIA_BOOTS || otmp->otyp == PLATINUM_SPELL_BOOTS || otmp->otyp == INVIS_WALKERS || otmp->otyp == NOISY_BOOTS || otmp->otyp == MORK_BOOTS || otmp->otyp == HELM_OF_THIRST || otmp->otyp == CLOCKLOAK || otmp->otyp == DULLER_GLOVES || otmp->otyp == INACCURATE_GLOVES || otmp->otyp == KILLER_HEELS || otmp->otyp == VIOLET_BEAUTY_HEELS || otmp->otyp == DARK_HAND_GLOVES || otmp->otyp == CHECKER_BOOTS || otmp->otyp == ETERNAL_LIAR_BOOTS || otmp->otyp == ELVIS_SHOES || otmp->otyp == HELM_OF_AMNESIA || otmp->otyp == BLACKY_HELMET || otmp->otyp == BLOODSUCKING_SHOES || otmp->otyp == ANTI_DRINKER_HELMET || otmp->otyp == NOKEDEX_CLOAK || otmp->otyp == CYPHER_HELM || otmp->otyp == DIZZY_HELMET || otmp->otyp == MUTING_HELM || otmp->otyp == ULCH_HELMET || otmp->otyp == GAUNTLETS_OF_BAD_CASTING || otmp->otyp == MARY_SUE_GLOVES || otmp->otyp == DIMMER_HELMET || otmp->otyp == BORDERLESS_HELMET || otmp->otyp == BROWN_SHIT_CLOAK || otmp->otyp == ANTICALL_CLOAK || otmp->otyp == YELLOW_WING || otmp->otyp == ELESDE_CLOAK || otmp->otyp == CLOAK_OF_GRAVATION || otmp->otyp == ALLPICKING_GLOVES || otmp->otyp == SILVER_SPELL_GLOVES || otmp->otyp == SPELLDRAIN_GLOVES || otmp->otyp == CLOAK_OF_NONFOLLOWING || otmp->otyp == SPELL_RETAIN_CLOAK || otmp->otyp == CLOAK_OF_FAST_DECAY || otmp->otyp == ORANGE_SPELL_GLOVES || otmp->otyp == MOJIBAKE_GLOVES || otmp->otyp == DIXPLOSION_GLOVES || otmp->otyp == LEFT_APPENDAGE_GLOVES || otmp->otyp == HELMET_OF_ANTI_SEARCHING || otmp->otyp == RARE_HELMET || otmp->otyp == OPTIONAL_HELMET || otmp->otyp == HEAVY_GRABBING_GLOVES || otmp->otyp == AIRSTEP_BOOTS || otmp->otyp == BOOTS_OF_INTERRUPTION || otmp->otyp == BLACK_SPELL_GAUNTLETS || otmp->otyp == HIGH_HEELED_SKIERS || otmp->otyp == HIGH_SCORING_HEELS || otmp->otyp == HELM_OF_STARVATION || otmp->otyp == QUAFFER_HELMET || otmp->otyp == PSEUDO_TELEPORTER_CLOAK || otmp->otyp == SNARENET_CLOAK || otmp->otyp == PINK_SPELL_CLOAK || otmp->otyp == QUAVERSAL_HELMET || otmp->otyp == HELM_OF_SHUFFLING || otmp->otyp == GOLDSPELL_HELMET || otmp->otyp == AIRHEAD_CAP || otmp->otyp == FALLOUT_HELMET || otmp->otyp == IDENTIFY_CURD_HELMET || otmp->otyp == BAEAEAEP_SPY_HELMET || otmp->otyp == CRUNCHER_HELMET || otmp->otyp == DISTORTED_GRIMACE || otmp->otyp == ELM_ET || otmp->otyp == SANEMAKER_HELMET || otmp->otyp == GRAYOUT_CLOAK || otmp->otyp == TRON_BOOTS || otmp->otyp == RED_SPELL_HEELS || otmp->otyp == KILLER_SPAWN_BOOTS || otmp->otyp == DESTRUCTIVE_HEELS || otmp->otyp == CARTRIDGE_OF_HAVING_A_HORROR || otmp->otyp == SOUND_EFFECT_HELMET || otmp->otyp == INCORRECTLY_ADJUSTED_HELMET || otmp->otyp == CLOAK_OF_RESPAWNING || otmp->otyp == HELM_OF_BAD_ALIGNMENT || otmp->otyp == SOUNDPROOF_HELMET || otmp->otyp == HELM_OF_COUNTER_ROTATION || otmp->otyp == EPVI_SLIPPERS || otmp->otyp == DELIGHT_HELMET || otmp->otyp == OUT_OF_MEMORY_HELMET || otmp->otyp == FUCKUP_MELEE_GAUNTLETS || otmp->otyp == INFOLESS_HELMET || otmp->otyp == UNDETECTION_GLOVES || otmp->otyp == BLUE_SPELL_HELMET || otmp->otyp == MORE_HELMET || otmp->otyp == FISHINGHAIL_MET || otmp->otyp == MESSAGE_FILTER_HELMET || otmp->otyp == FLICKER_VISOR || otmp->otyp == STORMY_CLOAK || otmp->otyp == CLOAK_OF_WRONG_ANNOUNCEMENT || otmp->otyp == BATTERY_CLOAK || otmp->otyp == NAYLIGHT_CLOAK || otmp->otyp == UNDERLAYER_CLOAK || otmp->otyp == EVENCORE_CLOAK || otmp->otyp == SCALER_MITTENS || otmp->otyp == GLOVES_OF_ENERGY_DRAINING || otmp->otyp == MENU_NOSE_GLOVES || otmp->otyp == UNWIELDY_GLOVES || otmp->otyp == ELONGATION_CLOAK || otmp->otyp == CYAN_SPELL_CLOAK || otmp->otyp == BANKING_GLOVES || otmp->otyp == DIFFICULT_GLOVES || otmp->otyp == CHAOS_GLOVES || otmp->otyp == COMPETITION_BOOTS || otmp->otyp == QUASIMODULAR_BOOTS || otmp->otyp == SINFUL_HEELS || otmp->otyp == LEVELING_GLOVES || otmp->otyp == GIMP_CLOAK || otmp->otyp == UNFAIR_ATTACK_CLOAK || otmp->otyp == CLOAK_OF_BAD_PART || otmp->otyp == ADOM_CLOAK || otmp->otyp == EMPTY_LINE_HELMET || otmp->otyp == GREEN_SPELL_HELMET || otmp->otyp == EGOIST_CLOAK || otmp->otyp == CHATBOX_CLOAK || otmp->otyp == VANCIAN_CLOAK || otmp->otyp == CHOICE_O_MATE_CLOAK || otmp->otyp == COVID____COATED_CLOAK || otmp->otyp == HERETIC_CLOAK || otmp->otyp == EERIE_CLOAK || otmp->otyp == PETHATE_CLOAK || otmp->otyp == PET_LASHOUT_CLOAK || otmp->otyp == PETSTARVE_CLOAK || otmp->otyp == PETSCREW_CLOAK || otmp->otyp == NON_PROOF_CLOAK || otmp->otyp == CLOAK_OF_BAD_TRAPPING || otmp->otyp == CLOAK_OF_NAKEDNESS || otmp->otyp == GAUNTLETS_OF_REVERSE_ENCHANTME || otmp->otyp == CLOAK_OF_TIME || otmp->otyp == SPAWN_CLOAK || otmp->otyp == CONFUSING_GLOVES || otmp->otyp == DISENCHANTING_BOOTS || otmp->otyp == LIMITATION_BOOTS || otmp->otyp == THROUGH_THE_FLOOR_BOOTS || otmp->otyp == UNDROPPABLE_GLOVES || otmp->otyp == GAUNTLETS_OF_MISSING_INFORMATI || otmp->otyp == GAUNTLETS_OF_TRAP_CREATION || otmp->otyp == GAUNTLETS_OF_STEALING || otmp->otyp == CLOAK_OF_SUDDEN_ATTACK || otmp->otyp == TRUMP_COAT || otmp->otyp == GREYOUT_CLOAK || otmp->otyp == WHITE_SPELL_CLOAK || otmp->otyp == GAUNTLETS_OF_MISFIRING || otmp->otyp == SADO_MASO_GLOVES || otmp->otyp == FEMININE_PUMPS || otmp->otyp == LEATHER_PEEP_TOES || otmp->otyp == COMBAT_STILETTOS || otmp->otyp == DIDIER_SACHS_SHOES || otmp->otyp == MEN_S_HIGH_HEELS || otmp->otyp == LADY_BOOTS || otmp->otyp == BASIC_SHOES || otmp->otyp == ITALIAN_HEELS || otmp->otyp == STILETTO_SANDALS || otmp->otyp == AUTODESTRUCT_DE_VICE_BOOTS || otmp->otyp == SPEEDBUG_BOOTS || otmp->otyp == DISCONNECTED_BOOTS || otmp->otyp == BOSS_BOOTS || otmp->otyp == PET_STOMPING_PLATFORM_BOOTS || otmp->otyp == DEMENTIA_BOOTS || otmp->otyp == BOOTS_OF_FAINTING || otmp->otyp == DIFFICULT_BOOTS || otmp->otyp == BOOTS_OF_WEAKNESS || otmp->otyp == BUGXPLORE_HELMET || otmp->otyp == YAWNING_VISOR || otmp->otyp == REALLY_BAD_HELM || otmp->otyp == GRIDBUG_CONDUCT_BOOTS || otmp->otyp == STAIRWELL_STOMPING_BOOTS ) && !rn2(5) ) ||
3935 ((otmp->otyp == HIPPIE_HEELS || otmp->otyp == SENTIENT_HIGH_HEELED_SHOES) && !rn2(3)) ) {
3937 otmp->enchantment = randenchantment();
3941 /* certain base items are characterized by the fact that they always have an enchantment and are otherwise plain --Amy */
3942 if (otmp->otyp == SPECIAL_CLOAK || otmp->otyp == CHANTER_SHIRT || otmp->otyp == MAGIC_DRAGON_SCALE_MAIL || otmp->otyp == MAGIC_DRAGON_SCALES || otmp->otyp == MAGIC_DRAGON_SCALE_SHIELD || otmp->otyp == SPECIAL_SHIELD || otmp->otyp == SPECIAL_LEATHER_ARMOR || otmp->otyp == MAGE_PLATE_MAIL || otmp->otyp == ROBE_OF_SPECIALTY || otmp->otyp == WONDER_HELMET || otmp->otyp == ARCANE_GAUNTLETS || otmp->otyp == SKY_HIGH_HEELS || itemhasappearance(otmp, APP_SELF_TYPE_HELMET) || itemhasappearance(otmp, APP_ENCHANTMENT_CLOAK) ) {
3943 otmp->enchantment = randenchantment();
3946 if (itemhasappearance(otmp, APP_HIGHER_HELMET)) otmp->spe += rne(2);
3947 if (itemhasappearance(otmp, APP_SUPER_BOOTS)) otmp->spe += 5;
3948 if (otmp->otyp == WOWEE_GAUNTLETS) otmp->spe += rnd(10);
3950 if (itemhasappearance(otmp, APP_REPAIR_WORTHY_BOOTS)) {
3951 if (!rn2(3)) otmp->oeroded = rnd(3);
3952 else if (!rn2(2)) otmp->oeroded2 = rnd(3);
3953 else {
3954 otmp->oeroded = rnd(3);
3955 otmp->oeroded2 = rnd(3);
3959 if ((artif != 3) && itemhasappearance(otmp, APP_INSTAFEMINISM_SHOES)) {
3960 if (!FemtrapActiveRuth) pline("Ha ha ha...");
3961 randomfeminismtrap(rnz( (level_difficulty() + 2) * rnd(50)));
3962 if (!FemtrapActiveRuth) pline("The woman is laughing loudly because you were unable to avoid that effect.");
3965 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
3967 break;
3968 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
3969 case WAND_CLASS:
3970 if(otmp->otyp == WAN_WISHING) {
3971 if (rn2(50)) otmp->spe = rnd(ishaxor ? 3 : 2);
3972 else otmp->spe = rnd(ishaxor ? 4 : 3); /* if you get really lucky... --Amy */
3973 if (Is_stronghold(&u.uz)) otmp->oinvis = 1;
3974 otmp->recharged = 0;
3975 if(!rn2(2)) otmp->recharged = 1;
3976 } else if(otmp->otyp == WAN_GENOCIDE) {
3977 if (rn2(20)) otmp->spe = rnd(ishaxor ? 4 : 3);
3978 else otmp->spe = rnd(ishaxor ? 6 : 4); /* sometimes you may get lucky --Amy */
3979 otmp->recharged = 0;
3980 if(!rn2(3)) otmp->recharged = rnd(7);
3981 } else if(otmp->otyp == WAN_ACQUIREMENT) {
3982 if (rn2(20)) otmp->spe = rnd(ishaxor ? 6 : 5);
3983 else otmp->spe = rnd(ishaxor ? 10 : 8); /* sometimes you may get lucky --Amy */
3984 otmp->recharged = 0;
3985 if(!rn2(3)) otmp->recharged = 1;
3986 } else if(otmp->otyp == WAN_GAIN_LEVEL) {
3987 if (rn2(20)) otmp->spe = rnd(ishaxor ? 5 : 4);
3988 else otmp->spe = rnd(ishaxor ? 6 : 5); /* sometimes you may get lucky --Amy */
3989 otmp->recharged = 0;
3990 if(!rn2(2)) otmp->recharged = rnd(7);
3991 } else if(otmp->otyp == WAN_VENOM_SCATTERING) {
3992 if (rn2(20)) otmp->spe = rnd(ishaxor ? 40 : 20);
3993 else otmp->spe = rnd(ishaxor ? 50 : 25); /* sometimes you may get lucky --Amy */
3994 otmp->recharged = 0;
3995 if(!rn2(10)) otmp->recharged = rnd(7);
3996 } else if(otmp->otyp == WAN_INCREASE_MAX_HITPOINTS) {
3997 if (rn2(20)) otmp->spe = rnd(ishaxor ? 6 : 5);
3998 else otmp->spe = rnd(ishaxor ? 7 : 6); /* sometimes you may get lucky --Amy */
3999 otmp->recharged = 0;
4000 if(!rn2(2)) otmp->recharged = rnd(7);
4001 } else if(otmp->otyp == WAN_PARALYSIS || otmp->otyp == WAN_DISINTEGRATION || otmp->otyp == WAN_DISINTEGRATION_BEAM || otmp->otyp == WAN_STONING || otmp->otyp == WAN_INERTIA || otmp->otyp == WAN_TIME || otmp->otyp == WAN_IDENTIFY || otmp->otyp == WAN_REMOVE_CURSE || otmp->otyp == WAN_TIME_STOP || otmp->otyp == WAN_TELE_LEVEL || otmp->otyp == WAN_ENTRAPPING || otmp->otyp == WAN_MAGIC_MAPPING || otmp->otyp == WAN_CREATE_FAMILIAR) {
4002 if (rn2(20)) otmp->spe = rnd(ishaxor ? 6 : 5);
4003 else otmp->spe = rnd(ishaxor ? 10 : 8); /* sometimes you may get lucky --Amy */
4004 otmp->recharged = 0;
4005 if(!rn2(10)) otmp->recharged = rnd(7);
4006 } else if(otmp->otyp == WAN_ENLIGHTENMENT || otmp->otyp == WAN_TRAP_DISARMING || otmp->otyp == WAN_CANCELLATION || otmp->otyp == WAN_POLYMORPH || otmp->otyp == WAN_MUTATION || otmp->otyp == WAN_CHARGING || otmp->otyp == WAN_BAD_EQUIPMENT) {
4007 if (rn2(20)) otmp->spe = rnd(ishaxor ? 10 : 7);
4008 else otmp->spe = rnd(ishaxor ? 15 : 10); /* sometimes you may get lucky --Amy */
4009 otmp->recharged = 0;
4010 if(!rn2(10)) otmp->recharged = rnd(7);
4012 } else if (rn2(10) && !ishaxor) otmp->spe = rnd( (objects[otmp->otyp].oc_dir == NODIR) ? 20 : (objects[otmp->otyp].oc_dir == IMMEDIATE) ? 12 : 10);
4013 else otmp->spe = rnd( (objects[otmp->otyp].oc_dir == NODIR) ? 40 : (objects[otmp->otyp].oc_dir == IMMEDIATE) ? 24 : 20); /* low chance for extra charges --Amy */
4014 if (!rn2(3) && !issoviet) {
4015 otmp->spe -= rnd(3); /* allow random useless wands to spawn --Amy */
4016 if (otmp->spe < 0 && rn2(8)) otmp->spe = 0;
4018 /* "Remove chance of non-charged wands spawning." In Soviet Russia, players don't realize that a lower chance of finding useful stuff makes the game more interesting. The pre-cancelled wands are actually there for a reason: that way, players trying to zap-identify can randomly vaporize their wands if they happen to be cancelled, making identification more useful! --Amy */
4020 /* in the late game, wands may generate with more charges but only if they're a type that can be recharged
4021 * indefinitely, as we once again need to keep things balanced --Amy */
4022 if ((otmp->spe > 0) && !rn2(6) && In_lategame(&u.uz)) {
4023 if (!(otmp->otyp == WAN_WISHING || otmp->otyp == WAN_CHARGING || otmp->otyp == WAN_ACQUIREMENT || otmp->otyp == WAN_GAIN_LEVEL || otmp->otyp == WAN_INCREASE_MAX_HITPOINTS))
4024 otmp->spe += rnd(otmp->spe);
4027 blessorcurse_on_creation(otmp, 17);
4028 if (otmp->otyp != WAN_WISHING && otmp->otyp != WAN_ACQUIREMENT && otmp->otyp != WAN_GENOCIDE && otmp->otyp != WAN_GAIN_LEVEL && otmp->otyp != WAN_INCREASE_MAX_HITPOINTS) otmp->recharged = 0; /* used to control recharging */
4029 if (!rn2(10)) otmp->recharged = rnd(7); /* allow recharged wands to spawn --Amy */
4031 if (!rn2(achieve.get_amulet ? 800 : 3200)) otmp->oerodeproof = 1;
4032 if (!rn2(3200)) {
4033 if (!rn2(3)) otmp->oeroded = rnd(3);
4034 if (!rn2(3)) otmp->oeroded2 = rnd(3);
4036 if (!rn2(achieve.get_amulet ? 400 : 1600)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
4038 if (artif && (artif != 2) && artigenechance(160)) {
4039 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
4040 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
4042 else if (artif && !rn2(500)) {
4043 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
4044 otmp->fakeartifact = 1;
4045 if (artif != 2) u.fakeartifacts++;
4048 break;
4049 case RING_CLASS:
4050 if(objects[otmp->otyp].oc_charged) {
4051 blessorcurse_on_creation(otmp, 3);
4052 if(rn2(10)) {
4053 if(rn2(10) && bcsign(otmp))
4054 otmp->spe = bcsign(otmp) * rne(Race_if(PM_LISTENER) ? 3 : 2);
4055 else otmp->spe = rn2(2) ? rne(Race_if(PM_LISTENER) ? 3 : 2) : -rne(Race_if(PM_LISTENER) ? 3 : 2);
4057 /* make useless +0 rings much less common */
4058 if (otmp->spe == 0) {
4059 /* otmp->spe = rn2(4) - rn2(3); */
4060 /* wow! +8! */
4061 if (rn2(3)) otmp->spe = rne(2)+1;
4062 else otmp->spe = -(rne(2)+1);
4065 if ((otmp->spe > 0) && !rn2(6) && In_lategame(&u.uz)) {
4066 otmp->spe += rnd(otmp->spe);
4068 if ((otmp->spe < 0) && !rn2(6) && In_lategame(&u.uz)) {
4069 otmp->spe -= rnd(abs(otmp->spe));
4072 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT)) && (abs(otmp->spe) > 3 || (abs(otmp->spe) == 3 && rn2(2) ) || (abs(otmp->spe) == 2 && !rn2(3) )|| (abs(otmp->spe) == 1 && !rn2(5) ) ) ) pline("Precognition: made object with enchantment %d", abs(otmp->spe));
4074 /* negative rings are usually cursed */
4075 if (otmp->spe < 0 && rn2(5)) curse_on_creation(otmp);
4076 } else if(rn2(10) && (otmp->otyp == RIN_TELEPORTATION ||
4077 otmp->otyp == RIN_POLYMORPH ||
4078 otmp->otyp == RIN_AGGRAVATE_MONSTER ||
4079 otmp->otyp == RIN_SLEEPING ||
4080 otmp->otyp == RIN_INDIGESTION ||
4081 otmp->otyp == RIN_DISARMING ||
4082 otmp->otyp == RIN_NUMBNESS ||
4083 otmp->otyp == RIN_REVERSE_REGENERATION ||
4084 otmp->otyp == RIN_CURSE ||
4085 otmp->otyp == RIN_DIMNESS ||
4086 otmp->otyp == RIN_WINCING ||
4087 otmp->otyp == RIN_HALLUCINATION ||
4088 otmp->otyp == RIN_HUNGER || !rn2(18))) {
4089 curse_on_creation(otmp);
4090 } else if (!rn2(9)) { /* wtf why couldn't non-charged rings generate blessed??? --Amy */
4091 blessorcurse_on_creation(otmp, 1);
4094 if (!rn2(achieve.get_amulet ? 250 : 1000)) otmp->oerodeproof = 1;
4095 if (!rn2(1000)) {
4096 if (!rn2(3)) otmp->oeroded = rnd(3);
4097 if (!rn2(3)) otmp->oeroded2 = rnd(3);
4099 if (!rn2(achieve.get_amulet ? 125 : 500)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
4101 if (artif && (artif != 2) && artigenechance(50)) {
4102 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
4103 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
4105 else if (artif && !rn2(125)) {
4106 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
4107 otmp->fakeartifact = 1;
4108 if (artif != 2) u.fakeartifacts++;
4111 if (uarmh && uarmh->oartifact == ART_RULE_CONFORMING_SCHWANZLUT && otmp->spe > 0) otmp->spe = 0;
4113 break;
4114 case ROCK_CLASS:
4115 switch (otmp->otyp) {
4116 case STATUE:
4117 /* possibly overridden by mkcorpstat() */
4118 otmp->corpsenm = rndmonnum();
4119 if ( (!verysmall(&mons[otmp->corpsenm]) || !rn2(10) ) && timebasedlowerchance() && (artif != 2) && !rn2(10))
4120 (void) add_to_container(otmp, mkobj(SPBOOK_CLASS, FALSE, FALSE), TRUE);
4122 blessorcurse_on_creation(otmp, 7);
4124 if (!rn2(achieve.get_amulet ? 1000 : 4000)) otmp->oerodeproof = 1;
4125 if (!rn2(4000)) {
4126 if (!rn2(3)) otmp->oeroded = rnd(3);
4127 if (!rn2(3)) otmp->oeroded2 = rnd(3);
4129 if (!rn2(achieve.get_amulet ? 500 : 2000)) otmp->greased = rn2(5) ? 1 : rn2(3) ? 2 : 3;
4131 if (artif && (artif != 2) && artigenechance(200)) {
4132 otmp = mk_artifact(otmp, (aligntyp)A_NONE, TRUE);
4133 if ((Race_if(PM_LISTENER) || (uimplant && uimplant->oartifact == ART_FOREBODING) || RngeListening) && !Hallucination && (rnd(30) < ACURR(A_INT))) pline("Precognition: made artifact");
4135 else if (artif && !rn2(500)) {
4136 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
4137 otmp->fakeartifact = 1;
4138 if (artif != 2) u.fakeartifacts++;
4141 break;
4142 case COIN_CLASS:
4143 break; /* do nothing */
4144 default:
4145 impossible("impossible mkobj %ld, sym '%c'. Debug info for Amy: %d, %d, %d, %d, let %c", otmp->otyp, objects[otmp->otyp].oc_class, otyp, (int) init, artif, (int) shopinit, let);
4147 return (struct obj *)0;
4150 if (iserosator && otmp && otmp->oclass != COIN_CLASS) {
4151 if (!rn2(3)) otmp->oeroded = rnd(3);
4152 else if (!rn2(2)) otmp->oeroded2 = rnd(3);
4153 else {
4154 otmp->oeroded = rnd(3);
4155 otmp->oeroded2 = rnd(3);
4157 if (!rn2(100)) otmp->oeroded = rn2(4);
4158 if (!rn2(100)) otmp->oeroded2 = rn2(4);
4161 /* nice patch idea by Amy - sometimes have items start out with partial identification */
4163 if (otmp && otmp->oclass != COIN_CLASS && !rn2(1000 - (u.ulevel * (ishaxor ? 20 : 10) ) )) otmp->rknown = TRUE;
4164 if (otmp && otmp->oclass != COIN_CLASS && !rn2(1000 - (u.ulevel * (ishaxor ? 20 : 10) ) )) otmp->known = TRUE;
4165 if (otmp && otmp->oclass != COIN_CLASS && !rn2(1000 - (u.ulevel * (ishaxor ? 20 : 10) ) )) otmp->dknown = TRUE;
4166 if (otmp && otmp->oclass != COIN_CLASS && !rn2(1000 - (u.ulevel * (ishaxor ? 20 : 10) ) )) otmp->bknown = TRUE;
4167 if (otmp && otmp->oclass != COIN_CLASS && trophylevel()) otmp->rknown = TRUE;
4168 if (otmp && otmp->oclass != COIN_CLASS && trophylevel()) otmp->known = TRUE;
4169 if (otmp && otmp->oclass != COIN_CLASS && trophylevel()) otmp->dknown = TRUE;
4170 if (otmp && otmp->oclass != COIN_CLASS && trophylevel()) otmp->bknown = TRUE;
4171 if (otmp && otmp->oclass != COIN_CLASS && (bucreclevel() > rn2(400)) ) otmp->bknown = TRUE;
4172 if (otmp && otmp->oclass != COIN_CLASS && weapon_type(otmp) == P_NONE && (enchantreclevel() > rn2(400)) ) otmp->known = TRUE;
4173 if (otmp && otmp->oclass != COIN_CLASS && weapon_type(otmp) != P_NONE && (weapchantreclevel() > rn2(400)) ) otmp->known = TRUE;
4175 if (otmp && otmp->oclass != COIN_CLASS && (otmp->otyp == TIN || otmp->otyp == EGG) && !rn2(100 - (u.ulevel * (ishaxor ? 2 : 1) ) )) otmp->known = TRUE;
4177 /* For a curser, every item has an 80% chance of being cursed if it would have been noncursed. --Amy */
4178 if (iscurser && otmp && otmp->oclass != COIN_CLASS && rn2(5)) curse_on_creation(otmp);
4179 if (u.genericcursechance && otmp && otmp->oclass != COIN_CLASS && (u.genericcursechance >= rnd(100)) ) curse_on_creation(otmp);
4181 if (otyp == u.alwayscurseditem) curse_on_creation(otmp);
4182 if (otyp == u.alwayscurseditem2) curse_on_creation(otmp);
4183 if (otyp == u.alwayscurseditem3) curse_on_creation(otmp);
4184 if (otyp == u.alwayscurseditem4) curse_on_creation(otmp);
4185 if (otyp == u.alwayscurseditem5) curse_on_creation(otmp);
4186 if (otyp == u.alwayscurseditem6) curse_on_creation(otmp);
4187 if (otyp == u.alwayscurseditem7) curse_on_creation(otmp);
4188 if (otyp == u.alwayscurseditem8) curse_on_creation(otmp);
4189 if (otyp == u.alwayscurseditem9) curse_on_creation(otmp);
4190 if (otyp == u.alwayscurseditem10) curse_on_creation(otmp);
4192 /* Some things must get done (timers) even if init = 0 */
4193 switch (otmp->otyp) {
4194 case CORPSE:
4195 start_corpse_timeout(otmp);
4196 break;
4199 /* unique objects may have an associated artifact entry */
4200 if (objects[otyp].oc_unique && !otmp->oartifact)
4201 otmp = mk_artifact(otmp, (aligntyp)A_NONE, FALSE);
4202 otmp->owt = weight(otmp);
4203 return(otmp);
4207 * Start a corpse decay or revive timer.
4208 * This takes the age of the corpse into consideration as of 3.4.0.
4210 void
4211 start_corpse_timeout(body)
4212 struct obj *body;
4214 struct monst *mtmp;
4215 long when; /* rot away when this old */
4216 long corpse_age; /* age of corpse */
4217 int rot_adjust;
4218 short action;
4220 #define TAINT_AGE (50L) /* age when corpses go bad */
4221 #define TROLL_REVIVE_CHANCE 37 /* 1/37 chance for 50 turns ~ 75% chance */
4222 #define TROLL_REVIVE_LATE_CHANCE 300 /* 1/300 chance for 200 turns ~ 49% chance */
4223 #define SIN_REVIVE_CHANCE 24 /* 1/24 chance for 30 turns ~ 72% chance */
4224 #define SIN_REVIVE_LATE_CHANCE 400 /* 1/400 chance for 200 turns ~ 40% chance */
4225 #define MOLD_REVIVE_CHANCE 23 /* 1/23 chance for 50 turns ~ 90% chance */
4226 #define MOLDY_CHANCE 900 /* 1/290 chance for 200 turns ~ 50% chance, but edited by Amy to be much more rare, actual chance about 20% now */
4227 #define ROT_AGE (250L) /* age when corpses rot away */
4229 /* lizards and lichen don't rot or revive */
4230 if ( nocorpsedecay(&mons[body->corpsenm]) ) return;
4232 action = ROT_CORPSE; /* default action: rot away */
4233 rot_adjust = in_mklev ? 25 : 10; /* give some variation */
4234 corpse_age = monstermoves - body->age;
4235 if (corpse_age > ROT_AGE)
4236 when = rot_adjust;
4237 else
4238 when = ROT_AGE - corpse_age;
4239 when += (long)(rnz(rot_adjust) - rot_adjust);
4241 if (is_rider(&mons[body->corpsenm])) {
4243 * Riders always revive. They have a 1/3 chance per turn
4244 * of reviving after 12 turns. Always revive by 500.
4246 action = REVIVE_MON;
4247 for (when = 12L; when < 500L; when++)
4248 if (!rn2(3)) break;
4250 } else if (is_deadlysin(&mons[body->corpsenm]) ) {
4251 long age;
4252 for (age = TAINT_AGE + 1; age <= ROT_AGE; age++)
4253 if (!rn2(SIN_REVIVE_LATE_CHANCE) ) { /* sin revives */
4254 action = REVIVE_MON;
4255 when = age;
4256 break;
4258 /* sins shouldn't resurrect instantly after being killed! --Amy */
4259 for (age = 2; age <= TAINT_AGE; age++)
4260 if (!rn2(SIN_REVIVE_CHANCE) && age >= 20) { /* sin revives */
4261 action = REVIVE_MON;
4262 when = age;
4263 break;
4266 if (u.uprops[STARVATION_EFFECT].extrinsic || StarvationEffect || (uarmc && uarmc->oartifact == ART_FEMMY_FATALE) || have_starvationstone() || (ublindf && ublindf->oartifact == ART_TOTAL_PERSPECTIVE_VORTEX) ) {
4267 if (rn2(10)) {
4268 action = REVIVE_MON;
4269 when = 1;
4270 } else {
4271 action = ROT_CORPSE;
4272 when = 1;
4276 } else if ((mons[body->corpsenm].mlet == S_TROLL && !body->norevive) ) {
4277 long age;
4278 for (age = TAINT_AGE + 1; age <= ROT_AGE; age++)
4279 if (!rn2(TROLL_REVIVE_LATE_CHANCE) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE) ) { /* troll revives */
4280 action = REVIVE_MON;
4281 when = age;
4282 break;
4284 for (age = 2; age <= TAINT_AGE; age++)
4285 if (!rn2(TROLL_REVIVE_CHANCE) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE) ) { /* troll revives */
4286 action = REVIVE_MON;
4287 when = age;
4288 break;
4291 if (u.uprops[STARVATION_EFFECT].extrinsic || StarvationEffect || (uarmc && uarmc->oartifact == ART_FEMMY_FATALE) || have_starvationstone() || (ublindf && ublindf->oartifact == ART_TOTAL_PERSPECTIVE_VORTEX) ) {
4292 if (rn2(10) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE)) {
4293 action = REVIVE_MON;
4294 when = 1;
4295 } else {
4296 action = ROT_CORPSE;
4297 when = 1;
4301 } else if (mons[body->corpsenm].mlet == S_FUNGUS || is_reviver(&mons[body->corpsenm]) ||
4302 ((((mtmp = get_mtraits(body, FALSE)) != (struct monst *)0) ) && mtmp->egotype_troll)
4304 /* Fungi come back with a vengeance - if you don't eat it or
4305 * destroy it, any live cells will quickly use the dead ones
4306 * as food and come back.
4308 long age;
4310 for (age = 2; age <= TAINT_AGE; age++)
4311 if ((mons[body->corpsenm].mlet == S_FUNGUS) && !rn2(MOLD_REVIVE_CHANCE) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE)) { /* mold revives */
4312 action = REVIVE_MON;
4313 when = age;
4314 break;
4315 } else if (is_reviver(&mons[body->corpsenm]) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE) && !rn2(MOLD_REVIVE_CHANCE)) {
4316 action = REVIVE_MON;
4317 when = age;
4318 break;
4319 } else if (((((mtmp = get_mtraits(body, FALSE)) != (struct monst *)0) ) && mtmp->egotype_troll && !(uwep && uwep->oartifact == ART_ZOMBIEBANE)) && !rn2(MOLD_REVIVE_CHANCE)) {
4320 action = REVIVE_MON;
4321 when = age;
4322 break;
4325 if (u.uprops[STARVATION_EFFECT].extrinsic || StarvationEffect || (uarmc && uarmc->oartifact == ART_FEMMY_FATALE) || have_starvationstone() || (ublindf && ublindf->oartifact == ART_TOTAL_PERSPECTIVE_VORTEX) ) {
4326 if (rn2(10) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE)) {
4327 action = REVIVE_MON;
4328 when = 1;
4329 } else {
4330 action = ROT_CORPSE;
4331 when = 1;
4337 if (action == ROT_CORPSE && !acidic(&mons[body->corpsenm])) {
4338 /* Corpses get moldy
4340 long age;
4341 for (age = TAINT_AGE + 1; age <= ROT_AGE; age++)
4342 if (!rn2(MOLDY_CHANCE)) { /* "revives" as a random s_fungus */
4343 action = ((!rn2(100) && !(uwep && uwep->oartifact == ART_ZOMBIEBANE)) ? REVIVE_MON : MOLDY_CORPSE); /* or rarely the monster revives itself --Amy */
4344 when = age;
4345 break;
4349 if (body->norevive) body->norevive = 0;
4350 (void) start_timer(when, TIMER_OBJECT, action, (void *)body);
4353 void
4354 bless(otmp)
4355 register struct obj *otmp;
4357 #ifdef GOLDOBJ
4358 if (otmp->oclass == COIN_CLASS) return;
4359 #endif
4360 if ((otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(100) ) {
4361 otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4363 else if (otmp->prmcurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(10) ) {
4364 otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4366 else if (!(otmp->prmcurse) && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && otmp->hvycurse && !rn2(3) ) {
4367 otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4369 else if (!(otmp->prmcurse) && !(otmp->hvycurse) && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) ) otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4371 if (otmp->cursed == 0) {
4372 otmp->blessed = 1;
4373 if (carried(otmp) && confers_luck(otmp))
4374 set_moreluck();
4375 if (otmp->otyp == HEALTHSTONE)
4376 recalc_health();
4377 if (otmp->otyp == BAG_OF_HOLDING || otmp->otyp == ICE_BOX_OF_HOLDING || otmp->otyp == CHEST_OF_HOLDING || otmp->oartifact == ART_SACK_OF_HOLDING)
4378 otmp->owt = weight(otmp);
4379 if (otmp->otyp == FIGURINE && otmp->timed)
4380 (void) stop_timer(FIG_TRANSFORM, (void *) otmp);
4382 return;
4385 void
4386 unbless(otmp)
4387 register struct obj *otmp;
4389 otmp->blessed = 0;
4390 if (carried(otmp) && confers_luck(otmp))
4391 set_moreluck();
4392 if (otmp->otyp == HEALTHSTONE)
4393 recalc_health();
4394 if (otmp->otyp == BAG_OF_HOLDING || otmp->otyp == ICE_BOX_OF_HOLDING || otmp->otyp == CHEST_OF_HOLDING || otmp->oartifact == ART_SACK_OF_HOLDING)
4395 otmp->owt = weight(otmp);
4396 if (otmp->otyp == FIGURINE && otmp->timed)
4397 (void) stop_timer(FIG_TRANSFORM, (void *) otmp);
4398 return;
4401 void
4402 curse(otmp)
4403 register struct obj *otmp;
4405 #ifdef GOLDOBJ
4406 if (otmp->oclass == COIN_CLASS) return;
4407 #endif
4408 otmp->blessed = 0;
4410 if (!rn2(isfriday ? 50 : 100)) otmp->stckcurse = 1;
4412 if (u.stickycursechance && (u.stickycursechance >= rnd(100)) ) otmp->stckcurse = 1;
4413 if (youmonst.data && Role_if(PM_CELLAR_CHILD) && !rn2(10)) otmp->stckcurse = 1;
4415 if (otmp->cursed) {
4416 if (!otmp->hvycurse && !rn2(5)) otmp->hvycurse = 1;
4417 else if (otmp->hvycurse && !otmp->prmcurse && !rn2(25)) otmp->prmcurse = 1;
4418 else if (otmp->prmcurse && !rn2(250)) {
4419 if (!rn2(3)) otmp->morgcurse = 1;
4420 else if (!rn2(2)) otmp->evilcurse = 1;
4421 else otmp->bbrcurse = 1;
4423 } else {
4424 otmp->cursed = 1;
4425 if (!otmp->hvycurse && !otmp->prmcurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(isfriday ? 20 : 35)) otmp->hvycurse = 1;
4426 if (otmp->hvycurse && !otmp->prmcurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(isfriday ? 100 : 225)) otmp->prmcurse = 1;
4427 if (otmp->prmcurse && !rn2(isfriday ? 1000 : 6255)) {
4428 if (!rn2(3)) otmp->morgcurse = 1;
4429 else if (!rn2(2)) otmp->evilcurse = 1;
4430 else otmp->bbrcurse = 1;
4434 /* welded two-handed weapon interferes with some armor removal */
4435 if (otmp == uwep && bimanual(uwep)) reset_remarm();
4436 /* rules at top of wield.c state that twoweapon cannot be done
4437 with cursed alternate weapon */
4438 if (otmp == uswapwep && u.twoweap && (PlayerCannotUseSkills || (P_SKILL(P_TWO_WEAPON_COMBAT) < P_EXPERT) ) )
4439 drop_uswapwep();
4440 /* some cursed items need immediate updating */
4441 if (carried(otmp) && confers_luck(otmp))
4442 set_moreluck();
4443 if (otmp->otyp == HEALTHSTONE)
4444 recalc_health();
4445 if (otmp->otyp == BAG_OF_HOLDING || otmp->otyp == ICE_BOX_OF_HOLDING || otmp->otyp == CHEST_OF_HOLDING || otmp->oartifact == ART_SACK_OF_HOLDING)
4446 otmp->owt = weight(otmp);
4447 if (otmp->otyp == FIGURINE) {
4448 if (otmp->corpsenm != NON_PM
4449 && !dead_species(otmp->corpsenm,TRUE)
4450 && (carried(otmp) || mcarried(otmp)))
4451 attach_fig_transform_timeout(otmp);
4453 return;
4456 /* Special function for objects that get cursed on creation --Amy */
4457 void
4458 curse_on_creation(otmp)
4459 register struct obj *otmp;
4461 #ifdef GOLDOBJ
4462 if (otmp->oclass == COIN_CLASS) return;
4463 #endif
4464 otmp->blessed = 0;
4466 if (!rn2(isfriday ? 50 : 100)) otmp->stckcurse = 1;
4468 if (u.stickycursechance && (u.stickycursechance >= rnd(100)) ) otmp->stckcurse = 1;
4469 if (youmonst.data && Role_if(PM_CELLAR_CHILD) && !rn2(10)) otmp->stckcurse = 1;
4471 if (otmp->cursed) { /* should not happen, but oh well */
4472 if (!otmp->hvycurse && !rn2(5)) otmp->hvycurse = 1;
4473 else if (otmp->hvycurse && !otmp->prmcurse && !rn2(25)) otmp->prmcurse = 1;
4474 else if (otmp->prmcurse && !rn2(250)) {
4475 if (!rn2(3)) otmp->morgcurse = 1;
4476 else if (!rn2(2)) otmp->evilcurse = 1;
4477 else otmp->bbrcurse = 1;
4479 } else {
4480 otmp->cursed = 1;
4482 if (u.heavycursechance && (u.heavycursechance >= rnd(100)) ) otmp->hvycurse = 1;
4484 if (!u.dungeongrowthhack) {
4486 if (!rn2(10) && uarmc && itemhasappearance(uarmc, APP_CURSED_CALLED_CLOAK)) otmp->hvycurse = 1;
4490 if (!otmp->hvycurse && !otmp->prmcurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(Role_if(PM_CAMPERSTRIKER) ? 5 : isfriday ? 15 : 25)) otmp->hvycurse = 1;
4492 if (otmp->hvycurse && u.primecursechance && (u.primecursechance >= rnd(100)) ) otmp->prmcurse = 1;
4494 if (otmp->hvycurse && !otmp->prmcurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(isfriday ? 50 : 125)) otmp->prmcurse = 1;
4495 if (otmp->prmcurse && !rn2(isfriday ? 500 : 1255)) {
4496 if (!rn2(3)) otmp->morgcurse = 1;
4497 else if (!rn2(2)) otmp->evilcurse = 1;
4498 else otmp->bbrcurse = 1;
4502 /* welded two-handed weapon interferes with some armor removal */
4503 if (otmp == uwep && bimanual(uwep)) reset_remarm();
4504 /* rules at top of wield.c state that twoweapon cannot be done
4505 with cursed alternate weapon */
4506 if (otmp == uswapwep && u.twoweap && (PlayerCannotUseSkills || (P_SKILL(P_TWO_WEAPON_COMBAT) < P_EXPERT) ) )
4507 drop_uswapwep();
4508 /* some cursed items need immediate updating */
4509 if (carried(otmp) && confers_luck(otmp))
4510 set_moreluck();
4511 if (otmp->otyp == HEALTHSTONE)
4512 recalc_health();
4513 if (otmp->otyp == BAG_OF_HOLDING || otmp->otyp == ICE_BOX_OF_HOLDING || otmp->otyp == CHEST_OF_HOLDING || otmp->oartifact == ART_SACK_OF_HOLDING)
4514 otmp->owt = weight(otmp);
4515 if (otmp->otyp == FIGURINE) {
4516 if (otmp->corpsenm != NON_PM
4517 && !dead_species(otmp->corpsenm,TRUE)
4518 && (carried(otmp) || mcarried(otmp)))
4519 attach_fig_transform_timeout(otmp);
4521 return;
4524 void
4525 uncurse(otmp, guaranteed)
4526 register struct obj *otmp;
4527 boolean guaranteed; /* can it work even when you have permacurse nastytrap effect? (can still fail if heavily cursed --Amy */
4529 if (!guaranteed && (PermacurseEffect || u.uprops[PERMACURSE_EFFECT].extrinsic || have_permacursestone() || (uarmu && uarmu->oartifact == ART_MENSTRUATION_HURTS && !Role_if(PM_CLIMACTERIAL)) || (uimplant && uimplant->oartifact == ART_ARABELLA_S_RECTIFIER) || (uarmf && uarmf->oartifact == ART_PROPERTY_GRUMBLE) ) ) return;
4531 if (!guaranteed && uarm && uarm->oartifact == ART_ARABELLA_S_FEMINIZER && rn2(2)) return;
4533 if (otmp && otmp->oartifact == ART_HAVE_IT_ALL_BUT_NOT_GET) return; /* so immune that even "guaranteed" remove curse effects do not uncurse it --Amy */
4535 if ((otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(100) ) {
4536 otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4538 else if (otmp->prmcurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && !rn2(10) ) {
4539 otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4541 else if (!(otmp->prmcurse) && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) && otmp->hvycurse && !rn2(3) ) {
4542 otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4544 else if (!(otmp->prmcurse) && !otmp->hvycurse && !(otmp->morgcurse || otmp->evilcurse || otmp->bbrcurse) ) otmp->morgcurse = otmp->evilcurse = otmp->bbrcurse = otmp->prmcurse = otmp->hvycurse = otmp->cursed = otmp->stckcurse = 0;
4545 if (carried(otmp) && confers_luck(otmp))
4546 set_moreluck();
4547 /* KMH, balance patch -- healthstones affect healing */
4548 if (otmp->otyp == HEALTHSTONE)
4549 recalc_health();
4550 if (otmp->otyp == BAG_OF_HOLDING || otmp->otyp == ICE_BOX_OF_HOLDING || otmp->otyp == CHEST_OF_HOLDING || otmp->oartifact == ART_SACK_OF_HOLDING)
4551 otmp->owt = weight(otmp);
4554 #endif /* OVLB */
4555 #ifdef OVL1
4557 void
4558 blessorcurse(otmp, chance)
4559 register struct obj *otmp;
4560 register int chance;
4562 if(otmp->blessed || otmp->cursed) return;
4564 if(!rn2(chance)) {
4565 if(!rn2(isfriday ? 2 : 3)) {
4566 curse(otmp);
4567 } else {
4568 bless(otmp);
4570 } else if (Role_if(PM_CAMPERSTRIKER) && !rn2(chance)) curse(otmp);
4572 return;
4575 void
4576 blessorcurse_on_creation(otmp, chance)
4577 register struct obj *otmp;
4578 register int chance;
4580 if(otmp->blessed || otmp->cursed) return;
4582 if(!rn2(chance)) {
4583 if(!rn2(isfriday ? 2 : 3)) {
4584 curse_on_creation(otmp);
4585 } else if (!u.dungeongrowthhack) {
4586 if (!rn2(5) && uarmc && itemhasappearance(uarmc, APP_CURSED_CALLED_CLOAK)) {
4587 curse_on_creation(otmp);
4588 } else if (uarmc && uarmc->oartifact == ART_FINDEET && !rn2(10)) {
4589 curse_on_creation(otmp);
4590 } else {
4591 bless(otmp);
4593 } else {
4594 bless(otmp);
4596 } else if (Role_if(PM_CAMPERSTRIKER) && !rn2(chance)) curse_on_creation(otmp);
4598 return;
4601 #endif /* OVL1 */
4602 #ifdef OVLB
4605 bcsign(otmp)
4606 register struct obj *otmp;
4608 return(!!otmp->blessed - !!otmp->cursed);
4611 #endif /* OVLB */
4612 #ifdef OVL0
4615 * Calculate the weight of the given object. This will recursively follow
4616 * and calculate the weight of any containers.
4618 * Note: It is possible to end up with an incorrect weight if some part
4619 * of the code messes with a contained object and doesn't update the
4620 * container's weight.
4623 weight(obj)
4624 register struct obj *obj;
4626 int wt = objects[obj->otyp].oc_weight;
4628 if (obj->otyp == LARGE_BOX && obj->spe == 1) /* Schroedinger's Cat */
4629 wt += mons[PM_HOUSECAT].cwt;
4630 if (Is_container(obj) || obj->otyp == STATUE) {
4631 struct obj *contents;
4632 register int cwt = 0;
4634 if (obj->otyp == STATUE && obj->corpsenm >= LOW_PM)
4635 wt = (int)obj->quan *
4636 ((int)mons[obj->corpsenm].cwt * 3 / 2);
4638 for(contents=obj->cobj; contents; contents=contents->nobj)
4639 cwt += weight(contents);
4640 /* KMH -- support artifact BoH (including the Wallet of Perseus)
4642 * The weight of bags of holding is calculated as the weight
4643 * of the bag plus the weight of the bag's contents modified
4644 * as follows:
4646 * Bag status Ordinary Artifact
4647 * ---------- -------- --------
4648 * cursed 2x 4x
4649 * blessed (x + 3)/4 (x + 5)/6
4650 * otherwise (x + 1)/2 (x + 2)/3
4652 * The macro DELTA_CWT in pickup.c also implements these
4653 * weight equations.
4655 * Note: The above checks are performed in the given order.
4656 * this means that if an object is both blessed and
4657 * cursed (not supposed to happen), it will be treated
4658 * as cursed.
4660 #define CEILDIV(x,y) (((x)+(y)-1)/(y)) /* ceil(x/y) */
4661 if (obj->otyp == BAG_OF_HOLDING || obj->otyp == ICE_BOX_OF_HOLDING || obj->otyp == CHEST_OF_HOLDING || obj->oartifact == ART_SACK_OF_HOLDING) {
4662 int cursemult = 2;
4663 if (obj->oartifact && obj->oartifact != ART_SACK_OF_HOLDING) cursemult = 4;
4664 int noncursemult = 2;
4665 if (obj->oartifact && obj->oartifact != ART_SACK_OF_HOLDING) noncursemult = 3;
4667 cwt = obj->cursed ? (cwt * cursemult) :
4668 CEILDIV(cwt, noncursemult * (obj->blessed ? 2 : 1));
4670 if (obj->otyp == HANDYBAG) cwt = (flags.female ? (cwt * 4 / 5) : cwt );
4671 #undef CEILDIV
4672 return wt + cwt;
4674 if (obj->otyp == CORPSE && obj->corpsenm >= LOW_PM) {
4675 long long_wt = (int)obj->quan * mons[obj->corpsenm].cwt;
4677 wt = (long_wt > LARGEST_INT) ? LARGEST_INT : (int)long_wt;
4678 if (obj->oeaten) wt = eaten_stat(wt, obj);
4679 return wt;
4680 } else if (obj->oclass == FOOD_CLASS && obj->oeaten) {
4681 return eaten_stat((int)obj->quan * wt, obj);
4682 } else if (obj->oclass == COIN_CLASS)
4683 return (int)((obj->quan + 50L) / /*100*/10000L); /* gold weight fix --Amy */
4684 else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0)
4685 return((int)(obj->owt)); /* kludge for "very" heavy iron ball */
4686 return(wt ? wt*(int)obj->quan : ((int)obj->quan + 1)>>5);
4689 static int treefruits[] = {APPLE,ORANGE,PEAR,BANANA,EUCALYPTUS_LEAF,LEMON,CHERRY};
4690 static int treefruitsX[] = {APPLE,ORANGE,PEAR,BANANA,EUCALYPTUS_LEAF,CHERRY,ASIAN_PEAR,BLACK_HENBANE,MOTHERWORT,LICHOR,AMBROSIA,WATER_HYACINTH,SPIDDAL_STICK,HARRADA,MEADOWFOAM,LEMON,MELON,SLIME_MOLD,LUMP_OF_ROYAL_JELLY,HONEYCOMB,WATERMELON,WHITE_PEACH,MAGIC_BANANA};
4691 /* rare fruits added by Amy, of course they don't grow in Soviet Russia, it's too cold there because the type of ice block
4692 * brings winter - he's like "Väterchen Frost" :-P */
4694 struct obj *
4695 rnd_treefruit_at(x,y)
4696 int x, y;
4698 if (rn2(200) || issoviet) return mksobj_at(treefruits[rn2(SIZE(treefruits))], x, y, TRUE, FALSE, FALSE);
4699 else return mksobj_at(treefruitsX[rn2(SIZE(treefruitsX))], x, y, TRUE, FALSE, FALSE);
4701 #endif /* OVL0 */
4702 #ifdef OVLB
4704 struct obj *
4705 mkgold(amount, x, y)
4706 long amount;
4707 int x, y;
4709 register struct obj *gold = g_at(x,y);
4711 if (amount <= 0L) {
4712 amount = (long)(1 + rnd(level_difficulty()+2) * rnd(10));
4713 if (!rn2(2)) amount += (long)(1 + rnd(level_difficulty()+2) * rnd(10));
4715 if (Race_if(PM_VENTURE_CAPITALIST)) { /* they get extra money, idea by deepy */
4717 if (rn2(2)) amount *= 2;
4718 if (!rn2(5)) amount *= 3;
4719 if (!rn2(20)) amount *= 5;
4720 if (!rn2(200)) amount *= 10;
4721 if (!rn2(1000)) amount *= 20;
4722 if (!rn2(5000)) amount *= 50;
4723 if (!rn2(25000)) amount *= 100;
4726 if (uarmh && uarmh->oartifact == ART_GOLD_STANDARD) amount *= 2;
4727 if (uarmg && uarmg->oartifact == ART_ROBBERY_GONE_RIGHT) amount *= 3;
4728 if (uarmf && uarmf->oartifact == ART_SPARKLING_GOLD) amount *= 2;
4730 if (RngeWealth) amount *= (1 + rnd(2)); /* 2.5 times as much gold on average --Amy */
4731 if (uarmf && uarmf->oartifact == ART_PRACTICLASSY) amount *= 2;
4734 if (gold) {
4735 gold->quan += amount;
4736 } else {
4737 gold = mksobj_at(GOLD_PIECE, x, y, TRUE, FALSE, FALSE);
4738 gold->quan = amount;
4740 gold->owt = weight(gold);
4741 return (gold);
4744 #endif /* OVLB */
4745 #ifdef OVL1
4747 /* return TRUE if the corpse has special timing */
4748 /* special timing is a timing that is not rotting or molding */
4750 #define special_corpse(num) (((num) == PM_KATNISS) \
4751 || (nocorpsedecay(&mons[num])) \
4752 || (is_rider(&mons[num])) \
4753 || (is_deadlysin(&mons[num])) \
4754 || (is_reviver(&mons[num])) \
4755 || (mons[num].mlet == S_FUNGUS) \
4756 || (mons[num].mlet == S_TROLL))
4759 * OEXTRA note: Passing mtmp causes mtraits to be saved
4760 * even if ptr passed as well, but ptr is always used for
4761 * the corpse type (corpsenm). That allows the corpse type
4762 * to be different from the original monster,
4763 * i.e. vampire -> human corpse
4764 * yet still allow restoration of the original monster upon
4765 * resurrection.
4767 struct obj *
4768 mkcorpstat(objtype, mtmp, ptr, x, y, init)
4769 int objtype; /* CORPSE or STATUE */
4770 struct monst *mtmp;
4771 struct permonst *ptr;
4772 int x, y;
4773 boolean init;
4775 register struct obj *otmp;
4777 /* hack by Amy: can't easily dispose of riders or sins by genociding corpses! */
4778 if (mtmp && (is_rider(mtmp->data) || is_deadlysin(mtmp->data)) && objtype == CORPSE) u.riderhack = TRUE;
4780 if (objtype != CORPSE && objtype != STATUE)
4781 impossible("making corpstat type %d", objtype);
4782 if (x == 0 && y == 0) { /* special case - random placement */
4783 otmp = mksobj(objtype, init, FALSE, FALSE);
4784 if (otmp) rloco(otmp);
4785 } else
4786 otmp = mksobj_at(objtype, x, y, init, FALSE, FALSE);
4788 u.riderhack = FALSE;
4790 if (otmp) {
4791 if (mtmp) {
4792 struct obj *otmp2;
4794 if (!ptr) ptr = mtmp->data;
4795 /* save_mtraits frees original data pointed to by otmp */
4796 otmp2 = save_mtraits(otmp, mtmp);
4797 if (otmp2) otmp = otmp2;
4799 /* use the corpse or statue produced by mksobj() as-is
4800 unless `ptr' is non-null */
4801 if (ptr) {
4802 int old_corpsenm = otmp->corpsenm;
4804 otmp->corpsenm = monsndx(ptr);
4805 otmp->owt = weight(otmp);
4806 if (otmp->otyp == CORPSE && ( autismweaponcheck(ART_CUTRELEASE) ) ) {
4807 int cutreleasedmg = 1;
4808 if (mons[otmp->corpsenm].mlevel > 0) cutreleasedmg = mons[otmp->corpsenm].mlevel;
4809 pline("There is a discharge of energy!");
4810 losehp(cutreleasedmg, "an energy release", KILLED_BY);
4813 if (otmp->otyp == CORPSE &&
4814 (special_corpse(old_corpsenm) || (mtmp && mtmp->egotype_troll) ||
4815 special_corpse(otmp->corpsenm))) {
4816 obj_stop_timers(otmp);
4817 start_corpse_timeout(otmp);
4821 return(otmp);
4825 * Attach a monster id to an object, to provide
4826 * a lasting association between the two.
4828 struct obj *
4829 obj_attach_mid(obj, mid)
4830 struct obj *obj;
4831 unsigned mid;
4833 struct obj *otmp;
4834 int lth, namelth;
4836 if (!mid || !obj) return (struct obj *)0;
4837 lth = sizeof(mid);
4838 namelth = obj->onamelth ? strlen(ONAME(obj)) + 1 : 0;
4839 if (namelth)
4840 otmp = realloc_obj(obj, lth, (void *) &mid, namelth, ONAME(obj));
4841 else {
4842 otmp = obj;
4843 otmp->oxlth = sizeof(mid);
4844 (void) memcpy((void *)otmp->oextra, (void *)&mid,
4845 sizeof(mid));
4847 if (otmp && otmp->oxlth) otmp->oattached = OATTACHED_M_ID; /* mark it */
4848 return otmp;
4851 static struct obj *
4852 save_mtraits(obj, mtmp)
4853 struct obj *obj;
4854 struct monst *mtmp;
4856 struct obj *otmp;
4857 int lth, namelth;
4859 lth = sizeof(struct monst) + mtmp->mxlth + mtmp->mnamelth;
4860 namelth = obj->onamelth ? strlen(ONAME(obj)) + 1 : 0;
4861 otmp = realloc_obj(obj, lth, (void *) mtmp, namelth, ONAME(obj));
4862 if (otmp && otmp->oxlth) {
4863 struct monst *mtmp2 = (struct monst *)otmp->oextra;
4864 if (mtmp->data) mtmp2->mnum = monsndx(mtmp->data);
4865 /* invalidate pointers */
4866 /* m_id is needed to know if this is a revived quest leader */
4867 /* but m_id must be cleared when loading bones */
4868 mtmp2->nmon = (struct monst *)0;
4869 mtmp2->data = (struct permonst *)0;
4870 mtmp2->minvent = (struct obj *)0;
4871 otmp->oattached = OATTACHED_MONST; /* mark it */
4873 return otmp;
4876 /* returns a pointer to a new monst structure based on
4877 * the one contained within the obj.
4879 struct monst *
4880 get_mtraits(obj, copyof)
4881 struct obj *obj;
4882 boolean copyof;
4884 struct monst *mtmp = (struct monst *)0;
4885 struct monst *mnew = (struct monst *)0;
4887 if (obj->oxlth && obj->oattached == OATTACHED_MONST)
4888 mtmp = (struct monst *)obj->oextra;
4889 if (mtmp) {
4890 if (copyof) {
4891 int lth = mtmp->mxlth + mtmp->mnamelth;
4892 mnew = newmonst(lth);
4893 lth += sizeof(struct monst);
4894 (void) memcpy((void *)mnew,
4895 (void *)mtmp, lth);
4896 } else {
4897 /* Never insert this returned pointer into mon chains! */
4898 mnew = mtmp;
4901 return mnew;
4904 #endif /* OVL1 */
4905 #ifdef OVLB
4907 /* make an object named after someone listed in the scoreboard file */
4908 struct obj *
4909 mk_tt_object(objtype, x, y)
4910 int objtype; /* CORPSE or STATUE */
4911 register int x, y;
4913 register struct obj *otmp, *otmp2;
4914 boolean initialize_it;
4916 /* player statues never contain books */
4917 initialize_it = (objtype != STATUE);
4918 if ((otmp = mksobj_at(objtype, x, y, initialize_it, FALSE, FALSE)) != 0) {
4919 /* tt_oname will return null if the scoreboard is empty */
4920 if ((otmp2 = tt_oname(otmp)) != 0) otmp = otmp2;
4922 return(otmp);
4925 /* make a new corpse or statue, uninitialized if a statue (i.e. no books) */
4926 struct obj *
4927 mk_named_object(objtype, ptr, x, y, nm)
4928 int objtype; /* CORPSE or STATUE */
4929 struct permonst *ptr;
4930 int x, y;
4931 const char *nm;
4933 struct obj *otmp;
4935 otmp = mkcorpstat(objtype, (struct monst *)0, ptr,
4936 x, y, (boolean)(objtype != STATUE));
4937 if (nm)
4938 otmp = oname(otmp, nm);
4939 return(otmp);
4942 /* for e.g. helmets: do they stop rocks? metal works, wood is supposed to be hard enough, most lithic materials too
4943 * keyword "materialeffect" --Amy */
4944 boolean
4945 is_hardmaterial(otmp)
4946 register struct obj *otmp;
4948 if (otmp->otyp == SKULLCAP) return TRUE;
4950 if (objects[(otmp)->otyp].oc_material == MT_ETHER) return FALSE;
4951 if (objects[(otmp)->otyp].oc_material == MT_ALKALINE) return FALSE;
4953 if (is_metallic(otmp)) return TRUE;
4954 if (objects[(otmp)->otyp].oc_material == MT_WOOD) return TRUE;
4955 if (objects[(otmp)->otyp].oc_material == MT_BONE) return TRUE;
4956 if (objects[(otmp)->otyp].oc_material == MT_GLASS) return TRUE;
4957 if (objects[(otmp)->otyp].oc_material == MT_GEMSTONE) return TRUE;
4958 if (objects[(otmp)->otyp].oc_material == MT_MINERAL) return TRUE;
4959 if (objects[(otmp)->otyp].oc_material == MT_OBSIDIAN) return TRUE;
4960 if (objects[(otmp)->otyp].oc_material == MT_CONUNDRUM) return TRUE;
4961 if (objects[(otmp)->otyp].oc_material == MT_CERAMIC) return TRUE;
4962 if (objects[(otmp)->otyp].oc_material == MT_TAR) return TRUE;
4963 if (objects[(otmp)->otyp].oc_material == MT_BRICK) return TRUE;
4964 if (objects[(otmp)->otyp].oc_material == MT_NANOMACHINE) return TRUE;
4965 if (objects[(otmp)->otyp].oc_material == MT_PWN_BUBBLE) return TRUE;
4966 if (objects[(otmp)->otyp].oc_material == MT_MENGETIUM) return TRUE;
4967 if (objects[(otmp)->otyp].oc_material == MT_AMBER) return TRUE;
4968 if (objects[(otmp)->otyp].oc_material == MT_FIRMAMENT) return TRUE;
4969 if (objects[(otmp)->otyp].oc_material == MT_ADAMANTIUM) return TRUE;
4970 if (objects[(otmp)->otyp].oc_material == MT_ALIMATHIUM) return TRUE;
4972 return FALSE;
4976 /* Amy grepping target: "materialeffect" */
4977 boolean
4978 is_flammable(otmp)
4979 register struct obj *otmp;
4981 int otyp = otmp->otyp;
4982 int omat = objects[otyp].oc_material;
4984 if (uamul && uamul->oartifact == ART_AUTOMATICALLY_METAL) {
4985 return (!(is_metallic(otmp)));
4988 if (objects[otyp].oc_oprop == FIRE_RES || otyp == WAN_FIRE)
4989 return FALSE;
4991 if (objects[otyp].oc_material == MT_PLASTIC) return TRUE;
4992 if (objects[otyp].oc_material == MT_VIVA) return TRUE;
4993 if (objects[otyp].oc_material == MT_SILK) return TRUE;
4994 if (objects[otyp].oc_material == MT_ARCANIUM) return TRUE;
4995 if (objects[otyp].oc_material == MT_POURPOOR) return TRUE;
4996 if (objects[otyp].oc_material == MT_ALUMEN) return TRUE;
4997 if (objects[otyp].oc_material == MT_ETHER) return TRUE;
4998 if (objects[otyp].oc_material == MT_BRICK) return TRUE;
4999 if (objects[otyp].oc_material == MT_NANOMACHINE) return TRUE;
5000 if (objects[otyp].oc_material == MT_FOAM) return TRUE;
5001 if (objects[otyp].oc_material == MT_CHITIN) return TRUE;
5002 if (objects[otyp].oc_material == MT_TINSEL) return TRUE;
5003 if (objects[otyp].oc_material == MT_AMBER) return TRUE;
5004 if (objects[otyp].oc_material == MT_MERCURIAL) return TRUE;
5005 if (objects[otyp].oc_material == MT_BAMBOO) return TRUE;
5006 if (objects[otyp].oc_material == MT_FILM) return TRUE;
5007 if (objects[otyp].oc_material == MT_ALKALINE) return TRUE;
5008 if (objects[otyp].oc_material == MT_DRAGON_HIDE && evilfriday) return TRUE;
5009 if (objects[otyp].oc_material == MT_COMPOST && evilfriday) return TRUE;
5010 if (objects[otyp].oc_material == MT_INKA && evilfriday) return TRUE;
5011 if (objects[otyp].oc_material == MT_SHADOWSTUFF && evilfriday) return TRUE;
5012 if (objects[otyp].oc_material == MT_OBSIDIAN && evilfriday) return TRUE;
5013 if (objects[otyp].oc_material == MT_LEAD && evilfriday) return TRUE;
5014 if (objects[otyp].oc_material == MT_CHROME && evilfriday) return TRUE;
5015 if (objects[otyp].oc_material == MT_CERAMIC && evilfriday) return TRUE;
5016 if (objects[otyp].oc_material == MT_SHELL && evilfriday) return TRUE;
5017 if (objects[otyp].oc_material == MT_CELESTIUM && evilfriday) return TRUE;
5018 if (objects[otyp].oc_material == MT_COBALT && evilfriday) return TRUE;
5019 if (objects[otyp].oc_material == MT_MESH && evilfriday) return TRUE;
5020 if (objects[otyp].oc_material == MT_PWN_BUBBLE && evilfriday) return TRUE;
5022 if (omat <= MT_WOOD && omat != MT_LIQUID) return TRUE;
5023 return FALSE;
5027 boolean
5028 is_rottable(otmp)
5029 register struct obj *otmp;
5031 int otyp = otmp->otyp;
5032 int omat = objects[otyp].oc_material;
5034 if (itemhasappearance(otmp, APP_WHITE_BUFFALO_BOOTS)) return TRUE;
5036 if (uamul && uamul->oartifact == ART_AUTOMATICALLY_METAL) {
5037 return (!(is_metallic(otmp)));
5040 if (objects[otyp].oc_material == MT_INKA) return TRUE;
5041 if (objects[otyp].oc_material == MT_ARCANIUM) return TRUE;
5042 if (objects[otyp].oc_material == MT_SECREE) return TRUE;
5043 if (objects[otyp].oc_material == MT_COMPOST) return TRUE;
5044 if (objects[otyp].oc_material == MT_BRICK) return TRUE;
5045 if (objects[otyp].oc_material == MT_SAND) return TRUE;
5046 if (objects[otyp].oc_material == MT_NANOMACHINE) return TRUE;
5047 if (objects[otyp].oc_material == MT_BAMBOO) return TRUE;
5048 if (objects[otyp].oc_material == MT_ANTIDOTIUM) return TRUE;
5049 if (objects[otyp].oc_material == MT_CHITIN) return TRUE;
5050 if (objects[otyp].oc_material == MT_CORAL) return TRUE;
5051 if (objects[otyp].oc_material == MT_FOAM) return TRUE;
5052 if (objects[otyp].oc_material == MT_MESH) return TRUE;
5053 if (objects[otyp].oc_material == MT_SCRAP) return TRUE;
5054 if (objects[otyp].oc_material == MT_AMBER) return TRUE;
5055 if (objects[otyp].oc_material == MT_ALKALINE) return TRUE;
5056 if (objects[otyp].oc_material == MT_BONE && evilfriday) return TRUE;
5057 if (objects[otyp].oc_material == MT_DRAGON_HIDE && evilfriday) return TRUE;
5058 if (objects[otyp].oc_material == MT_SHADOWSTUFF && evilfriday) return TRUE;
5059 if (objects[otyp].oc_material == MT_CELESTIUM && evilfriday) return TRUE;
5061 if (omat <= MT_WOOD && omat != MT_LIQUID) return TRUE;
5062 return FALSE;
5065 /* keyword "materialeffect" --Amy */
5066 boolean
5067 is_rustprone(otmp)
5068 register struct obj *otmp;
5070 int otyp = otmp->otyp;
5072 if (otmp && otmp->oartifact == ART_CAN_T_BE_DAMAGED_FURTHER) return FALSE;
5074 if (SpellColorMetal) {
5075 return (!(is_metallic(otmp)));
5078 if (objects[otyp].oc_material == MT_IRON) return TRUE;
5079 if (objects[otyp].oc_material == MT_SINNUM) return TRUE;
5080 if (objects[otyp].oc_material == MT_SCRAP) return TRUE;
5081 if (objects[otyp].oc_material == MT_ALLOY) return TRUE;
5082 if (objects[otyp].oc_material == MT_INKA) return TRUE;
5083 if (objects[otyp].oc_material == MT_ARCANIUM) return TRUE;
5084 if (objects[otyp].oc_material == MT_BRONZE) return TRUE;
5085 if (objects[otyp].oc_material == MT_POURPOOR) return TRUE;
5086 if (objects[otyp].oc_material == MT_ETERNIUM) return TRUE;
5087 if (objects[otyp].oc_material == MT_COBALT) return TRUE;
5088 if (objects[otyp].oc_material == MT_ETHER) return TRUE;
5089 if (objects[otyp].oc_material == MT_BRICK) return TRUE;
5090 if (objects[otyp].oc_material == MT_TINSEL) return TRUE;
5091 if (objects[otyp].oc_material == MT_SAND && evilfriday) return TRUE;
5092 if (objects[otyp].oc_material == MT_NANOMACHINE && evilfriday) return TRUE;
5093 if (itemhasappearance(otmp, APP_RUSTPRONE_BOOTS)) return TRUE;
5095 return FALSE;
5098 boolean
5099 is_corrodeable(otmp)
5100 register struct obj *otmp;
5102 int otyp = otmp->otyp;
5104 if (uamul && uamul->oartifact == ART_AUTOMATICALLY_METAL) {
5105 return (!(is_metallic(otmp)));
5108 if (objects[otyp].oc_material == MT_COPPER) return TRUE;
5109 if (objects[otyp].oc_material == MT_BRONZE) return TRUE;
5110 if (objects[otyp].oc_material == MT_IRON) return TRUE;
5111 if (objects[otyp].oc_material == MT_SINNUM) return TRUE;
5112 if (objects[otyp].oc_material == MT_VIVA) return TRUE;
5113 if (objects[otyp].oc_material == MT_ALUMEN) return TRUE;
5114 if (objects[otyp].oc_material == MT_TAR) return TRUE;
5115 if (objects[otyp].oc_material == MT_ARCANIUM) return TRUE;
5116 if (objects[otyp].oc_material == MT_COBALT) return TRUE;
5117 if (objects[otyp].oc_material == MT_SECREE) return TRUE;
5118 if (objects[otyp].oc_material == MT_POURPOOR) return TRUE;
5119 if (objects[otyp].oc_material == MT_ETERNIUM) return TRUE;
5120 if (objects[otyp].oc_material == MT_BRICK) return TRUE;
5121 if (objects[otyp].oc_material == MT_CHROME) return TRUE;
5122 if (objects[otyp].oc_material == MT_FOAM) return TRUE;
5123 if (objects[otyp].oc_material == MT_SCRAP) return TRUE;
5124 if (objects[otyp].oc_material == MT_ALLOY) return TRUE;
5125 if (objects[otyp].oc_material == MT_GREEN_STEEL) return TRUE;
5126 if (objects[otyp].oc_material == MT_CORAL) return TRUE;
5127 if (objects[otyp].oc_material == MT_TINSEL) return TRUE;
5128 if (objects[otyp].oc_material == MT_LEAD && evilfriday) return TRUE;
5129 if (objects[otyp].oc_material == MT_METAL && evilfriday) return TRUE;
5130 if (objects[otyp].oc_material == MT_SILVER && evilfriday) return TRUE;
5131 if (objects[otyp].oc_material == MT_PLATINUM && evilfriday) return TRUE;
5132 if (objects[otyp].oc_material == MT_SAND && evilfriday) return TRUE;
5133 if (objects[otyp].oc_material == MT_OBSIDIAN && evilfriday) return TRUE;
5134 if (objects[otyp].oc_material == MT_NANOMACHINE && evilfriday) return TRUE;
5135 if (objects[otyp].oc_material == MT_CONUNDRUM && evilfriday) return TRUE;
5136 if (objects[otyp].oc_material == MT_AMBER && evilfriday) return TRUE;
5137 if (objects[otyp].oc_material == MT_CHITIN && evilfriday) return TRUE;
5138 if (objects[otyp].oc_material == MT_MESH && evilfriday) return TRUE;
5139 if (objects[otyp].oc_material == MT_TITANIUM && evilfriday) return TRUE;
5140 if (objects[otyp].oc_material == MT_LACQUER && evilfriday) return TRUE;
5142 return FALSE;
5145 #endif /* OVLB */
5146 #ifdef OVL1
5149 * These routines maintain the single-linked lists headed in level.objects[][]
5150 * and threaded through the nexthere fields in the object-instance structure.
5153 /* put the object at the given location */
5154 void
5155 place_object(otmp, x, y)
5156 register struct obj *otmp;
5157 int x, y;
5159 register struct obj *otmp2 = level.objects[x][y];
5161 if (otmp->where != OBJ_FREE)
5162 panic("place_object: obj not free");
5164 obj_no_longer_held(otmp);
5165 if (otmp->otyp == BOULDER) block_point(x,y); /* vision */
5167 /* obj goes under boulders */
5168 if (otmp2 && (otmp2->otyp == BOULDER)) {
5169 otmp->nexthere = otmp2->nexthere;
5170 otmp2->nexthere = otmp;
5171 } else {
5172 otmp->nexthere = otmp2;
5173 level.objects[x][y] = otmp;
5176 /* set the new object's location */
5177 otmp->ox = x;
5178 otmp->oy = y;
5180 otmp->where = OBJ_FLOOR;
5182 /* add to floor chain */
5183 otmp->nobj = fobj;
5184 fobj = otmp;
5185 if (otmp->timed) obj_timer_checks(otmp, x, y, 0);
5188 #define ON_ICE(a) ((a)->recharged)
5189 #define ROT_ICE_ADJUSTMENT 2 /* rotting on ice takes 2 times as long */
5191 /* If ice was affecting any objects correct that now
5192 * Also used for starting ice effects too. [zap.c]
5194 void
5195 obj_ice_effects(x, y, do_buried)
5196 int x, y;
5197 boolean do_buried;
5199 struct obj *otmp;
5201 for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) {
5202 if (otmp->timed) obj_timer_checks(otmp, x, y, 0);
5204 if (do_buried) {
5205 for (otmp = level.buriedobjlist; otmp; otmp = otmp->nobj) {
5206 if (otmp->ox == x && otmp->oy == y) {
5207 if (otmp->timed) obj_timer_checks(otmp, x, y, 0);
5214 * Returns an obj->age for a corpse object on ice, that would be the
5215 * actual obj->age if the corpse had just been lifted from the ice.
5216 * This is useful when just using obj->age in a check or calculation because
5217 * rot timers pertaining to the object don't have to be stopped and
5218 * restarted etc.
5220 long
5221 peek_at_iced_corpse_age(otmp)
5222 struct obj *otmp;
5224 long age, retval = otmp->age;
5226 if (otmp->otyp == CORPSE && ON_ICE(otmp)) {
5227 /* Adjust the age; must be same as obj_timer_checks() for off ice*/
5228 age = monstermoves - otmp->age;
5229 retval = otmp->age + (age / ROT_ICE_ADJUSTMENT);
5230 #ifdef DEBUG_EFFECTS
5231 pline_The("%s age has ice modifications:otmp->age = %ld, returning %ld.",
5232 s_suffix(doname(otmp)),otmp->age, retval);
5233 pline("Effective age of corpse: %ld.",
5234 monstermoves - retval);
5235 #endif
5237 return retval;
5240 STATIC_OVL void
5241 obj_timer_checks(otmp, x, y, force)
5242 struct obj *otmp;
5243 xchar x, y;
5244 int force; /* 0 = no force so do checks, <0 = force off, >0 force on */
5246 long tleft = 0L;
5247 short action = ROT_CORPSE;
5248 boolean restart_timer = FALSE;
5249 boolean on_floor = (otmp->where == OBJ_FLOOR);
5250 boolean buried = (otmp->where == OBJ_BURIED);
5252 /* Check for corpses just placed on or in ice */
5253 if (otmp->otyp == CORPSE && (on_floor || buried) && is_ice(x,y)) {
5254 tleft = stop_timer(action, (void *)otmp);
5255 if (tleft == 0L) {
5256 action = MOLDY_CORPSE;
5257 tleft = stop_timer(action, (void *)otmp);
5258 if (tleft == 0L) {
5259 action = REVIVE_MON;
5260 tleft = stop_timer(action, (void *)otmp);
5263 if (tleft != 0L) {
5264 long age;
5266 tleft = tleft - monstermoves;
5267 /* mark the corpse as being on ice */
5268 ON_ICE(otmp) = 1;
5269 #ifdef DEBUG_EFFECTS
5270 pline("%s is now on ice at %d,%d.", The(xname(otmp)),x,y);
5271 #endif
5272 /* Adjust the time remaining */
5273 tleft *= ROT_ICE_ADJUSTMENT;
5274 restart_timer = TRUE;
5275 /* Adjust the age; must be same as in obj_ice_age() */
5276 age = monstermoves - otmp->age;
5277 otmp->age = monstermoves - (age * ROT_ICE_ADJUSTMENT);
5280 /* Check for corpses coming off ice */
5281 else if ((force < 0) ||
5282 (otmp->otyp == CORPSE && ON_ICE(otmp) &&
5283 ((on_floor && !is_ice(x,y)) || !on_floor))) {
5284 tleft = stop_timer(action, (void *)otmp);
5285 if (tleft == 0L) {
5286 action = MOLDY_CORPSE;
5287 tleft = stop_timer(action, (void *)otmp);
5288 if (tleft == 0L) {
5289 action = REVIVE_MON;
5290 tleft = stop_timer(action, (void *)otmp);
5293 if (tleft != 0L) {
5294 long age;
5296 tleft = tleft - monstermoves;
5297 ON_ICE(otmp) = 0;
5298 #ifdef DEBUG_EFFECTS
5299 pline("%s is no longer on ice at %d,%d.", The(xname(otmp)),x,y);
5300 #endif
5301 /* Adjust the remaining time */
5302 tleft /= ROT_ICE_ADJUSTMENT;
5303 restart_timer = TRUE;
5304 /* Adjust the age */
5305 age = monstermoves - otmp->age;
5306 otmp->age = otmp->age + (age / ROT_ICE_ADJUSTMENT);
5309 /* now re-start the timer with the appropriate modifications */
5310 if (restart_timer)
5311 (void) start_timer(tleft, TIMER_OBJECT, action, (void *)otmp);
5314 #undef ON_ICE
5315 #undef ROT_ICE_ADJUSTMENT
5317 void
5318 remove_object(otmp)
5319 register struct obj *otmp;
5321 xchar x = otmp->ox;
5322 xchar y = otmp->oy;
5324 if (otmp->where != OBJ_FLOOR)
5325 panic("remove_object: obj not on floor");
5326 if (otmp->otyp == BOULDER) unblock_point(x,y); /* vision */
5327 extract_nexthere(otmp, &level.objects[x][y]);
5328 extract_nobj(otmp, &fobj);
5329 if (otmp->timed) obj_timer_checks(otmp,x,y,0);
5332 /* throw away all of a monster's inventory */
5333 void
5334 discard_minvent(mtmp)
5335 struct monst *mtmp;
5337 struct obj *otmp, *curr;
5339 while (mtmp->minvent) {
5340 /* Move all contained objects out into the monster's main inventory
5341 * so that we can easily check that every object (whether contained
5342 * or not) does not evade destruction.
5344 while (Has_contents((otmp = mtmp->minvent))) {
5345 curr = otmp->cobj;
5346 obj_extract_self(curr);
5347 (void) add_to_minv(mtmp, curr);
5349 obj_extract_self(otmp);
5350 if (evades_destruction(otmp)) {
5351 impossible("%s discarded from %s inventory",
5352 obj_typename(otmp->otyp), s_suffix(mon_nam(mtmp)));
5353 place_object(otmp, mtmp->mx, mtmp->my);
5354 continue;
5356 obfree(otmp, (struct obj *)0); /* dealloc_obj() isn't sufficient */
5361 * Free obj from whatever list it is on in preperation of deleting it or
5362 * moving it elsewhere. This will perform all high-level consequences
5363 * involved with removing the item. E.g. if the object is in the hero's
5364 * inventory and confers heat resistance, the hero will lose it.
5366 * Object positions:
5367 * OBJ_FREE not on any list
5368 * OBJ_FLOOR fobj, level.locations[][] chains (use remove_object)
5369 * OBJ_CONTAINED cobj chain of container object
5370 * OBJ_INVENT hero's invent chain (use freeinv)
5371 * OBJ_MINVENT monster's invent chain
5372 * OBJ_MIGRATING migrating chain
5373 * OBJ_BURIED level.buriedobjs chain
5374 * OBJ_ONBILL on billobjs chain
5376 void
5377 obj_extract_self(obj)
5378 struct obj *obj;
5380 switch (obj->where) {
5381 case OBJ_FREE:
5382 break;
5383 case OBJ_FLOOR:
5384 remove_object(obj);
5385 break;
5386 case OBJ_CONTAINED:
5387 extract_nobj(obj, &obj->ocontainer->cobj);
5388 container_weight(obj->ocontainer);
5389 break;
5390 case OBJ_INVENT:
5391 freeinv(obj);
5392 break;
5393 case OBJ_MINVENT:
5394 extract_nobj(obj, &obj->ocarry->minvent);
5395 break;
5396 case OBJ_MIGRATING:
5397 extract_nobj(obj, &migrating_objs);
5398 break;
5399 case OBJ_BURIED:
5400 extract_nobj(obj, &level.buriedobjlist);
5401 break;
5402 case OBJ_ONBILL:
5403 extract_nobj(obj, &billobjs);
5404 break;
5405 default:
5406 panic("obj_extract_self");
5407 break;
5411 /* Extract a contained indestructable object (if one exists) and return it */
5412 struct obj *
5413 container_extract_indestructable(struct obj *obj)
5415 struct obj *otmp = obj->cobj, *indestructable = (struct obj *)0;
5416 while (!indestructable && otmp) {
5417 if (Has_contents(otmp))
5418 indestructable = container_extract_indestructable(otmp);
5419 if (!indestructable && evades_destruction(otmp)) {
5420 indestructable = otmp;
5421 obj_extract_self(indestructable);
5423 otmp = otmp->nobj;
5425 return indestructable;
5428 /* Extract the given object from the chain, following nobj chain. */
5429 void
5430 extract_nobj(obj, head_ptr)
5431 struct obj *obj, **head_ptr;
5433 struct obj *curr, *prev;
5435 curr = *head_ptr;
5436 for (prev = (struct obj *) 0; curr; prev = curr, curr = curr->nobj) {
5437 if (curr == obj) {
5438 if (prev)
5439 prev->nobj = curr->nobj;
5440 else
5441 *head_ptr = curr->nobj;
5442 break;
5445 if (!curr) panic("extract_nobj: object lost");
5446 obj->where = OBJ_FREE;
5451 * Extract the given object from the chain, following nexthere chain.
5453 * This does not set obj->where, this function is expected to be called
5454 * in tandem with extract_nobj, which does set it.
5456 void
5457 extract_nexthere(obj, head_ptr)
5458 struct obj *obj, **head_ptr;
5460 struct obj *curr, *prev;
5462 curr = *head_ptr;
5463 for (prev = (struct obj *) 0; curr; prev = curr, curr = curr->nexthere) {
5464 if (curr == obj) {
5465 if (prev)
5466 prev->nexthere = curr->nexthere;
5467 else
5468 *head_ptr = curr->nexthere;
5469 break;
5472 if (!curr) panic("extract_nexthere: object lost");
5477 * Add obj to mon's inventory. If obj is able to merge with something already
5478 * in the inventory, then the passed obj is deleted and 1 is returned.
5479 * Otherwise 0 is returned.
5482 add_to_minv(mon, obj)
5483 struct monst *mon;
5484 struct obj *obj;
5486 struct obj *otmp;
5488 if (obj->where != OBJ_FREE)
5489 panic("add_to_minv: obj not free");
5491 /* merge if possible */
5492 for (otmp = mon->minvent; otmp; otmp = otmp->nobj)
5493 if (merged(&otmp, &obj))
5494 return 1; /* obj merged and then free'd */
5495 /* else insert; don't bother forcing it to end of chain */
5496 obj->where = OBJ_MINVENT;
5497 obj->ocarry = mon;
5498 obj->nobj = mon->minvent;
5499 mon->minvent = obj;
5500 return 0; /* obj on mon's inventory chain */
5504 * Add obj to container, make sure obj is "free". Returns (merged) obj.
5505 * The input obj may be deleted in the process.
5506 * For statue traps, "clearinventflags" is false: this is because the items get transferred from a live monster, without
5507 * a chance for them to potentially be deleted, so we need to ensure they keep the mstartinvent flags --Amy
5509 struct obj *
5510 add_to_container(container, obj, clearinventflags)
5511 struct obj *container, *obj;
5512 boolean clearinventflags;
5514 struct obj *otmp;
5516 if (obj->where != OBJ_FREE)
5517 panic("add_to_container: obj not free");
5518 if (container->where != OBJ_INVENT && container->where != OBJ_MINVENT)
5519 obj_no_longer_held(obj);
5521 /* merge if possible */
5522 for (otmp = container->cobj; otmp; otmp = otmp->nobj)
5523 if (merged(&otmp, &obj)) return (otmp);
5525 if (clearinventflags) {
5526 obj->mstartinvent = 0;
5527 obj->mstartinventB = 0;
5528 obj->mstartinventC = 0;
5529 obj->mstartinventD = 0;
5530 obj->mstartinventE = 0;
5532 if (obj->mstartinventX) u.itemcleanupneeded = TRUE;
5533 obj->where = OBJ_CONTAINED;
5534 obj->ocontainer = container;
5535 obj->nobj = container->cobj;
5536 container->cobj = obj;
5537 return (obj);
5540 void
5541 add_to_migration(obj)
5542 struct obj *obj;
5544 if (obj->where != OBJ_FREE)
5545 panic("add_to_migration: obj not free");
5547 obj->where = OBJ_MIGRATING;
5548 obj->nobj = migrating_objs;
5549 migrating_objs = obj;
5552 void
5553 add_to_buried(obj)
5554 struct obj *obj;
5556 if (obj->where != OBJ_FREE)
5557 panic("add_to_buried: obj not free");
5559 obj->where = OBJ_BURIED;
5560 obj->nobj = level.buriedobjlist;
5561 level.buriedobjlist = obj;
5564 /* Recalculate the weight of this container and all of _its_ containers. */
5565 STATIC_OVL void
5566 container_weight(container)
5567 struct obj *container;
5569 container->owt = weight(container);
5570 if (container->where == OBJ_CONTAINED)
5571 container_weight(container->ocontainer);
5573 else if (container->where == OBJ_INVENT)
5574 recalculate load delay here ???
5579 * Deallocate the object. _All_ objects should be run through here for
5580 * them to be deallocated.
5582 void
5583 dealloc_obj(obj)
5584 struct obj *obj;
5586 if (obj->where != OBJ_FREE)
5587 panic("dealloc_obj: obj not free");
5589 /* free up any timers attached to the object */
5590 if (obj->timed)
5591 obj_stop_timers(obj);
5594 * Free up any light sources attached to the object.
5596 * We may want to just call del_light_source() without any
5597 * checks (requires a code change there). Otherwise this
5598 * list must track all objects that can have a light source
5599 * attached to it (and also requires lamplit to be set).
5601 if (obj_sheds_light(obj))
5602 del_light_source(LS_OBJECT, (void *) obj);
5604 if (obj == thrownobj) thrownobj = (struct obj*)0;
5606 free((void *) obj);
5609 #if defined(OBJ_SANITY) || defined(WIZARD)
5610 # ifdef WIZARD
5611 # define msgprefix ""
5612 # else
5613 # define msgprefix "BUG (please report): "
5614 # endif
5616 /* Check all object lists for consistency. */
5617 void
5618 obj_sanity_check()
5620 int x, y;
5621 struct obj *obj;
5622 struct monst *mon;
5623 const char *mesg;
5624 char obj_address[20], mon_address[20]; /* room for formatted pointers */
5626 mesg = "fobj sanity";
5627 for (obj = fobj; obj; obj = obj->nobj) {
5628 if (obj->where != OBJ_FLOOR) {
5629 pline("%s%s obj %s %s@(%d,%d): %s\n", msgprefix, mesg,
5630 fmt_ptr((void *)obj, obj_address),
5631 where_name(obj->where),
5632 obj->ox, obj->oy, doname(obj));
5634 check_contained(obj, mesg);
5637 mesg = "location sanity";
5638 for (x = 0; x < COLNO; x++)
5639 for (y = 0; y < ROWNO; y++)
5640 for (obj = level.objects[x][y]; obj; obj = obj->nexthere)
5641 if (obj->where != OBJ_FLOOR) {
5642 pline("%s%s obj %s %s@(%d,%d): %s\n", msgprefix, mesg,
5643 fmt_ptr((void *)obj, obj_address),
5644 where_name(obj->where),
5645 obj->ox, obj->oy, doname(obj));
5648 mesg = "invent sanity";
5649 for (obj = invent; obj; obj = obj->nobj) {
5650 if (obj->where != OBJ_INVENT) {
5651 pline("%s%s obj %s %s: %s\n", msgprefix, mesg,
5652 fmt_ptr((void *)obj, obj_address),
5653 where_name(obj->where), doname(obj));
5655 check_contained(obj, mesg);
5658 mesg = "migrating sanity";
5659 for (obj = migrating_objs; obj; obj = obj->nobj) {
5660 if (obj->where != OBJ_MIGRATING) {
5661 pline("%s%s obj %s %s: %s\n", msgprefix, mesg,
5662 fmt_ptr((void *)obj, obj_address),
5663 where_name(obj->where), doname(obj));
5665 check_contained(obj, mesg);
5668 mesg = "buried sanity";
5669 for (obj = level.buriedobjlist; obj; obj = obj->nobj) {
5670 if (obj->where != OBJ_BURIED) {
5671 pline("%s%s obj %s %s: %s\n", msgprefix, mesg,
5672 fmt_ptr((void *)obj, obj_address),
5673 where_name(obj->where), doname(obj));
5675 check_contained(obj, mesg);
5678 mesg = "bill sanity";
5679 for (obj = billobjs; obj; obj = obj->nobj) {
5680 if (obj->where != OBJ_ONBILL) {
5681 pline("%s%s obj %s %s: %s\n", msgprefix, mesg,
5682 fmt_ptr((void *)obj, obj_address),
5683 where_name(obj->where), doname(obj));
5685 /* shouldn't be a full container on the bill */
5686 if (obj->cobj) {
5687 pline("%s%s obj %s contains %s! %s\n", msgprefix, mesg,
5688 fmt_ptr((void *)obj, obj_address),
5689 something, doname(obj));
5693 mesg = "minvent sanity";
5694 for (mon = fmon; mon; mon = mon->nmon)
5695 for (obj = mon->minvent; obj; obj = obj->nobj) {
5696 if (obj->where != OBJ_MINVENT) {
5697 pline("%s%s obj %s %s: %s\n", msgprefix, mesg,
5698 fmt_ptr((void *)obj, obj_address),
5699 where_name(obj->where), doname(obj));
5701 if (obj->ocarry != mon) {
5702 pline("%s%s obj %s (%s) not held by mon %s (%s)\n", msgprefix, mesg,
5703 fmt_ptr((void *)obj, obj_address),
5704 doname(obj),
5705 fmt_ptr((void *)mon, mon_address),
5706 mon_nam(mon));
5708 check_contained(obj, mesg);
5712 /* This must stay consistent with the defines in obj.h. */
5713 static const char *obj_state_names[NOBJ_STATES] = {
5714 "free", "floor", "contained", "invent",
5715 "minvent", "migrating", "buried", "onbill"
5718 struct obj *
5719 turnintofakeartifact(otmp)
5720 register struct obj *otmp;
5722 if (!otmp) return (struct obj *)0;
5723 otmp = oname(otmp, !rn2(20) ? generate_garbage_string() : fauxartinames[rn2(SIZE(fauxartinames))] );
5724 if (otmp) {
5725 otmp->fakeartifact = 1;
5726 u.fakeartifacts++;
5727 return otmp;
5730 return (struct obj *)0;
5735 STATIC_OVL const char *
5736 where_name(where)
5737 int where;
5739 return (where<0 || where>=NOBJ_STATES) ? "unknown" : obj_state_names[where];
5742 /* obj sanity check: check objs contained by container */
5743 STATIC_OVL void
5744 check_contained(container, mesg)
5745 struct obj *container;
5746 const char *mesg;
5748 struct obj *obj;
5749 char obj1_address[20], obj2_address[20];
5751 for (obj = container->cobj; obj; obj = obj->nobj) {
5752 if (obj->where != OBJ_CONTAINED)
5753 pline("%scontained %s obj %s: %s\n", msgprefix, mesg,
5754 fmt_ptr((void *)obj, obj1_address),
5755 where_name(obj->where));
5756 else if (obj->ocontainer != container)
5757 pline("%s%s obj %s not in container %s\n", msgprefix, mesg,
5758 fmt_ptr((void *)obj, obj1_address),
5759 fmt_ptr((void *)container, obj2_address));
5762 #endif /* OBJ_SANITY || WIZARD */
5764 #endif /* OVL1 */
5766 /*mkobj.c*/