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. */
9 STATIC_DCL
void mkbox_cnts(struct obj
*);
10 STATIC_DCL
void obj_timer_checks(struct obj
*, XCHAR_P
, XCHAR_P
, int);
12 STATIC_DCL
void container_weight(struct obj
*);
13 STATIC_DCL
struct obj
*save_mtraits(struct obj
*, struct monst
*);
15 STATIC_DCL
const char *where_name(int);
16 STATIC_DCL
void check_contained(struct obj
*,const char *);
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 */
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",
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
[] = {
62 /* KMH -- amulets now appear later in the game */
63 /*{ 0, AMULET_CLASS}*/
66 const struct icp boxiprobs
[] = {
86 const struct icp tchestprobs
[] = {
107 const struct icp rogueprobs
[] = {
118 const struct icp hellprobs
[] = {
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 */
141 artigenechance(artichance
)
144 if (uarm
&& uarm
->oartifact
== ART_AMMY_S_RETRIBUTION
) return FALSE
;
146 if (Race_if(PM_LISTENER
)) artichance
*= 2;
148 if (MagicFindBonus
) {
152 if (StrongMagicFindBonus
) {
156 if (Race_if(PM_STARTSCUMMER
)) {
160 if (uarms
&& uarms
->oartifact
== ART_DNETHACKC_NOONISHNESS
) {
164 if (achieve
.get_amulet
) {
168 if (artichance
< 1) artichance
= 1; /* fail safe */
170 if (!rn2(artichance
)) return TRUE
;
176 mkobj_at(let
, x
, y
, artif
, shopinit
)
184 otmp
= mkobj(let
, artif
, shopinit
);
185 if (!otmp
) return (struct obj
*)0; /* fail safe added by Amy */
186 place_object(otmp
, x
, y
);
191 mksobj_at(otyp
, x
, y
, init
, artif
, shopinit
)
199 otmp
= mksobj(otyp
, init
, artif
, shopinit
);
200 if (!otmp
) return (struct obj
*)0;
201 place_object(otmp
, x
, y
);
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
)
216 int prob
= rnd(100000);
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);*/
242 /* somehow there's a weird potential for infinite loops... let's prevent them --Amy */
245 goto levscalerollpast
;
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
);
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
)) {
277 /*pline("item %d has level %d but scale is %d", i, objects[i].oc_minlvl, levscalediff);*/
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
);
296 mkobj(oclass
, artif
, shopinit
)
301 int tprob
, i
, j
, prob
= rnd(100000);
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
;
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
=
324 (Is_rogue_level(&u
.uz
)) ?
325 (const struct icp
*)rogueprobs
:
327 Inhell
? (const struct icp
*)hellprobs
:
328 (const struct icp
*)mkobjprobs
;
330 for(tprob
= rnd(1000);
331 (tprob
-= iprobs
->iprob
) > 0;
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
)) {
351 if ((oclass
== POTION_CLASS
) && (rn2(100) < u
.potionspawnchance
)) {
354 if ((oclass
== SPBOOK_CLASS
) && (rn2(100) < u
.bookspawnchance
)) {
357 if ((oclass
== WAND_CLASS
) && (rn2(100) < u
.wandspawnchance
)) {
360 if ((oclass
== AMULET_CLASS
) && (rn2(100) < u
.amuletspawnchance
)) {
363 if ((oclass
== IMPLANT_CLASS
) && (rn2(100) < u
.implantspawnchance
)) {
366 if ((oclass
== RING_CLASS
) && (rn2(100) < u
.ringspawnchance
)) {
369 if ((oclass
== WEAPON_CLASS
) && (rn2(100) < u
.weaponspawnchance
)) {
372 if ((oclass
== ARMOR_CLASS
) && (rn2(100) < u
.armorspawnchance
)) {
375 if ((oclass
== TOOL_CLASS
) && (rn2(100) < u
.toolspawnchance
)) {
378 if ((oclass
== FOOD_CLASS
) && (rn2(100) < u
.foodspawnchance
)) {
382 if ((oclass
== SCROLL_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() ) {
386 if ((oclass
== WEAPON_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() ) {
390 if ((oclass
== ARMOR_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() ) {
394 if ((oclass
== TOOL_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() ) {
398 if ((oclass
== POTION_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() ) {
402 if ((oclass
== WAND_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() ) {
406 if ((oclass
== AMULET_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() ) {
410 if ((oclass
== SPBOOK_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() && !timebasedlowerchance() ) {
414 if ((oclass
== FOOD_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && !timebasedlowerchance() && !timebasedlowerchance() ) {
418 if ((oclass
== GEM_CLASS
) && !wildcard
&& evilfriday
&& !timebasedlowerchance() && (!timebasedlowerchance() || !timebasedlowerchance() ) ) {
422 if ((oclass
== RING_CLASS
) && !wildcard
&& evilfriday
&& ( (!timebasedlowerchance() && !timebasedlowerchance() ) || (!timebasedlowerchance() && !timebasedlowerchance() ) ) ) {
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
);
434 i
= makeobject_core(oclass
);
436 if (oclass
== SPBOOK_CLASS
) {
438 if (u
.spellbookbias1
>= 0 && (rnd(100) <= u
.spellbookchance1
) && (spell_skilltype(i
) != u
.spellbookbias1
)) {
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
)) {
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
)) {
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
) {
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
) {
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)) {
515 while (!isvanillaarmor(i
) && (armortries
< 5000)) {
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
));
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
));
588 register int n
, minn
= 0;
589 register struct obj
*otmp
, *otmpX
;
591 box
->cobj
= (struct obj
*) 0;
596 otmp
= mksobj(makemusableitem(), TRUE
, TRUE
, FALSE
);
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
);
604 otmp
->owt
= weight(otmp
);
605 (void) add_to_container(box
, otmp
, TRUE
);
609 if (depth(&u
.uz
) >= 1 && depth(&u
.uz
) <= 5 && !issoviet
) {
611 otmp
= mkobj(WEAPON_CLASS
, TRUE
, FALSE
);
613 otmp
->owt
= weight(otmp
);
614 (void) add_to_container(box
, otmp
, TRUE
);
618 otmp
= mkobj(ARMOR_CLASS
, TRUE
, FALSE
);
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
) {
627 otmp
= mkobj(WEAPON_CLASS
, TRUE
, FALSE
);
629 otmp
->owt
= weight(otmp
);
630 (void) add_to_container(box
, otmp
, TRUE
);
634 otmp
= mkobj(ARMOR_CLASS
, TRUE
, FALSE
);
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
) {
643 otmp
= mkobj(WEAPON_CLASS
, TRUE
, FALSE
);
645 otmp
->owt
= weight(otmp
);
646 (void) add_to_container(box
, otmp
, TRUE
);
650 otmp
= mkobj(ARMOR_CLASS
, TRUE
, FALSE
);
652 otmp
->owt
= weight(otmp
);
653 (void) add_to_container(box
, otmp
, TRUE
);
658 n
= (ishaxor
? rnd(2) : rn2(2)); break;
663 /* any random class from WEAPON_CLASS to VENOM_CLASS */
664 otmp
= mkobj(WEAPON_CLASS
+ rn2(17), TRUE
, FALSE
);
666 otmp
->owt
= weight(otmp
);
667 (void) add_to_container(box
, otmp
, TRUE
);
670 otmp
= mkobj(WEAPON_CLASS
+ rn2(17), TRUE
, FALSE
);
672 otmp
->owt
= weight(otmp
);
673 (void) add_to_container(box
, otmp
, TRUE
);
676 otmp
= mkobj(WEAPON_CLASS
+ rn2(17), TRUE
, FALSE
);
678 otmp
->owt
= weight(otmp
);
679 (void) add_to_container(box
, otmp
, TRUE
);
684 n
= (ishaxor
? rnd(2) : rn2(2)); break;
688 n
= (ishaxor
? 120 : 60);
689 /* Initial inventory, no empty medical kits */
690 if (moves
<= 1 && !in_mklev
) minn
= 1;
693 n
= (ishaxor
? rnd(100) : rnd(50));
695 otmp
= mksobj(SCR_RETURN
, TRUE
, FALSE
, FALSE
);
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 */
703 n
= (ishaxor
? rnd(12) : rnd(6));
705 case ICE_BOX_OF_HOLDING
:
706 case ICE_BOX_OF_WATERPROOFING
:
709 n
= (ishaxor
? 40 : 20);
711 case CHEST_OF_HOLDING
:
713 n
= (ishaxor
? rnd(10) : rnd(5));
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) {
727 otmp
= mkobj(ARMOR_CLASS
, TRUE
, FALSE
);
729 otmp
->owt
= weight(otmp
);
730 (void) add_to_container(box
, otmp
, TRUE
);
739 n
= (ishaxor
? rnd(6) : rnd(3));
742 n
= (ishaxor
? rnd(6) : rnd(3));
745 n
= (ishaxor
? rnd(6) : rnd(3));
751 /* initial inventory: sack starts out empty */
752 if (moves
<= 1 && !in_mklev
) {
757 n
= (ishaxor
? rnd(2) : rn2(2));
759 case LARGE_BOX_OF_DIGESTION
:
760 case ICE_BOX_OF_DIGESTION
:
761 case BAG_OF_DIGESTION
: /* makes sense, doesn't it ? */
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
) {
772 if (n
> 1 && rn2(2) && (minn
< 2)) {
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
) {
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
)))
791 otmp
->oinvis
= otmp
->oinvisreal
= FALSE
;
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
801 otmp
->icedobject
= TRUE
;
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
) {
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
) {
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
);
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
) {
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
;
912 /* Plan A: get a level-appropriate common monster */
914 if (ptr
) return(monsndx(ptr
));
916 /* Plan B: get any common monster */
918 i
= rn1(SPECIAL_PM
- LOW_PM
, LOW_PM
);
920 } while((ptr
->geno
& G_NOGEN
) /*|| (!Inhell && (ptr->geno & G_HELL))*/);
926 usefulitem() /* select the ID number of an item that may be useful for the player --Amy */
936 return AMULET_OF_LIFE_SAVING
;
938 return AMULET_VERSUS_STONE
;
942 return MAGIC_WHISTLE
;
960 return CAN_OF_GREASE
;
973 return CHEMISTRY_SET
;
975 return HUGE_CHUNK_OF_MEAT
;
980 return EUCALYPTUS_LEAF
;
983 return LUMP_OF_ROYAL_JELLY
;
986 return HACKER_S_FOOD
;
989 return POT_RESTORE_ABILITY
;
995 return POT_GAIN_ENERGY
;
999 return POT_GAIN_HEALTH
;
1005 return POT_FULL_HEALING
;
1011 return POT_GAIN_ABILITY
;
1017 return POT_GAIN_LEVEL
;
1024 return SCR_CREATE_FAMILIAR
;
1028 return SCR_INVENTORY_ID
;
1034 return SCR_GAIN_MANA
;
1038 return SCR_ENCHANT_WEAPON
;
1041 return SCR_ENCHANT_ARMOR
;
1047 return SCR_RANDOM_ENCHANTMENT
;
1050 return SCR_REMOVE_CURSE
;
1056 return SCR_TELEPORTATION
;
1059 return SCR_TELE_LEVEL
;
1063 return SCR_TRAP_DISARMING
;
1067 return SCR_CHARGING
;
1070 return SCR_GENOCIDE
;
1073 return SCR_TRAP_DETECTION
;
1075 return SCR_ACQUIREMENT
;
1077 return SCR_CONSECRATION
;
1079 return SCR_ENTHRONIZATION
;
1081 return SPE_CURE_HALLUCINATION
;
1083 return SPE_EXTRA_HEALING
;
1085 return SPE_FULL_HEALING
;
1087 return SPE_RESTORE_ABILITY
;
1089 return SPE_CREATE_FAMILIAR
;
1091 return SPE_IDENTIFY
;
1097 return SPE_CHEMISTRY
;
1099 return SPE_REMOVE_CURSE
;
1101 return SPE_LEVITATION
;
1104 return SPE_REPAIR_ARMOR
;
1106 return SPE_MAGIC_MISSILE
;
1108 return SPE_FORCE_BOLT
;
1112 return WAN_GAIN_LEVEL
;
1118 return WAN_IDENTIFY
;
1120 return WAN_REMOVE_CURSE
;
1122 return WAN_TRAP_DISARMING
;
1124 return WAN_ENTRAPPING
;
1126 return WAN_INCREASE_MAX_HITPOINTS
;
1128 return WAN_CREATE_FAMILIAR
;
1131 return WAN_TELEPORTATION
;
1133 return WAN_EXTRA_HEALING
;
1135 return WAN_FULL_HEALING
;
1137 return WAN_ACQUIREMENT
;
1139 return WAN_CHARGING
;
1142 return WAN_MAGIC_MISSILE
;
1153 return WAN_LIGHTNING
;
1157 return WAN_SOLAR_BEAM
;
1159 return SPE_REPAIR_WEAPON
;
1161 return SCR_MAKE_PENTAGRAM
;
1163 return WAN_RESTORATION
;
1169 return SCR_PROOF_ACCESSORY
;
1171 return SCR_PROOF_TOOL
;
1173 return AMULET_OF_SYMBIOTE_SAVING
;
1183 return CLOAK_OF_MYSTERY
;
1185 return GAUNTLETS_OF_MYSTERY_RESISTANC
;
1187 return RIN_MYSTERY_RESISTANCE
;
1189 return WAN_STRONG_HEALING
;
1191 return WAN_TELEPORT_SELF
;
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 */
1209 return WAN_CREATE_MONSTER
;
1217 return SCR_CREATE_MONSTER
;
1221 return SCR_CREATE_VICTIM
;
1224 return WAN_CREATE_HORDE
;
1228 return RIN_TIMELY_BACKUP
;
1232 return SCR_ROOT_PASSWORD_DETECTION
;
1240 return SCR_SUMMON_UNDEAD
;
1244 return WAN_SUMMON_UNDEAD
;
1248 return WAN_REDUCE_MAX_HITPOINTS
;
1250 return WAN_INCREASE_MAX_HITPOINTS
;
1262 return SCR_TRAP_CREATION
;
1265 return SCR_CREATE_TRAP
;
1268 return WAN_TRAP_CREATION
;
1276 return SCR_BARRHING
;
1280 return (rn2(10) ? WAN_TELEPORTATION
: WAN_BANISHMENT
);
1288 return POT_HALLUCINATION
;
1300 return POT_STUNNING
;
1308 return POT_NUMBNESS
;
1312 return POT_CANCELLATION
;
1321 return SCR_BAD_EFFECT
;
1323 return WAN_BAD_EFFECT
;
1333 return WAN_GAIN_LEVEL
;
1335 return WAN_MUTATION
;
1337 return WAN_CLONE_MONSTER
;
1339 return SCR_DESTROY_ARMOR
;
1341 return SCR_DESTROY_WEAPON
;
1348 return BAG_OF_TRICKS
;
1352 return WAN_DISINTEGRATION
;
1354 return WAN_PARALYSIS
;
1356 return WAN_CURSE_ITEMS
;
1360 return WAN_BAD_LUCK
;
1362 return WAN_REMOVE_RESISTANCE
;
1364 return WAN_CORROSION
;
1366 return WAN_STARVATION
;
1368 return WAN_CONFUSION
;
1372 return WAN_LYCANTHROPY
;
1374 return WAN_FUMBLING
;
1376 return WAN_PUNISHMENT
;
1379 return SCR_PUNISHMENT
;
1385 return SCR_SUMMON_BOSS
;
1396 return SCR_BULLSHIT
;
1398 return SCR_CHAOS_TERRAIN
;
1400 return SCR_NASTINESS
;
1402 return SCR_DEMONOLOGY
;
1404 return SCR_ELEMENTALISM
;
1406 return SCR_GIRLINESS
;
1408 return WAN_SUMMON_SEXY_GIRL
;
1414 return SCR_GROUP_SUMMONING
;
1418 return WAN_STUN_MONSTER
;
1420 return SCR_SUMMON_GHOST
;
1422 return SCR_MEGALOAD
;
1426 return WAN_TIDAL_WAVE
;
1428 return SCR_ANTIMATTER
;
1431 return SCR_SUMMON_ELM
;
1433 return WAN_SUMMON_ELM
;
1435 return WAN_DRAIN_MANA
;
1437 return WAN_FINGER_BENDING
;
1441 return SCR_IMMOBILITY
;
1443 return WAN_IMMOBILITY
;
1445 return SCR_FLOODING
;
1461 return WAN_LEVITATION
;
1463 return SCR_VILENESS
;
1473 return SCR_OFFLEVEL_ITEM
;
1475 return SCR_NASTY_CURSE
;
1477 return WAN_FLEECY_TERRAIN
;
1479 return WAN_DISENCHANTMENT
;
1481 return WAN_CONTAMINATION
;
1483 return WAN_TREMBLING
;
1491 return SCR_MOUNTAINS
;
1495 return SCR_CRYSTALLIZATION
;
1497 return SCR_MOORLAND
;
1501 return SCR_QUICKSAND
;
1515 return SCR_GRASSLAND
;
1519 return SCR_STALACTITE
;
1523 return SCR_BUBBLE_BOBBLE
;
1527 return WAN_CHAOS_TERRAIN
;
1529 return SCR_EVIL_VARIANT
;
1531 return WAN_STAT_REDUCTION
;
1533 return SCR_COURSE_TRAVELING
;
1536 default: /* fail safe */
1537 return WAN_CREATE_HORDE
;
1543 makemusableitem() /* select the ID number of a musable item --Amy */
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 */
1886 return TOOTH_OF_AN_ALGOLIAN_SUNTIGER
;
1888 return DWARVISH_BATTLE_AXE
;
1890 return ELECTRIC_SWORD
;
1892 return BASTERD_SWORD
;
1898 return INSECT_SQUASHER
;
1902 return REINFORCED_MACE
;
1908 return SLEDGE_HAMMER
;
1912 return BATTLE_STAFF
;
1924 return DEMON_CROSSBOW
;
1930 return FULL_PLATE_MAIL
;
1932 return ROBE_OF_MAGIC_RESISTANCE
;
1934 return GRAY_DRAGON_SCALE_MAIL
;
1936 return SILVER_DRAGON_SCALE_MAIL
;
1938 return MERCURIAL_DRAGON_SCALE_MAIL
;
1940 return DEEP_DRAGON_SCALE_MAIL
;
1942 return BLACK_DRAGON_SCALE_MAIL
;
1944 return GOLDEN_DRAGON_SCALE_MAIL
;
1946 return STONE_DRAGON_SCALE_MAIL
;
1948 return SKY_DRAGON_SCALE_MAIL
;
1950 return CLOAK_OF_MAGIC_RESISTANCE
;
1952 return CLOAK_OF_DRAIN_RESISTANCE
;
1954 return CLOAK_OF_REFLECTION
;
1958 return CLOAK_OF_STABILITY
;
1962 return CLOAK_OF_SHIFTING
;
1964 return SENSOR_CLOAK
;
1966 return CLOAK_OF_SPEED
;
1968 return OPERATION_CLOAK
;
1970 return CLOAK_OF_FREEDOM
;
1972 return CLOAK_OF_CURSE_CATCHING
;
1974 return HELM_OF_DRAIN_RESISTANCE
;
1976 return HELM_OF_SPEED
;
1978 return HELM_OF_DETOXIFICATION
;
1980 return HELM_OF_TELEPATHY
;
1982 return ORIHALCYON_GAUNTLETS
;
1984 return GAUNTLETS_OF_REFLECTION
;
1986 return GAUNTLETS_OF_FREE_ACTION
;
1988 return SHIELD_OF_MOBILITY
;
1990 return GRAY_DRAGON_SCALE_SHIELD
;
1992 return SILVER_DRAGON_SCALE_SHIELD
;
1994 return MERCURIAL_DRAGON_SCALE_SHIELD
;
1996 return DEEP_DRAGON_SCALE_SHIELD
;
1998 return BLACK_DRAGON_SCALE_SHIELD
;
2000 return GOLDEN_DRAGON_SCALE_SHIELD
;
2002 return STONE_DRAGON_SCALE_SHIELD
;
2004 return SKY_DRAGON_SCALE_SHIELD
;
2008 return FLYING_BOOTS
;
2010 return BOOTS_OF_FREEDOM
;
2012 return BOOTS_OF_TOTAL_STABILITY
;
2014 return RIN_DRAIN_RESISTANCE
;
2016 return RIN_MAGIC_RESISTANCE
;
2018 return RIN_MATERIAL_STABILITY
;
2020 return RIN_SICKNESS_RESISTANCE
;
2022 return RIN_ALACRITY
;
2024 return RIN_FREE_ACTION
;
2026 return RIN_POLYMORPH_CONTROL
;
2028 return AMULET_OF_DRAIN_RESISTANCE
;
2030 return AMULET_OF_ESP
;
2032 return AMULET_OF_FLYING
;
2034 return AMULET_OF_LIFE_SAVING
;
2036 return AMULET_OF_REFLECTION
;
2038 return AMULET_OF_DEPETRIFY
;
2040 return AMULET_OF_MAGIC_RESISTANCE
;
2042 return AMULET_OF_SICKNESS_RESISTANCE
;
2044 return AMULET_OF_DISINTEGRATION_RESIS
;
2046 return AMULET_OF_SPEED
;
2048 return AMULET_OF_POLYMORPH_CONTROL
;
2050 return AMULET_OF_PRISM
;
2052 return AMULET_OF_WARP_DIMENSION
;
2054 return AMULET_VERSUS_CURSES
;
2056 return CHEST_OF_HOLDING
;
2058 return ICE_BOX_OF_HOLDING
;
2060 return ICE_BOX_OF_WATERPROOFING
;
2062 return BAG_OF_HOLDING
;
2064 return MAGIC_CANDLE
;
2066 return MAGIC_WHISTLE
;
2070 return RED_DOUBLE_LIGHTSABER
;
2072 return MAGIC_MARKER
;
2078 return CHEMISTRY_SET
;
2080 return POT_GAIN_HEALTH
;
2082 return POT_FULL_HEALING
;
2084 return POT_GAIN_LEVEL
;
2086 return POT_INVULNERABILITY
;
2088 return POT_RECOVERY
;
2092 return SCR_CREATE_FAMILIAR
;
2094 return SCR_SECURE_IDENTIFY
;
2096 return SCR_INVENTORY_ID
;
2098 return SCR_ARMOR_SPECIALIZATION
;
2100 return SCR_ARTIFACT_CREATION
;
2102 return SCR_GENOCIDE
;
2104 return SCR_ACQUIREMENT
;
2106 return SCR_REVERSE_IDENTIFY
;
2108 return SCR_ALTER_REALITY
;
2112 return SCR_POWER_HEALING
;
2114 return SCR_SKILL_UP
;
2116 return SCR_CREATE_ALTAR
;
2118 return SCR_WORLD_FALL
;
2120 return SCR_RESURRECTION
;
2122 return SCR_CONSECRATION
;
2124 return SCR_REPAIR_ITEM
;
2126 return SCR_ITEM_GENOCIDE
;
2130 return SPE_DISINTEGRATION
;
2132 return SPE_DISINTEGRATION_BEAM
;
2136 return SPE_MAP_LEVEL
;
2140 return SPE_REMOVE_CURSE
;
2142 return SPE_TIME_STOP
;
2144 return SPE_LEVELPORT
;
2146 return SPE_PARALYSIS
;
2150 return SPE_GRAVITY_BEAM
;
2152 return SPE_GOOD_NIGHT
;
2156 return SPE_ICE_BEAM
;
2164 return SPE_NETHER_BEAM
;
2166 return SPE_AURORA_BEAM
;
2168 return SPE_CHLOROFORM
;
2170 return SPE_FINGER_OF_DEATH
;
2172 return WAN_GAIN_LEVEL
;
2174 return WAN_TIME_STOP
;
2176 return WAN_TELE_LEVEL
;
2178 return WAN_GENOCIDE
;
2180 return WAN_ENTRAPPING
;
2182 return WAN_PARALYSIS
;
2184 return WAN_DISINTEGRATION
;
2188 return WAN_INCREASE_MAX_HITPOINTS
;
2190 return WAN_CREATE_FAMILIAR
;
2192 return WAN_DISINTEGRATION_BEAM
;
2194 return WAN_ACQUIREMENT
;
2196 return WAN_CHARGING
;
2198 return WAN_GRAVITY_BEAM
;
2200 return WAN_GOOD_NIGHT
;
2204 return WAN_ICE_BEAM
;
2212 return WAN_NETHER_BEAM
;
2214 return WAN_AURORA_BEAM
;
2220 return MATERIAL_KIT
;
2222 return INTELLIGENCE_PACK
;
2226 return SCR_SUPERIOR_MATERIAL
;
2228 return SCR_GREATER_ENCHANT_WEAPON
;
2230 return SCR_GREATER_ENCHANT_ARMOR
;
2232 return SCR_POWER_CHARGING
;
2236 return POT_TECH_LEVEL_UP
;
2238 return SCR_BRANCH_TELEPORT
;
2246 return SCR_EXTRA_SKILL_POINT
;
2248 return COMBINATION_CLOAK
;
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).
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 */
2284 obj
->owt
= weight(obj
);
2286 otmp
->owt
= weight(otmp
); /* -= obj->owt ? */
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
;
2293 (void)memcpy((void *)otmp
->oextra
, (void *)obj
->oextra
,
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
);
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.
2313 replace_object(obj
, otmp
)
2317 otmp
->where
= obj
->where
;
2318 switch (obj
->where
) {
2323 otmp
->nobj
= obj
->nobj
;
2325 extract_nobj(obj
, &invent
);
2328 otmp
->nobj
= obj
->nobj
;
2329 otmp
->ocontainer
= obj
->ocontainer
;
2331 extract_nobj(obj
, &obj
->ocontainer
->cobj
);
2334 otmp
->nobj
= obj
->nobj
;
2335 otmp
->ocarry
= obj
->ocarry
;
2337 extract_nobj(obj
, &obj
->ocarry
->minvent
);
2340 otmp
->nobj
= obj
->nobj
;
2341 otmp
->nexthere
= obj
->nexthere
;
2345 obj
->nexthere
= otmp
;
2346 extract_nobj(obj
, &fobj
);
2347 extract_nexthere(obj
, &level
.objects
[obj
->ox
][obj
->oy
]);
2350 otmp
->nobj
= obj
->nobj
;
2352 extract_nobj(obj
, &migrating_objs
);
2355 otmp
->nobj
= obj
->nobj
;
2357 extract_nobj(obj
, &level
.buriedobjlist
);
2360 otmp
->nobj
= obj
->nobj
;
2362 extract_nobj(obj
, &billobjs
);
2365 panic("replace_object: obj position");
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.
2385 bill_dummy_object(otmp
)
2386 register struct obj
*otmp
;
2388 register struct obj
*dummy
, *obj
;
2391 subfrombill(otmp
, shop_keeper(*u
.ushops
));
2392 dummy
= newobj(otmp
->oxlth
+ otmp
->onamelth
);
2394 if (Has_contents(otmp
)) {
2395 for(obj
= otmp
->cobj
; obj
; obj
= obj
->nobj
)
2396 bill_dummy_object(obj
);
2399 dummy
->where
= OBJ_FREE
;
2400 dummy
->o_id
= flags
.ident
++;
2401 if (!dummy
->o_id
) dummy
->o_id
= flags
.ident
++; /* ident overflowed */
2404 (void)memcpy((void *)dummy
->oextra
,
2405 (void *)otmp
->oextra
, otmp
->oxlth
);
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;
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
2425 mksobj(otyp
, init
, artif
, shopinit
)
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
);
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
);
2444 if (otyp
== u
.unobtainable
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2448 if (otyp
== u
.unobtainable2
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2452 if (otyp
== u
.unobtainable3
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2456 if (otyp
== u
.unobtainable4
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2460 if (otyp
== u
.unobtainable5
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2464 if (otyp
== u
.unobtainable6
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2468 if (otyp
== u
.unobtainable7
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2472 if (otyp
== u
.unobtainable8
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2476 if (otyp
== u
.unobtainable9
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2480 if (otyp
== u
.unobtainable10
&& !(u
.riderhack
&& otyp
== CORPSE
) && !(issokosolver
&& otyp
== BOULDER
)) {
2484 if (otyp
== u
.unobtainablegeno
&& !(u
.riderhack
&& otyp
== CORPSE
)) { /* your fault for genociding them. No sokosolver specialties! --Amy */
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
2493 && otyp
!= BELL_OF_OPENING
&& otyp
!= SPE_BOOK_OF_THE_DEAD
)
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
);
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 */
2511 otmp
->where
= OBJ_FREE
;
2512 otmp
->dknown
= index(dknowns
, let
) ? 0 : 1;
2513 otmp
->selfmade
= FALSE
;
2515 otmp
->oinvisreal
= 0;
2516 otmp
->petmarked
= 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
)
2544 if (!objects
[otmp
->otyp
].oc_uses_known
)
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 */
2566 switch (otmp
->otyp
) {
2569 otmp
->age
= MAX_OIL_IN_FLASK
; /* amount of oil */
2571 case STICK_OF_DYNAMITE
:
2572 otmp
->age
= rn2(10) + 10;
2576 case JAPAN_WAX_CANDLE
:
2578 case UNSPECIFIED_CANDLE
:
2579 case SPECIFIC_CANDLE
:
2581 case NATURAL_CANDLE
:
2582 case UNAFFECTED_CANDLE
:
2583 case GENERAL_CANDLE
:
2587 otmp
->age
= (long) rn1(300,600);
2591 otmp
->age
= (long) rn1(500,1000);
2594 otmp
->age
= (long) rn1(2500,5000);
2596 case RED_DOUBLE_LIGHTSABER
:
2597 case CYAN_DOUBLE_LIGHTSABER
:
2600 case PINK_DOUBLE_LIGHTSWORD
:
2604 case WHITE_DOUBLE_LIGHTSABER
:
2609 case PINK_LIGHTSWORD
:
2611 case GREEN_LIGHTSABER
:
2612 case ORANGE_LIGHTSABER
:
2613 case BLACK_LIGHTSABER
:
2614 case BLUE_LIGHTSABER
:
2615 case DARK_LIGHTSABER
:
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
:
2627 case ELECTRIC_CIGARETTE
:
2628 otmp
->age
= (long) rn1(1000,1000);
2630 case HEAVY_LASER_BALL
:
2632 otmp
->age
= (long) rn1(500,1000);
2638 if (init
) switch (let
) {
2639 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
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
) {
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;
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;
2818 switch(otmp
->otyp
) {
2820 /* possibly overridden by mkcorpstat() */
2822 do otmp
->corpsenm
= undead_to_corpse(rndmonnum());
2823 while ((mvitals
[otmp
->corpsenm
].mvflags
& G_NOCORPSE
) && (--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);
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
);
2842 if (!rn2(200)) otmp
->spe
= 2;
2843 blessorcurse_on_creation(otmp
, 8);
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
;
2857 blessorcurse_on_creation(otmp
, 10);
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);
2885 case WATER_HYACINTH
:
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);
2908 } /* end switch statement */
2909 blessorcurse_on_creation(otmp
, 10);
2910 if (!rn2(achieve
.get_amulet
? 1000 : 4000)) otmp
->oerodeproof
= 1;
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
++;
2926 /* no longer fall into next case --Amy */
2928 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
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;
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;
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;
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;
3092 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
3094 switch(otmp
->otyp
) {
3097 case JAPAN_WAX_CANDLE
:
3099 case UNSPECIFIED_CANDLE
:
3100 case SPECIFIC_CANDLE
:
3102 case NATURAL_CANDLE
:
3103 case UNAFFECTED_CANDLE
:
3104 case GENERAL_CANDLE
:
3106 otmp
->age
= 2000L; /* used to depend on cost but that's BS --Amy */
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
);
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);
3135 case TORCH
: otmp
->spe
= 0;
3136 otmp
->age
= (long) rn1(300,600);
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
);
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);
3166 otmp
->recharged
= 0;
3167 if(!rn2(5)) otmp
->recharged
= rnd(7);
3169 otmp
->age
= (long) rn1(500,1000);
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
);
3182 blessorcurse_on_creation(otmp
, 5);
3185 otmp
->recharged
= 0;
3186 if(!rn2(5)) otmp
->recharged
= rnd(7);
3188 otmp
->age
= (long) rn1(2500,5000);
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
);
3201 blessorcurse_on_creation(otmp
, 5);
3207 blessorcurse_on_creation(otmp
, 2);
3209 case RED_DOUBLE_LIGHTSABER
:
3210 case CYAN_DOUBLE_LIGHTSABER
:
3213 case PINK_DOUBLE_LIGHTSWORD
:
3217 case WHITE_DOUBLE_LIGHTSABER
:
3218 otmp
->altmode
= FALSE
;
3223 case PINK_LIGHTSWORD
:
3225 case GREEN_LIGHTSABER
:
3226 case ORANGE_LIGHTSABER
:
3227 case BLACK_LIGHTSABER
:
3228 case BLUE_LIGHTSABER
:
3229 case DARK_LIGHTSABER
:
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
:
3241 case ELECTRIC_CIGARETTE
:
3242 otmp
->recharged
= 0;
3243 if(!rn2(5)) otmp
->recharged
= rnd(7);
3245 otmp
->age
= (long) rn1(1000,1000);
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 */
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;
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);
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);
3316 case CHEST_OF_HOLDING
:
3320 otmp
->olocked
= !!(rn2(5));
3321 otmp
->otrapped
= !(rn2(10));
3323 case DISPERSION_BOX
:
3324 case ICE_BOX_OF_HOLDING
:
3325 case ICE_BOX_OF_WATERPROOFING
:
3332 case BAG_OF_HOLDING
:
3334 if (artif
!= 2) mkbox_cnts(otmp
);
3335 blessorcurse_on_creation(otmp
, 8);
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);
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);
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);
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);
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);
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);
3385 case ORB_OF_ENCHANTMENT
:
3386 otmp
->spe
= rnd(3) + 1;
3387 otmp
->spe
-= rn2(3);
3388 blessorcurse_on_creation(otmp
, 2);
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);
3397 case HORN_OF_PLENTY
:
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);
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);
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);
3424 do otmp
->corpsenm
= rndmonnum();
3425 while(is_human(&mons
[otmp
->corpsenm
]) && !rn2(5) && tryct2
++ < 30);
3426 blessorcurse_on_creation(otmp
, 4);
3429 case BELL_OF_OPENING
:
3430 otmp
->spe
= (ishaxor
? 60 : 30);
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);
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);
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;
3490 if (!rn2(achieve
.get_amulet
? 200 : 800)) otmp
->oerodeproof
= 1;
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
++;
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
);
3520 blessorcurse_on_creation(otmp
, 10);
3522 if (!rn2(achieve
.get_amulet
? 300 : 1200)) otmp
->oerodeproof
= 1;
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
++;
3542 if(objects
[otmp
->otyp
].oc_charged
) {
3543 blessorcurse_on_creation(otmp
, 5);
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); */
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;
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;
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;
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;
3669 switch (otmp
->otyp
) {
3670 case HEAVY_LASER_BALL
:
3672 otmp
->recharged
= 0;
3673 if(!rn2(5)) otmp
->recharged
= rnd(7);
3675 otmp
->age
= (long) rn1(500,1000);
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
);
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;
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;
3749 if (otmp
->otyp
== POT_OIL
)
3750 otmp
->age
= MAX_OIL_IN_FLASK
; /* amount of oil */
3754 if (otmp
->otyp
!= SCR_MAIL
)
3756 blessorcurse_on_creation(otmp
, 4);
3758 if (!rn2(achieve
.get_amulet
? 80 : 320)) otmp
->oerodeproof
= 1;
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
3776 || otmp
->otyp
== SCR_MAIL
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) );
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);
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;
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
;
3831 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
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;
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
) ) {
3923 /* optimizer bitfield bug */
3924 otmp
->oerodeproof
= 1;
3927 otmp
->oerodeproof
= otmp
->rknown
= 1;
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);
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;
3968 /* -----------============STEPHEN WHITE'S NEW CODE============----------- */
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;
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
++;
4050 if(objects
[otmp
->otyp
].oc_charged
) {
4051 blessorcurse_on_creation(otmp
, 3);
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); */
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;
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;
4115 switch (otmp
->otyp
) {
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;
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
++;
4143 break; /* do nothing */
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);
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
) {
4195 start_corpse_timeout(otmp
);
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
);
4207 * Start a corpse decay or revive timer.
4208 * This takes the age of the corpse into consideration as of 3.4.0.
4211 start_corpse_timeout(body
)
4215 long when
; /* rot away when this old */
4216 long corpse_age
; /* age of corpse */
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
)
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
++)
4250 } else if (is_deadlysin(&mons
[body
->corpsenm
]) ) {
4252 for (age
= TAINT_AGE
+ 1; age
<= ROT_AGE
; age
++)
4253 if (!rn2(SIN_REVIVE_LATE_CHANCE
) ) { /* sin revives */
4254 action
= REVIVE_MON
;
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
;
4266 if (u
.uprops
[STARVATION_EFFECT
].extrinsic
|| StarvationEffect
|| (uarmc
&& uarmc
->oartifact
== ART_FEMMY_FATALE
) || have_starvationstone() || (ublindf
&& ublindf
->oartifact
== ART_TOTAL_PERSPECTIVE_VORTEX
) ) {
4268 action
= REVIVE_MON
;
4271 action
= ROT_CORPSE
;
4276 } else if ((mons
[body
->corpsenm
].mlet
== S_TROLL
&& !body
->norevive
) ) {
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
;
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
;
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
;
4296 action
= ROT_CORPSE
;
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.
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
;
4315 } else if (is_reviver(&mons
[body
->corpsenm
]) && !(uwep
&& uwep
->oartifact
== ART_ZOMBIEBANE
) && !rn2(MOLD_REVIVE_CHANCE
)) {
4316 action
= REVIVE_MON
;
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
;
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
;
4330 action
= ROT_CORPSE
;
4337 if (action
== ROT_CORPSE
&& !acidic(&mons
[body
->corpsenm
])) {
4338 /* Corpses get moldy
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 */
4349 if (body
->norevive
) body
->norevive
= 0;
4350 (void) start_timer(when
, TIMER_OBJECT
, action
, (void *)body
);
4355 register struct obj
*otmp
;
4358 if (otmp
->oclass
== COIN_CLASS
) return;
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) {
4373 if (carried(otmp
) && confers_luck(otmp
))
4375 if (otmp
->otyp
== HEALTHSTONE
)
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
);
4387 register struct obj
*otmp
;
4390 if (carried(otmp
) && confers_luck(otmp
))
4392 if (otmp
->otyp
== HEALTHSTONE
)
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
);
4403 register struct obj
*otmp
;
4406 if (otmp
->oclass
== COIN_CLASS
) return;
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;
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;
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
) ) )
4440 /* some cursed items need immediate updating */
4441 if (carried(otmp
) && confers_luck(otmp
))
4443 if (otmp
->otyp
== HEALTHSTONE
)
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
);
4456 /* Special function for objects that get cursed on creation --Amy */
4458 curse_on_creation(otmp
)
4459 register struct obj
*otmp
;
4462 if (otmp
->oclass
== COIN_CLASS
) return;
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;
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
) ) )
4508 /* some cursed items need immediate updating */
4509 if (carried(otmp
) && confers_luck(otmp
))
4511 if (otmp
->otyp
== HEALTHSTONE
)
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
);
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
))
4547 /* KMH, balance patch -- healthstones affect healing */
4548 if (otmp
->otyp
== HEALTHSTONE
)
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
);
4558 blessorcurse(otmp
, chance
)
4559 register struct obj
*otmp
;
4560 register int chance
;
4562 if(otmp
->blessed
|| otmp
->cursed
) return;
4565 if(!rn2(isfriday
? 2 : 3)) {
4570 } else if (Role_if(PM_CAMPERSTRIKER
) && !rn2(chance
)) curse(otmp
);
4576 blessorcurse_on_creation(otmp
, chance
)
4577 register struct obj
*otmp
;
4578 register int chance
;
4580 if(otmp
->blessed
|| otmp
->cursed
) return;
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
);
4596 } else if (Role_if(PM_CAMPERSTRIKER
) && !rn2(chance
)) curse_on_creation(otmp
);
4606 register struct obj
*otmp
;
4608 return(!!otmp
->blessed
- !!otmp
->cursed
);
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.
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
4646 * Bag status Ordinary Artifact
4647 * ---------- -------- --------
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
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
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
) {
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
);
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
);
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 */
4695 rnd_treefruit_at(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
);
4705 mkgold(amount
, x
, y
)
4709 register struct obj
*gold
= g_at(x
,y
);
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;
4735 gold
->quan
+= amount
;
4737 gold
= mksobj_at(GOLD_PIECE
, x
, y
, TRUE
, FALSE
, FALSE
);
4738 gold
->quan
= amount
;
4740 gold
->owt
= weight(gold
);
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
4768 mkcorpstat(objtype
, mtmp
, ptr
, x
, y
, init
)
4769 int objtype
; /* CORPSE or STATUE */
4771 struct permonst
*ptr
;
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
);
4786 otmp
= mksobj_at(objtype
, x
, y
, init
, FALSE
, FALSE
);
4788 u
.riderhack
= FALSE
;
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 */
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
);
4825 * Attach a monster id to an object, to provide
4826 * a lasting association between the two.
4829 obj_attach_mid(obj
, mid
)
4836 if (!mid
|| !obj
) return (struct obj
*)0;
4838 namelth
= obj
->onamelth
? strlen(ONAME(obj
)) + 1 : 0;
4840 otmp
= realloc_obj(obj
, lth
, (void *) &mid
, namelth
, ONAME(obj
));
4843 otmp
->oxlth
= sizeof(mid
);
4844 (void) memcpy((void *)otmp
->oextra
, (void *)&mid
,
4847 if (otmp
&& otmp
->oxlth
) otmp
->oattached
= OATTACHED_M_ID
; /* mark it */
4852 save_mtraits(obj
, mtmp
)
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 */
4876 /* returns a pointer to a new monst structure based on
4877 * the one contained within the obj.
4880 get_mtraits(obj
, 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
;
4891 int lth
= mtmp
->mxlth
+ mtmp
->mnamelth
;
4892 mnew
= newmonst(lth
);
4893 lth
+= sizeof(struct monst
);
4894 (void) memcpy((void *)mnew
,
4897 /* Never insert this returned pointer into mon chains! */
4907 /* make an object named after someone listed in the scoreboard file */
4909 mk_tt_object(objtype
, x
, y
)
4910 int objtype
; /* CORPSE or STATUE */
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
;
4925 /* make a new corpse or statue, uninitialized if a statue (i.e. no books) */
4927 mk_named_object(objtype
, ptr
, x
, y
, nm
)
4928 int objtype
; /* CORPSE or STATUE */
4929 struct permonst
*ptr
;
4935 otmp
= mkcorpstat(objtype
, (struct monst
*)0, ptr
,
4936 x
, y
, (boolean
)(objtype
!= STATUE
));
4938 otmp
= oname(otmp
, nm
);
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 */
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
;
4976 /* Amy grepping target: "materialeffect" */
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
)
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
;
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
;
5065 /* keyword "materialeffect" --Amy */
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
;
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
;
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 */
5155 place_object(otmp
, x
, y
)
5156 register struct obj
*otmp
;
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
;
5172 otmp
->nexthere
= otmp2
;
5173 level
.objects
[x
][y
] = otmp
;
5176 /* set the new object's location */
5180 otmp
->where
= OBJ_FLOOR
;
5182 /* add to floor chain */
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]
5195 obj_ice_effects(x
, y
, do_buried
)
5201 for (otmp
= level
.objects
[x
][y
]; otmp
; otmp
= otmp
->nexthere
) {
5202 if (otmp
->timed
) obj_timer_checks(otmp
, x
, y
, 0);
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
5221 peek_at_iced_corpse_age(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
);
5241 obj_timer_checks(otmp
, x
, y
, force
)
5244 int force
; /* 0 = no force so do checks, <0 = force off, >0 force on */
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
);
5256 action
= MOLDY_CORPSE
;
5257 tleft
= stop_timer(action
, (void *)otmp
);
5259 action
= REVIVE_MON
;
5260 tleft
= stop_timer(action
, (void *)otmp
);
5266 tleft
= tleft
- monstermoves
;
5267 /* mark the corpse as being on ice */
5269 #ifdef DEBUG_EFFECTS
5270 pline("%s is now on ice at %d,%d.", The(xname(otmp
)),x
,y
);
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
);
5286 action
= MOLDY_CORPSE
;
5287 tleft
= stop_timer(action
, (void *)otmp
);
5289 action
= REVIVE_MON
;
5290 tleft
= stop_timer(action
, (void *)otmp
);
5296 tleft
= tleft
- monstermoves
;
5298 #ifdef DEBUG_EFFECTS
5299 pline("%s is no longer on ice at %d,%d.", The(xname(otmp
)),x
,y
);
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 */
5311 (void) start_timer(tleft
, TIMER_OBJECT
, action
, (void *)otmp
);
5315 #undef ROT_ICE_ADJUSTMENT
5319 register struct obj
*otmp
;
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 */
5334 discard_minvent(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
))) {
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
);
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.
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
5377 obj_extract_self(obj
)
5380 switch (obj
->where
) {
5387 extract_nobj(obj
, &obj
->ocontainer
->cobj
);
5388 container_weight(obj
->ocontainer
);
5394 extract_nobj(obj
, &obj
->ocarry
->minvent
);
5397 extract_nobj(obj
, &migrating_objs
);
5400 extract_nobj(obj
, &level
.buriedobjlist
);
5403 extract_nobj(obj
, &billobjs
);
5406 panic("obj_extract_self");
5411 /* Extract a contained indestructable object (if one exists) and return it */
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
);
5425 return indestructable
;
5428 /* Extract the given object from the chain, following nobj chain. */
5430 extract_nobj(obj
, head_ptr
)
5431 struct obj
*obj
, **head_ptr
;
5433 struct obj
*curr
, *prev
;
5436 for (prev
= (struct obj
*) 0; curr
; prev
= curr
, curr
= curr
->nobj
) {
5439 prev
->nobj
= curr
->nobj
;
5441 *head_ptr
= curr
->nobj
;
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.
5457 extract_nexthere(obj
, head_ptr
)
5458 struct obj
*obj
, **head_ptr
;
5460 struct obj
*curr
, *prev
;
5463 for (prev
= (struct obj
*) 0; curr
; prev
= curr
, curr
= curr
->nexthere
) {
5466 prev
->nexthere
= curr
->nexthere
;
5468 *head_ptr
= curr
->nexthere
;
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
)
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
;
5498 obj
->nobj
= mon
->minvent
;
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
5510 add_to_container(container
, obj
, clearinventflags
)
5511 struct obj
*container
, *obj
;
5512 boolean clearinventflags
;
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
;
5541 add_to_migration(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
;
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. */
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.
5586 if (obj
->where
!= OBJ_FREE
)
5587 panic("dealloc_obj: obj not free");
5589 /* free up any timers attached to the object */
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;
5609 #if defined(OBJ_SANITY) || defined(WIZARD)
5611 # define msgprefix ""
5613 # define msgprefix "BUG (please report): "
5616 /* Check all object lists for consistency. */
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 */
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
),
5705 fmt_ptr((void *)mon
, mon_address
),
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"
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
))] );
5725 otmp
->fakeartifact
= 1;
5730 return (struct obj
*)0;
5735 STATIC_OVL
const char *
5739 return (where
<0 || where
>=NOBJ_STATES
) ? "unknown" : obj_state_names
[where
];
5742 /* obj sanity check: check objs contained by container */
5744 check_contained(container
, mesg
)
5745 struct obj
*container
;
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 */