Enable more ways to specify monster inventory in special levels
This originated with a bug in NerfHack in which the developer specified an inventory for a quest nemesis, but neglected to include the Bell of Opening in it. Since monsters' inventory contents from makemon() were tossed out completely, this caused a situation where the Bell was deleted and the game was unwinnable. The first part of this change is guarding against that by adding mdrop_special_objs before discarding the inventory. This does create a possibility where if the programmer *does* specify a nemesis get the Bell item in their inventory, while neglecting to remove its special case generation in makemon.c, it would generate twice - but two Bells is better than none. Working on that fix led me to think about a limitation of the current sp_lev.c behavior. You could either have a monster generate with its species-typical inventory by not specifying an inventory for it, or you could have it generate with custom inventory but then have to use that to clumsily reproduce the normal inventory's complex chances and conditionals in mongets(). So the remainder of this commit implements another flag for des.monster(), keep_default_invent, that allows for more flexibility in two ways: 1. When des.monster() contains an inventory function and keep_default_invent is true, the monster will retain everything it gets from makemon() and the objects in the inventory function are in ADDITION to those. This is useful for augmenting a monster's default kit with something to make them more threatening, or just more loot. 2. When des.monster contains no inventory function and keep_default_invent is false, the monster will get NO inventory even if its species is normally supposed to. I'm not sure where exactly this would be used, but it doesn't hurt to have it available. When keep_default_invent is not specified at all, the behavior remains the same as it is now - if inventory is provided, default items are discarded, and if not, they are kept.
This commit is contained in:
committed by
Pasi Kallinen
parent
171d48c881
commit
2d4f9893ad
@@ -74,6 +74,11 @@ enum lvlinit_types {
|
||||
#define NO_LOC_WARN 0x20 /* no complaints and set x & y to -1, if no loc */
|
||||
#define SPACELOC 0x40 /* like DRY, but accepts furniture too */
|
||||
|
||||
/* has_invent flags */
|
||||
#define NO_INVENT 0 /* monster doesn't get any invent */
|
||||
#define CUSTOM_INVENT 0x01 /* monster gets items specified in lua */
|
||||
#define DEFAULT_INVENT 0x02 /* monster gets items from makemon() */
|
||||
|
||||
#define SP_COORD_X(l) (l & 0xff)
|
||||
#define SP_COORD_Y(l) ((l >> 16) & 0xff)
|
||||
#define SP_COORD_PACK(x, y) (((x) & 0xff) + (((y) & 0xff) << 16))
|
||||
|
||||
Reference in New Issue
Block a user