Example #1
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, BattleContext context)
        {
            if (context.ContextStates.Contains <Redirected>())
            {
                yield break;
            }

            if (context.ActionType == BattleActionType.Trap || context.ActionType == BattleActionType.Item)
            {
                yield break;
            }

            if (Element != 00 && context.Data.Element != Element)
            {
                yield break;
            }

            Character targetChar = ZoneManager.Instance.CurrentMap.GetCharAtLoc(context.ExplosionTile);

            if (targetChar == null)
            {
                yield break;
            }

            //the attack needs to be able to hit foes
            if ((context.HitboxAction.TargetAlignments & Alignment.Foe) == Alignment.None)
            {
                yield break;
            }

            //original target char needs to be a friend of the target char
            if ((DungeonScene.Instance.GetMatchup(ownerChar, targetChar) & DrawFrom) == Alignment.None)
            {
                yield break;
            }

            CharAnimSpin spinAnim = new CharAnimSpin();

            spinAnim.CharLoc   = ownerChar.CharLoc;
            spinAnim.CharDir   = ownerChar.CharDir;
            spinAnim.MajorAnim = true;

            yield return(CoroutineManager.Instance.StartCoroutine(ownerChar.StartAnim(spinAnim)));

            yield return(new WaitWhile(ownerChar.OccupiedwithAction));

            DungeonScene.Instance.LogMsg(String.Format(Msg.ToLocal(), ownerChar.GetDisplayName(false), owner.GetDisplayName()));
            context.ExplosionTile   = ownerChar.CharLoc;
            context.Explosion.Range = 0;
            context.ContextStates.Set(new Redirected());
        }
Example #2
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, BattleContext context)
        {
            if (context.ContextStates.Contains <Redirected>())
            {
                yield break;
            }

            if (context.ActionType == BattleActionType.Trap || context.ActionType == BattleActionType.Item)
            {
                yield break;
            }

            Character targetChar = ZoneManager.Instance.CurrentMap.GetCharAtLoc(context.ExplosionTile);

            if (targetChar == null)
            {
                yield break;
            }

            if (ownerChar.HP < ownerChar.MaxHP / 2)
            {
                yield break;
            }

            //char needs to be a friend of the target char
            if (DungeonScene.Instance.GetMatchup(ownerChar, targetChar) != Alignment.Friend)
            {
                yield break;
            }

            CharAnimSpin spinAnim = new CharAnimSpin();

            spinAnim.CharLoc   = ownerChar.CharLoc;
            spinAnim.CharDir   = ownerChar.CharDir;
            spinAnim.MajorAnim = true;

            yield return(CoroutineManager.Instance.StartCoroutine(ownerChar.StartAnim(spinAnim)));

            yield return(new WaitWhile(ownerChar.OccupiedwithAction));

            DungeonScene.Instance.LogMsg(String.Format(new StringKey("MSG_COVER_ATTACK").ToLocal(), ownerChar.GetDisplayName(false)));
            context.ExplosionTile = ownerChar.CharLoc;
            context.ContextStates.Set(new Redirected());
        }
Example #3
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, BattleContext context)
        {
            if (context.ContextStates.Contains <Redirected>())
            {
                yield break;
            }

            if (context.ActionType == BattleActionType.Trap || context.ActionType == BattleActionType.Item)
            {
                yield break;
            }

            //needs to be an attacking move
            if (context.Data.Category != BattleData.SkillCategory.Physical && context.Data.Category != BattleData.SkillCategory.Magical)
            {
                yield break;
            }

            if (ZoneManager.Instance.CurrentMap.GetCharAtLoc(context.ExplosionTile) != ownerChar)
            {
                yield break;
            }

            foreach (Character newTarget in ZoneManager.Instance.CurrentMap.IterateCharacters())
            {
                if (!newTarget.Dead && newTarget != ownerChar && newTarget != context.User &&
                    (newTarget.CharLoc - ownerChar.CharLoc).Dist8() <= 1)
                {
                    CharAnimSpin spinAnim = new CharAnimSpin();
                    spinAnim.CharLoc   = ownerChar.CharLoc;
                    spinAnim.CharDir   = ownerChar.CharDir;
                    spinAnim.MajorAnim = true;

                    yield return(CoroutineManager.Instance.StartCoroutine(ownerChar.StartAnim(spinAnim)));

                    yield return(new WaitWhile(ownerChar.OccupiedwithAction));

                    DungeonScene.Instance.LogMsg(String.Format(new StringKey("MSG_PASS_ATTACK").ToLocal(), ownerChar.GetDisplayName(false), newTarget.GetDisplayName(false)));
                    context.ExplosionTile = newTarget.CharLoc;
                    context.ContextStates.Set(new Redirected());
                    yield break;
                }
            }
        }