Refactor mongets to return the object it creates
The impetus for this was to avoid ugly constructions such as the one below (none of which currently appear in vanilla NetHack): mongets(mtmp, LONG_SWORD); struct obj* sword = m_carrying(mtmp, LONG_SWORD); if (sword) /* do thing to sword */ Most cases where mongets is used discard the returned value (which used to be the created object's spe); the only places that do use it are the series of statements that give various human monsters armor and prevent them from getting too much armor. These statements included hardcoded constants representing the base AC of the armor, which would have caused discrepancies if armor's base AC were ever changed. With mongets now returning a pointer to the created object, it can just be passed into ARM_BONUS instead, which covers both the base AC and the enchantment. (It will also cover erosion, if anyone ever decides that armor should rarely generate as pre-eroded). The overall algorithm is not changed by this; human monsters should receive armor with the same probabilities as before.
This commit is contained in:
committed by
Pasi Kallinen
parent
a9dd7a5a46
commit
4b7f34f5f8
@@ -1227,7 +1227,7 @@ E struct permonst *FDECL(mkclass_aligned, (CHAR_P, int, ALIGNTYP_P));
|
||||
E int FDECL(mkclass_poly, (int));
|
||||
E int FDECL(adj_lev, (struct permonst *));
|
||||
E struct permonst *FDECL(grow_up, (struct monst *, struct monst *));
|
||||
E int FDECL(mongets, (struct monst *, int));
|
||||
E struct obj* FDECL(mongets, (struct monst *, int));
|
||||
E int FDECL(golemhp, (int));
|
||||
E boolean FDECL(peace_minded, (struct permonst *));
|
||||
E void FDECL(set_malign, (struct monst *));
|
||||
|
||||
Reference in New Issue
Block a user