create a stack of N gold pieces; never returns Null */
| 2000 | |
| 2001 | /* create a stack of N gold pieces; never returns Null */ |
| 2002 | struct obj * |
| 2003 | mkgold(long amount, coordxy x, coordxy y) |
| 2004 | { |
| 2005 | struct obj *gold = g_at(x, y); |
| 2006 | |
| 2007 | if (amount <= 0L) { |
| 2008 | long mul = rnd(30 / max(12-depth(&u.uz), 2)); |
| 2009 | |
| 2010 | amount = (long) (1 + rnd(level_difficulty() + 2) * mul); |
| 2011 | } |
| 2012 | if (gold) { |
| 2013 | gold->quan += amount; |
| 2014 | } else { |
| 2015 | gold = mksobj_at(GOLD_PIECE, x, y, TRUE, FALSE); |
| 2016 | gold->quan = amount; |
| 2017 | } |
| 2018 | gold->owt = weight(gold); |
| 2019 | return gold; |
| 2020 | } |
| 2021 | |
| 2022 | /* potions of oil use their obj->age field differently from other potions |
| 2023 | so changing potion type to or from oil needs to have that fixed up */ |
no test coverage detected