Exemple #1
0
        public static Packet JoinParty(PartyMember joined, Party pt)
        {
            Packet pw = new Packet(ServerMessages.PARTY_RESULT);

            pw.WriteByte((byte)PartyFunction.JOIN_DONE);
            pw.WriteInt(pt.partyId); //pid? charid?
            pw.WriteString(joined.name);
            AddPartyData(pw, joined, pt);
            return(pw);
        }
Exemple #2
0
 public int GetCharacterSlot(PartyMember pm)
 {
     for (var i = 0; i < Constants.MaxPartyMembers; i++)
     {
         if (members[i] == pm)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemple #3
0
        public void Chat(int chatter, string text)
        {
            PartyMember chr = GetById(chatter);

            if (members.Count(e => e?.IsOnline ?? false) <= 1)
            {
                chr.SendPacket(PartyPacket.NoneOnline());
            }
            else
            {
                // Send to all other members
                ForAllMembers(m => m.SendPacket(PartyPacket.PartyChat(chr.name, text, 1)), chatter);
            }
        }
Exemple #4
0
        public static Packet MemberLeft(PartyMember sendTo, PartyMember leaving, Party pt, bool disband, bool expel)
        {
            Packet pw = new Packet(ServerMessages.PARTY_RESULT);

            pw.WriteByte((byte)PartyFunction.WITHDRAW_DONE);
            pw.WriteInt(pt.partyId);
            pw.WriteInt(leaving.id);
            pw.WriteBool(!disband); //disband ? 0 : 1
            if (!disband)
            {
                pw.WriteBool(expel);
                pw.WriteString(leaving.name);
                AddPartyData(pw, sendTo, pt, leaving);
            }
            return(pw);
        }
Exemple #5
0
        private void Join(Character chr)
        {
            var slot = GetFirstFreeSlot();

            if (slot == -1)
            {
                _log.Error($"Trying to join the party, but the free slot is -1??? Party {partyId} Character {chr.ID}");
                return;
            }

            _log.Debug($"{chr.ID} joins the party {partyId} under slot {slot}");

            chr.PartyID = partyId;
            var member = new PartyMember(chr.ID, chr.Name, false);

            members[slot] = member;

            ForAllMembers(m => m.SendPacket(PartyPacket.JoinParty(member, this)));
            member.SendHpUpdate();
            SendUpdatePartyData();
            UpdateAllDoors();
        }
Exemple #6
0
        public static void AddPartyData(Packet packet, PartyMember member, Party pt, PartyMember remove = null, int disconnect = -1)
        {
            //226
            var ids       = pt.members.Select(e => e == null ? 0 : e.id);
            var names     = pt.members.Select(e => e == null ? "" : e.name);
            var maps      = pt.members.Select(e => (e == null || e.id == disconnect || e.GetChannel() != member.GetChannel()) ? -1 : e.GetMap());
            var doorTowns = pt.members.Select(e => e == null ? Constants.InvalidMap : e.door.DstMap);

            ids.ForEach(packet.WriteInt);
            names.ForEach(packet.WriteString13);
            maps.ForEach(packet.WriteInt);
            packet.WriteInt(pt.leader.id);
            maps.ForEach(m => packet.WriteInt(-1));

            //doors - these are f****d, fix in v39 i guess
            for (int i = 0; i < Constants.MaxPartyMembers; i++)
            {
                packet.WriteInt(Constants.InvalidMap);
                packet.WriteInt(Constants.InvalidMap);
                packet.WriteShort(0);
                packet.WriteShort(0);
            }
        }