MCPcopy Index your code
hub / github.com/NetHack/NetHack / mkgold

Function mkgold

src/mkobj.c:2002–2020  ·  view source on GitHub ↗

create a stack of N gold pieces; never returns Null */

Source from the content-addressed store, hash-verified

2000
2001/* create a stack of N gold pieces; never returns Null */
2002struct obj *
2003mkgold(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 */

Callers 10

fill_zooFunction · 0.85
make_corpseFunction · 0.85
kick_nondoorFunction · 0.85
fill_ordinary_roomFunction · 0.85
populate_mazeFunction · 0.85
create_objectFunction · 0.85
fill_special_roomFunction · 0.85
fill_empty_mazeFunction · 0.85
lspo_goldFunction · 0.85
dipfountainFunction · 0.85

Calls 6

g_atFunction · 0.85
rndFunction · 0.85
depthFunction · 0.85
level_difficultyFunction · 0.85
mksobj_atFunction · 0.85
weightFunction · 0.85

Tested by

no test coverage detected