User:Forte/解析メモ/ダメージ

From Ylvapedia
< User:Forte‎ | 解析メモ
Revision as of 14:40, 26 December 2024 by Forte (talk | contribs)
バージョン EA23.67: この記事はElin最新の安定版リリースに対応しています。

ページの説明

ダメージ計算のコードを読んでます

Evalueリスト

Value# Element 備考
(961) 魔法耐性

属性耐性

      if (!e.source.aliasRef.IsEmpty() && attackSource != AttackSource.ManaBackfire)
      {
        dmg = Element.GetResistDamage(dmg, this.Evalue(e.source.aliasRef));
        dmg = dmg * 100 / (100 + Mathf.Clamp(this.Evalue(961) * 5, -50, 200));
      }

Element.GetResistDamageで各属性を軽減。

Evalue(961)は魔法耐性。2倍から1/3倍まで細かく増加、軽減。

 public static int GetResistDamage(int dmg, int v)
  {
    int resistLv = Element.GetResistLv(v);
    if (resistLv >= 4)
      return 0;
    switch (resistLv - -2)
    {
      case 0:
        return dmg * 2;
      case 1:
        return dmg * 3 / 2;
      case 3:
        return dmg / 2;
      case 4:
        return dmg / 3;
      case 5:
        return dmg / 4;
      default:
        return dmg;
    }
  }

耐性5毎にダメージを軽減もしくは増加。

-10で200% 15で25% 20以上は0。

濡れ補正

switch (e.id)
      {
        case 910:
          Chara chara1 = this.Chara;
          if ((chara1 != null ? (chara1.isWet ? 1 : 0) : 0) != 0)
          {
            dmg /= 3;
            break;
          }
          break;
        case 912:
          Chara chara2 = this.Chara;
          if ((chara2 != null ? (chara2.isWet ? 1 : 0) : 0) != 0)
          {
            dmg = dmg * 150 / 100;
            break;
          }
          break;
      }

濡れてたら火炎属性1/3 電撃属性1.5倍

軽減処理

    if (attackSource != AttackSource.Finish)
    {
      if (!this.IsPCFaction && this.LV > 50)
        dmg = dmg * (100 - (int) Mathf.Min(80f, Mathf.Sqrt((float) (this.LV - 50)) * 2.5f)) / 100;
      dmg = dmg * Mathf.Max(0, 100 - this.Evalue(e == Element.Void ? 55 : 56)) / 100;
      if (origin != null && origin.IsPC && EClass.player.codex.Has(this.id))
        dmg = dmg * (100 + Mathf.Min(10, EClass.player.codex.GetOrCreate(this.id).weakspot)) / 100;
      if (this.isChara && this.Chara.body.GetAttackStyle() == AttackStyle.Shield && this.elements.ValueWithoutLink(123) >= 5 && e == Element.Void)
        dmg = dmg * 90 / 100;
      if (this.Evalue(971) > 0)
        dmg = dmg * 100 / Mathf.Clamp(100 + this.Evalue(971), 25, 1000);
      if (this.HasElement(1305))
        dmg = dmg * 90 / 100;
      if (EClass.pc.HasElement(1207) && this.isChara)
      {
        int num1 = 0;
        int num2 = 0;
        foreach (Condition condition in this.Chara.conditions)
        {
          if (condition.Type == ConditionType.Buff)
            ++num1;
          else if (condition.Type == ConditionType.Debuff)
            ++num2;
        }
        dmg = !this.IsPCParty ? dmg * Mathf.Min(100 + num2 * 5, 120) / 100 : dmg * 100 / Mathf.Min(100 + num1 * 5, 120);
      }
      if (this.IsPCParty && EClass.pc.ai is GoalAutoCombat)
        dmg = dmg * 100 / Mathf.Min(105 + EClass.pc.Evalue(135) / 10, 110);
      if (this.HasElement(1218))
      {
        dmg = dmg * (1000 - this.Evalue(1218)) / 1000;
        if (dmg <= 0 && EClass.rnd(4) == 0)
          dmg++;
      }
      if (dmg >= this.MaxHP / 10 && this.Evalue(68) > 0)
      {
        int num3 = this.MaxHP / 10;
        int num4 = (dmg - num3) * 100 / (200 + this.Evalue(68) * 10);
        dmg = num3 + num4;
      }
    }

敵かつLv50より大きい場合√(Lv-50)×2.5%ダメージを軽減 最大80%

物理か属性かを判断して軽減ステータスを適用

弱点が判明(危ない本の効果)していればダメージを増加 最大1.1倍

盾Lv5以上かつ盾スタイルなら0.9倍

ダメージ軽減をもつならダメージを軽減(ダメージ軽減自体が現状使われている様子はなし)

オパートス信仰なら0.9倍

狐守補正 最大 与ダメ1.2倍 被ダメ1/1.2倍

オートコンバット補正 1/1.05~1.1倍

メタル補正 25%の確率で1ダメージ加算

致命傷耐性 HPの10%を超えるダメージを軽減 致命傷耐性は大地の力(数値未確認)と黄金の騎士(固定値100)

DamageHP()

 public void DamageHP(
    int dmg,
    int ele,
    int eleP = 100,
    AttackSource attackSource = AttackSource.None,
    Card origin = null,
    bool showEffect = true)
  {
    if (this.hp < 0)
      return;
    Element e;
    if (ele == 0)
    {
      e = Element.Void;
    }
    else
    {
      e = Element.Create(ele);
      if (attackSource != AttackSource.Condition & showEffect)
        ActEffect.TryDelay((Action) (() =>
        {
          this.PlayEffect(e.id, range: 0.25f);
          EClass.Sound.Play("atk_" + e.source.alias);
        }));
      if (!e.source.aliasRef.IsEmpty() && attackSource != AttackSource.ManaBackfire)
      {
        dmg = Element.GetResistDamage(dmg, this.Evalue(e.source.aliasRef));
        dmg = dmg * 100 / (100 + Mathf.Clamp(this.Evalue(961) * 5, -50, 200));
      }
      switch (e.id)
      {
        case 910:
          Chara chara1 = this.Chara;
          if ((chara1 != null ? (chara1.isWet ? 1 : 0) : 0) != 0)
          {
            dmg /= 3;
            break;
          }
          break;
        case 912:
          Chara chara2 = this.Chara;
          if ((chara2 != null ? (chara2.isWet ? 1 : 0) : 0) != 0)
          {
            dmg = dmg * 150 / 100;
            break;
          }
          break;
      }
    }
    if (attackSource != AttackSource.Finish)
    {
      if (!this.IsPCFaction && this.LV > 50)
        dmg = dmg * (100 - (int) Mathf.Min(80f, Mathf.Sqrt((float) (this.LV - 50)) * 2.5f)) / 100;
      dmg = dmg * Mathf.Max(0, 100 - this.Evalue(e == Element.Void ? 55 : 56)) / 100;
      if (origin != null && origin.IsPC && EClass.player.codex.Has(this.id))
        dmg = dmg * (100 + Mathf.Min(10, EClass.player.codex.GetOrCreate(this.id).weakspot)) / 100;
      if (this.isChara && this.Chara.body.GetAttackStyle() == AttackStyle.Shield && this.elements.ValueWithoutLink(123) >= 5 && e == Element.Void)
        dmg = dmg * 90 / 100;
      if (this.Evalue(971) > 0)
        dmg = dmg * 100 / Mathf.Clamp(100 + this.Evalue(971), 25, 1000);
      if (this.HasElement(1305))
        dmg = dmg * 90 / 100;
      if (EClass.pc.HasElement(1207) && this.isChara)
      {
        int num1 = 0;
        int num2 = 0;
        foreach (Condition condition in this.Chara.conditions)
        {
          if (condition.Type == ConditionType.Buff)
            ++num1;
          else if (condition.Type == ConditionType.Debuff)
            ++num2;
        }
        dmg = !this.IsPCParty ? dmg * Mathf.Min(100 + num2 * 5, 120) / 100 : dmg * 100 / Mathf.Min(100 + num1 * 5, 120);
      }
      if (this.IsPCParty && EClass.pc.ai is GoalAutoCombat)
        dmg = dmg * 100 / Mathf.Min(105 + EClass.pc.Evalue(135) / 10, 110);
      if (this.HasElement(1218))
      {
        dmg = dmg * (1000 - this.Evalue(1218)) / 1000;
        if (dmg <= 0 && EClass.rnd(4) == 0)
          dmg++;
      }
      if (dmg >= this.MaxHP / 10 && this.Evalue(68) > 0)
      {
        int num3 = this.MaxHP / 10;
        int num4 = (dmg - num3) * 100 / (200 + this.Evalue(68) * 10);
        dmg = num3 + num4;
      }
    }
    if (origin != null && origin.IsPC && EClass.pc.Evalue(654) > 0)
      dmg = 0;
    if (dmg < 0)
      dmg = 0;
    int num5 = Mathf.Clamp(dmg * 6 / this.MaxHP, 0, 4) + (dmg > 0 ? 1 : 0);
    if (this.Evalue(1421) > 0)
    {
      int num6 = 0;
      int num7 = dmg;
      if (this.hp > 0)
      {
        num7 = dmg - this.hp;
        this.hp -= dmg;
        num6 += dmg;
        if (this.hp < 0 && this.Chara.mana.value >= 0)
        {
          num6 += this.hp;
          this.hp = 0;
        }
      }
      if (this.hp <= 0)
      {
        if (this.Evalue(1421) >= 2)
          num7 /= 2;
        dmg = num7;
        if (this.Chara.mana.value > 0)
        {
          num7 -= this.Chara.mana.value;
          this.Chara.mana.value -= dmg;
          num6 += dmg;
        }
        if (this.Chara.mana.value <= 0)
        {
          this.hp -= num7;
          num6 += num7;
        }
      }
      dmg = num6;
    }
    else
      this.hp -= dmg;
    if (this.isSynced && dmg != 0)
    {
      float ratio = (float) dmg / (float) this.MaxHP;
      Card c = this.parent is Chara ? (Card) (this.parent as Chara) : this;
      ActEffect.TryDelay((Action) (() =>
      {
        c.PlayEffect("blood").SetParticleColor(EClass.Colors.matColors[this.material.alias].main).Emit(20 + (int) (30.0 * (double) ratio));
        if (!EClass.core.config.test.showNumbers && !this.isThing)
          return;
        Popper popper = EClass.scene.popper.Pop(this.renderer.PositionCenter(), "DamageNum");
        Color color = c.IsPC ? EClass.Colors.textColors.damagePC : (c.IsPCFaction ? EClass.Colors.textColors.damagePCParty : EClass.Colors.textColors.damage);
        if (e != Element.Void)
        {
          color = EClass.Colors.elementColors.TryGetValue<string, Color>(e.source.alias);
          float num8 = (float) (((double) color.r + (double) color.g + (double) color.b) / 3.0);
          float num9 = (double) num8 > 0.5 ? 0.0f : 0.6f - num8;
          color = new Color(color.r + num9, color.g + num9, color.b + num9, 1f);
        }
        string s = dmg.ToString() ?? "";
        Color c1 = color;
        popper.SetText(s, c1);
      }));
    }
    ZoneInstanceBout instance = EClass._zone.instance as ZoneInstanceBout;
    if (this.hp < 0 && Religion.recentWrath == null)
    {
      if (this.isRestrained && this.IsPCFaction && EClass._zone.IsPCFaction && (!this.IsPC || this.Chara.ai is AI_Torture && this.Chara.ai.IsRunning))
      {
        EvadeDeath();
        if (this.Chara.stamina.value > 0 && (EClass.rnd(2) == 0 || !this.IsPC))
          this.Chara.stamina.Mod(-1);
      }
      else if (this.IsInstalled && this.pos.HasBlock && this.trait.IsDoor)
        EvadeDeath();
      else if (!this.trait.CanBeDestroyed)
        EvadeDeath();
      else if (this.HasEditorTag(EditorTag.Invulnerable) || this.HasEditorTag(EditorTag.InvulnerableToMobs) && (origin == null || !origin.IsPCParty))
        EvadeDeath();
      else if (this.isChara)
      {
        if (this.Chara.HasCondition<ConInvulnerable>())
          EvadeDeath();
        else if (this.IsPC && EClass.debug.godMode)
          EvadeDeath();
        else if (this.Chara.host != null)
          EvadeDeath();
        else if (instance != null && (bool) (UnityEngine.Object) LayerDrama.Instance)
          EvadeDeath();
        else if (LayerDrama.IsActive() && this.IsPC)
        {
          EvadeDeath();
        }
        else
        {
          if (attackSource != AttackSource.Finish && this.IsPCParty && this.Chara.host == null && EClass.pc.ai is GoalAutoCombat)
          {
            if (!EClass.player.invlunerable && (EClass.pc.ai as GoalAutoCombat).listHealthy.Contains(this.Chara))
            {
              EClass.core.actionsNextFrame.Add((Action) (() => Msg.Say(this.IsPC ? "abort_damage" : "abort_damgeAlly")));
              EClass.player.invlunerable = true;
              EClass.player.TryAbortAutoCombat();
              EClass.pc.stamina.Mod(-EClass.pc.stamina.max / 5);
            }
            if (EClass.player.invlunerable)
            {
              EvadeDeath();
              goto label_88;
            }
          }
          if (this.IsPC && this.Evalue(1220) > 0 && this.Chara.stamina.value >= this.Chara.stamina.max / 2)
          {
            this.Chara.stamina.Mod(-this.Chara.stamina.max / 2);
            this.Chara.AddCondition<ConInvulnerable>();
            EvadeDeath();
          }
        }
      }
    }
label_88:
    if (this.trait.CanBeAttacked)
    {
      this.renderer.PlayAnime(AnimeID.HitObj);
      this.hp = this.MaxHP;
    }
    if (this.hp < 0)
    {
      if ((attackSource == AttackSource.Melee || attackSource == AttackSource.Range) && origin != null && (origin.isSynced || this.IsPC))
      {
        string str = "";
        if (this.IsPC && Lang.setting.combatTextStyle == 0)
        {
          if (e != Element.Void && e != null)
            str = "dead_" + e.source.alias;
          if (str == "" || !LangGame.Has(str))
            str = "dead_attack";
          EClass.pc.Say(str, this, "");
        }
        else
        {
          if (e != Element.Void && e != null)
            str = "kill_" + e.source.alias;
          if (str == "" || !LangGame.Has(str))
            str = "kill_attack";
          (this.IsPC ? (Card) EClass.pc : origin).Say(str, origin, this);
        }
      }
      if (this.isChara && Religion.recentWrath == null)
      {
        if (this.HasElement(1410) && !this.Chara.HasCooldown(1410))
        {
          this.Chara.AddCooldown(1410);
          this.Say("reboot", this);
          this.PlaySound("reboot");
          this.Chara.Cure(CureType.Boss);
          this.hp = this.MaxHP / 3;
          this.Chara.AddCondition<ConInvulnerable>();
          return;
        }
        foreach (Chara chara in EClass._map.charas)
        {
          if (this.Chara.IsFriendOrAbove(chara) && chara.HasElement(1408) && chara.faith == EClass.game.religions.Healing && EClass.world.date.GetRawDay() != chara.GetInt(58) && (!chara.IsPCFaction || this.IsPCFaction))
          {
            Msg.alwaysVisible = true;
            Msg.Say("layhand", (Card) chara, this);
            Msg.Say("pray_heal", this);
            this.hp = this.MaxHP;
            this.Chara.AddCondition<ConInvulnerable>();
            this.PlayEffect("revive");
            this.PlaySound("revive");
            chara.SetInt(58, EClass.world.date.GetRawDay());
            return;
          }
        }
      }
      if (instance != null)
      {
        Chara target = EClass._map.FindChara(instance.uidTarget);
        if (target != null)
        {
          if (this.IsPC)
          {
            EClass.pc.hp = 0;
            Heal();
            target.ShowDialog("_chara", "bout_lose");
            return;
          }
          if (target == this)
          {
            this.hp = 0;
            Heal();
            target.ModAffinity(EClass.pc, 10);
            target.ShowDialog("_chara", "bout_win");
            return;
          }
        }

        void Heal()
        {
          target.Cure(CureType.Death);
          foreach (Chara member in EClass.pc.party.members)
            member.Cure(CureType.Death);
        }
      }
      if (!this.isDestroyed)
        this.Die(e, origin, attackSource);
      if (origin != null && origin.isChara)
      {
        if (origin.IsPCFactionOrMinion && this.isChara && !this.isCopy)
        {
          ++EClass.player.stats.kills;
          EClass.game.quests.list.ForeachReverse<Quest>((Action<Quest>) (q => q.OnKillChara(this.Chara)));
          EClass.player.codex.AddKill(this.id);
          if (Guild.Fighter.CanGiveContribution(this.Chara))
            Guild.Fighter.AddContribution(5 + this.LV / 5);
          if (Guild.Fighter.HasBounty(this.Chara))
          {
            int a = EClass.rndHalf(200 + this.LV * 20);
            Msg.Say("bounty", (Card) this.Chara, a.ToString() ?? "");
            EClass.pc.ModCurrency(a);
            SE.Pay();
          }
        }
        if (origin.IsPCParty && EClass.pc.Evalue(1355) > 0)
        {
          if (!(EClass.pc.AddCondition<ConStrife>() is ConStrife conStrife))
            conStrife = EClass.pc.GetCondition<ConStrife>();
          conStrife?.AddKill();
        }
        if (origin.GetInt(106) == 0)
          origin.Chara.TalkTopic("kill");
      }
      Msg.SetColor();
    }
    else if ((attackSource == AttackSource.Melee || attackSource == AttackSource.Range) && origin != null)
      (this.IsPC ? (Card) EClass.pc : origin).Say("dmgMelee" + num5.ToString() + (this.IsPC ? "pc" : ""), origin, this);
    else if (this.isChara)
    {
      int num10 = attackSource == AttackSource.Condition || attackSource == AttackSource.WeaponEnchant ? 2 : 1;
      if (num5 >= num10)
      {
        if (e != Element.Void)
          this.Say("dmg_" + e.source.alias, this);
        if (e == Element.Void || num5 >= 2)
          this.Say(nameof (dmg) + num5.ToString(), this);
      }
    }
    if (this.isChara && origin != null && origin.IsAliveInCurrentZone && origin.isChara)
    {
      if (e.id == 916)
        origin.HealHP(Mathf.Clamp(EClass.rnd(dmg * (50 + eleP) / 500 + 5), 1, origin.MaxHP / 5 + EClass.rnd(10)));
      if ((attackSource == AttackSource.Melee || attackSource == AttackSource.Range) && origin.Dist(this) <= 1)
      {
        if (attackSource == AttackSource.Melee && this.HasElement(1221))
        {
          int ele1 = this.Chara.MainElement == Element.Void ? 924 : this.Chara.MainElement.id;
          if (this.id == "hedgehog_ether")
            ele1 = 922;
          this.Say("reflect_thorne", this, origin);
          origin.DamageHP(Mathf.Clamp(dmg / 20, 1, this.MaxHP / 20), ele1, this.Power, AttackSource.Condition);
        }
        if (this.HasElement(1223))
        {
          int ele2 = this.Chara.MainElement == Element.Void ? 923 : this.Chara.MainElement.id;
          this.Say("reflect_acid", this, origin);
          origin.DamageHP(Mathf.Clamp(dmg / 20, 1, this.MaxHP / 20), ele2, this.Power * 2, AttackSource.Condition);
        }
      }
      if (origin.HasElement(662) && attackSource == AttackSource.Melee && origin.isChara && this.Chara.IsHostile(origin as Chara))
      {
        int a = EClass.rnd(3 + Mathf.Clamp(dmg / 100, 0, origin.Evalue(662) / 10));
        origin.Chara.stamina.Mod(a);
        if (this.IsAliveInCurrentZone)
          this.Chara.stamina.Mod(-a);
      }
      if (origin.HasElement(1350) && attackSource == AttackSource.Melee)
      {
        int a = EClass.rndHalf(2 + Mathf.Clamp(dmg / 10, 0, origin.Chara.GetPietyValue() + 10));
        origin.Chara.mana.Mod(a);
        if (this.IsAliveInCurrentZone)
          this.Chara.mana.Mod(-a);
      }
      if (origin.HasElement(661) && attackSource == AttackSource.Melee)
      {
        int a = EClass.rnd(2 + Mathf.Clamp(dmg / 10, 0, origin.Evalue(661) + 10));
        origin.Chara.mana.Mod(a);
        if (this.IsAliveInCurrentZone)
          this.Chara.mana.Mod(-a);
      }
    }
    if (this.hp < 0 || !this.isChara)
      return;
    if (dmg > 0)
    {
      int a = Mathf.Min(100 * (dmg * 100 / this.MaxHP) / 100, this.Chara.isRestrained ? 15 : 200);
      this.elements.ModExp(this.GetArmorSkill(), a);
      if (this.Chara.body.GetAttackStyle() == AttackStyle.Shield)
        this.elements.ModExp(123, a);
    }
    int a1 = EClass.rnd(2) == 0 ? 1 : 0;
    if (attackSource == AttackSource.Condition)
      a1 = 1 + EClass.rnd(2);
    if (a1 > 0)
    {
      bool flag = this.Chara.HasCondition<ConPoison>() || (e.id == 915 || e.id == 923) && this.ResistLv(this.Evalue(955)) < 4;
      this.AddBlood(a1, flag ? 6 : -1);
    }
    bool flag1 = true;
    switch (e.id)
    {
      case 910:
        if (Chance(30 + eleP / 5, 100))
        {
          this.Chara.AddCondition<ConBurning>(eleP);
          break;
        }
        break;
      case 911:
        if (this.Chara.isWet)
        {
          if (Chance(30 + eleP / 10, 100))
          {
            this.Chara.AddCondition<ConFreeze>(eleP);
            break;
          }
          break;
        }
        if (Chance(50 + eleP / 10, 100))
        {
          this.Chara.AddCondition<ConWet>(eleP);
          break;
        }
        break;
      case 912:
        if (Chance(75 + eleP / 20, 100) && EClass.rnd(3) == 0)
        {
          this.Chara.AddCondition<ConParalyze>(1, true);
          break;
        }
        break;
      case 913:
        if (Chance(30 + eleP / 5, 100))
        {
          this.Chara.AddCondition<ConBlind>(eleP);
          break;
        }
        break;
      case 914:
        flag1 = false;
        if (EClass.rnd(3) != 0)
        {
          if (Chance(30 + eleP / 5, 100))
          {
            this.Chara.AddCondition<ConConfuse>(eleP);
            break;
          }
          break;
        }
        if (Chance(30 + eleP / 5, 100))
        {
          this.Chara.AddCondition<ConSleep>(eleP);
          break;
        }
        break;
      case 915:
        if (Chance(30 + eleP / 5, 100))
        {
          this.Chara.AddCondition<ConPoison>(eleP);
          break;
        }
        break;
      case 917:
        if (Chance(50 + eleP / 10, 100))
        {
          this.Chara.AddCondition<ConDim>(eleP);
          break;
        }
        break;
      case 918:
        flag1 = false;
        if (Chance(30 + eleP / 5, 100))
        {
          this.Chara.AddCondition<ConParalyze>(eleP);
          break;
        }
        break;
      case 920:
        flag1 = false;
        if (Chance(5 + eleP / 25, 40))
          this.Chara.AddCondition<ConBlind>(eleP / 2);
        if (Chance(5 + eleP / 25, 40))
          this.Chara.AddCondition<ConParalyze>(eleP / 2);
        if (Chance(5 + eleP / 25, 40))
          this.Chara.AddCondition<ConConfuse>(eleP / 2);
        if (Chance(5 + eleP / 25, 40))
          this.Chara.AddCondition<ConPoison>(eleP / 2);
        if (Chance(5 + eleP / 25, 40))
          this.Chara.AddCondition<ConSleep>(eleP / 2);
        if (Chance(5 + eleP / 25, 40))
          this.Chara.AddCondition<ConDim>(eleP / 2);
        if (Chance(30 + eleP / 10, 100))
        {
          this.Chara.SAN.Mod(EClass.rnd(2));
          break;
        }
        break;
      case 922:
        this.Chara.ModCorruption(EClass.rnd(eleP / 50 + 10));
        break;
      case 923:
        if (Chance(50 + eleP / 10, 100) && EClass.rnd(4) == 0)
        {
          ActEffect.Proc(EffectId.Acid, (Card) this.Chara);
          break;
        }
        break;
      case 924:
        if (Chance(50 + eleP / 10, 100))
        {
          this.Chara.AddCondition<ConBleed>(eleP);
          break;
        }
        break;
      case 925:
        if (EClass.rnd(3) == 0)
        {
          if (Chance(30 + eleP / 5, 100))
          {
            this.Chara.AddCondition<ConDim>(eleP);
            break;
          }
          break;
        }
        if (EClass.rnd(2) == 0)
        {
          if (EClass.rnd(3) == 0)
          {
            this.Chara.AddCondition<ConParalyze>(1, true);
            break;
          }
          break;
        }
        if (EClass.rnd(2) == 0)
        {
          this.Chara.AddCondition<ConConfuse>(1 + EClass.rnd(3), true);
          break;
        }
        break;
    }
    if (origin != null && origin.HasElement(1411) && !this.Chara.HasCondition<ConGravity>())
    {
      Condition.ignoreEffect = true;
      this.Chara.AddCondition<ConGravity>(2000);
      Condition.ignoreEffect = false;
    }
    if (this.Chara.conSleep != null & flag1)
      this.Chara.conSleep.Kill();
    if (this.Chara.host != null && this.hp == 0 && !this.Chara.HasCondition<ConFaint>())
      this.Chara.AddCondition<ConFaint>(200, true);
    if (this.IsPC)
    {
      float num11 = (float) this.hp / (float) this.MaxHP;
      if (this.Evalue(1421) > 0)
        num11 = (float) this.Chara.mana.value / (float) this.Chara.mana.max;
      if ((double) num11 < 0.30000001192092896)
        this.PlaySound("heartbeat", (float) (1.0 - (double) num11 * 2.0));
    }
    if (!this.IsPC && this.hp < this.MaxHP / 5 && this.Evalue(423) <= 0 && dmg * 100 / this.MaxHP + 10 > EClass.rnd(this.IsPowerful ? 400 : 150) && !this.HasCondition<ConFear>())
      this.Chara.AddCondition<ConFear>(100 + EClass.rnd(100));
    if (this.Chara.ai.Current.CancelWhenDamaged && attackSource != AttackSource.Hunger && attackSource != AttackSource.Fatigue)
      this.Chara.ai.Current.TryCancel(origin);
    if (this.Chara.HasCondition<ConWeapon>())
    {
      ConWeapon condition = this.Chara.GetCondition<ConWeapon>();
      if (e.source.aliasRef == condition.sourceElement.aliasRef)
        condition.Mod(-1);
    }
    if (this.Chara.HasElement(1222) && (dmg >= this.MaxHP / 10 || EClass.rnd(20) == 0))
      ActEffect.Proc(EffectId.Duplicate, this);
    if (this.hp < this.MaxHP / 3 && this.HasElement(1409) && !this.Chara.HasCooldown(1409))
    {
      this.Chara.AddCooldown(1409);
      this.Chara.AddCondition<ConBoost>(this.Power);
      this.Chara.Cure(CureType.Boss);
      this.Chara.HealHP(this.MaxHP / 2);
    }
    if (origin == null || !origin.isChara || attackSource == AttackSource.Finish)
      return;
    if (!AI_PlayMusic.ignoreDamage)
      this.Chara.TrySetEnemy(origin.Chara);
    if (origin.Evalue(428) <= 0 || this.IsPCFactionOrMinion || EClass.rnd(dmg) < EClass.rnd(this.MaxHP / 10) + this.MaxHP / 100 + 1)
      return;
    origin.Chara.TryNeckHunt(this.Chara, origin.Evalue(428) * 20, true);

    void EvadeDeath()
    {
      this.hp = 0;
      if (this.Evalue(1421) <= 0 || !this.isChara || this.Chara.mana.value >= 0)
        return;
      this.Chara.mana.value = 0;
    }

    bool Chance(int a, int max)
    {
      return (dmg > 0 || origin != null && origin.HasElement(1345)) && Mathf.Min(a, max) > EClass.rnd(100);
    }
  }