Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
ADD - Parse CEX (CRT by combo, on healed, on dodged)
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Jan 24, 2021
1 parent c68b291 commit b31740a
Show file tree
Hide file tree
Showing 23 changed files with 220 additions and 59 deletions.
18 changes: 13 additions & 5 deletions .data/custom/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,6 @@
"id": "ENUM_COND_IN_BUFF_ZONE_BY_ALLY_3",
"text": "友建 3 Buff 區內"
},
{
"id": "ENUM_COND_IN_BUFF_ZONE",
"text": "Buff 區內"
},
{
"id": "ENUM_COND_WEAPON_SWORD",
"text": "武器: 劍"
Expand Down Expand Up @@ -703,6 +699,14 @@
"id": "ENUM_COND_ON_ENTERED_BUFF_ZONE",
"text": "進入 Buff 區時"
},
{
"id": "ENUM_COND_ON_HEALED",
"text": "回血時"
},
{
"id": "ENUM_COND_ON_DODGE_SUCCESS",
"text": "成功迴避攻擊"
},
{
"id": "ENUM_COND_ON_HP_LT_30",
"text": "HP < 30% 時"
Expand Down Expand Up @@ -783,6 +787,10 @@
"id": "ENUM_COND_ON_COMBO_GTE_10",
"text": "Combo >= 10 時"
},
{
"id": "ENUM_COND_ON_COMBO_DIV_BY_10",
"text": "每 10 Combo"
},
{
"id": "ENUM_COND_ON_COMBO_DIV_BY_20",
"text": "每 20 Combo"
Expand All @@ -796,7 +804,7 @@
"text": "Combo 重設時"
},
{
"id": "ENUM_COND_ON_HIT_BY_POISON",
"id": "ENUM_COND_ON_HIT",
"text": "被攻擊"
},
{
Expand Down
16 changes: 12 additions & 4 deletions .data/custom/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,6 @@
"id": "ENUM_COND_IN_BUFF_ZONE_BY_ALLY_3",
"text": "In 3 Ally Buff Zone"
},
{
"id": "ENUM_COND_IN_BUFF_ZONE",
"text": "In Buff Zone"
},
{
"id": "ENUM_COND_WEAPON_SWORD",
"text": "Weapon: Sword"
Expand Down Expand Up @@ -703,6 +699,14 @@
"id": "ENUM_COND_ON_ENTERED_BUFF_ZONE",
"text": "Upon entering buff zone"
},
{
"id": "ENUM_COND_ON_HEALED",
"text": "Upon healed"
},
{
"id": "ENUM_COND_ON_DODGE_SUCCESS",
"text": "Upon successfully dodged"
},
{
"id": "ENUM_COND_ON_HP_LT_30",
"text": "Upon HP < 30%"
Expand Down Expand Up @@ -783,6 +787,10 @@
"id": "ENUM_COND_ON_COMBO_GTE_10",
"text": "Upon Combo >= 10"
},
{
"id": "ENUM_COND_ON_COMBO_DIV_BY_10",
"text": "Every 10 Combo"
},
{
"id": "ENUM_COND_ON_COMBO_DIV_BY_20",
"text": "Every 20 Combo"
Expand Down
16 changes: 12 additions & 4 deletions .data/custom/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,6 @@
"id": "ENUM_COND_IN_BUFF_ZONE_BY_ALLY_3",
"text": "友建 3 Buff 區內"
},
{
"id": "ENUM_COND_IN_BUFF_ZONE",
"text": "Buff 區內"
},
{
"id": "ENUM_COND_WEAPON_SWORD",
"text": "武器: 劍"
Expand Down Expand Up @@ -703,6 +699,14 @@
"id": "ENUM_COND_ON_ENTERED_BUFF_ZONE",
"text": "進入 Buff 區時"
},
{
"id": "ENUM_COND_ON_HEALED",
"text": "Upon healed"
},
{
"id": "ENUM_COND_ON_DODGE_SUCCESS",
"text": "成功迴避攻擊"
},
{
"id": "ENUM_COND_ON_HP_LT_30",
"text": "Upon HP < 30%"
Expand Down Expand Up @@ -783,6 +787,10 @@
"id": "ENUM_COND_ON_COMBO_GTE_10",
"text": "Upon Combo >= 10"
},
{
"id": "ENUM_COND_ON_COMBO_DIV_BY_10",
"text": "每 10 Combo"
},
{
"id": "ENUM_COND_ON_COMBO_DIV_BY_20",
"text": "每 20 Combo"
Expand Down
3 changes: 3 additions & 0 deletions dlparse/enums/ability_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class AbilityCondition(Enum):
EFF_SELF_HP_GTE_2 = 60
EFF_SELF_HP_LT_2 = 61
EFF_IN_BUFF_ZONE = 88
TRG_HEALED = 92
TRG_COMBO_COUNT_DIV_LIMITED = 95
TRG_DODGE_SUCCESS = 96

@property
def is_shapeshifted_to_dragon(self) -> bool:
Expand Down
2 changes: 2 additions & 0 deletions dlparse/enums/ability_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class AbilityUpParameter(Enum):
Ability status up parameters.
This can be found in the ID-A field of the abiltity variants.
The enum definition can be found in ``Gluon.TargetParam`` of the metadata.
"""

NONE = 0 # None
Expand Down
2 changes: 1 addition & 1 deletion dlparse/enums/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AbilityTargetAction(Enum):
This can be found in the field ``_TargetAction`` of ``ActionGrant``.
The official definition can be found in ``Gluon.AbilityTargetAction`` of the metadata.
The enum definition can be found in ``Gluon.AbilityTargetAction`` of the metadata.
"""

UNKNOWN = -1
Expand Down
2 changes: 1 addition & 1 deletion dlparse/enums/action_debuff_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ActionDebuffType(Enum):
This is used by the ability condition fields, where if the condition type is ``DEBUFF`` (``50``),
the condition value will be this.
The enum definition can be found in ``Gluon.CharacterBuff.ActionDefDebuff`` in the metadata.
The enum definition can be found in ``Gluon.CharacterBuff.ActionDefDebuff`` of the metadata.
"""

UNKNOWN = -1
Expand Down
6 changes: 4 additions & 2 deletions dlparse/enums/buff_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BuffParameter(Enum):
"""ATK up (calculated as buff). A value of 0.12 means ATK +12%."""
DEF_BUFF = 102
"""DEF up (calculated as buff). A value of 0.12 means DEF +12%."""
CRT_RATE = 103
CRT_RATE_BUFF = 103
"""Critical rate up (calculated as buff). A value of 0.12 means CRT +12%."""
CRT_DAMAGE = 104
"""Critical damage up (calculated as buff). A value of 0.12 means CRT DMG +12%."""
Expand Down Expand Up @@ -69,6 +69,8 @@ class BuffParameter(Enum):
"""ATK up (calculated as passive). A value of 0.12 means ATK +12%."""
DEF_PASSIVE = 152
"""DEF up (calculated as passive). A value of 0.12 means DEF +12%."""
CRT_RATE_PASSIVE = 153
"""Critical rate up (calculated as passive). A value of 0.12 means CRT +12%."""
ASPD_PASSIVE = 156
"""Attack speed up (calculated as passive). A value of 0.12 means ASPD +12%."""
# endregion
Expand Down Expand Up @@ -315,7 +317,7 @@ class BuffParameter(Enum):
"""Increased the damage dealt in the dragon form. A value of 0.12 means damage in dragon +12%."""
DRAGON_GAUGE_FILL = 606
"""
Fill the dragon gauge by a certain percentage. A value of 0.12 means to fill 12% of the dragon gauge.
Fill the dragon gauge by a certain percentage. A value of 0.12 means to fill 12% of the dragon gauge.
(Shapeshifting once takes 50% of the dragon gauge)
"""
# endregion
Expand Down
13 changes: 8 additions & 5 deletions dlparse/enums/condition/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,16 @@ class ConditionCategories:
Condition.ON_REVIVED,
Condition.ON_ENERGY_LV_UP,
Condition.ON_ENTERED_BUFF_ZONE,
Condition.ON_SELF_HP_LT_30,
Condition.ON_SELF_HP_LT_40,
Condition.ON_SELF_HP_LT_60,
Condition.ON_SELF_HP_GTE_40,
Condition.ON_SELF_HP_GTE_60,
Condition.ON_HEALED,
Condition.ON_DODGE_SUCCESS,
Condition.ON_HP_LT_30,
Condition.ON_HP_LT_40,
Condition.ON_HP_LT_60,
Condition.ON_HP_GTE_40,
Condition.ON_HP_GTE_60,
Condition.ON_COMBO_RESET,
Condition.ON_COMBO_GTE_10,
Condition.ON_COMBO_DIV_BY_10,
Condition.ON_COMBO_DIV_BY_20,
Condition.ON_COMBO_DIV_BY_50,
Condition.ON_HIT,
Expand Down
17 changes: 10 additions & 7 deletions dlparse/enums/condition/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,16 @@ class Condition(Enum):
ON_REVIVED = 802
ON_ENERGY_LV_UP = 803
ON_ENTERED_BUFF_ZONE = 804
ON_HEALED = 805
ON_DODGE_SUCCESS = 806
# endregion

# region HP change
ON_SELF_HP_LT_30 = 810
ON_SELF_HP_LT_40 = 811
ON_SELF_HP_LT_60 = 812
ON_SELF_HP_GTE_40 = 820
ON_SELF_HP_GTE_60 = 821
ON_HP_LT_30 = 810
ON_HP_LT_40 = 811
ON_HP_LT_60 = 812
ON_HP_GTE_40 = 820
ON_HP_GTE_60 = 821
# endregion

# region Infliction
Expand All @@ -297,8 +299,9 @@ class Condition(Enum):
# region Combo count
ON_COMBO_RESET = 850
ON_COMBO_GTE_10 = 851
ON_COMBO_DIV_BY_20 = 855
ON_COMBO_DIV_BY_50 = 856
ON_COMBO_DIV_BY_10 = 855
ON_COMBO_DIV_BY_20 = 856
ON_COMBO_DIV_BY_50 = 857
# endregion
# endregion

Expand Down
9 changes: 6 additions & 3 deletions dlparse/model/ability_var_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ class AbilityVariantEffectPayload(ActionCondEffectConvertPayload):

source_ability_id: int = field(init=False)
condition_probability: float = field(init=False)
max_stack_count: int = field(init=False)

def __post_init__(self):
self.source_ability_id = self.source_ability.id
self.condition_probability = self.source_ability.condition.probability
self.max_stack_count = self.source_ability.condition.max_stack_count

@property
def is_source_ex_ability(self) -> bool:
Expand Down Expand Up @@ -110,8 +112,9 @@ def to_dispel_unit(
) -> Optional[AbilityVariantEffectUnit]:
return self._action_cond_unit(param_enum, 0, action_cond, payload, target=HitTargetSimple.ENEMY)

@staticmethod
def _action_cond_unit(
self, param_enum: BuffParameter, param_rate: float, action_cond: ActionConditionEntry,
param_enum: BuffParameter, param_rate: float, action_cond: ActionConditionEntry,
payload: AbilityVariantEffectPayload = None, /,
target: Optional[HitTargetSimple] = None
) -> AbilityVariantEffectUnit:
Expand Down Expand Up @@ -164,7 +167,7 @@ def _direct_buff_unit(
status=Status.NONE,
duration_sec=0,
duration_count=0,
max_stack_count=0,
max_stack_count=payload.source_ability.condition.max_stack_count,
slip_damage_mod=0,
slip_interval=0,
)
Expand Down Expand Up @@ -214,7 +217,7 @@ def _from_dmg_up(
def _from_crt_up(
self, asset_manager: "AssetManager", payload: AbilityVariantEffectPayload
) -> set[AbilityVariantEffectUnit]:
return self._direct_buff_unit(BuffParameter.CRT_RATE, asset_manager, payload)
return self._direct_buff_unit(BuffParameter.CRT_RATE_PASSIVE, asset_manager, payload)

def _from_crt_dmg_up(
self, asset_manager: "AssetManager", payload: AbilityVariantEffectPayload
Expand Down
2 changes: 1 addition & 1 deletion dlparse/model/action_cond_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _units_common_buffs(
BuffParameter.DEF_BUFF, action_cond.buff_def + action_cond.buff_def_b, action_cond, payload
),
# CRT rate
self.to_param_up(BuffParameter.CRT_RATE, action_cond.buff_crt_rate, action_cond, payload),
self.to_param_up(BuffParameter.CRT_RATE_BUFF, action_cond.buff_crt_rate, action_cond, payload),
# CRT damage
self.to_param_up(BuffParameter.CRT_DAMAGE, action_cond.buff_crt_damage, action_cond, payload),
# Skill damage
Expand Down
26 changes: 21 additions & 5 deletions dlparse/mono/asset/base/ability.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ def __post_init__(self):
AbilityCondition.EFF_IN_BUFF_ZONE: Condition.ON_ENTERED_BUFF_ZONE,
AbilityCondition.TRG_SHAPESHIFT_COMPLETED: Condition.SELF_SHAPESHIFT_COMPLETED,
AbilityCondition.TRG_GOT_HIT: Condition.ON_HIT,
AbilityCondition.TRG_HEALED: Condition.ON_HEALED,
AbilityCondition.TRG_DODGE_SUCCESS: Condition.ON_DODGE_SUCCESS,
}
self._cond_method_map = {
AbilityCondition.EFF_IN_DRAGON: self._cond_self_in_dragon,
AbilityCondition.TRG_COMBO_COUNT_GTE: self._cond_combo_count_gte,
AbilityCondition.TRG_COMBO_COUNT_DIV: self._cond_combo_count_div,
AbilityCondition.TRG_COMBO_COUNT_DIV_LIMITED: self._cond_combo_count_div,
AbilityCondition.EFF_TARGET_DEBUFFED: self._cond_target_debuffed,
AbilityCondition.EFF_TARGET_AFFLICTED: self._cond_target_afflicted,
AbilityCondition.EFF_SELF_BUFFED_ACTION_COND: self._cond_self_buffed,
Expand Down Expand Up @@ -134,9 +137,9 @@ def _cond_self_hp_gte(self) -> Condition:

def _cond_self_hp_gte_trigger(self) -> Condition:
if self.val_1 == 40:
return Condition.ON_SELF_HP_GTE_40
return Condition.ON_HP_GTE_40
if self.val_1 == 60:
return Condition.ON_SELF_HP_GTE_60
return Condition.ON_HP_GTE_60

raise self._condition_unconvertible()

Expand All @@ -150,11 +153,11 @@ def _cond_self_hp_lt(self) -> Condition:

def _cond_self_hp_lt_trigger(self) -> Condition:
if self.val_1 == 30:
return Condition.ON_SELF_HP_LT_30
return Condition.ON_HP_LT_30
if self.val_1 == 40:
return Condition.ON_SELF_HP_LT_40
return Condition.ON_HP_LT_40
if self.val_1 == 60:
return Condition.ON_SELF_HP_LT_60
return Condition.ON_HP_LT_60

raise self._condition_unconvertible()

Expand All @@ -173,6 +176,8 @@ def _cond_combo_count_gte(self) -> Condition:
raise self._condition_unconvertible()

def _cond_combo_count_div(self) -> Condition:
if self.val_1 == 10:
return Condition.ON_COMBO_DIV_BY_10
if self.val_1 == 20:
return Condition.ON_COMBO_DIV_BY_20
if self.val_1 == 50:
Expand Down Expand Up @@ -255,6 +260,17 @@ def is_unknown_condition(self) -> bool:
"""Check if the condition type is unknown."""
return self.condition_type == AbilityCondition.UNKNOWN

@property
def max_stack_count(self) -> int:
"""
Maximum count of the stacks allowed for the ability.
This limited is placed at the ability level. Do not use this for the stack count limit of a single ability.
``0`` means no ability level stack count limit.
"""
return 0


@dataclass
class AbilityVariantEntryBase(ABC):
Expand Down
9 changes: 8 additions & 1 deletion dlparse/mono/asset/master/ability.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass, field
from typing import Optional, TYPE_CHECKING, TextIO, Union

from dlparse.enums import AbilityCondition, AbilityVariantType, Condition, SkillNumber, Element, Weapon, UnitType
from dlparse.enums import AbilityCondition, AbilityVariantType, Condition, Element, SkillNumber, UnitType, Weapon
from dlparse.errors import AbilityConditionUnconvertibleError, AbilityOnSkillUnconvertibleError
from dlparse.mono.asset.base import (
AbilityConditionEntryBase, AbilityEntryBase, AbilityVariantEntryBase, MasterAssetBase, MasterEntryBase,
Expand Down Expand Up @@ -44,6 +44,13 @@ def _cond_self_buffed_additional(self) -> Optional[Condition]:

return None

@property
def max_stack_count(self) -> int:
if self.condition_type == AbilityCondition.TRG_COMBO_COUNT_DIV_LIMITED:
return int(self.val_2)

return super().max_stack_count


@dataclass
class AbilityVariantEntry(AbilityVariantEntryBase):
Expand Down
Loading

0 comments on commit b31740a

Please sign in to comment.