using System.Collections.Generic; using Continentis.MainGame; using Continentis.MainGame.Character; using Continentis.MainGame.Combat; using SLSUtilities.General; using UnityEngine; namespace Continentis.Mods.Basic.Buffs { /// /// 感电(Storm 元素):承载者每次被攻击时, /// 对随机 1 个其他敌方目标造成等同于层数的雷电伤害,然后层数 -1。 /// 对单敌战斗退化(无其他目标时无效)。 /// 过滤 Reactive/HpRemoval/Reflected 防递归。 /// public sealed class Shocked : CharacterCombatBuffBase { public Shocked(int stack) { Initialize(BuffType.Negative, BuffDispelLevel.Basic); this.contentSubmodule = new ContentSubmodule(this) .AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString()); this.iconSubmodule = new IconSubmodule(this); this.unitedStackSubmodule = new UnitedStackSubmodule(this, stack); this.eventSubmodule = new EventSubmodule(this); this.eventSubmodule.onGetAttacked.Add("Shocked", new PrioritizedAction(OnGetAttacked)); } private void OnGetAttacked(AttackResult result) { // 响应式 / 生命移除 / 反弹伤害不触发感电 if (result.context.HasAnyTag(AttackTags.Reactive, AttackTags.HpRemoval, AttackTags.Reflected)) return; // 收集除自身以外的其他同阵营敌方角色 List others = CombatMainManager.Instance.characterController .GetAllEnemies(attachedCharacter); others.Remove(attachedCharacter); if (others.Count == 0) return; CharacterBase spreadTarget = others[Random.Range(0, others.Count)]; int damage = unitedStackSubmodule.stackAmount; var ctx = new AttackContext() .WithTag(AttackTags.Reactive) .WithTag(AttackTags.GuaranteedHit) .WithDamageKeywords("Storm"); sourceCharacter.Attack(spreadTarget, damage, ctx); unitedStackSubmodule.ReduceStack(1); iconSubmodule.Update(); } public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff) { MainGameManager.Instance.basePrefabs.GenerateInfoText( contentSubmodule.displayName, attachedCharacter.characterView); if (FindExistingSameBuff(out existingBuff)) { existingBuff.unitedStackSubmodule.AddStack(this.unitedStackSubmodule.stackAmount); return false; } return true; } } }