FireEmblemCombatV2 module

Contains the updated combat logic for FireEmblemClone

exception FireEmblemCombatV2.InvalidWeapon[source]

Bases: Exception

Exception raised when attempting to equip a weapon a unit does not have access to

exception FireEmblemCombatV2.LimitIdNotFound[source]

Bases: Exception

exception FireEmblemCombatV2.SkillIsIncorrectCategoryException[source]

Bases: Exception

Exception raised when a supplied skill is of an incorrect category

class FireEmblemCombatV2.ArbitraryAttributeClass(**kwargs)[source]

Bases: object

Intended for use as a base class to inherit from. Initializes class with attributes given by keyword arguments or a supplied dictionary.

classmethod from_dict(input_dict: dict, **kwargs)[source]

Builds class from a supplied dictionary and/or list of keyword arguments

Parameters
  • input_dict

  • kwargs

Returns

Class with attributes defined by input

get_all_attrs()[source]

Returns object dictionary

Returns

class FireEmblemCombatV2.Character(**kwargs)[source]

Bases: FireEmblemCombatV2.ArbitraryAttributeClass

attack_enemy(enemy: FireEmblemCombatV2.Character)[source]

Handles attacking an enemy

Parameters

enemy

Returns

None

attack_node(pos: Tuple[int, int])[source]

Attacks a designated node using attack_enemy()

Parameters

node

Returns

None

calc_boosted_damage(enemy: FireEmblemCombatV2.Character)[source]
calc_effectiveness(enemy: FireEmblemCombatV2.Character)[source]

Checks whether unit has weapon effectiveness against enemy and returns corresponding attack multiplier value (i.e., 1.5 or 1)

Parameters

enemy

Returns

calc_weapon_triangle(enemy: FireEmblemCombatV2.Character)[source]

Checks whether unit has weapon advantage/disadvantage against enemy and returns corresponding attack multiplier value as a percent (i.e., 0.2, -0.2, or 0)

Parameters

enemy

Returns

check_is_dead()[source]
damage_enemy(enemy: FireEmblemCombatV2.Character, damage: int)[source]
die()[source]

Handles unit death. Removes unit from the field and char_list.

Returns

equip_skill(skill: str)[source]
equip_weapon(weapon: Union[str, FireEmblemCombatV2.Weapon])[source]

Handles equipping a weapon to a character

Parameters

weapon

Returns

fight(enemy: FireEmblemCombatV2.Character)[source]

Handles a fight between unit and enemy. Uses attack_enemy() for both sides and calculates whether either side doubles.

Parameters

enemy

Returns

None

get_distance_to(enemy: FireEmblemCombatV2.Character)[source]

Returns distance from unit to enemy

Parameters

enemy

Returns

get_skill(category: str)[source]
get_weapon()[source]
hp_change(prop, old, new)[source]

Listener function for changes in a Character’s hp. Checks whether hp change resulted in death.

Parameters
  • prop

  • old

  • new

Returns

move(new_pos: tuple)[source]

Handles character movement

Parameters

new_pos

Returns

None

move_direction(direction: Tuple, distance: int = 1)[source]

Moves unit in the specified direction.

Parameters

direction – X,Y tuple specifying the individual distances to move in the

X and Y directions :param distance: Integer value by which direction tuple is scaled. Defaults to one. :return: None

move_to_attack(enemy: FireEmblemCombatV2.Character)[source]

Intended for use by AI (or lazy players I guess). Moves unit using move_towards() and then attacks enemy using fight()

Parameters

enemy

Returns

None

move_towards(enemy: FireEmblemCombatV2.Character)[source]

Utilizes dijkstra algorithm to find valid spaces from which unit can attack enemy and moves unit to closest.

Parameters

enemy

Returns

None

set_attribute_values()[source]

Sets default values for character attributes

Returns

set_stats_to_stats_for_level()[source]

Gets stats for unit at current level and sets stats to corresponding values

Returns

None

stat(stat_num)[source]

Takes in number between 0 and 4 and translates to corresponding stat, then returns unit’s value for this stat.

Parameters

stat_num – Integer between 0 and 4

Returns

stat2(stat_num)[source]

Takes in number between 0 and 4 and translates to corresponding stat, then returns sum of unit’s value for this stat and this stat’s current buff.

Parameters

stat_num – Integer between 0 and 4

Returns

stat_difference(stat_num, other: FireEmblemCombatV2.Character)[source]

Returns difference between given stat for unit and other unit.

Parameters
  • stat_num – Integer between 0 and 4

  • other

Returns

unequip_skill(category: str)[source]
unequip_weapon()[source]

Handles unequipping a weapon

Returns

validate_skill(skill: FireEmblemCombatV2.Skill)[source]
validate_weapon(weapon: FireEmblemCombatV2.Weapon)[source]

Checks whether unit may possess weapon

adaptive: bool

does unit have adaptive damage; boolean

adaptive_aoe: bool

does unit have adaptive special damage; boolean

affinity

affinity bonus (bonus granted by skills like gem weapons or triangle adept)

asset: Union[None, str]

Unit’s asset stat

base_stats: Dict[str, int]

base stat values at 3 star rarity, level 1

base_vector_id: int

value used to construct stat growth vectors

brave: bool

does unit have brave effect; boolean

buffs: Dict[str, int]

visible buffs applied to unit; integer

color: int

unit color; integer

combat_boosts: Dict[str, int]

sum of invisible in-combat buffs/debuffs applied to unit; integer

counter: bool

unit can counterattack regardless of opponent’s range; boolean

debuffs: Dict[str, int]

visible debuffs applied to unit; integer

desperation: bool

does unit have desperation; boolean

dragonflowers: Dict

number of dragon flowers added

equipped_skills: Dict[str, Skill]

Currently equipped skills. Dict keys correspond to skill category.

face_name: str

stores reference to face file

flaw: Union[None, str]

Unit’s flaw stat

follow_up: int

can unit make a follow-up (1 = guaranteed, 0 = normal, -1 = no follow-up); integer

growth_rates

percent growth rates for each stat

has_acted: bool

has unit acted already; boolean

property hp
id_tag: str

internal identifier tag

is_initiating: bool

is unit the one initiating combat; boolean

legendary: Dict

character legendary status

level: int

current level; integer

max_special_cd: int

Maximum special cooldown value; int

move_range: int

movement range; integer

move_type: int

movement type (flier, infantry, armor, cavalry)

name: str

translated unit name

no_counter: bool

unit cannot counterattack; boolean

node: Node

node at character’s position

pos

position; tuple (x, y)

rarity: int

current rarity; integer

raven: bool

does unit have raven effect; boolean

refresher: bool

dancer/singer status; boolean

roman: str

romanized name

skills: List[List]

index of first list corresponds to unit rarity; index of second list corresponds to skill category. For given rarity, first 6 values (0-5) are default (already learned), remaining 8 (6-13) are unlockable - index 0 and index 6 are weapons - index 1 and index 7 are assists - index 2 and index 8 are specials - index 3 and index 9 are A slot (except for Drag Back on Gwendolyn) - index 4 and index 10 are B slot (Except Defiant Attack on Ogma) - index 5 and index 11 are C slot (Except HP+ on Abel) - index 12 is empty - index 13 is empty

Type

List of lists

sort_value: int

sort priority (bitmask?)

special_cd: int

Current special cooldown value; int

stats: Dict[str, int]

stats scaled to current level

status_effects: Dict[str, bool]

dictionary of status effects on unit; string keys and boolean values

timestamp: str

release date

tome_class: int

tome’s magic type; 0 for non-magic characters

vantage: bool

does unit have vantage; boolean

weapon: Union[Weapon, None]

currently equipped weapon

weapon_class

base weapon class (kinda useless right now?)

weapon_type: int

weapon type; integer

wrathful_staff: bool

does unit calculate damage from staff like normal weapons; boolean

class FireEmblemCombatV2.Enemy(**kwargs)[source]

Bases: FireEmblemCombatV2.Character

Enemy class. Defines behaviors and characteristics for enemy units.

class FireEmblemCombatV2.GameLoop[source]

Bases: object

after_combat(unit: FireEmblemCombatV2.Character, foe: FireEmblemCombatV2.Character)[source]
after_movement(unit: FireEmblemCombatV2.Character)[source]
attack(unit: FireEmblemCombatV2.Character, foe: FireEmblemCombatV2.Character)[source]
battle_phase()[source]
before_combat(unit: FireEmblemCombatV2.Character, foe: FireEmblemCombatV2.Character)[source]
calc_arena_score(characters)[source]
during_combat(unit: FireEmblemCombatV2.Character, foe: FireEmblemCombatV2.Character)[source]
enemy_phase()[source]
evaluate_skills(characters: Union[FireEmblemCombatV2.Character, Iterable[FireEmblemCombatV2.Character]], timing_contexts: Iterable[int])[source]
static get_phase(self)[source]
main(autobattle=False)[source]
player_phase()[source]
process_instruction(instruction: str)[source]
start_of_turn(characters)[source]
swap_phase()[source]
upon_movement(unit: FireEmblemCombatV2.Character)[source]
use_assist(unit: FireEmblemCombatV2.Character, target: FireEmblemCombatV2.Character)[source]
use_duo_skill(unit: FireEmblemCombatV2.Character)[source]
property phase
class FireEmblemCombatV2.Player(**kwargs)[source]

Bases: FireEmblemCombatV2.Character

Player class. Defines behaviors and characteristics for player units.

class FireEmblemCombatV2.Point(x: int, y: int)[source]

Bases: tuple

Used to hold character positions

property x

Alias for field number 0

property y

Alias for field number 1

class FireEmblemCombatV2.Skill(**kwargs)[source]

Bases: FireEmblemCombatV2.ArbitraryAttributeClass

Class for Character skills. Structure defined by JSON data (not dynamically unfortunately, I wrote it all by hand).

activate(**kwargs)[source]
combat_boost(unit: FireEmblemCombatV2.Character)[source]

For each stat, grants/inflicts skill’s stat + skill’s skill_params to/on unit during combat.

Parameters

unitCharacter

Returns

None

combat_boost2(unit: FireEmblemCombatV2.Character)[source]

For each stat, grants/inflicts skill’s stat + skill’s skill_params2 to/on unit during combat.

Parameters

unitCharacter

Returns

None

skill_targets(unit: FireEmblemCombatV2.Character)[source]

Similar to targeted() method. Return boolean value based on whether given unit is targeted by skill. Skill targeting is defined by the skill’s target_mov and target_wep attributes.

Parameters

unitCharacter

Returns

bool

targeted(items: Iterable[Character])[source]

Return list of units within the given group which are targeted by the skill. Skill targeting is defined by the skill’s target_mov and target_wep attributes.

Parameters

items

Returns

ability_id

An index into the string table in Common/SRPG/SkillAbility.bin indicating the skill effect type. A skill can only contain one skill effect (refined weapons have an extra skill effect if refine_id is non-null).

assist_cd

True if the skill grants Special cooldown count-1 to the unit after this Assist is used.

beast_effect_id

Internal string identifier of the skill that activates while the unit is transformed into a beast, e.g. SID_化身効果・奥義強化

category
Category of the skill.
0 0xBC Weapon
1 0xBD Assist
2 0xBE Special
3 0xBF Passive A
4 0xB8 Passive B
5 0xB9 Passive C
6 0xBA Sacred Seal
7 0xBB Refined weapon skill effect
8 0xB4 Beast transformation effect
class_params

A set of extra parameters that are used only for skill effects common to weapon classes for which is_staff, is_dagger, is_breath, or is_beast is true: - is_staff: If class_params.hp = 1, calculates damage from staff like other weapons.;

If class_params.hp = 2, foe cannot counterattack.

  • is_dagger: After combat, if unit attacked, inflicts stat+class_params on target and foes within class_params.hp spaces of target through their next actions.

  • is_breath: If class_params.hp = 1, and if target_mov foe uses target_wep, calculates damage using the lower of foe’s Def or Res.

  • is_beast: If class_params.hp = 1, at start of turn, if unit is adjacent to only beast or dragon allies or if unit is not adjacent to any ally, unit transforms (otherwise, unit reverts); if unit transforms, grants stat+class_params.

Note

is_staff, is_dagger, is_breath, and is_beast are currently implemented as Character attributes, not as Weapon attributes or methods

cooldown_count

Cooldown count of the skill. The total cooldown count of a unit is the sum of cooldown_count for all equipped skills. Skills that accelerate Special trigger have a negative value.

desc_id

Internal string identifier of the skill description resource, e.g. MSID_H_ジークリンデ改

enemy_only

True if the skill can only be equipped by enemies.

exclusive

True if the skill cannot be inherited.

healing

True if the skill is a healing Assist skill.

icon_id

The icon index of the skill, referring to the files UI/Skill_Passive*.png.

id_num

A unique increasing index for every skill, added to 0x10000000 for refined weapons.

id_tag

Full internal string identifier of the skill e.g. SID_ジークリンデ_共 for Sieglinde

limit1_id

An index into the string table in Common/SRPG/SkillTiming.bin indicating the skill’s activation restriction.

limit1_params

Restriction-dependent parameters.

limit2_id

An additional activation restriction on the given skill. Both must be satisfied for the skill to activate.

might

Might for weapon skills, including bonuses that come from refinements, 0 for other skills.

min_lv

If non-zero, represent the lowest and highest levels respectively that allow random units to equip the given skill.

mov_adaptive

A bitmask indexed by move_index, representing movement classes that receive damage from this skill calculated using the lower of Def or Res. Currently unused. Only meaningful on weapon skills.

mov_effective

A bitmask indexed by move_index, representing movement class effectivenesses this skill grants. Only meaningful on weapon skills.

mov_equip

A bitmask indexed by move_index, with bits set for movement classes that can equip the current skill.

mov_shield

A bitmask indexed by move_index, representing movement class effectivenesses this skill protects from.

mov_weakness

A bitmask indexed by move_index, representing movement class weaknesses this skill grants. Currently unused.

name_id

Internal string identifier of the skill name resource e.g. MSID_ジークリンデ

next_skill

Internal string identifier of the canonical upgrade of the current skill. It is defined if and only if promotion_rarity is not zero.

passive_next

Like next_skill, except that this field is null for weapons, Spur Atk 2 does not point to Spur Atk 3, and similarly for the three other Spur passives. (Death Blow 3 pointed to Death Blow 4 even before the CYL2 update.)

prerequisites

Internal string identifiers of skills required to learn the current skill.

promotion_rarity

If non-zero, this skill would be promoted on derived maps if the unit’s rarity is greater than or equal to this value.

promotion_tier

2 for a few low-tier Specials and staff weapons / Assists, 0 for highest-tier skills, and 1 for everything else. Used by derived maps to determine how far skills are allowed to promote.

random_allowed

Indicates whether random units can equip this skill. This affects Training Tower and Allegiance Battles. It has 3 possible values: - 0: This skill may not be equipped on random units. - 10: This skill may be equipped on random units. - 20: Purpose unknown. Same effect as 10. Used by basic non-staff weapons

(e.g. Iron Sword, Flametongue+, Adult (Cavalry)) and basic staff Assists.

random_mode

(see #Random skills for details) - 0: This skill may not be equipped on random units. - 1: This skill may be equipped by any random unit. - 2: This skill may be equipped by random units that own the skill.

Type

Controls how random units may equip this skill. It has 3 possible values

range

Range of the skill for weapons and Assists, 0 for other skills.

range_shape

Defines the shape used for range functions (finding units within range of skill). Shape refers to the physical shape, such as column, row, cardinals, etc.

refine_base

Internal string identifier of the unrefined version of the weapon e.g. SID_ジークリンデ

refine_id

Internal string identifier of the skill that gives rise to the refined skill effect, e.g. SID_強化共有R

refine_sort_id

1 and 2 for skills, 101 – 104 for Atk/Spd/Def/Res refinements, 0 otherwise.

Type

Internal sort value for refined weapons

refine_stats

Stat bonuses of the skill’s refinement, as shown on the weapon description.

refined

True if the skill is a refined weapon.

score

A value that roughly corresponds to the SP cost of the skill. Might have been used for Arena matches.

skill_params

Various skill parameters packed into a stat tuple. These do not necessarily represent stat values. Their meanings depend on the skill abilities.

skill_params2

Various skill parameters packed into a stat tuple. These do not necessarily represent stat values. Their meanings depend on the skill abilities.

skill_range

Range of the skill effect that comes with the given skill, e.g. 1 for Hone skills and weapons that give equivalent skill effects.

sort_id

The internal sort value used in places such as the skill inheritance menu to order skills within the same category according to their skill families.

sp_cost

SP required to learn the given skill.

sprites

bow, weapon / arrow, map animation, AoE Special map animation.

Type

Filenames of the sprites used by the weapon, in this order

stats

Permanent stat bonuses of the skill. For weapons this does not include might.

target_either

Controls whether skill targets units with both the targeted weapon and targeted movement type or whether having either one marks the unit as a valid target

target_mov

A bitmask indexed by move_index, representing the target’s movement classes required for the skill’s effect to activate. If zero, works on all movement classes.

target_wep

A bitmask indexed by weapon_index, representing the target’s weapon classes required for the skill’s effect to activate. If zero, works on all weapon classes.

timestamp

A POSIX timestamp relative to the skill’s release date; half a month into the future for skills released before Version 2.0.0, 1 month into the future for skills released since Version 2.0.0. This skill may be equipped by random units if timestamp is -1 or the current time is past timestamp.

timing_id

An index into the string table in Common/SRPG/SkillTiming.bin indicating the moment where the skill triggers.

tome_class

The element type for tome weapon skills.

tt_inherit_base

If true, this skill may be considered by the 10th Stratum of the Training Tower for the random skill pool if it is equipped by the corresponding unit from the base map.

wep_adaptive

A bitmask indexed by weapon_index, representing weapon classes that receive damage from this skill calculated using the lower of Def or Res. Used by breaths. Only meaningful on weapon skills.

wep_effective

A bitmask indexed by weapon_index, representing weapon class effectivenesses this skill grants. Only meaningful on weapon skills.

wep_equip

A bitmask indexed by weapon_index, with bits set for weapon classes that can equip the current skill.

wep_shield

A bitmask indexed by weapon_index, representing weapon class effectivenesses this skill protects from. Used by Breath of Blight.

wep_weakness

A bitmask indexed by weapon_index, representing weapon class weaknesses this skill grants. Used by Loptous.

class FireEmblemCombatV2.Slid(skill, id)[source]

Bases: object

Creates self.param1 and self.param2

class FireEmblemCombatV2.Weapon(**kwargs)[source]

Bases: FireEmblemCombatV2.Skill

static get_base_weapon_class(weapon)[source]
set_attribute_values()[source]

Calls get_base_weapon_class() if weapon does not already have a WeaponClass

Returns

None

weapon_class

Base weapon class

Type

WeaponClass

class FireEmblemCombatV2.WeaponClass(**kwargs)[source]

Bases: FireEmblemCombatV2.ArbitraryAttributeClass

This class refers to a weapon’s base weapon-class. For example, the base weapon class of Clarisse’s Sniper’s Bow is colorless bow

Warning

Not to be confused with the Weapon class

base_weapon

Base weapon of this class (ex. Iron Sword for Sword weapon class)

id_tag

Internal identifier tag

is_beast

bool

is_breath

bool

is_dagger

bool

is_staff

bool

range

Weapon class range (melee or ranged)

Type

int

res_damage

Does weapon class use res to calculate damage

Type

bool

FireEmblemCombatV2.adaptive(unit: FireEmblemCombatV2.Character)[source]

Calculates unit’s damage during combat using the lower of opponent’s Def or Res

Parameters

unit

Returns

FireEmblemCombatV2.adaptive_aoe(unit: FireEmblemCombatV2.Character)[source]

Calculates damage from unit’s area-of-effect Specials using the lower of opponent’s Def or Res

Parameters

unit

Returns

FireEmblemCombatV2.add_status(status_effect: str, unit: FireEmblemCombatV2.Character)[source]

Grants/inflicts status to/on unit

Parameters
  • status_effect

  • unit

Returns

FireEmblemCombatV2.allies(items: Iterable, unit: FireEmblemCombatV2.Character) → list[source]

Takes a list of Character objects, ‘items’, and returns a filtered list containing only characters on the same team as ‘unit’ (teams are based on the class of ‘unit’, e.g if ‘unit’ is of class Player, list will be comprised of all Player characters in ‘items’). Note: the result is inclusive of ‘unit’ in order to keep consistent with the output of the foes() function.

Parameters
  • items

  • unit

Returns

FireEmblemCombatV2.beast(items: Iterable[FireEmblemCombatV2.Character]) → List[FireEmblemCombatV2.Character][source]
FireEmblemCombatV2.bonus_broad(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.bonus_narrow(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.brave(unit: FireEmblemCombatV2.Character)[source]

Unit attacks twice

Parameters

unit

Returns

FireEmblemCombatV2.buff(skill: FireEmblemCombatV2.Skill, unit: Union[FireEmblemCombatV2.Character, Iterable[FireEmblemCombatV2.Character]])[source]
FireEmblemCombatV2.buff2(skill: FireEmblemCombatV2.Skill, unit: Union[FireEmblemCombatV2.Character, Iterable[FireEmblemCombatV2.Character]])[source]
FireEmblemCombatV2.buff_total(unit: FireEmblemCombatV2.Character) → int[source]
FireEmblemCombatV2.charge(mode: int, charge_num: int, unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.combat_add_hp(hp_change: int, unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.combine_buffs_debuffs(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.convert_bonuses_to_penalties(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.convert_penalties_to_bonuses(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.convert_to_bitmask_list(int_bitmask: int) → list[source]

Converts integer bitmask to list of 1’s and 0’s, e.g if ‘int_bitmask’ is 571, returns [1, 1, 0, 1, 1, 1, 0, 0, 0, 1]

Parameters

int_bitmask

Returns

FireEmblemCombatV2.cooldown(cooldown: int, unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.count_around(unit: FireEmblemCombatV2.Character, unit_type: Callable, context: Union[Slid, Skill]) → int[source]
If context is:
SkillLimit (Slid instance):

returns the number of ‘unit_type’ within param1 spaces of ‘unit’ (excluding ‘unit’)

SkillAbility (Skill instance):

returns the number of ‘unit_type’ within skill_range spaces of ‘unit’ (excluding ‘unit’)

Parameters
  • unit – Unit to use as origin

  • unit_type – Condition to evaluate

  • context – Context function is being used in

Returns

FireEmblemCombatV2.counter(unit: FireEmblemCombatV2.Character)[source]

Unit can counterattack regardless of opponent’s range

Parameters

unit

Returns

FireEmblemCombatV2.debuff_total(unit: FireEmblemCombatV2.Character) → int[source]
FireEmblemCombatV2.desperation(unit: FireEmblemCombatV2.Character)[source]

Unit can make a follow-up attack before opponent can counterattack

Parameters

unit

Returns

FireEmblemCombatV2.dragon(items: Iterable[FireEmblemCombatV2.Character]) → List[FireEmblemCombatV2.Character][source]
FireEmblemCombatV2.filter_true_indexes(bitmask_list: List[int]) → List[int][source]

Takes a bitmask list ‘bitmask_list’ (output from convert_to_bitmask_list function) and returns a list of integers for each index in ‘bitmask_list’ at which the value is True (or in this case, 1)

Parameters

bitmask_list

Returns

FireEmblemCombatV2.find(skill, slid_value)[source]
FireEmblemCombatV2.find_inconsistencies()[source]

Function intended to search character data files for skills in incorrect categories.

Returns

FireEmblemCombatV2.foes(items: Iterable, unit: FireEmblemCombatV2.Character) → list[source]

Takes a list of Character objects, ‘items’, and returns a filtered list containing only characters not on the same team as ‘unit’ (teams are based on the class of ‘unit’, e.g if ‘unit’ is of class Player, list will be comprised of all non-Player characters in ‘items’).

Parameters
  • items

  • unit

Returns

FireEmblemCombatV2.follow_up(follow_up_value: int, unit: FireEmblemCombatV2.Character)[source]

If follow_up_value is 1, unit makes a guaranteed follow-up attack, if follow_up_value is -1 unit cannot make a follow-up attack.

Parameters
  • follow_up_value – 1 or -1

  • unit

Returns

FireEmblemCombatV2.get_direction(unit: Union[FireEmblemCombatV2.Character, Tuple], target: Union[FireEmblemCombatV2.Character, Tuple]) → Tuple[source]
FireEmblemCombatV2.get_distance(self: FireEmblemCombatV2.Character, enemy: FireEmblemCombatV2.Character)[source]

Simple utility function that returns the distance between 2 (X,Y) Character units. Uses the same logic as in get_distance_from_tuples().

Parameters
  • self

  • enemy

Returns

FireEmblemCombatV2.get_distance_from_tuples(self: tuple, enemy: tuple)[source]

Simple utility function that returns the distance between 2 (X,Y) tuples. Distance is not the minimal diagonal distance as given by the standard distance function, but rather the tile-based distance used to navigate grids. For example, if an object A is at position (1,1) and an object B is at position (3,4), the distance is 5 (as opposed to the shortest-route diagonal distance of 3.60555…)

Parameters
  • self

  • enemy

Returns

FireEmblemCombatV2.get_enemies() → List[FireEmblemCombatV2.Character][source]

Returns a list of all Enemy instances in char_list

Returns

FireEmblemCombatV2.get_players() → List[FireEmblemCombatV2.Character][source]

Returns a list of all Player instances in char_list

Returns

FireEmblemCombatV2.give_action(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.hp_between(min_hp_percent: int, max_hp_percent: int, unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.hundreds(x: int) → int[source]

Simple utility function to return the hundreds’ place digit of a number.

Parameters

x

Returns

FireEmblemCombatV2.in_bitmask(nums: Union[int, Iterable[int]], bitmask: int) → Union[bool, Dict[int, Any]][source]

Takes an integer bitmask ‘bitmask’, converts to binary, and casts binary to a list of ones and zeroes, ‘bitmask_list’.

If ‘nums’ is an integer:

Indexes ‘bitmask_list’ by ‘nums’, if value at index is 1 returns True, else False

If ‘nums’ is an Iterable of integers:

For ‘num’ in ‘nums’, indexes ‘bitmask_list’ by ‘num’, if value at index is 1 sets value to True at key ‘num’ in ‘in_bitmask_dict’ else sets value to False

Parameters
  • nums

  • bitmask

Returns

FireEmblemCombatV2.in_range(away: FireEmblemCombatV2.Point, origin: FireEmblemCombatV2.Point, distance: int)[source]

Returns boolean denoting whether away coordinate is within distance spaces of origin coordinates or not.

Parameters
  • away

  • origin

  • distance

Returns

FireEmblemCombatV2.luna(reduction_percent)[source]
FireEmblemCombatV2.map_add_hp(hp_change: int, unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.neg(expr: int) → int[source]

Simple utility function that returns 0 for all input values above 0, or the input value otherwise.

Parameters

expr

Returns

FireEmblemCombatV2.neighborhood(unit: FireEmblemCombatV2.Character, skill: FireEmblemCombatV2.Skill) → List[FireEmblemCombatV2.Character][source]

Unit and units on unit’s team within_range() of unit

Parameters
  • unit

  • skill

Returns

FireEmblemCombatV2.neighborhood_ex(unit: FireEmblemCombatV2.Character, skill: Optional[FireEmblemCombatV2.Skill], range_shape_override: str = '') → List[FireEmblemCombatV2.Character][source]
FireEmblemCombatV2.neutralize_penalties(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.no_counter(unit: FireEmblemCombatV2.Character)[source]

Unit cannot counterattack

Parameters

unit

Returns

FireEmblemCombatV2.not_beast(items: Iterable[FireEmblemCombatV2.Character]) → List[FireEmblemCombatV2.Character][source]
FireEmblemCombatV2.not_dragon(items: Iterable[FireEmblemCombatV2.Character]) → List[FireEmblemCombatV2.Character][source]
FireEmblemCombatV2.null_follow_up(neut_guarantee_foe: bool, neut_prevent_unit: bool, unit: FireEmblemCombatV2.Character, enemy: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.ones(x: int) → int[source]

Simple utility function to return the one’s place digit of a number.

Parameters

x

Returns

FireEmblemCombatV2.penalty_broad(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.penalty_narrow(unit: FireEmblemCombatV2.Character)[source]
FireEmblemCombatV2.pos(expr: int) → int[source]

Simple utility function that returns 0 for all input values below 0, or the input value otherwise.

Parameters

expr

Returns

FireEmblemCombatV2.print_grid(input_grid: Code.FEH_DijkstraAlgorithm.Graph)[source]

Prints the current field grid. Empty nodes are represented by spaces, nodes containing players by O’s, and nodes containing enemies by X’s.

Parameters

input_grid

Returns

FireEmblemCombatV2.program_instructions()[source]
FireEmblemCombatV2.raven(unit: FireEmblemCombatV2.Character)[source]

Grants weapon-triangle advantage to unit against colorless opponents, and inflicts weapon-triangle disadvantage on colorless opponents during combat.

Parameters

unit

Returns

FireEmblemCombatV2.scale_tuple(tup, scale)[source]

Simple utility function that scales an (X,Y) tuple by an integer value and returns the result.

Parameters
  • tup

  • scale

Returns

FireEmblemCombatV2.special_damage(damage)[source]
FireEmblemCombatV2.spectrum_buff(units: Union[FireEmblemCombatV2.Character, Iterable[FireEmblemCombatV2.Character]], buff: int)[source]
FireEmblemCombatV2.spectrum_debuff(units: Union[FireEmblemCombatV2.Character, Iterable[FireEmblemCombatV2.Character]], debuff: int)[source]
FireEmblemCombatV2.status(status_id: int) → str[source]

Converts status id to status name

Parameters

status_id

Returns

FireEmblemCombatV2.tens(x: int) → int[source]

Simple utility function to return the ten’s place digit of a number.

Parameters

x

Returns

FireEmblemCombatV2.tens_ones(x: int) → int[source]

Simple utility function to return a number composed of the one’s and ten’s place digits of the input number.

Parameters

x

Returns

FireEmblemCombatV2.tuple_add(tup1, tup2)[source]

Simple utility function that adds 2 (X,Y) tuples and returns the result.

Parameters
  • tup1

  • tup2

Returns

FireEmblemCombatV2.unit_near(self, other_unit: FireEmblemCombatV2.Character, skill: FireEmblemCombatV2.Skill)[source]

If unit is within_range() of unit

Parameters
  • self

  • other_unit

  • skill

Returns

FireEmblemCombatV2.vantage(unit: FireEmblemCombatV2.Character)[source]

Unit can counterattack before opponent’s first attack

Parameters

unit

Returns

FireEmblemCombatV2.within_range_abstracted(unit: FireEmblemCombatV2.Character, skill: Optional[FireEmblemCombatV2.Skill], condition: str = 'within_range', grid: Code.FEH_DijkstraAlgorithm.Graph = <Code.FEH_DijkstraAlgorithm.Graph object>, distance_override=0) → List[FireEmblemCombatV2.Character][source]

Returns a list of Character instances whose position is within Skill.skill_range spaces of unit

Note

Excludes ‘unit’

FireEmblemCombatV2.within_range_ex_abstract(unit: FireEmblemCombatV2.Character, skill: Optional[FireEmblemCombatV2.Skill], grid: Code.FEH_DijkstraAlgorithm.Graph = <Code.FEH_DijkstraAlgorithm.Graph object>, range_shape_override: str = '')[source]
FireEmblemCombatV2.wrathful_staff(unit: FireEmblemCombatV2.Character)[source]

Calculates damage from unit’s staff like other weapons

Parameters

unit

Returns

FireEmblemCombatV2.CONFIG = {'AR auto-dispatch home notification': 'on', 'BGM volume': 6, 'SE volume': 5, 'asset/flaw color display': 'on', 'assist skills in auto': 'no move skills', 'auto-battle button': 'all locations', 'auto-battle text': 'auto-advance', 'auto-favorite': '5', 'auto: no animation': 'off', 'battle music': 'on', 'combat_animations': 'off', 'compile CMs home notification': 'on', 'confirm action': 'auto', 'confirm move': 'auto', 'continuous auto': 'on', 'double tap to wait': 'off', 'duo hero display': 'full', 'enemy music': 'on', 'foe/ally autobattle movement': 'simple', 'forging bonds home notification': 'on', 'forging bonds: skip conversation': 'off', 'lost lore home notification': 'on', 'map: no animation': 'off', "mjolnir's strike home notification": 'on', 'no duo skill animation': 'off', 'show danger area': 'off', 'silent mode': 'off', 'smart end': 'on', 'sorting by level': 'default', 'starting a map': 'go into battle', 'support_animations': 'off', 'tt difficulty tip': 'on', 'voice volume': 0, 'voting gauntlet home notification': 'on'}

Config dictionary

FireEmblemCombatV2.category_name_to_number_dict = {'a': 3, 'assist': 1, 'b': 4, 'beast transformation': 8, 'c': 5, 'refined weapon skill': 7, 'seal': 6, 'special': 2, 'weapon': 0}

Mapping dictionary; maps skill type to skill category number

FireEmblemCombatV2.category_number_to_name_dict = {0: 'weapon', 1: 'assist', 2: 'special', 3: 'a', 4: 'b', 5: 'c', 6: 'seal', 7: 'refined weapon skill', 8: 'beast transformation'}

Mapping dictionary; maps skill category number to skill type

FireEmblemCombatV2.char_list = []

Module-level variable containing all active units

FireEmblemCombatV2.stat_num_to_name_dict = {0: 'hp', 1: 'atk', 2: 'spd', 3: 'def', 4: 'res'}

Mapping dictionary; maps stat position to stat name

FireEmblemCombatV2.weapon_advantage = {1: 3, 2: 1, 3: 2}

Weapon advantage definitions where 1, 2, and 3 correspond to red, blue, and green, respectively. The value of each key represents the color that has advantage against the key.