Skip to content

HeroStatusFlag

Bases: _DataSetIntFlags

This enum class provides the integer values for the different hero status flags that can be used in the 'Modify Attribute' effect with the 'Hero Status' attribute. This is a combinable bit field

Methods

  • HeroStatusFlag.combine()
  • HeroStatusFlag.split_flags()

Examples

Source code in AoE2ScenarioParser/datasets/trigger_lists/hero_status_flag.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class HeroStatusFlag(_DataSetIntFlags):
    """
    This enum class provides the integer values for the different hero status flags that can be used in the 'Modify
    Attribute' effect with the 'Hero Status' attribute. This is a combinable bit field

    **Methods**

    - ``HeroStatusFlag.combine()``
    - ``HeroStatusFlag.split_flags()``


    **Examples**







    """

    @staticmethod
    def combine(
            full_hero_status: bool = False,
            cannot_be_converted: bool = False,
            hero_regeneration: bool = False,
            defensive_stance_by_default: bool = False,
            protected_formation: bool = False,
            delete_confirmation: bool = False,
            hero_glow: bool = False,
            invert_all_flags: bool = False
    ) -> HeroStatusFlag:
        """
        This method combines the given hero status flags into an integer value

        Args:
            full_hero_status: Enabling this for a unit grants all the flags mentioned below except invert_all_flags
            cannot_be_converted: Enabling this for a unit makes it un-convertable
            hero_regeneration: Enabling this for a unit grants 0.5 HP/s heal rate to the unit
            defensive_stance_by_default: Enabling this for a unit makes it be on defensive stance by default
            protected_formation: Enabling this for a unit makes it be in protected formation by default
            delete_confirmation: Enabling this for a unit will bring up a delete confirmation for the unit when trying
            to delete it IF the player has them enabled
            hero_glow: Enabling this for a unit grants it the golden hero glow effect
            invert_all_flags: Enabling this for a unit will invert all the above flags except full_hero_status

        Returns:
            An integer combining all the different hero status flags into one value
        """
        total = 1 if full_hero_status else 0
        total += 2 if cannot_be_converted else 0
        total += 4 if hero_regeneration else 0
        total += 8 if defensive_stance_by_default else 0
        total += 16 if protected_formation else 0
        total += 32 if delete_confirmation else 0
        total += 64 if hero_glow else 0
        total += 128 if invert_all_flags else 0
        return HeroStatusFlag(total)

    @staticmethod
    def split_flags(value: int) -> Dict[HeroStatusFlag, bool]:
        """
        Split the Hero Status flags into boolean variables related to their effects

        Args:
            value: An integer value representing all the hero status flags set

        Returns:
            A dict with all the flags values as keys and a bool as their value
        """
        flags = {}
        for flag in HeroStatusFlag:
            flags[flag] = bool(flag & value)

        return flags

    NO_HERO_STATUS = 0
    FULL_HERO_STATUS = 1
    CANNOT_BE_CONVERTED = 2
    HERO_REGENERATION = 4
    DEFENSIVE_STANCE_BY_DEFAULT = 8
    PROTECTED_FORMATION = 16
    DELETE_CONFIRMATION = 32
    HERO_GLOW = 64
    INVERT_FLAGS = 128

Attributes

NO_HERO_STATUS = 0 class-attribute instance-attribute

Value: 0

FULL_HERO_STATUS = 1 class-attribute instance-attribute

Value: 1

CANNOT_BE_CONVERTED = 2 class-attribute instance-attribute

Value: 2

HERO_REGENERATION = 4 class-attribute instance-attribute

Value: 4

DEFENSIVE_STANCE_BY_DEFAULT = 8 class-attribute instance-attribute

Value: 8

PROTECTED_FORMATION = 16 class-attribute instance-attribute

Value: 16

DELETE_CONFIRMATION = 32 class-attribute instance-attribute

Value: 32

HERO_GLOW = 64 class-attribute instance-attribute

Value: 64

INVERT_FLAGS = 128 class-attribute instance-attribute

Value: 128

Functions


def combine(...) staticmethod

This method combines the given hero status flags into an integer value

Parameters:

Name Type Description Default
full_hero_status bool

Enabling this for a unit grants all the flags mentioned below except invert_all_flags

False
cannot_be_converted bool

Enabling this for a unit makes it un-convertable

False
hero_regeneration bool

Enabling this for a unit grants 0.5 HP/s heal rate to the unit

False
defensive_stance_by_default bool

Enabling this for a unit makes it be on defensive stance by default

False
protected_formation bool

Enabling this for a unit makes it be in protected formation by default

False
delete_confirmation bool

Enabling this for a unit will bring up a delete confirmation for the unit when trying

False
hero_glow bool

Enabling this for a unit grants it the golden hero glow effect

False
invert_all_flags bool

Enabling this for a unit will invert all the above flags except full_hero_status

False

Returns:

Type Description
HeroStatusFlag

An integer combining all the different hero status flags into one value

Source code in AoE2ScenarioParser/datasets/trigger_lists/hero_status_flag.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@staticmethod
def combine(
        full_hero_status: bool = False,
        cannot_be_converted: bool = False,
        hero_regeneration: bool = False,
        defensive_stance_by_default: bool = False,
        protected_formation: bool = False,
        delete_confirmation: bool = False,
        hero_glow: bool = False,
        invert_all_flags: bool = False
) -> HeroStatusFlag:
    """
    This method combines the given hero status flags into an integer value

    Args:
        full_hero_status: Enabling this for a unit grants all the flags mentioned below except invert_all_flags
        cannot_be_converted: Enabling this for a unit makes it un-convertable
        hero_regeneration: Enabling this for a unit grants 0.5 HP/s heal rate to the unit
        defensive_stance_by_default: Enabling this for a unit makes it be on defensive stance by default
        protected_formation: Enabling this for a unit makes it be in protected formation by default
        delete_confirmation: Enabling this for a unit will bring up a delete confirmation for the unit when trying
        to delete it IF the player has them enabled
        hero_glow: Enabling this for a unit grants it the golden hero glow effect
        invert_all_flags: Enabling this for a unit will invert all the above flags except full_hero_status

    Returns:
        An integer combining all the different hero status flags into one value
    """
    total = 1 if full_hero_status else 0
    total += 2 if cannot_be_converted else 0
    total += 4 if hero_regeneration else 0
    total += 8 if defensive_stance_by_default else 0
    total += 16 if protected_formation else 0
    total += 32 if delete_confirmation else 0
    total += 64 if hero_glow else 0
    total += 128 if invert_all_flags else 0
    return HeroStatusFlag(total)

def split_flags(...) staticmethod

Split the Hero Status flags into boolean variables related to their effects

Parameters:

Name Type Description Default
value int

An integer value representing all the hero status flags set

required

Returns:

Type Description
Dict[HeroStatusFlag, bool]

A dict with all the flags values as keys and a bool as their value

Source code in AoE2ScenarioParser/datasets/trigger_lists/hero_status_flag.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@staticmethod
def split_flags(value: int) -> Dict[HeroStatusFlag, bool]:
    """
    Split the Hero Status flags into boolean variables related to their effects

    Args:
        value: An integer value representing all the hero status flags set

    Returns:
        A dict with all the flags values as keys and a bool as their value
    """
    flags = {}
    for flag in HeroStatusFlag:
        flags[flag] = bool(flag & value)

    return flags