UnitObject class

class app.engine.objects.unit.UnitObject

A unit. The entities that can move around on the map, attack, be attacked, etc.

Units have name IDs (or NIDs) that uniquely identify them. The remaining attributes and methods of UnitObjects are described below.

nid: str

Unique identifier

prefab_nid: str = None

NID of this unit’s prefab (usually the same as it’s nid)

generic: bool = False

Whether the unit is a generic

persistent: bool = True

If unit is persistent, unit will not be removed between levels. Generic units start off without persistence.

ai: str = None

NID of this unit’s base combat AI (skills might modify this)

roam_ai: str = None

NID of this unit’s base roaming AI (skills might modify this)

stats: Dict[str, int]

Current stats without bonuses

growths: Dict[str, int]

Current growths without bonuses

growth_points: Dict[str, int]

Used for Fixed and Dynamic leveling. Do not modify directly

stat_cap_modifiers: Dict[str, int]

Personal stat cap modifiers

position: Tuple[int, int] = None

Current position on the map

starting_position: Tuple[int, int] = None

Where the unit was placed on the map in the editor

previous_position: Tuple[int, int] = None

Where the unit started their turn

traveler: str = None

Paired up unit when pair-up is active, otherwise rescued unit.

strike_partner: UnitObject = None

Set to attack stance partner during combat

lead_unit: bool = False

Is the unit the lead unit in the pairup?

dead: bool = False

Is the unit dead?

is_dying: bool = False

Is the unit in the process of dying? (likely not dead yet)

items: List[ItemObject]

List of ItemObjects currently held by the unit

has_rescued: bool = False

Has the unit rescued someone this phase?

has_taken: bool = False

Has the unit taken someone this phase?

has_given: bool = False

Has the unit given someone this phase?

has_dropped: bool = False

Has the unit dropped someone this phase?

has_run_ai: bool = False

Has the unit run their AI this phase?

get_max_hp() int
Returns:

Unit’s maximum HP

get_hp() int
Returns:

Unit’s current HP

get_max_mana()
Returns:

Unit’s maximum mana

get_mana() int
Returns:

Unit’s current mana

get_max_fatigue()
Returns:

Fatigue value at which the unit counts as fatigued

get_fatigue()
Returns:

Unit’s current fatigue

get_exp() int
Returns:

Unit’s current experience points

add_skill(skill, source=None, source_type=SourceType.DEFAULT, test=False)

# Adds skill to the UnitSkill list while checking if the skill already exists/stack is full # If so, removes the oldest displaceable skill and returns it # If no existing skill is displaceable AND the new skill is displaceable, returns the new skill back # Only actually adds the new skill on test=False

remove_skill(skill, source, source_type=SourceType.DEFAULT, test=False)

# Removes the given skill and returns it along with its source and source type # If the given skill cannot be removed, returns nothing # Only actually removes the skill on test=False

property skills: List[SkillObject]

Returns a list of the unit’s current skills.

Units keep track of all skills the unit has received, even when they would be duplicates. This method returns only those actionable skills that aren’t being shadowed by other more recently added skills with the same nid Utilizes a cache that is reset when a skill is added or removed from self._skills

Returns:

A List of SkillObjects

stat_bonus(stat_nid: str) int

Given a stat NID, determines the unit’s bonus for that stat.

Stat bonuses can come from skills or their currently equipped items.

Parameters:

stat_nid (NID) – The NID of the stat in question.

Returns:

The unit’s bonus stats for that stat.

get_stat(stat_nid: str) int

Given a stat NID, determines the unit’s total stat for that stat (base + bonus)

Parameters:

stat_nid (NID) – The NID of the stat in question.

Returns:

The unit’s total stat for that stat.

get_growth(stat_nid: str) int

Given a stat NID, determines the unit’s total growth percentage for that stat (base + bonus)

Parameters:

stat_nid (NID) – The NID of the stat in question.

Returns:

The unit’s total growth percentage for that stat.

get_stat_cap(stat_nid: str) int

Given a stat NID, determines the unit’s stat cap for that stat.

Determined by adding together the unit’s class’s stat cap for that stat plus their personal stat cap modifier.

Parameters:

stat_nid (NID) – The NID of the stat in question.

Returns:

The unit’s stat cap for that stat.

get_damage_with_current_weapon() int

Returns the unit’s base might while wielding their currently equipped weapon

get_accuracy_with_current_weapon() int

Returns the unit’s base hit rate while wielding their currently equipped weapon

get_avoid_with_current_weapon() int

Returns the unit’s base avoid while wielding their currently equipped weapon

property tags: List[str]

Returns all tags this unit has.

Gathers tags from the unit itself, its current class, and any additional tags given by the unit’s skills. Never includes any duplicates.

Returns:

A List of Tags (strs)

get_ai() str

Returns the NID of the unit’s current combat AI.

get_roam_ai() str

Returns the NID of the unit’s current roaming AI.

property accessories: List[ItemObject]

Returns a list of all accessories in the unit’s inventory

property nonaccessories: List[ItemObject]

Returns a list of all non-accessory items in the unit’s inventory

get_skill(nid: str) SkillObject | None

Given a skill’s NID or UID, return that skill if found in the unit’s list of skills.

Returns the most recently added skill with the given NID if multiple skills with the same NID are present.

Parameters:

nid (NID) – NID of skill to return. Can also be the skill’s UID.

Returns:

The SkillObject, if found. Otherwise returns None.

get_weapon() ItemObject | None

Returns the currently equipped weapon of the unit

get_accessory() ItemObject | None

Returns the currently equipped accessory of the unit

can_equip(item: ItemObject) bool

Return True if the unit can equip item

get_internal_level() int

Returns the unit’s internal level

Calculated by summing all the max levels of the classes that this unit’s class promoted from. Can be negative if the unit is tier 0 (trainee).

Returns:

The unit’s internal level.

Return type:

int