Exemplo n.º 1
0
        public List <MapleCharacter> GetPartyMembers(MapleParty party)
        {
            var partym = new List <MapleCharacter>();

            party.GetMembers().ForEach(partychar =>
            {
                if (partychar.ChannelId == ChannelId)
                {
                    // Make sure the thing doesn't get duplicate plays due to ccing bug.
                    var chr = Characters.FirstOrDefault(x => x.Name == partychar.CharacterName);
                    if (chr != null)
                    {
                        partym.Add(chr);
                    }
                }
            });
            return(partym);
        }
Exemplo n.º 2
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            byte           response  = pr.ReadByte();
            int            inviterId = pr.ReadInt();
            MapleCharacter chr       = c.Account.Character;

            switch (response)
            {
            case 0x21:     //Invite success
            {
                Invite inv;
                if (chr.Invites.TryGetValue(InviteType.Party, out inv))
                {
                    if (inv.SenderId == inviterId)
                    {
                        //response is same as here, changes sometimes
                        Program.GetClientByCharacterId(inviterId)?.SendPacket(MapleParty.Packets.InviteResponse(response, chr.Name));
                    }
                }
            }
            break;

            case 0x22:     //Blocking invitations
            {
                Invite inv;
                if (chr.Invites.TryGetValue(InviteType.Party, out inv))
                {
                    if (inv.SenderId == inviterId)
                    {
                        Program.GetClientByCharacterId(inviterId)?.Account.Character.SendWhiteMessage(chr.Name + " is currently blocking any party invitations.");
                    }
                }
            }
            break;

            case 0x25:    //Deny invite
            {
                Invite inv;
                if (chr.Invites.TryGetValue(InviteType.Party, out inv))
                {
                    if (inv.SenderId == inviterId)
                    {
                        chr.Invites.Remove(InviteType.Party);
                        Program.GetCharacterById(inviterId)?.SendWhiteMessage(chr.Name + "has denied the party request.");
                    }
                }
            }
            break;

            case 0x26:     //Accept invite
            {
                Invite inv;
                if (chr.Invites.TryGetValue(InviteType.Party, out inv))
                {
                    if (inv.SenderId == inviterId)
                    {
                        chr.Invites.Remove(InviteType.Party);
                        if (chr.Party == null)
                        {
                            MapleCharacter inviter = Program.GetCharacterById(inviterId);
                            if (inviter != null)
                            {
                                if (inviter.Party == null)         //If the inviter doesn't have a party yet one is created
                                {
                                    inviter.Party = MapleParty.CreateParty(inviter, inviter.Name + "'s Party", false);
                                    inviter.Party.AddPlayer(chr);
                                }
                                else if (inviter.Party.LeaderId == inviter.Id)         //Check if the inviter is the leader, in case of packet edit
                                {
                                    inviter.Party.AddPlayer(chr);
                                }
                                else
                                {
                                    inviter.SendWhiteMessage("You are not the leader of your party.");
                                }
                            }
                        }
                    }
                }
            }
            break;
            }
        }
Exemplo n.º 3
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            byte           operation = pr.ReadByte();
            MapleCharacter chr       = c.Account.Character;

            switch (operation)
            {
            case 0x01:     //Create party
                if (chr.Party == null)
                {
                    bool   privateParty = !pr.ReadBool();
                    string partyName    = pr.ReadMapleString();
                    chr.Party = MapleParty.CreateParty(chr, partyName, privateParty);
                }
                break;

            case 0x02:     //Leave party
                if (chr.Party != null)
                {
                    chr.Party.RemovePlayer(chr.Id, false);
                }
                break;

            case 0x04:     //Invite to party
                string         targetName = pr.ReadMapleString();
                MapleCharacter target     = Program.GetCharacterByName(targetName);
                if (target != null && !target.Hidden)
                {
                    if (target.Party != null)
                    {
                        chr.SendWhiteMessage("'" + targetName + "' is already in a party.");
                        return;
                    }
                    Invite inv;
                    if (target.Invites.TryGetValue(InviteType.Party, out inv))
                    {
                        if (inv.SenderId == chr.Id)
                        {
                            chr.SendWhiteMessage("You have already invited '" + targetName + "' to your party.");
                        }
                        else
                        {
                            chr.SendWhiteMessage("'" + targetName + "' currently has a party invite pending.");
                        }
                    }
                    else
                    {
                        if (chr.Party != null && chr.Party.LeaderId != chr.Id)
                        {
                            chr.SendWhiteMessage("You are not the leader of your party.");
                        }
                        else
                        {
                            target.Invites.Add(InviteType.Party, new Invite(chr.Id, InviteType.Party));
                            target.Client.SendPacket(MapleParty.Packets.GenerateInvite(chr));
                        }
                    }
                }
                else
                {
                    chr.SendWhiteMessage("'" + targetName + "' could not be found.");
                }
                break;

            case 0x07:     //Set leader
            {
                if (!chr.Map.PartyLeaderChangeLimit)
                {
                    MapleParty party = chr.Party;
                    if (party != null && party.LeaderId == chr.Id)
                    {
                        party.SetLeader(pr.ReadInt());
                    }
                }
            }
            break;

            case 0x0D:     //Rename
            {
                MapleParty party = chr.Party;
                if (party != null && party.LeaderId == chr.Id)
                {
                    party.Private = !pr.ReadBool();
                    party.Name    = pr.ReadMapleString();
                    party.BroadcastPacket(MapleParty.Packets.UpdatePartyName(party));
                }
                break;
            }

            /*
             * case 0x22://deny invite
             * {
             *  int id = pr.ReadInt();
             *  Invite inv;
             *  if (chr.Invites.TryGetValue(InviteType.Party, out inv))
             *  {
             *      if (inv.SenderId == id)
             *      {
             *          chr.Invites.Remove(InviteType.Party);
             *          MapleCharacter from = Program.GetCharacterById(id);
             *          if (from != null)
             *              from.SendWhiteMessage(chr.Name + " has denied the party request.");//should be a white message.
             *      }
             *  }
             * }
             * break;
             * case 0x23://accept invite
             * {
             *  int id = pr.ReadInt();
             *  Invite inv;
             *  if (chr.Invites.TryGetValue(InviteType.Party, out inv))
             *  {
             *      if (inv.SenderId == id)
             *      {
             *          chr.Invites.Remove(InviteType.Party);
             *          if (chr.Party == null)
             *          {
             *              MapleClient victim = Program.GetClientByCharacterId(id);
             *              MapleParty p = victim.Account.Character.Party;
             *              if (p != null)
             *              {
             *                  chr.Party = p;
             *                  p.AddPlayer(chr);
             *              }
             *          }
             *          else
             *          {
             *          }
             *      }
             *  }
             * }
             * break;*/
            default:
                ServerConsole.Warning("Unknown PartyHandler operation: 0x" + operation.ToString("X"));
                break;
            }
        }
Exemplo n.º 4
0
 public OnePartyAttacker(MapleParty lastKnownParty, int damage)
 {
     LastKnownParty = lastKnownParty;
     Damage         = damage;
     LastAttackTime = DateTime.Now.GetTimeMilliseconds();
 }
Exemplo n.º 5
0
            public void KilledMob(MapleMap map, int baseExp, bool mostDamage)
            {
                Dictionary <MapleCharacter, OnePartyAttacker> attackers = ResolveAttackers();

                MapleCharacter highest       = null;
                int            highestDamage = 0;

                Dictionary <MapleCharacter, int> expMap = new Dictionary <MapleCharacter, int>(6);

                foreach (var attacker in attackers)
                {
                    MapleParty party             = attacker.Value.LastKnownParty;
                    double     averagePartyLevel = 0;

                    List <MapleCharacter> expApplicable = new List <MapleCharacter>();
                    foreach (var partychar in party.GetMembers())
                    {
                        if (attacker.Key.Level - partychar.Level <= 5 || m_monster.Stats.Level - partychar.Level <= 5)
                        {
                            MapleCharacter pchr = m_cserv.Characters.FirstOrDefault(x => x.Name == partychar.CharacterName);
                            if (pchr == null)
                            {
                                continue;
                            }
                            if (!pchr.IsAlive || pchr.Map != map)
                            {
                                continue;
                            }
                            expApplicable.Add(pchr);
                            averagePartyLevel += pchr.Level;
                        }
                    }
                    double expBonus = 1.0;
                    if (expApplicable.Count > 1)
                    {
                        expBonus           = 1.10 + 0.05 * expApplicable.Count;
                        averagePartyLevel /= expApplicable.Count;
                    }

                    int iDamage = attacker.Value.Damage;
                    if (iDamage > highestDamage)
                    {
                        highest       = attacker.Key;
                        highestDamage = iDamage;
                    }
                    double innerBaseExp = baseExp * ((double)iDamage / m_totDamage);
                    double expFraction  = innerBaseExp * expBonus / (expApplicable.Count + 1);

                    foreach (var expReceiver in expApplicable)
                    {
                        int    oexp;
                        int    iexp      = !expMap.TryGetValue(expReceiver, out oexp) ? 0 : oexp;
                        double expWeight = expReceiver == attacker.Key ? 2.0 : 1.0;
                        double levelMod  = expReceiver.Level / averagePartyLevel;
                        if (levelMod > 1.0 || m_attackers.ContainsKey(expReceiver.Id))
                        {
                            levelMod = 1.0;
                        }
                        iexp += (int)Math.Round(expFraction * expWeight * levelMod);
                        if (expMap.ContainsKey(expReceiver))
                        {
                            expMap[expReceiver] = iexp;
                        }
                        else
                        {
                            expMap.Add(expReceiver, iexp);
                        }
                    }
                }
                // F**K we are done -.-
                foreach (var expReceiver in expMap)
                {
                    bool white = mostDamage && expReceiver.Key == highest;
                    m_monster.GiveExpToCharacter(expReceiver.Key, expReceiver.Value, white, expMap.Count);
                }
            }