Пример #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 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 && !((Recruit)i).Owner.Player.Dead)
                {
                    var recruit = i as Recruit;

                    if (setup.moveIndex == -1)
                    {
                        if (setup.AttackerMap.Moral == Enums.MapMoral.Safe || setup.AttackerMap.Moral == Enums.MapMoral.House)
                        {
                            Scripting.ScriptManager.InvokeSub("InteractWithPlayer", Owner, recruit.Owner);
                        }
                    }
                }
                else
                {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel)
                    {
                        return;
                    }
                }
            }
        }
Пример #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;
                    }
                }
            }
        }
Пример #5
0
 public static void PartyMsg(Party party, string msg, Color color)
 {
     foreach (Client i in party.GetOnlineMemberClients()) {
         if (i.IsPlaying()) {
             Messenger.PlayerMsg(i, msg, color);
         }
     }
 }
Пример #6
0
        /*
        public static void SendDataToPlayerMap(ConnectedClient client, TcpPacket packet) {
            if (client.Player.Map != -2) {
                SendDataToMap(client.Player.Map, packet);
            } else {
                SendDataTo(client, packet);
            }
        }

        public static void SendDataToPlayerMapBut(ConnectedClient client, TcpPacket packet) {
            if (client.Player.Map != -2) {
                SendDataToMapBut(client, client.Player.Map, packet);
            }
        }

        public static TcpPacket CreatePartyMemberDataPacket(PartyMember member, int slot) {
            Client memberClient = ClientManager.GetClient(Players.PlayerID.FindTcpID(member.PlayerID));
            if (memberClient != null) {
                return PacketBuilder.CreatePartyMemberDataPacket(memberClient, slot);
            } else {
                return null;
            }
        }

        public static void SendPartyMemberData(Party party, PartyMember member, int slot) {
            Client memberClient = ClientManager.GetClient(Players.PlayerID.FindTcpID(member.PlayerID));
            if (memberClient != null) {
                SendDataToParty(party, PacketBuilder.CreatePartyMemberDataPacket(memberClient, slot));
            }
        }

        public static void SendPartyMemberData(Client client, Client member, int slot) {
            SendDataTo(client, PacketBuilder.CreatePartyMemberDataPacket(member, slot));
        }

        public static void SendPartyMemberData(Client client, PartyMember member, int slot) {
            Client memberClient = ClientManager.GetClient(Players.PlayerID.FindTcpID(member.PlayerID));
            if (memberClient != null) {Send
                SendDataTo(client, CreatePartyMemberDataPacket(member, slot));
            }
        }

        */
        public static void SendPartyMemberData(Party party, Client member, int slot)
        {
            SendDataToParty(party, PacketBuilder.CreatePartyMemberDataPacket(party, member, slot));
        }
Пример #7
0
 public static void SendLeftParty(Party party, int slot)
 {
     SendDataToParty(party, TcpPacket.CreatePacket("clearpartyslot", slot.ToString()));
 }
Пример #8
0
 public static void DeleteParty(MySql database, Party partyData)
 {
     database.ExecuteNonQuery("DELETE FROM parties WHERE PartyID = \'" + partyData.PartyID + "\'");
 }
Пример #9
0
        public static void SaveParty(MySql database, Party partyData)
        {
            database.ExecuteNonQuery("DELETE FROM parties WHERE PartyID = \'" + partyData.PartyID + "\'");
            //database.DeleteRow("friends", "CharID = \'" + playerData.CharID + "\'");

            for (int i = 0; i < partyData.Members.Count; i++)
            {
                database.UpdateOrInsert("parties", new IDataColumn[] {
                    database.CreateColumn(false, "PartyID", partyData.PartyID),
                    database.CreateColumn(false, "PartySlot", i.ToString()),
                    database.CreateColumn(false, "CharID", partyData.Members[i])
                });
            }
        }
Пример #10
0
        public static void RemoveFromParty(Party party, Client client)
        {
            if (party != null) {
                //if (CanBeRemovedFromParty(party, client)) {
                    int slot = party.GetMemberSlot(client.Player.CharID);

                    party.Remove(client);
                    client.Player.PartyID = null;
                    client.Player.RemoveExpKitModule(Enums.ExpKitModules.Party);
                    Messenger.PlayerMsg(client, "You have been removed from your party!", Text.Black);
                    Messenger.SendLeftParty(party, slot);
                    Messenger.PartyMsg(party, client.Player.Name + " has been removed from the party!", Text.BrightGreen);
                    if (slot == 0 && party.IsLeaderInParty()) {
                        Client client2 = party.GetLeader();
                        if (client2 != null) {
                            Messenger.PartyMsg(party, client2.Player.Name + " is now the party leader!", Text.BrightGreen);
                        }
                    }
                    PerformPartyChecks(party);
                //} else {
                //    Messenger.PlayerMsg(client, "You can't be removed from your party here!", Text.Black);
                //}
            } else {
                Messenger.PlayerMsg(client, "You are not in a party!", Text.Black);
            }
        }
Пример #11
0
 public static void LoadParty(MySql database, Party partyData)
 {
     string query = "SELECT parties.CharID " +
         "FROM parties " +
         "WHERE parties.PartyID = \'" + partyData.PartyID + "\';";
     List<DataColumnCollection> rows = database.RetrieveRows(query);
     if (rows != null)
     {
         for (int i = 0; i < rows.Count; i++)
         {
             partyData.Members.Add(rows[i]["CharID"].ValueString);
         }
     }
 }
Пример #12
0
        public static Party LoadCharacterParty(MySql database, string charID)
        {
            string partyID = "";

            string query = "SELECT parties.PartyID " +
                "FROM parties " +
                "WHERE parties.CharID = \'" + charID + "\';";
            List<DataColumnCollection> rows = database.RetrieveRows(query);
            if (rows != null)
            {
                for (int i = 0; i < rows.Count; i++)
                {
                    partyID = rows[i]["PartyID"].ValueString;
                }
            }
            else
            {
                return null;
            }

            Party partyData = new Party(partyID);

            query = "SELECT parties.CharID " +
                "FROM parties " +
                "WHERE parties.PartyID = \'" + partyData.PartyID + "\';";
            rows = database.RetrieveRows(query);
            if (rows != null)
            {
                for (int i = 0; i < rows.Count; i++)
                {
                    partyData.Members.Add(rows[i]["CharID"].ValueString);
                }
            }
            return partyData;
        }
Пример #13
0
        public static void JoinParty(Party party, Client client)
        {
            PacketHitList hitlist = null;
            PacketHitList.MethodStart(ref hitlist);

            if (party != null) {
                Client leader = party.GetLeader();
                if (Combat.MoveProcessor.IsInAreaRange(1, client.Player.X, client.Player.Y, leader.Player.X, leader.Player.Y)) {
                    if (party.AddToParty(client)) {
                        client.Player.PartyID = party.PartyID;
                        client.Player.AddExpKitModule(new AvailableExpKitModule(Enums.ExpKitModules.Party, true));
                        hitlist.AddPacket(client, PacketBuilder.CreateChatMsg("You have joined the party!", Text.BrightGreen));
                        //PartyMember member = party.FindMember(client.Player.CharID);
                        int slot = party.GetMemberSlot(client.Player.CharID);
                        //Messenger.SendPartyMemberData(client, member, slot);
                        foreach (Client i in party.GetOnlineMemberClients()) {
                            if (i.IsPlaying() && i != client) {
                                //PartyMember teamMember = party.Members.FindMember(i.Player.CharID);
                                //int teamMemberSlot = party.Members.GetMemberSlot(i.Player.CharID);
                                //Messenger.SendPartyMemberData(client, teamMember, teamMemberSlot);
                                //Messenger.SendPartyMemberData(i, member, slot);
                                hitlist.AddPacket(i, PacketBuilder.CreateChatMsg(client.Player.Name + " has joined the party!", Text.BrightGreen));
                            }
                            PacketBuilder.AppendPartyMemberData(i, hitlist, slot);
                        }
                    } else {
                        hitlist.AddPacket(client, PacketBuilder.CreateChatMsg("You couldn't join the party!", Text.BrightRed));
                    }
                } else {
                    Messenger.PlayerMsg(client, "You need to stand next to the leader to join the party!", Text.BrightRed);
                }
            }

            PacketHitList.MethodEnded(ref hitlist);
        }
Пример #14
0
        public static void DisbandParty(Party party)
        {
            rwLock.EnterWriteLock();
            try {
                int partyIndex = parties.IndexOfValue(party);
                if (partyIndex > -1) {
                    parties.RemoveAt(partyIndex);
                }
            } finally {
                rwLock.ExitWriteLock();
            }

            foreach (Client client in party.GetOnlineMemberClients()) {
                if (client.IsPlaying()) {
                    client.Player.RemoveExpKitModule(Enums.ExpKitModules.Party);
                    client.Player.PartyID = null;
                    Messenger.SendDisbandPartyTo(client);
                    Messenger.PlayerMsg(client, "Your party has been disbanded!", Text.BrightRed);
                }
            }
        }
Пример #15
0
        //public static bool CanBeRemovedFromParty(Party party, Client client) {
        //    if (client.Player.Map.Moral == Enums.MapMoral.None) return false;
        //    return true;
        //}
        private static void PerformPartyChecks(Party party)
        {
            //bool shouldDisband = false;
            if (party.MemberCount == 0) {
                //shouldDisband = true;
                rwLock.EnterWriteLock();
                try {
                    int partyIndex = parties.IndexOfValue(party);
                    if (partyIndex > -1) {
                        parties.RemoveAt(partyIndex);
                    }
                } finally {
                    rwLock.ExitWriteLock();
                }
            }
            //if (party.IsLeaderInParty() == false) {
            //    shouldDisband = true;
            //}

            //if (shouldDisband) {
            //    DisbandParty(party);
            //}

            HandleMemberLogout(party.PartyID, null);
        }
Пример #16
0
 public static TcpPacket CreatePartyMemberDataPacket(Party playerParty, Client member, int slot)
 {
     return TcpPacket.CreatePacket("partymemberdata", slot.ToString(), member.Player.Name, member.Player.GetActiveRecruit().Species.ToString(), member.Player.GetActiveRecruit().Form.ToString(), ((int)member.Player.GetActiveRecruit().Shiny).ToString(), ((int)member.Player.GetActiveRecruit().Sex).ToString(),
                                           member.Player.GetActiveRecruit().Exp.ToString(), member.Player.GetActiveRecruit().GetNextLevel().ToString(),
                                           member.Player.GetActiveRecruit().HP.ToString(), member.Player.GetActiveRecruit().MaxHP.ToString());
 }
Пример #17
0
        public static void CreateNewParty(Client leader)
        {
            PacketHitList hitlist = null;
            PacketHitList.MethodStart(ref hitlist);
            List<string> partyIDs = new List<string>();
            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                partyIDs = LoadPartyIDList(dbConnection.Database);
            }

            if (leader.Player.PartyID == null) {
                string partyID = null;
                rwLock.EnterWriteLock();
                try {
                    while (true) {
                        string tempID = Security.PasswordGen.Generate(10, 15);
                        if (partyIDs.Contains(tempID) == false) {
                            partyID = tempID;
                            break;
                        }
                    }
                    Party party = new Party(partyID, leader);
                    leader.Player.PartyID = partyID;
                    parties.Add(partyID, party);
                } finally {
                    rwLock.ExitWriteLock();
                }
                leader.Player.AddExpKitModule(new AvailableExpKitModule(Enums.ExpKitModules.Party, true));
                PacketBuilder.AppendPartyMemberDataFor(leader, hitlist, 0);
                hitlist.AddPacket(leader, PacketBuilder.CreateChatMsg("You have created a new party!", Text.BrightGreen));
            } else {
                hitlist.AddPacket(leader, PacketBuilder.CreateChatMsg("You are already in a party!", Text.BrightRed));
            }

            PacketHitList.MethodEnded(ref hitlist);
        }