예제 #1
0
        public void UseMoveOnAllies(BattleSetup setup, TargetCollection targets)
        {
            Parties.Party party = null;
            if (owner.Player.IsInParty())
            {
                party = Parties.PartyManager.FindPlayerParty(owner);
            }
            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);
            Move move = setup.SetdownMove();

            // Attack any players that are on the map
            foreach (ICharacter i in targets.Friends)
            {
                if (i.CharacterType == Enums.CharacterType.Recruit && Ranks.IsAllowed(((Recruit)i).Owner, Enums.Rank.Moniter) &&
                    !((Recruit)i).Owner.Player.Hunted && !((Recruit)i).Owner.Player.Dead)
                {
                }
                else
                {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel)
                    {
                        return;
                    }
                }
            }
        }
예제 #2
0
        public void UseMove(int moveSlot)
        {
            if (owner.Player.Dead)
            {
                return;
            }


            owner.Player.Map.ProcessingPaused = false;


            if (Ranks.IsDisallowed(owner, Enums.Rank.Moniter) || owner.Player.ProtectionOff)
            {
                owner.Player.Hunted = true;
                Messenger.SendHunted(owner);
            }

            if (!Core.GetTickCount().Elapsed(owner.Player.PauseTimer, 0))
            {
                return;
            }

            if (moveSlot > -1 && moveSlot < 4)
            {
                Move move       = MoveManager.Moves[Moves[moveSlot].MoveNum];
                IMap currentMap = owner.Player.GetCurrentMap();
                if (move.KeyItem > 0)
                {
                    bool doorOpened = UseMoveKey(currentMap, move, moveSlot);
                    if (doorOpened)
                    {
                        return;
                    }
                }
            }
            BattleSetup setup = new BattleSetup();

            setup.Attacker = this;
            setup.moveSlot = moveSlot;

            BattleProcessor.HandleAttack(setup);


            BattleProcessor.FinalizeAction(setup);
        }
예제 #3
0
        public void UseMoveOnFoes(BattleSetup setup, TargetCollection targets)
        {
            Parties.Party party = null;
            if (owner.Player.IsInParty())
            {
                party = Parties.PartyManager.FindPlayerParty(owner);
            }

            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);

            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Foes)
            {
                // Don't attack allies
                if (i.CharacterType == Enums.CharacterType.Recruit)
                {
                    Recruit recruit = i as Recruit;

                    var canHit = true;

                    if (Ranks.IsAllowed(recruit.Owner, Enums.Rank.Monitor) && !recruit.Owner.Player.Hunted)
                    {
                        canHit = false;
                    }

                    if ((recruit.Owner.Player.Map.Tile[recruit.Owner.Player.X, recruit.Owner.Player.Y].Type == Enums.TileType.Arena) != (Owner.Player.Map.Tile[X, Y].Type == Enums.TileType.Arena))
                    {
                        canHit = false;
                    }

                    // Override to allow hitting the player ANYWHERE
                    if (recruit.Owner.Player.KillableAnywhere)
                    {
                        canHit = true;
                    }

                    if (canHit)
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc && (((MapNpc)i).Num <= 0 || ((MapNpc)i).HP <= 0))
                {
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc)
                {
                    MapNpc npc = i as MapNpc;
                    if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Scripted)
                    {
                        if (setup.moveIndex == -1)
                        {
                            Scripting.ScriptManager.InvokeSub("ScriptedNpc", setup.Attacker, Npcs.NpcManager.Npcs[npc.Num].AIScript, npc.Num, owner.Player.Map, i);
                        }
                    }
                    else if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Story)
                    {
                        if (setup.moveIndex == -1)
                        {
                            var npcObject = Npcs.NpcManager.Npcs[npc.Num];

                            var storyChapter = npcObject.Story - 1;
                            if (storyChapter <= -1 || owner.Player.GetStoryState(storyChapter))
                            {
                                Stories.StoryManager.PlayStory(owner, Npcs.NpcManager.Npcs[npc.Num].CreateAttackSayStory());
                            }
                            else
                            {
                                if (owner.Player.GetClientEdition() == Constants.ALTERNATE_CLIENT_EDITION)
                                {
                                    Stories.StoryManager.PlayStory(owner, storyChapter);
                                }
                                else
                                {
                                    Stories.StoryManager.PlayStory(owner, Npcs.NpcManager.Npcs[npc.Num].CreateInvalidClientStory());
                                }
                            }
                        }
                    }
                    else if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper && Npcs.NpcManager.Npcs[npc.Num].Shop > 0)
                    {
                        if (setup.moveIndex == -1)
                        {
                            Messenger.SendShopMenu(owner, Npcs.NpcManager.Npcs[npc.Num].Shop);
                        }
                    }
                    else if (!string.IsNullOrEmpty(Npcs.NpcManager.Npcs[npc.Num].AttackSay) && (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Friendly || Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper))
                    {
                        if (setup.moveIndex == -1)
                        {
                            var story = Npcs.NpcManager.Npcs[npc.Num].CreateAttackSayStory();

                            Stories.StoryManager.PlayStory(owner, story);
                        }
                    }
                    else
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel)
                    {
                        return;
                    }
                }
            }
        }
예제 #4
0
        public void UseMoveOnFoes(BattleSetup setup, TargetCollection targets)
        {
            Parties.Party party = null;
            if (owner.Player.IsInParty())
            {
                party = Parties.PartyManager.FindPlayerParty(owner);
            }

            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);

            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Foes)
            {
                // Don't attack allies
                if (i.CharacterType == Enums.CharacterType.Recruit)
                {
                    Recruit recruit = i as Recruit;
                    if (Ranks.IsAllowed(recruit.Owner, Enums.Rank.Moniter) && !recruit.Owner.Player.Hunted ||
                        (recruit.Owner.Player.Map.Tile[recruit.Owner.Player.X, recruit.Owner.Player.Y].Type == Enums.TileType.Arena) != (Owner.Player.Map.Tile[X, Y].Type == Enums.TileType.Arena))
                    {
                    }
                    else
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc && (((MapNpc)i).Num <= 0 || ((MapNpc)i).HP <= 0))
                {
                }
                else if (i.CharacterType == Enums.CharacterType.MapNpc)
                {
                    MapNpc npc = i as MapNpc;
                    if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Scripted)
                    {
                        if (setup.moveIndex == -1)
                        {
                            Scripting.ScriptManager.InvokeSub("ScriptedNpc", setup.Attacker, Npcs.NpcManager.Npcs[npc.Num].AIScript, npc.Num, owner.Player.Map, i);
                        }
                    }
                    else if (!string.IsNullOrEmpty(Npcs.NpcManager.Npcs[npc.Num].AttackSay) && (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Friendly || Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper))
                    {
                        if (setup.moveIndex == -1)
                        {
                            Stories.Story story = new Stories.Story();
                            Stories.StoryBuilderSegment segment = Stories.StoryBuilder.BuildStory();
                            Stories.StoryBuilder.AppendSaySegment(segment, Npcs.NpcManager.Npcs[npc.Num].Name.Trim() + ": " + Npcs.NpcManager.Npcs[npc.Num].AttackSay.Trim(),
                                                                  Npcs.NpcManager.Npcs[npc.Num].Species, 0, 0);
                            segment.AppendToStory(story);
                            Stories.StoryManager.PlayStory(owner, story);
                        }
                    }
                    else
                    {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel)
                    {
                        return;
                    }
                }
            }
        }