Exemplo n.º 1
0
    public static void HandleRemoveListing(GameSession session)
    {
        Party party = session.Player.Party;

        if (party == null)
        {
            return;
        }

        party.BroadcastPacketParty(MatchPartyPacket.RemoveListing(party));

        if (party.Members.Count == 1)
        {
            party.RemoveMember(session.Player);
            return;
        }

        party.PartyFinderId = 0;
        party.BroadcastPacketParty(PartyPacket.MatchParty(null, false));
    }
Exemplo n.º 2
0
        private void JoinParty(GameSession session, string leaderName, bool accept, int unknown)
        {
            Player partyLeader = GameServer.Storage.GetPlayerByName(leaderName);

            if (partyLeader == null)
            {
                return;
            }

            GameSession leaderSession = partyLeader.Session;

            if (!accept)
            {
                //Send Decline message to inviting player
                leaderSession.Send(ChatPacket.Send(partyLeader, session.Player.Name + " declined the invitation.",
                                                   ChatType.NoticeAlert2));
                return;
            }

            Party party = GameServer.PartyManager.GetPartyByLeader(partyLeader);

            if (party != null)
            {
                //Existing party, add joining player to all other party members.
                party.BroadcastPacketParty(PartyPacket.Join(session.Player));
                party.BroadcastPacketParty(PartyPacket.UpdatePlayer(session.Player));
                party.BroadcastPacketParty(PartyPacket.UpdateHitpoints(session.Player));
                party.AddMember(session.Player);

                if (party.PartyFinderId != 0)
                {
                    if (party.Members.Count >= party.MaxMembers)
                    {
                        party.PartyFinderId = 0; //Hide from party finder if full
                        party.BroadcastPacketParty(MatchPartyPacket.RemoveListing(party));
                        party.BroadcastPacketParty(
                            MatchPartyPacket.SendListings(GameServer.PartyManager.GetPartyFinderList()));
                        party.BroadcastPacketParty(PartyPacket.MatchParty(null));
                    }
                    else
                    {
                        session.Send(
                            MatchPartyPacket.CreateListing(party)); //Add recruitment listing for newly joining player
                        session.Send(PartyPacket.MatchParty(party));
                    }
                }
            }
            else
            {
                //Create new party
                Party newParty = new(10, new List <Player> {
                    partyLeader, session.Player
                });
                GameServer.PartyManager.AddParty(newParty);

                //Send the party leader all the stuff for the joining player
                leaderSession.Send(PartyPacket.Join(session.Player));
                leaderSession.Send(PartyPacket.UpdatePlayer(session.Player));
                leaderSession.Send(PartyPacket.UpdateHitpoints(session.Player));

                leaderSession.Send(PartyPacket.UpdateHitpoints(partyLeader));

                party = newParty;
            }

            //Create existing party based on the list of party members
            session.Send(PartyPacket.CreateExisting(partyLeader, party.Members));
            session.Send(PartyPacket.UpdatePlayer(session.Player));
            foreach (Player partyMember in party.Members)
            {
                //Skip first character because of the scuffed Create packet. For now this is a workaround and functions the same.
                if (partyMember.CharacterId != party.Members.First().CharacterId)
                {
                    //Adds the party member to the UI
                    session.Send(PartyPacket.Join(partyMember));
                }

                //Update the HP for each party member.
                session.Send(PartyPacket.UpdateHitpoints(partyMember));
            }
        }