* Add functions reverse-engineered from ambushing unit code
* Fix whitespace
* Fix debug_showambush check
* Remove getOuterContainerRef from Lua API
Don't think this works properly without allocating a new specific_ref. More trouble that it's worth.
* Fixed tile visibility check
* I don't think gamemode or gametype are ever NULL
* Minor tweaks to documentation
* Reimplement getOuterContainerRef for Lua; fix some comments
* Update Units.cpp and changelog
* Update Units.cpp
* Update changelog.txt
develop
Ryan Williams2022-03-13 17:19:35 -07:00committed byGitHub
Returns a table (in the style of a ``specific_ref`` struct) of the outermost object that contains the unit (or one of the unit itself.)
The ``type`` field contains a ``specific_ref_type`` of ``UNIT``, ``ITEM_GENERAL``, or ``VERMIN_EVENT``.
The ``object`` field contains a pointer to a unit, item, or vermin, respectively.
* ``dfhack.units.getVisibleName(unit)``
* ``dfhack.units.getVisibleName(unit)``
Returns the language_name object visible in game, accounting for false identities.
Returns the language_name object visible in game, accounting for false identities.
@ -1266,10 +1272,18 @@ Units module
The unit is an alive sane citizen of the fortress; wraps the
The unit is an alive sane citizen of the fortress; wraps the
same checks the game uses to decide game-over by extinction.
same checks the game uses to decide game-over by extinction.
* ``dfhack.units.isFortControlled(unit)``
Similar to ``dfhack.units.isCitizen(unit)``, but is based on checks for units hidden in ambush, and includes tame animals. Returns *false* if not in fort mode.
* ``dfhack.units.isVisible(unit)``
* ``dfhack.units.isVisible(unit)``
The unit is visible on the map.
The unit is visible on the map.
* ``dfhack.units.isHidden(unit)``
The unit is hidden to the player, accounting for sneaking. Works for any game mode.
* ``dfhack.units.getAge(unit[,true_age])``
* ``dfhack.units.getAge(unit[,true_age])``
Returns the age of the unit in years as a floating-point value.
Returns the age of the unit in years as a floating-point value.
@ -1407,6 +1421,12 @@ Items module
Returns the container item or *nil*.
Returns the container item or *nil*.
* ``dfhack.items.getOuterContainerRef(item)``
Returns a table (in the style of a ``specific_ref`` struct) of the outermost object that contains the item (or one of the item itself.)
The ``type`` field contains a ``specific_ref_type`` of ``UNIT``, ``ITEM_GENERAL``, or ``VERMIN_EVENT``.
The ``object`` field contains a pointer to a unit, item, or vermin, respectively.
- Added functions reverse-engineered from ambushing unit code: ``Units::isHidden``, ``Units::isFortControlled``, ``Units::getOuterContainerRef``, ``Items::getOuterContainerRef``
## Lua
## Lua
- Lua wrappers for functions reverse-engineered from ambushing unit code: ``isHidden(unit)``, ``isFortControlled(unit)``, ``getOuterContainerRef(unit)``, ``getOuterContainerRef(item)``