Difference between revisions of "Modding:level blueprint (0.9.9.7)"

From DoomRL Wiki

Jump to: navigation, search
(Created page)
 
(updated for 0995 (there MIGHT be some beta functions, sorry about that))
Line 95: Line 95:
 
   |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 
   |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 
   |c2=padding:0px 2px;
 
   |c2=padding:0px 2px;
   |[[Modding:Being|Being]]|Level.[[#level_get_being|get_being]]('''integer''' index)
+
   |value|Level.[[#level_property_get|property_get]]('''string''' property)  
  |[[Modding:Item|Item]]|Level.[[#level_get_item|get_item]]('''integer''' index)
+
   |void|Level.[[#level_property_set|property_set]]('''string''' property, '''value''' value)  
  |[[Modding:Being|Being]]|Level.[[#level_get_being_by_uid|get_being_by_uid]]('''integer''' uid)
+
  |[[Modding:Item|Item]]|Level.[[#level_get_item_by_uid|get_item_by_uid]]('''integer''' uid)
+
  |[[Modding:Being|Being]]|Level.[[#level_drop_being|drop_being]]([[Modding:Being|Being ID]] bid, [[Modding:Coord|Coord]] position)
+
  |[[Modding:Item|Item]]|Level.[[#level_drop_item|drop_item]]([[Modding:Item|Item ID]] iid, [[Modding:Coord|Coord]] position)  
+
   |void|Level.[[#level_player|player]]('''integer''' x, '''integer''' y)  
+
 
   |boolean|Level.[[#level_flag_get|flag_get]]([[Modding:Constants#Level Flags|Level Flag]] flag)  
 
   |boolean|Level.[[#level_flag_get|flag_get]]([[Modding:Constants#Level Flags|Level Flag]] flag)  
 
   |void|Level.[[#level_flag_set|flag_set]]([[Modding:Constants#Level Flags|Level Flag]] flag, '''boolean''' value)  
 
   |void|Level.[[#level_flag_set|flag_set]]([[Modding:Constants#Level Flags|Level Flag]] flag, '''boolean''' value)  
 
   |boolean|Level.[[#level_light_flag_get|light_flag_get]]([[Modding:Coord|Coord]] position, [[Modding:Constants#LightFlag|LightFlag]] flag)  
 
   |boolean|Level.[[#level_light_flag_get|light_flag_get]]([[Modding:Coord|Coord]] position, [[Modding:Constants#LightFlag|LightFlag]] flag)  
 
   |void|Level.[[#level_light_flag_set|light_flag_set]]([[Modding:Coord|Coord]] position, [[Modding:Constants#LightFlag|LightFlag]] flag, '''boolean''' value)  
 
   |void|Level.[[#level_light_flag_set|light_flag_set]]([[Modding:Coord|Coord]] position, [[Modding:Constants#LightFlag|LightFlag]] flag, '''boolean''' value)  
   |integer|Level.[[#level_hp_get|hp_get]]([[Modding:Coord|Coord]] position)  
+
   |value|Level.[[#level_roll_weight|roll_weight]]('''list''' list, '''integer''' sum)
   |void|Level.[[#level_hp_set|hp_set]]([[Modding:Coord|Coord]] position, '''integer''' value)  
+
  |integer|Level.[[#level_weight_list_sum|weight_list_sum]]('''list''' list)  
 +
   |void|Level.[[#level_place_tile|place_tile]]('''table''' translation, '''string''' tile, '''integer''' x, '''integer''' y)
 +
  |void|Level.[[#level_player|player]]('''integer''' x, '''integer''' y)
 +
  |integer|Level.[[#level_result|result]]('''integer''' value)
 +
  |boolean|Level.[[#level_eye_contact|eye_contact]]([[Modding:Coord|Coord]] c1, [[Modding:Coord|Coord]] c2)
 
   |boolean|Level.[[#level_is_visible|is_visible]]([[Modding:Coord|Coord]] position)  
 
   |boolean|Level.[[#level_is_visible|is_visible]]([[Modding:Coord|Coord]] position)  
 
   |void|Level.[[#level_nuke|nuke]]()  
 
   |void|Level.[[#level_nuke|nuke]]()  
 
   |void|Level.[[#level_explosion|explosion]]([[Modding:Coord|Coord]] position, '''integer''' radius, '''integer''' delay, '''integer''' damage_dice, '''integer''' damage_sides, [[Modding:Constants#Colors|Color]] color, '''Sound ID''' sound, [[Modding:Constants#DamageType|DamageType]] damagetype, [[Modding:Constants#ExplosionFlag|ExplosionFlag]] '''list''' flags, [[Modding:Cell|Cell ID]] content)  
 
   |void|Level.[[#level_explosion|explosion]]([[Modding:Coord|Coord]] position, '''integer''' radius, '''integer''' delay, '''integer''' damage_dice, '''integer''' damage_sides, [[Modding:Constants#Colors|Color]] color, '''Sound ID''' sound, [[Modding:Constants#DamageType|DamageType]] damagetype, [[Modding:Constants#ExplosionFlag|ExplosionFlag]] '''list''' flags, [[Modding:Cell|Cell ID]] content)  
   |void|Level.[[#level_clear_item|clear_item]]([[Modding:Coord|Coord]] position)  
+
   ||'''Cell-specific functions'''
   |void|Level.[[#level_clear_being|clear_being]]([[Modding:Coord|Coord]] position)  
+
  |integer|Level.[[#level_hp_get|hp_get]]([[Modding:Coord|Coord]] position)  
   |void|Level.[[#level_property_set|property_set]]('''string''' property, '''value''' value)  
+
   |void|Level.[[#level_hp_set|hp_set]]([[Modding:Coord|Coord]] position, '''integer''' value)  
   |value|Level.[[#level_property_get|property_get]]('''string''' property)
+
   |boolean|Level.[[#level_is_corpse|is_corpse]]([[Modding:Coord|Coord]] position)  
}}
+
   |boolean|Level.[[#level_scan|scan]]([[Modding:Area|Area]] scan_area, [[Modding:Cell|Cell ID]] good)
{{Table2Col
+
  |es=background: #333;
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
+
  |c2=padding:0px 2px;
+
 
   |void|Level.[[#level_fill|fill]]([[Modding:Cell|Cell ID]] cell, [[Modding:Area|Area]] fill_area)  
 
   |void|Level.[[#level_fill|fill]]([[Modding:Cell|Cell ID]] cell, [[Modding:Area|Area]] fill_area)  
   |[[Modding:Being|Being]]iterator|Level.[[#level_beings|beings]]()  
+
  |void|Level.[[#level_flood|flood]]([[Modding:Cell|Cell ID]] tile, [[Modding:Area|Area]] flood_area)
   |[[Modding:Item|Item]]iterator|Level.[[#level_items|items]]()  
+
  |void|Level.[[#level_scatter|scatter]]([[Modding:Area|Area]] scatter_area, [[Modding:Cell|Cell ID]] good, [[Modding:Cell|Cell ID]] fill, '''integer''' count)
   |value|Level.[[#level_roll_weight|roll_weight]]('''list''' list, '''integer''' sum)  
+
  |void|Level.[[#level_scatter_put|scatter_put]]([[Modding:Area|Area]] scatter_area, '''table''' translation, '''string''' tile, [[Modding:Cell|Cell ID]] good, '''integer''' count)
   |integer|Level.[[#level_weight_list_sum|weight_list_sum]]('''list''' list)  
+
  |boolean|Level.[[#level_push_cell|push_cell]]([[Modding:Coord|Coord]] c, [[Modding:Coord|Coord]] target, '''boolean''' quiet)
 +
  ||'''Being-specific functions'''
 +
   |[[Modding:Being|Being]]|Level.[[#level_get_being|get_being]]('''integer''' index)  
 +
   |[[Modding:Being|Being]]|Level.[[#level_get_being_by_uid|get_being_by_uid]]('''integer''' uid)  
 +
   |[[Modding:Being|Being]]|Level.[[#level_drop_being|drop_being]]([[Modding:Being|Being ID]] bid, [[Modding:Coord|Coord]] position)
 +
  |void|Level.[[#level_drop_being_ext|drop_being_ext]]('''table''' being, [[Modding:Coord|Coord]] position)
 +
  |[[Modding:Being|Being]]|Level.[[#level_summon|summon]]([[Modding:Being|Being ID]] bid, '''integer''' count)  
 +
   |[[Modding:Being|Being]]|Level.[[#level_area_summon|area_summon]]([[Modding:Area|Area]] where, [[Modding:Being|Being ID]] bid, '''integer''' count)
 +
  |void|Level.[[#level_clear_being|clear_being]]([[Modding:Coord|Coord]] position)  
 
   |list, integer|Level.[[#level_get_being_list|get_being_list]]()  
 
   |list, integer|Level.[[#level_get_being_list|get_being_list]]()  
  |list, integer|Level.[[#level_get_item_list|get_item_list]]('''integer''' max_level, '''integer''' unique_mult)
 
  |void|Level.[[#level_flood_monsters|flood_monsters]]('''integer''' amount)
 
  |void|Level.[[#level_flood_monster|flood_monster]]([[Modding:Being|Being ID]] bid, '''integer''' amount)
 
  |void|Level.[[#level_flood_items|flood_items]]('''integer''' amount)
 
 
   |[[Modding:Being|Being ID]]|Level.[[#level_random_being|random_being]]()  
 
   |[[Modding:Being|Being ID]]|Level.[[#level_random_being|random_being]]()  
 +
  |void|Level.[[#level_flood_monster|flood_monster]]([[Modding:Being|Being ID]] bid, '''integer''' amount)
 +
  |void|Level.[[#level_flood_monsters|flood_monsters]]('''integer''' amount)
 +
  |[[Modding:Being|Being]]iterator|Level.[[#level_beings|beings]]()
 +
  |[[Modding:Being|Being]]iterator|Level.[[#level_beings_in_range|beings_in_range]]([[Modding:Coord|Coord]] position, '''integer''' range)
 +
  ||Item-specific functions
 +
  |[[Modding:Item|Item]]|Level.[[#level_get_item|get_item]]('''integer''' index)
 +
  |[[Modding:Item|Item]]|Level.[[#level_get_item_by_uid|get_item_by_uid]]('''integer''' uid)
 +
  |[[Modding:Item|Item]]|Level.[[#level_drop_item|drop_item]]([[Modding:Item|Item ID]] iid, [[Modding:Coord|Coord]] position)
 +
  |void|Level.[[#level_drop_item_ext|drop_item_ext]]('''table''' item, [[Modding:Coord|Coord]] position)
 +
  |[[Modding:Item|Item]]|Level.[[#level_drop|drop]]([[Modding:Item|Item ID]] iid, '''integer''' count)
 +
  |[[Modding:Item|Item]]|Level.[[#level_area_drop|area_drop]]([[Modding:Area|Area]] where, [[Modding:Item|Item ID]] iid, '''integer''' count)
 +
  |void|Level.[[#level_try_destroy_item|try_destroy_item]]([[Modding:Coord|Coord]] c)
 +
  |list, integer|Level.[[#level_get_item_list|get_item_list]]('''integer''' max_level, '''integer''' unique_mult)
 
   |[[Modding:Item|Item ID]]|Level.[[#level_roll_item_type|roll_item_type]]([[Modding:Constants#ItemType|ItemType]] '''list''' itypes, '''integer''' max_level, '''integer''' unique_mod)  
 
   |[[Modding:Item|Item ID]]|Level.[[#level_roll_item_type|roll_item_type]]([[Modding:Constants#ItemType|ItemType]] '''list''' itypes, '''integer''' max_level, '''integer''' unique_mod)  
 
   |[[Modding:Item|Item ID]]|Level.[[#level_roll_item|roll_item]]('''integer''' max_level, '''integer''' unique_mod)  
 
   |[[Modding:Item|Item ID]]|Level.[[#level_roll_item|roll_item]]('''integer''' max_level, '''integer''' unique_mod)  
   |[[Modding:Being|Being]]|Level.[[#level_summon|summon]]([[Modding:Being|Being ID]] bid, '''integer''' count)  
+
   |void|Level.[[#level_flood_items|flood_items]]('''integer''' amount)  
   |[[Modding:Item|Item]]|Level.[[#level_drop|drop]]([[Modding:Item|Item ID]] iid, '''integer''' count)
+
   |[[Modding:Item|Item]]iterator|Level.[[#level_items|items]]()  
  |[[Modding:Being|Being]]|Level.[[#level_area_summon|area_summon]]([[Modding:Area|Area]] where, [[Modding:Being|Being ID]] bid, '''integer''' count)  
+
   |[[Modding:Item|Item]]iterator|Level.[[#level_items_in_range|items_in_range]]([[Modding:Coord|Coord]] position, '''integer''' range)  
   |[[Modding:Item|Item]]|Level.[[#level_area_drop|area_drop]]([[Modding:Area|Area]] where, [[Modding:Item|Item ID]] iid, '''integer''' count)
+
  |void|Level.[[#level_scatter|scatter]]([[Modding:Area|Area]] scatter_area, [[Modding:Cell|Cell ID]] good, [[Modding:Cell|Cell ID]] fill, '''integer''' count)
+
  |void|Level.[[#level_scatter_put|scatter_put]]([[Modding:Area|Area]] scatter_area, '''table''' translation, '''string''' tile, [[Modding:Cell|Cell ID]] good, '''integer''' count)
+
  |boolean|Level.[[#level_scan|scan]]([[Modding:Area|Area]] scan_area, [[Modding:Cell|Cell ID]] good)
+
}}
+
{{Table2Col
+
  |es=background: #333;
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
+
  |c2=padding:0px 2px;
+
  |integer|Level.[[#level_result|result]]('''integer''' value)
+
  |void|Level.[[#level_drop_item_ext|drop_item_ext]]('''table''' item, [[Modding:Coord|Coord]] position)
+
  |void|Level.[[#level_drop_being_ext|drop_being_ext]]('''table''' being, [[Modding:Coord|Coord]] position)
+
  |void|Level.[[#level_flood|flood]]([[Modding:Cell|Cell ID]] tile, [[Modding:Area|Area]] flood_area)
+
  |void|Level.[[#level_place_tile|place_tile]]('''table''' translation, '''string''' tile, '''integer''' x, '''integer''' y)
+
  |boolean|Level.[[#level_is_corpse|is_corpse]]([[Modding:Coord|Coord]] position)  
+
 
  }}
 
  }}
 
|}
 
|}
  
{{Anchor|level_get_being}}
+
{{Anchor|level_property_get}}
;Level.get_being('''integer''' index) → [[Modding:Being|Being]]
+
;Level.property_get('''string''' property) → '''value'''
:Returns the being at the given index in the sparse being array. A being's index won't change as long as it is in the array.
+
:Gets the value of the given level property. It is preferred to use the Lua dot indexing syntax instead.
 
----
 
----
{{Anchor|level_get_item}}
+
{{Anchor|level_property_set}}
;Level.get_item('''integer''' index) → [[Modding:Item|Item]]
+
;Level.property_set('''string''' property, '''value''' value)  
:Returns the item at the given index in the sparse item array. An item's index won't change as long as it is in the array.
+
:Sets the given level property to the given value. It is preferred to use the Lua dot indexing syntax instead.
----
+
{{Anchor|level_get_being_by_uid}}
+
;Level.get_being_by_uid('''integer''' uid) → [[Modding:Being|Being]]
+
:Returns the being with the given uid, or nil if that being doesn't exist or has been removed from the map.
+
----
+
{{Anchor|level_get_item_by_uid}}
+
;Level.get_item_by_uid('''integer''' uid) → [[Modding:Item|Item]]
+
:Returns the item with the given uid, or nil if that item doesn't exist or has been removed from the map.
+
----
+
{{Anchor|level_drop_being}}
+
;Level.drop_being([[Modding:Being|Being ID]] bid, [[Modding:Coord|Coord]] position) → [[Modding:Being|Being]]
+
:Drops a newly created being in the given position. ''bid'' can also be an actual being object, although this should not be used for beings that are already on the map. If the position is occupied, the being will be dropped nearby. The dropped being is returned. If the function fails, nil is returned.
+
----
+
{{Anchor|level_drop_item}}
+
;Level.drop_item([[Modding:Item|Item ID]] iid, [[Modding:Coord|Coord]] position) → [[Modding:Item|Item]]
+
:Drops a newly created item in the given position. ''iid'' can also be an actual item object, although this should not be used for items that are already on the map. If the position is occupied, the item will be dropped nearby. The dropped item is returned. If the function fails, nil is returned.
+
----
+
{{Anchor|level_player}}
+
;Level.player('''integer''' x, '''integer''' y)
+
:Sets the initial position of the player for a special or scripted level. This should be called in the Create hook; after that it has no meaningful effect.
+
 
----
 
----
 
{{Anchor|level_flag_get}}
 
{{Anchor|level_flag_get}}
Line 203: Line 180:
 
:Sets the value of the given light flag at the given position. For the syntax without a position, the light flag will be set at every position on the map.  
 
:Sets the value of the given light flag at the given position. For the syntax without a position, the light flag will be set at every position on the map.  
 
----
 
----
{{Anchor|level_hp_get}}
+
{{Anchor|level_roll_weight}}
;Level.hp_get([[Modding:Coord|Coord]] position) → '''integer'''
+
;Level.roll_weight('''list''' list, '''integer''' sum) → '''value'''
;Level.hp[[[Modding:Coord|Coord]] position] → '''integer'''
+
:Randomly chooses an item from the list according to the weight property of the list items. Sum must be the sum of the weights of all the list items.
:Gets the current hp of the cell at the given position.  
+
 
----
 
----
{{Anchor|level_hp_set}}
+
{{Anchor|level_weight_list_sum}}
;Level.hp_set([[Modding:Coord|Coord]] position, '''integer''' value)  
+
;Level.weight_list_sum('''list''' list) → '''integer'''
;Level.hp[[[Modding:Coord|Coord]] position] = '''integer''' value
+
:Returns the sum of the weight properties of all the items in the list.
:Sets the current hp of the cell at the given position. Setting hp to 0 won't destroy a cell.
+
----
 +
{{Anchor|level_place_tile}}
 +
;Level.place_tile('''table''' translation, '''string''' tile, '''integer''' x, '''integer''' y)
 +
:Places the map tile given by ''translation'' and ''tile'' on the map at the position given by ''x'' and ''y''. ''translation'' should be a table that maps single character strings to either cell ids, or to tables. These tables have their first array element be a cell id, but they may also contain a being and''or'' item key that is mapped to a being or item id respectively. Level.drop_being_ext and Level.drop_item_ext syntax is allowed. ''tile'' should be a string of characters that are defined in ''translation''. Line breaks correspond to line breaks on the map.
 +
----
 +
{{Anchor|level_player}}
 +
;Level.player('''integer''' x, '''integer''' y)  
 +
:Sets the initial position of the player for a special or scripted level. This should be called in the Create hook; after that it has no meaningful effect.
 +
----
 +
{{Anchor|level_result}}
 +
;Level.result('''integer''' value) → '''integer'''
 +
:If ''value'' is given, updates the level's status and returns nil. If ''value'' is omitted, returns the current status.
 +
----
 +
{{Anchor|level_eye_contact}}
 +
;Level.eye_contact([[Modding:Coord|Coord]] c1, [[Modding:Coord|Coord]] c2) → '''boolean'''
 +
:Determines whether or not there is a line-of-sight path between '''c1''' and '''c2'''. This calculation ignores light flags (such that two beings can have eye contact even if they aren't visible to each other).
 
----
 
----
 
{{Anchor|level_is_visible}}
 
{{Anchor|level_is_visible}}
Line 225: Line 216:
 
:Creates an [[explosions|explosion]] centered at the given position with the given parameters. ''radius'' is the size of the explosion. ''delay'' is the delay in milliseconds between animation frames (typically this is around 40). ''damage_dice'' and ''damage_sides'' determine the damage roll for the explosion. For a no-damage explosion, both should be 0. The default damage type is fire. ''content'' determines the cell that is randomly created wherever the explosion does enough damage. By default, there are no flags and there is no content. Only some colors are supported, and these are automatically translated into 3 color combinations used by the explosion animation. The supported colors are LIGHTBLUE, BLUE, MAGENTA, GREEN, LIGHTRED, YELLOW, and the default RED.
 
:Creates an [[explosions|explosion]] centered at the given position with the given parameters. ''radius'' is the size of the explosion. ''delay'' is the delay in milliseconds between animation frames (typically this is around 40). ''damage_dice'' and ''damage_sides'' determine the damage roll for the explosion. For a no-damage explosion, both should be 0. The default damage type is fire. ''content'' determines the cell that is randomly created wherever the explosion does enough damage. By default, there are no flags and there is no content. Only some colors are supported, and these are automatically translated into 3 color combinations used by the explosion animation. The supported colors are LIGHTBLUE, BLUE, MAGENTA, GREEN, LIGHTRED, YELLOW, and the default RED.
 
----
 
----
{{Anchor|level_clear_item}}
+
{{Anchor|level_hp_get}}
;Level.clear_item([[Modding:Coord|Coord]] position)  
+
;Level.hp_get([[Modding:Coord|Coord]] position) → '''integer'''
;Level.clear_item('''integer''' index)
+
;Level.hp[[[Modding:Coord|Coord]] position] → '''integer'''
:Removes an item from the map at the given position, or from the given index in the item array.
+
:Gets the current hp of the cell at the given position.  
 
----
 
----
{{Anchor|level_clear_being}}
+
{{Anchor|level_hp_set}}
;Level.clear_being([[Modding:Coord|Coord]] position)  
+
;Level.hp_set([[Modding:Coord|Coord]] position, '''integer''' value)  
;Level.clear_being('''integer''' index)
+
;Level.hp[[[Modding:Coord|Coord]] position] = '''integer''' value
:Removes an item from the map at the given position, or from the given index in the item array.
+
:Sets the current hp of the cell at the given position. Setting hp to 0 won't destroy a cell.
 
----
 
----
{{Anchor|level_property_set}}
+
{{Anchor|level_is_corpse}}
;Level.property_set('''string''' property, '''value''' value)
+
;Level.is_corpse([[Modding:Coord|Coord]] position) → '''boolean'''
:Sets the given level property to the given value. It is preferred to use the Lua dot indexing syntax instead.
+
:Determines whether the given position has a corpse in it. This counts the cell with id "corpse" as a corpse even though it otherwise isn't a corpse as far as the engine is concerned.
 
----
 
----
{{Anchor|level_property_get}}
+
{{Anchor|level_scan}}
;Level.property_get('''string''' property) → '''value'''
+
;Level.scan([[Modding:Area|Area]] scan_area, [[Modding:Cell|Cell ID]] good) → '''boolean'''
:Gets the value of the given level property. It is preferred to use the Lua dot indexing syntax instead.
+
:Determines if every cell in ''scan_area'' is ''good''.
 
----
 
----
 
{{Anchor|level_fill}}
 
{{Anchor|level_fill}}
Line 247: Line 238:
 
:Sets every cell in the given area to the area. ''fill_area'' is optional; it defaults to the full map.
 
:Sets every cell in the given area to the area. ''fill_area'' is optional; it defaults to the full map.
 
----
 
----
{{Anchor|level_beings}}
+
{{Anchor|level_flood}}
;Level.beings() → [[Modding:Being|Being]] '''iterator'''
+
;Level.flood([[Modding:Cell|Cell ID]] tile, [[Modding:Area|Area]] flood_area)
:Gives an iterator over all beings in the level.
+
:Changes CELLSET_FLOORS and CF_LIQUID tiles in the area to ''tile''. If ''tile'' has CF_HAZARD, then it will destroy items.
 
----
 
----
{{Anchor|level_items}}
+
{{Anchor|level_scatter}}
;Level.items() → [[Modding:Item|Item]] '''iterator'''
+
;Level.scatter([[Modding:Area|Area]] scatter_area, [[Modding:Cell|Cell ID]] good, [[Modding:Cell|Cell ID]] fill, '''integer''' count)
:Gives an iterator over all items in the level.
+
:Chooses ''count'' random tiles in ''scatter_area'' (possibly with duplicates) and sets any chosen cells that are ''good'' to ''fill''.
 
----
 
----
{{Anchor|level_roll_weight}}
+
{{Anchor|level_scatter_put}}
;Level.roll_weight('''list''' list, '''integer''' sum) → '''value'''
+
;Level.scatter_put([[Modding:Area|Area]] scatter_area, '''table''' translation, '''string''' tile, [[Modding:Cell|Cell ID]] good, '''integer''' count)
:Randomly chooses an item from the list according to the weight property of the list items. Sum must be the sum of the weights of all the list items.
+
:Chooses ''count'' random subareas with upper-left corner in ''scatter_area'' of the size appropriate of ''tile'' (using the first line length and number of lines to define a rectangular area). There may be duplicates or overlaps. For each subarea, if the area is already filled with ''good'', then it is replaced with ''tile'' (according to ''translation''). See Level.place_tile for the semantics of ''translation'' and ''tile''.  
 
----
 
----
{{Anchor|level_weight_list_sum}}
+
{{Anchor|level_push_cell}}
;Level.weight_list_sum('''list''' list) → '''integer'''
+
;Level.push_cell([[Modding:Coord|Coord]] c, [[Modding:Coord|Coord]] target, '''boolean''' quiet) → '''boolean'''
:Returns the sum of the weight properties of all the items in the list.
+
:Swaps the content of the cells located in '''c''' and '''target''': this will only occur successfully if '''target''' is a part of CELLSET_FLOORS. If '''target''' has the CF_HAZARD flag, the cell on '''c''' activates its OnDestroy hook. '''quiet''', when set to true, includes messages (mostly specific to barrels, the only object pushed in the base game).
 +
----
 +
{{Anchor|level_get_being}}
 +
;Level.get_being('''integer''' index) → [[Modding:Being|Being]]
 +
:Returns the being at the given index in the sparse being array. A being's index won't change as long as it is in the array.
 +
----
 +
{{Anchor|level_get_being_by_uid}}
 +
;Level.get_being_by_uid('''integer''' uid) → [[Modding:Being|Being]]
 +
:Returns the being with the given uid, or nil if that being doesn't exist or has been removed from the map.
 +
----
 +
{{Anchor|level_drop_being}}
 +
;Level.drop_being([[Modding:Being|Being ID]] bid, [[Modding:Coord|Coord]] position) → [[Modding:Being|Being]]
 +
:Drops a newly created being in the given position. ''bid'' can also be an actual being object, although this should not be used for beings that are already on the map. If the position is occupied, the being will be dropped nearby. The dropped being is returned. If the function fails, nil is returned.
 +
----
 +
{{Anchor|level_drop_being_ext}}
 +
;Level.drop_being_ext('''table''' being, [[Modding:Coord|Coord]] position)
 +
:As Level.drop_being, except additional values are accetable for ''being'' as Level.drop_item_ext.
 +
----
 +
{{Anchor|level_summon}}
 +
;Level.summon([[Modding:Being|Being ID]] bid, '''integer''' count) → [[Modding:Being|Being]]
 +
:Creates new beings of the type given by ''bid'' and amount given by ''count'' and scatters them around the map. The last dropped being (if any) is returned. ''count'' is optional and defaults to 1.
 +
----
 +
{{Anchor|level_area_summon}}
 +
;Level.area_summon([[Modding:Area|Area]] where, [[Modding:Being|Being ID]] bid, '''integer''' count) → [[Modding:Being|Being]]
 +
:As Level.summon, but all the summoned beings are randomly placed in ''where'' rather than scattered across the whole map.
 +
----
 +
{{Anchor|level_clear_being}}
 +
;Level.clear_being([[Modding:Coord|Coord]] position)
 +
;Level.clear_being('''integer''' index)
 +
:Removes an item from the map at the given position, or from the given index in the item array.
 
----
 
----
 
{{Anchor|level_get_being_list}}
 
{{Anchor|level_get_being_list}}
 
;Level.get_being_list() → '''list''', '''integer'''
 
;Level.get_being_list() → '''list''', '''integer'''
:Returns the list and sum (ready to be used with Level.roll_weight) for beings and beings groups according to Level.danger_level and DIFFICULTY. The result is cached.
+
:Returns the list and sum (ready to be used with [[#level_roll_weight|Level.roll_weight]]) for beings and beings groups according to Level.danger_level and DIFFICULTY. The result is cached.
 
----
 
----
{{Anchor|level_get_item_list}}
+
{{Anchor|level_random_being}}
;Level.get_item_list('''integer''' max_level, '''integer''' unique_mult) → '''list''', '''integer'''
+
;Level.random_being() → [[Modding:Being|Being ID]]
:Returns the list and sum (ready to be used with Level.roll_weight) for items according to ''max_level'', and ''unique_mult''. ''max_level'' defaults to Level.danger_level, and is used to determine which items fall in the proper level range. Unique items' weights are multiplied by ''unique_mult'' (which defaults to 1). The result is cached.
+
:Returns a random being chosen according to weights from the current level's list. This will never choose a group. The returned id is always a string id.
 +
----
 +
{{Anchor|level_flood_monster}}
 +
;Level.flood_monster([[Modding:Being|Being ID]] bid, '''integer''' amount)
 +
:Add the given monster type to the level in an amount specified by the total danger value ''amount'' (so it scales appropriately with Level.flood_monsters).
 
----
 
----
 
{{Anchor|level_flood_monsters}}
 
{{Anchor|level_flood_monsters}}
Line 275: Line 299:
 
:Adds monsters to the level using the normal algorithm for random levels. The ''amount'' is a total danger value such as a value returned by Generator.being_weight.
 
:Adds monsters to the level using the normal algorithm for random levels. The ''amount'' is a total danger value such as a value returned by Generator.being_weight.
 
----
 
----
{{Anchor|level_flood_monster}}
+
{{Anchor|level_beings}}
;Level.flood_monster([[Modding:Being|Being ID]] bid, '''integer''' amount)
+
;Level.beings() → [[Modding:Being|Being]] '''iterator'''
:Add the given monster type to the level in an amount specified by the total danger value ''amount'' (so it scales appropriately with Level.flood_monsters).
+
:Gives an iterator over all beings in the level.
 
----
 
----
{{Anchor|level_flood_items}}
+
{{Anchor|level_beings_in_range}}
;Level.flood_items('''integer''' amount)  
+
;Level.beings_in_range([[Modding:Coord|Coord]] position, '''integer''' range) → [[Modding:Being|Being]]'''iterator'''
:Adds items to the level according to the normal algorithm for random levels (not counting special features). The number of items is given by ''amount''.
+
:Gives an iterator over all beings within '''range''' units of [[distance]] from '''position''' in the level.
 
----
 
----
{{Anchor|level_random_being}}
+
{{Anchor|level_get_item}}
;Level.random_being() → [[Modding:Being|Being ID]]
+
;Level.get_item('''integer''' index) → [[Modding:Item|Item]]
:Returns a random being chosen according to weights from the current level's list. This will never choose a group. The returned id is always a string id.
+
:Returns the item at the given index in the sparse item array. An item's index won't change as long as it is in the array.
 
----
 
----
{{Anchor|level_roll_item_type}}
+
{{Anchor|level_get_item_by_uid}}
;Level.roll_item_type([[Modding:Constants#ItemType|ItemType]] '''list''' itypes, '''integer''' max_level, '''integer''' unique_mod) → [[Modding:Item|Item ID]]
+
;Level.get_item_by_uid('''integer''' uid) → [[Modding:Item|Item]]
:Returns a random item chosen from among the given item types according to weights from the list specified by ''max_level'' and ''unique_mod''. The returned id is always a string id.
+
:Returns the item with the given uid, or nil if that item doesn't exist or has been removed from the map.
 
----
 
----
{{Anchor|level_roll_item}}
+
{{Anchor|level_drop_item}}
;Level.roll_item('''integer''' max_level, '''integer''' unique_mod) → [[Modding:Item|Item ID]]
+
;Level.drop_item([[Modding:Item|Item ID]] iid, [[Modding:Coord|Coord]] position) → [[Modding:Item|Item]]
:As Level.roll_item_type, but the item type of the result isn't restricted.
+
:Drops a newly created item in the given position. ''iid'' can also be an actual item object, although this should not be used for items that are already on the map. If the position is occupied, the item will be dropped nearby. The dropped item is returned. If the function fails, nil is returned.
 
----
 
----
{{Anchor|level_summon}}
+
{{Anchor|level_drop_item_ext}}
;Level.summon([[Modding:Being|Being ID]] bid, '''integer''' count) → [[Modding:Being|Being]]
+
;Level.drop_item_ext('''table''' item, [[Modding:Coord|Coord]] position)
:Creates new beings of the type given by ''bid'' and amount given by ''count'' and scatters them around the map. The last dropped being (if any) is returned. ''count'' is optional and defaults to 1.
+
:As Level.drop_item, except additional values are acceptable for ''item''. If ''item'' is a table, the first list element is passed used to determine which item to drop. For other key-value pairs in the table, the property of the dropped item that corresponds to the key will be set to the value.
 
----
 
----
 
{{Anchor|level_drop}}
 
{{Anchor|level_drop}}
 
;Level.drop([[Modding:Item|Item ID]] iid, '''integer''' count) → [[Modding:Item|Item]]
 
;Level.drop([[Modding:Item|Item ID]] iid, '''integer''' count) → [[Modding:Item|Item]]
 
:Creates new items of the type given by ''iid'' and amount given by ''count'' and scatters them around the map. The last dropped item (if any) is returned. ''count'' is optional and defaults to 1.
 
:Creates new items of the type given by ''iid'' and amount given by ''count'' and scatters them around the map. The last dropped item (if any) is returned. ''count'' is optional and defaults to 1.
----
 
{{Anchor|level_area_summon}}
 
;Level.area_summon([[Modding:Area|Area]] where, [[Modding:Being|Being ID]] bid, '''integer''' count) → [[Modding:Being|Being]]
 
:As Level.summon, but all the summoned beings are randomly placed in ''where'' rather than scattered across the whole map.
 
 
----
 
----
 
{{Anchor|level_area_drop}}
 
{{Anchor|level_area_drop}}
Line 311: Line 331:
 
:As Level.drop, but all dropped items are randomly placed in ''where'' rather than scattered across the whole map.
 
:As Level.drop, but all dropped items are randomly placed in ''where'' rather than scattered across the whole map.
 
----
 
----
{{Anchor|level_scatter}}
+
{{Anchor|level_try_destroy_item}}
;Level.scatter([[Modding:Area|Area]] scatter_area, [[Modding:Cell|Cell ID]] good, [[Modding:Cell|Cell ID]] fill, '''integer''' count)  
+
;Level.try_destroy_item([[Modding:Coord|Coord]] position)
:Chooses ''count'' random tiles in ''scatter_area'' (possibly with duplicates) and sets any chosen cells that are ''good'' to ''fill''.
+
:Destroys an item at '''position''', if there is one to be found.
 
----
 
----
{{Anchor|level_scatter_put}}
+
{{Anchor|level_get_item_list}}
;Level.scatter_put([[Modding:Area|Area]] scatter_area, '''table''' translation, '''string''' tile, [[Modding:Cell|Cell ID]] good, '''integer''' count)  
+
;Level.get_item_list('''integer''' max_level, '''integer''' unique_mult) → '''list''', '''integer'''
:Chooses ''count'' random subareas with upper-left corner in ''scatter_area'' of the size appropriate of ''tile'' (using the first line length and number of lines to define a rectangular area). There may be duplicates or overlaps. For each subarea, if the area is already filled with ''good'', then it is replaced with ''tile'' (according to ''translation''). See Level.place_tile for the semantics of ''translation'' and ''tile''.  
+
:Returns the list and sum (ready to be used with [[#level_roll_weight|Level.roll_weight]]) for items according to ''max_level'', and ''unique_mult''. ''max_level'' defaults to Level.danger_level, and is used to determine which items fall in the proper level range. Unique items' weights are multiplied by ''unique_mult'' (which defaults to 1). The result is cached.
 
----
 
----
{{Anchor|level_scan}}
+
{{Anchor|level_roll_item_type}}
;Level.scan([[Modding:Area|Area]] scan_area, [[Modding:Cell|Cell ID]] good) → '''boolean'''
+
;Level.roll_item_type([[Modding:Constants#ItemType|ItemType]] '''list''' itypes, '''integer''' max_level, '''integer''' unique_mod) → [[Modding:Item|Item ID]]
:Determines if every cell in ''scan_area'' is ''good''.
+
:Returns a random item chosen from among the given item types according to weights from the list specified by ''max_level'' and ''unique_mod''. The returned id is always a string id.
 
----
 
----
{{Anchor|level_result}}
+
{{Anchor|level_roll_item}}
;Level.result('''integer''' value) → '''integer'''
+
;Level.roll_item('''integer''' max_level, '''integer''' unique_mod) → [[Modding:Item|Item ID]]
:If ''value'' is given, updates the level's status and returns nil. If ''value'' is omitted, returns the current status.
+
:As Level.roll_item_type, but the item type of the result isn't restricted.
 
----
 
----
{{Anchor|level_drop_item_ext}}
+
{{Anchor|level_flood_items}}
;Level.drop_item_ext('''table''' item, [[Modding:Coord|Coord]] position)  
+
;Level.flood_items('''integer''' amount)  
:As Level.drop_item, except additional values are acceptable for ''item''. If ''item'' is a table, the first list element is passed used to determine which item to drop. For other key-value pairs in the table, the property of the dropped item that corresponds to the key will be set to the value.
+
:Adds items to the level according to the normal algorithm for random levels (not counting special features). The number of items is given by ''amount''.
 
----
 
----
{{Anchor|level_drop_being_ext}}
+
{{Anchor|level_items}}
;Level.drop_being_ext('''table''' being, [[Modding:Coord|Coord]] position)
+
;Level.items() → [[Modding:Item|Item]] '''iterator'''
:As Level.drop_being, except additional values are accetable for ''being'' as Level.drop_item_ext.
+
:Gives an iterator over all items in the level.
 
----
 
----
{{Anchor|level_flood}}
+
{{Anchor|level_items_in_range}}
;Level.flood([[Modding:Cell|Cell ID]] tile, [[Modding:Area|Area]] flood_area)
+
;Level.items_in_range([[Modding:Coord|Coord]] position, '''integer''' range) → [[Modding:Item|Item]]'''iterator'''
:Changes CELLSET_FLOORS and CF_LIQUID tiles in the area to ''tile''. If ''tile'' has CF_HAZARD, then it will destroy items.
+
:Gives an iterator over all items within '''range''' units of [[distance]] from '''position''' in the level.
----
+
{{Anchor|level_place_tile}}
+
;Level.place_tile('''table''' translation, '''string''' tile, '''integer''' x, '''integer''' y)
+
:Places the map tile given by ''translation'' and ''tile'' on the map at the position given by ''x'' and ''y''. ''translation'' should be a table that maps single character strings to either cell ids, or to tables. These tables have their first array element be a cell id, but they may also contain a being and''or'' item key that is mapped to a being or item id respectively. Level.drop_being_ext and Level.drop_item_ext syntax is allowed. ''tile'' should be a string of characters that are defined in ''translation''. Line breaks correspond to line breaks on the map.
+
----
+
{{Anchor|level_is_corpse}}
+
;Level.is_corpse([[Modding:Coord|Coord]] position) → '''boolean'''
+
:Determines whether the given position has a corpse in it. This counts the cell with id "corpse" as a corpse even though it otherwise isn't a corpse as far as the engine is concerned.
+

Revision as of 17:02, 24 January 2012

Level objects define the properties of fixed special levels. The level API, however, is a general purpose API for manipulating the level. This is used both for map generation (along with the generator API) and for changing the level on the fly. The Level variable also has some general properties that don't necessarily correspond to special levels in particular.

Contents

Prototype

Levels prototypes are only used for special levels and scripted levels, not random levels. They are declared using the Levels function with the ID as the first argument, and a prototype table as the second argument. They are stored by ID in a global table called levels.

Level Prototype
string ID The unique identifier used by the engine for this level. Instead of being included in the table, this must be passed as the first argument to the Levels function.
string name The name displayed in the HUD.
string welcome Optional message displayed on level entry.
integer chance Optional percent chance the level will appear. Defaults to 100.
Range level Level range where the level may appear.
string entry Optional mortem history message for level entry.

Engine Hooks

Level Hooks
void Create()
void OnTick()
void OnEnter()
void OnExit()
void OnKill()
void OnKillAll()
boolean IsCompleted()

Create()
This function should create the layout of the level. It also usually sets up the initial being and item locations. The player's initial location should be set here using Level.player.

OnTick()
This is called every 0.1s of game time. This will happen many times for each of the player's moves, so be careful about putting intense calculations here.

OnEnter()
This is triggered just after the player enters the level.

OnExit()
This is triggered when the player leaves the level.

OnKill()
This hook is triggered whenever an enemy is killed.

OnKillAll()
After OnKill has triggered, if there are no enemies left on the level, the OnKillAll will be triggered. It is possible for OnKillAll to trigger again later if more enemies are spawned. By default, the "relatively safe" message is displayed.

IsCompleted() → boolean
The game calls this hook to determine if the game statistics should count the level as completed. This is only called for special levels, not scripted levels. By default, all enemies must be dead for the level to be complete.

Properties

These are properties of the global Level variable. They are changed by the engine as the player moves from level to level. For some of the read-only properties, rawset can be used to create a lua property that shadows the pascal property, tricking APIs that are implemented in lua. This is particularly useful for tricking the generator API into using a custom style.

Level
Word status This is for use by level designers. It is preferred to access it through Level.result.
string name This is the level name as displayed on the HUD.
Byte name_number This controls the "LevX" part of the level name. If zero, it won't be displayed.
Byte danger_level Level generation parameter that corresponds to depth.
Byte style The style (tile set) used by the level generation functions. This property is read-only.
string special_exit The sid of the level that red stairs lead to on the current level number. This property is read-only.
string special_name The sid of the current level prototype or the empty string for random levels. This property is read-only.
DWord item_array_size Length of the sparse array that stores all the items on the level. This property is read-only.
DWord being_array_size Length of the sparse array that stores all the beings on the level. This property is read-only.

API

Level Interface
value Level.property_get(string property)
void Level.property_set(string property, value value)
boolean Level.flag_get(Level Flag flag)
void Level.flag_set(Level Flag flag, boolean value)
boolean Level.light_flag_get(Coord position, LightFlag flag)
void Level.light_flag_set(Coord position, LightFlag flag, boolean value)
value Level.roll_weight(list list, integer sum)
integer Level.weight_list_sum(list list)
void Level.place_tile(table translation, string tile, integer x, integer y)
void Level.player(integer x, integer y)
integer Level.result(integer value)
boolean Level.eye_contact(Coord c1, Coord c2)
boolean Level.is_visible(Coord position)
void Level.nuke()
void Level.explosion(Coord position, integer radius, integer delay, integer damage_dice, integer damage_sides, Color color, Sound ID sound, DamageType damagetype, ExplosionFlag list flags, Cell ID content)
Cell-specific functions
integer Level.hp_get(Coord position)
void Level.hp_set(Coord position, integer value)
boolean Level.is_corpse(Coord position)
boolean Level.scan(Area scan_area, Cell ID good)
void Level.fill(Cell ID cell, Area fill_area)
void Level.flood(Cell ID tile, Area flood_area)
void Level.scatter(Area scatter_area, Cell ID good, Cell ID fill, integer count)
void Level.scatter_put(Area scatter_area, table translation, string tile, Cell ID good, integer count)
boolean Level.push_cell(Coord c, Coord target, boolean quiet)
Being-specific functions
Being Level.get_being(integer index)
Being Level.get_being_by_uid(integer uid)
Being Level.drop_being(Being ID bid, Coord position)
void Level.drop_being_ext(table being, Coord position)
Being Level.summon(Being ID bid, integer count)
Being Level.area_summon(Area where, Being ID bid, integer count)
void Level.clear_being(Coord position)
list, integer Level.get_being_list()
Being ID Level.random_being()
void Level.flood_monster(Being ID bid, integer amount)
void Level.flood_monsters(integer amount)
Beingiterator Level.beings()
Beingiterator Level.beings_in_range(Coord position, integer range)
Item-specific functions
Item Level.get_item(integer index)
Item Level.get_item_by_uid(integer uid)
Item Level.drop_item(Item ID iid, Coord position)
void Level.drop_item_ext(table item, Coord position)
Item Level.drop(Item ID iid, integer count)
Item Level.area_drop(Area where, Item ID iid, integer count)
void Level.try_destroy_item(Coord c)
list, integer Level.get_item_list(integer max_level, integer unique_mult)
Item ID Level.roll_item_type(ItemType list itypes, integer max_level, integer unique_mod)
Item ID Level.roll_item(integer max_level, integer unique_mod)
void Level.flood_items(integer amount)
Itemiterator Level.items()
Itemiterator Level.items_in_range(Coord position, integer range)

Level.property_get(string property) → value
Gets the value of the given level property. It is preferred to use the Lua dot indexing syntax instead.

Level.property_set(string property, value value)
Sets the given level property to the given value. It is preferred to use the Lua dot indexing syntax instead.

Level.flag_get(Level Flag flag) → boolean
Level.flags[Level Flag flag] → boolean
Determines the current state of the given level flag.

Level.flag_set(Level Flag flag, boolean value)
Level.flags[Level Flag flag] = boolean value
Sets the given level flag to the given value.

Level.light_flag_get(Coord position, LightFlag flag) → boolean
Level.light[Coord position][LightFlag flag] → boolean
Gets the value of the given light flag at the given position.

Level.light_flag_set(Coord position, LightFlag flag, boolean value)
Level.light[Coord position][LightFlag flag] = boolean value
Level.light[LightFlag flag] = boolean value
Sets the value of the given light flag at the given position. For the syntax without a position, the light flag will be set at every position on the map.

Level.roll_weight(list list, integer sum) → value
Randomly chooses an item from the list according to the weight property of the list items. Sum must be the sum of the weights of all the list items.

Level.weight_list_sum(list list) → integer
Returns the sum of the weight properties of all the items in the list.

Level.place_tile(table translation, string tile, integer x, integer y)
Places the map tile given by translation and tile on the map at the position given by x and y. translation should be a table that maps single character strings to either cell ids, or to tables. These tables have their first array element be a cell id, but they may also contain a being andor item key that is mapped to a being or item id respectively. Level.drop_being_ext and Level.drop_item_ext syntax is allowed. tile should be a string of characters that are defined in translation. Line breaks correspond to line breaks on the map.

Level.player(integer x, integer y)
Sets the initial position of the player for a special or scripted level. This should be called in the Create hook; after that it has no meaningful effect.

Level.result(integer value) → integer
If value is given, updates the level's status and returns nil. If value is omitted, returns the current status.

Level.eye_contact(Coord c1, Coord c2) → boolean
Determines whether or not there is a line-of-sight path between c1 and c2. This calculation ignores light flags (such that two beings can have eye contact even if they aren't visible to each other).

Level.is_visible(Coord position) → boolean
Determines if the given position is visible to the player.

Level.nuke()
Triggers an immediate nuclear explosion as from a thermonuclear bomb.

Level.explosion(Coord position, integer radius, integer delay, integer damage_dice, integer damage_sides, Color color, Sound ID sound, DamageType damagetype, ExplosionFlag list flags, Cell ID content)
Creates an explosion centered at the given position with the given parameters. radius is the size of the explosion. delay is the delay in milliseconds between animation frames (typically this is around 40). damage_dice and damage_sides determine the damage roll for the explosion. For a no-damage explosion, both should be 0. The default damage type is fire. content determines the cell that is randomly created wherever the explosion does enough damage. By default, there are no flags and there is no content. Only some colors are supported, and these are automatically translated into 3 color combinations used by the explosion animation. The supported colors are LIGHTBLUE, BLUE, MAGENTA, GREEN, LIGHTRED, YELLOW, and the default RED.

Level.hp_get(Coord position) → integer
Level.hp[Coord position] → integer
Gets the current hp of the cell at the given position.

Level.hp_set(Coord position, integer value)
Level.hp[Coord position] = integer value
Sets the current hp of the cell at the given position. Setting hp to 0 won't destroy a cell.

Level.is_corpse(Coord position) → boolean
Determines whether the given position has a corpse in it. This counts the cell with id "corpse" as a corpse even though it otherwise isn't a corpse as far as the engine is concerned.

Level.scan(Area scan_area, Cell ID good) → boolean
Determines if every cell in scan_area is good.

Level.fill(Cell ID cell, Area fill_area)
Sets every cell in the given area to the area. fill_area is optional; it defaults to the full map.

Level.flood(Cell ID tile, Area flood_area)
Changes CELLSET_FLOORS and CF_LIQUID tiles in the area to tile. If tile has CF_HAZARD, then it will destroy items.

Level.scatter(Area scatter_area, Cell ID good, Cell ID fill, integer count)
Chooses count random tiles in scatter_area (possibly with duplicates) and sets any chosen cells that are good to fill.

Level.scatter_put(Area scatter_area, table translation, string tile, Cell ID good, integer count)
Chooses count random subareas with upper-left corner in scatter_area of the size appropriate of tile (using the first line length and number of lines to define a rectangular area). There may be duplicates or overlaps. For each subarea, if the area is already filled with good, then it is replaced with tile (according to translation). See Level.place_tile for the semantics of translation and tile.

Level.push_cell(Coord c, Coord target, boolean quiet) → boolean
Swaps the content of the cells located in c and target: this will only occur successfully if target is a part of CELLSET_FLOORS. If target has the CF_HAZARD flag, the cell on c activates its OnDestroy hook. quiet, when set to true, includes messages (mostly specific to barrels, the only object pushed in the base game).

Level.get_being(integer index) → Being
Returns the being at the given index in the sparse being array. A being's index won't change as long as it is in the array.

Level.get_being_by_uid(integer uid) → Being
Returns the being with the given uid, or nil if that being doesn't exist or has been removed from the map.

Level.drop_being(Being ID bid, Coord position) → Being
Drops a newly created being in the given position. bid can also be an actual being object, although this should not be used for beings that are already on the map. If the position is occupied, the being will be dropped nearby. The dropped being is returned. If the function fails, nil is returned.

Level.drop_being_ext(table being, Coord position)
As Level.drop_being, except additional values are accetable for being as Level.drop_item_ext.

Level.summon(Being ID bid, integer count) → Being
Creates new beings of the type given by bid and amount given by count and scatters them around the map. The last dropped being (if any) is returned. count is optional and defaults to 1.

Level.area_summon(Area where, Being ID bid, integer count) → Being
As Level.summon, but all the summoned beings are randomly placed in where rather than scattered across the whole map.

Level.clear_being(Coord position)
Level.clear_being(integer index)
Removes an item from the map at the given position, or from the given index in the item array.

Level.get_being_list() → list, integer
Returns the list and sum (ready to be used with Level.roll_weight) for beings and beings groups according to Level.danger_level and DIFFICULTY. The result is cached.

Level.random_being() → Being ID
Returns a random being chosen according to weights from the current level's list. This will never choose a group. The returned id is always a string id.

Level.flood_monster(Being ID bid, integer amount)
Add the given monster type to the level in an amount specified by the total danger value amount (so it scales appropriately with Level.flood_monsters).

Level.flood_monsters(integer amount)
Adds monsters to the level using the normal algorithm for random levels. The amount is a total danger value such as a value returned by Generator.being_weight.

Level.beings() → Being iterator
Gives an iterator over all beings in the level.

Level.beings_in_range(Coord position, integer range) → Beingiterator
Gives an iterator over all beings within range units of distance from position in the level.

Level.get_item(integer index) → Item
Returns the item at the given index in the sparse item array. An item's index won't change as long as it is in the array.

Level.get_item_by_uid(integer uid) → Item
Returns the item with the given uid, or nil if that item doesn't exist or has been removed from the map.

Level.drop_item(Item ID iid, Coord position) → Item
Drops a newly created item in the given position. iid can also be an actual item object, although this should not be used for items that are already on the map. If the position is occupied, the item will be dropped nearby. The dropped item is returned. If the function fails, nil is returned.

Level.drop_item_ext(table item, Coord position)
As Level.drop_item, except additional values are acceptable for item. If item is a table, the first list element is passed used to determine which item to drop. For other key-value pairs in the table, the property of the dropped item that corresponds to the key will be set to the value.

Level.drop(Item ID iid, integer count) → Item
Creates new items of the type given by iid and amount given by count and scatters them around the map. The last dropped item (if any) is returned. count is optional and defaults to 1.

Level.area_drop(Area where, Item ID iid, integer count) → Item
As Level.drop, but all dropped items are randomly placed in where rather than scattered across the whole map.

Level.try_destroy_item(Coord position)
Destroys an item at position, if there is one to be found.

Level.get_item_list(integer max_level, integer unique_mult) → list, integer
Returns the list and sum (ready to be used with Level.roll_weight) for items according to max_level, and unique_mult. max_level defaults to Level.danger_level, and is used to determine which items fall in the proper level range. Unique items' weights are multiplied by unique_mult (which defaults to 1). The result is cached.

Level.roll_item_type(ItemType list itypes, integer max_level, integer unique_mod) → Item ID
Returns a random item chosen from among the given item types according to weights from the list specified by max_level and unique_mod. The returned id is always a string id.

Level.roll_item(integer max_level, integer unique_mod) → Item ID
As Level.roll_item_type, but the item type of the result isn't restricted.

Level.flood_items(integer amount)
Adds items to the level according to the normal algorithm for random levels (not counting special features). The number of items is given by amount.

Level.items() → Item iterator
Gives an iterator over all items in the level.

Level.items_in_range(Coord position, integer range) → Itemiterator
Gives an iterator over all items within range units of distance from position in the level.
Personal tools