public static void RemoveOnDisconnect(WorldMgr.party p, PlayerMgr c) { //Remove client and member if it contains our removing character if (p.Members.Contains(c.Character.Information.UniqueID)) { p.Members.Remove(c.Character.Information.UniqueID); p.MembersClient.Remove(c.client); } //Send packet to each player foreach (int member in p.Members) { PlayerMgr playerdetail = Helpers.GetInformation.GetPlayer(member); if (p.Members.Count > 1) { playerdetail.client.Send(Packet.Party_Data(1, 0)); } else { //Send removal of party playerdetail.client.Send(Packet.Party_Data(3, playerdetail.Character.Information.UniqueID)); //Remove party state playerdetail.Character.Network.Party = null; } } }
public void NormalRequest() { try { //Create new packet reader PacketReader Reader = new PacketReader(PacketInformation.buffer); //Get invited member int Target = Reader.Int32(); //Get party type byte PartyType = Reader.Byte(); //Close reader Reader.Close(); //Get target player information PlayerMgr InvitedPlayer = Helpers.GetInformation.GetPlayer(Target); //First we check the our own player level if (Character.Information.Level < 5) { //Send message //Return return; } //Check target level if (InvitedPlayer.Character.Information.Level < 5) { //Send message //Return return; } //Set target information for invited player InvitedPlayer.Character.Network.TargetID = Character.Information.UniqueID; //If the player inviting, has no party yet. if (Character.Network.Party == null) { //Create new party WorldMgr.party Party = new WorldMgr.party(); //Set leader of party Party.LeaderID = Character.Information.UniqueID; //Set party type Party.Type = PartyType; //Add to party net info Character.Network.Party = Party; } //If the target player has no party yet. if (InvitedPlayer.Character.Network.Party == null) { //Send invitation packet InvitedPlayer.client.Send(Packet.PartyRequest(2, this.Character.Information.UniqueID, PartyType)); //Set invite bools InvitedPlayer.Character.Information.CheckParty = true; Character.Information.CheckParty = true; } } //Catch bad exception errors catch (Exception ex) { //Write information to the console Console.WriteLine(ex); //Write information to the debug log } }
public void CharacterRequest() { try { //Open packet reader PacketReader Reader = new PacketReader(PacketInformation.buffer); //Get targeted player information PlayerMgr sys = Helpers.GetInformation.GetPlayer(Character.Network.TargetID); if (this.Character.State.UnionApply && sys.Character.State.UnionApply) { if (Reader.Byte() == 1 && Reader.Byte() == 0) { //Need to sniff decline packet info Character.State.UnionApply = false; sys.Character.State.UnionApply = false; } else { //Check for null and set unique id for union and insert our own guild. if (sys.Character.Network.Guild.Unions == null) { int uniqueid = DB.GetRowsCount("SELECT * FROM guild_unions"); sys.Character.Network.Guild.UniqueUnion = uniqueid + 1; DB.query("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')"); } //Update database DB.query("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')"); //Send union packet to newly joined player client.Send(Packet.UnionInfo(this)); //Send update packet to all guilds in union foreach (int member in Character.Network.Guild.Members) { //Make sure the member is there if (member != 0) { //If the user is not the newly invited member get player info PlayerMgr tomember = Helpers.GetInformation.GetPlayerMainid(member); //Send guild update packet if (tomember != null) { if (!tomember.Character.Network.Guild.SingleSend) { if (Character.Information.CharacterID != tomember.Character.Information.CharacterID) { tomember.Character.Network.Guild.SingleSend = true; tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0)); } } } } } foreach (int member in Character.Network.Guild.UnionMembers) { //Make sure the member is there if (member != 0) { //If the user is not the newly invited member get player info PlayerMgr tomember = Helpers.GetInformation.GetPlayerMainid(member); //Send guild update packet if (tomember != null) { if (!tomember.Character.Network.Guild.SingleSend) { tomember.Character.Network.Guild.SingleSend = true; tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0)); } } } } //Disable the bool again foreach (int member in Character.Network.Guild.Members) { //Make sure member isnt null if (member != 0) { //Get guildmember details PlayerMgr guildmember = Helpers.GetInformation.GetPlayerMainid(member); //Make sure guildmember isnt null if (guildmember != null) { //Disable bool to allow resend new packets. guildmember.Character.Network.Guild.SingleSend = false; } } } //Disable the bool again foreach (int member in Character.Network.Guild.UnionMembers) { //Make sure member isnt null if (member != 0) { //Get guildmember details PlayerMgr guildmember = Helpers.GetInformation.GetPlayerMainid(member); //Make sure guildmember isnt null if (guildmember != null) { //Disable bool to allow resend new packets. guildmember.Character.Network.Guild.SingleSend = false; } } } //Reset bools Character.State.UnionApply = false; sys.Character.State.UnionApply = false; } } //------------------------------------- [ Exchange invite ] -------------------------------------// else if (this.Character.State.Exchanging && sys.Character.State.Exchanging) { if (Reader.Byte() == 1 && Reader.Byte() == 0) { sys.client.Send(Packet.Exchange_Cancel()); Character.State.Exchanging = false; sys.Character.State.Exchanging = false; } else { sys.client.Send(Packet.OpenExhangeWindow(1, this.Character.Information.UniqueID)); client.Send(Packet.OpenExhangeWindow(sys.Character.Information.UniqueID)); Character.Network.Exchange.Window = true; Character.Network.Exchange.ItemList = new List <ObjData.slotItem>(); sys.Character.Network.Exchange.Window = true; sys.Character.Network.Exchange.ItemList = new List <ObjData.slotItem>(); } } //------------------------------------- [ Guild invite ] -------------------------------------// else if (this.Character.State.GuildInvite && sys.Character.State.GuildInvite) { //If byte equals 2 the type is denied if (Reader.Byte() == 2) { //Denied request Character.State.GuildInvite = false; sys.Character.State.GuildInvite = false; //Send refused packet to sender sys.client.Send(Packet.Message(OperationCode.SERVER_GUILD, Messages.UIIT_MSG_GUILDERR_JOIN_GUILD_REFUSED)); } //If not denied we start adding the new member else { //Invite guild member (Add member count + 1). int guildmemberadd = sys.Character.Network.Guild.Members.Count + 1; //Update database DB.query("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Information.CharacterID + "','10','0','1','" + "" + "','0','0','0','0','0')"); DB.query("UPDATE guild SET guild_members_t='" + guildmemberadd + "' WHERE guild_name='" + sys.Character.Network.Guild.Name + "'"); //Reload new member and load character data for guildinfo LoadPlayerGuildInfo(true); //Send packets to network and spawned players foreach (int member in Character.Network.Guild.Members) { //Make sure the member is there if (member != 0) { //We dont send this info to the invited user. if (member != Character.Information.CharacterID) { //If the user is not the newly invited member get player info PlayerMgr tomember = Helpers.GetInformation.GetPlayerMainid(member); //Send guild update packet tomember.LoadPlayerGuildInfo(true); tomember.client.Send(Packet.GuildUpdate(Character, 1, Character.Information.CharacterID, 0, 0)); tomember.client.Send(Packet.GuildSetOnline(Character.Network.Guild, Character.Information.UniqueID)); tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0)); } //Send information to the invited player else { //Send guild data packets to invited client.Send(Packet.SendGuildStart()); client.Send(Packet.SendGuildInfo(Character.Network.Guild)); client.Send(Packet.SendGuildEnd()); //Load union data for new invited player LoadUnions(); } } } //Set bools to false for new invite Character.State.GuildInvite = false; sys.Character.State.GuildInvite = false; } } //------------------------------------- [ Party invite ] -------------------------------------// else { //If invitation is accepted if (Reader.Byte() == 1 && Reader.Byte() == 1) { //First we set our main checks (Check if player is in party or not). if (Character.Network.Party != null) { return; } //Set bools for check Character.Information.CheckParty = true; sys.Character.Information.CheckParty = true; //Set main party information WorldMgr.party JoiningParty = sys.Character.Network.Party; //Check party type members allowed need message if full if (JoiningParty.Type == 4 && JoiningParty.Members.Count > 3) { //Send party is full message to player client.Send(Packet.Message(OperationCode.SERVER_PARTY_MESSAGES, Messages.UIIT_MSG_PARTYERR_ALREADY_FULL)); return; } if (JoiningParty.Type == 5 && JoiningParty.Members.Count > 7) { //Send party is full message to player client.Send(Packet.Message(OperationCode.SERVER_PARTY_MESSAGES, Messages.UIIT_MSG_PARTYERR_ALREADY_FULL)); return; } //If the current count == 0 then add party and add me if (JoiningParty.Members.Count == 0) { //Add ourselfs to the party list JoiningParty.Members.Add(sys.Character.Information.UniqueID); //Add our client to the party list JoiningParty.MembersClient.Add(sys.client); //Set party id JoiningParty.ptid = Helpers.Manager.Party.Count + 1; //Set party network info sys.Character.Network.Party = JoiningParty; //Send permissions sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID)); //Send party data to leader sys.client.Send(Packet.Party_DataMember(JoiningParty)); //Send party data packet to leader (Other player that joined). sys.client.Send(Packet.Party_Data(2, Character.Information.UniqueID)); //Add invited member to the list JoiningParty.Members.Add(Character.Information.UniqueID); JoiningParty.MembersClient.Add(client); //Set party info for invited member Character.Network.Party = JoiningParty; //Send permissions client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID)); //Send party data client.Send(Packet.Party_DataMember(JoiningParty)); //return return; } //If there are more members in the current party else { //Repeat for each member using count for (byte b = 0; b <= JoiningParty.Members.Count - 1; b++) { //Get player information from [b] PlayerMgr others = Helpers.GetInformation.GetPlayer(JoiningParty.Members[b]); //Send party data to member others.client.Send(Packet.Party_Data(2, Character.Information.UniqueID)); } //Add the invited member to list JoiningParty.Members.Add(Character.Information.UniqueID); //Add the invited client to the list JoiningParty.MembersClient.Add(client); //Set party Character.Network.Party = JoiningParty; //Send permissions client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID)); //Send party data client.Send(Packet.Party_DataMember(JoiningParty)); return; } } //If denied request else { //Send denied message to the player joining client.Send(Packet.Message(OperationCode.SERVER_PARTY_MEMBER, Messages.UIIT_MSG_PARTYERR_JOIN_PARTY_REFUSED)); //Set both bools to false so inviting can be done again sys.Character.Information.CheckParty = false; Character.Information.CheckParty = false; } } } //Catch bad exception errors catch (Exception ex) { Log.Exception(ex); } }
public void CalcSharedPartyExpSp(int paramexp, party pt, PlayerMgr targetplayer, ref long outexp) { try { byte mlv = ObjData.Manager.ObjectBase[ID].Level; // party average int k = 0; List <int> NearbyMembers = new List <int>(9); if (pt.Members.Count != 0) { double playerDist; foreach (int memb in pt.Members) { PlayerMgr i = Helpers.GetInformation.GetPlayer(memb); //playerDist = Formule.gamedistance(targetplayer.Character.Position.x, targetplayer.Character.Position.y, i.Character.Position.x, i.Character.Position.y); playerDist = Formule.gamedistance(targetplayer.Character.Position, i.Character.Position); if (playerDist >= 50) { NearbyMembers.Add(i.Character.Information.UniqueID); } } foreach (int l in NearbyMembers) { k += Helpers.GetInformation.GetPlayer(l).Character.Information.Level; } k = (int)(k / pt.Members.Count); //k = átlag. foreach (int mem in NearbyMembers) { PlayerMgr ch = Helpers.GetInformation.GetPlayer(mem); int ptsp = 97; //This isn't the right formula. TODO: We must find the right one! int ptexp = (int)((((paramexp / mlv) + (mlv - k)) * mlv) / k) * ch.Character.Information.Level; ptexp *= Helpers.Settings.Rate.Experience; byte kat = Kat; if (kat == 20) { kat = 25; } ptexp *= kat; //we multiply the exp according to type of the mob. //TODO: premium ticket //gap: ptexp -= (ptexp * (ch.Character.Information.Level) - Math.Abs(ch.Character.Information.Level - ch.MasteryGetBigLevel)) * 10 / 100; if (ch.Character.Information.Level == 110 && ch.Character.Information.XP >= 4000000000) { ptexp = 0; } //we calculate the amount of sp: if (Math.Abs(ObjData.Manager.ObjectBase[ID].Level - k) < 10) { int gap = Math.Abs(ch.Character.Information.Level - ch.MasteryGetBigLevel) * 10; if (gap >= 90) { gap = 90; } ptsp = (ptsp * (100 + gap)) / k; //Instead of 100 I share with the avareage of the party, so we get a proportionate number. ptsp *= kat; ptsp *= Helpers.Settings.Rate.SkillPoint; } //Send total to all in party (Set exp from formula) SetPartyMemberExp(ch, (long)ptexp, ch.Character.Information.Attributes, (long)ptsp); SetSp(ch, ptsp); if (ch.Character.Network.Guild.Guildid != 0) { if (Math.Abs(ch.Character.Network.Guild.LastDonate - ch.Character.Network.Guild.DonateGP) >= 10) { DB.query("UPDATE guild_members SET guild_points='" + ch.Character.Network.Guild.DonateGP + "' WHERE guild_member_id='" + ch.Character.Information.CharacterID + "'"); ch.Character.Network.Guild.LastDonate = ch.Character.Network.Guild.DonateGP; // set new amount to every guild members guild class foreach (int m in ch.Character.Network.Guild.Members) { int targetindex = ch.Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m); if (ch.Character.Network.Guild.MembersInfo[targetindex].Online) { PlayerMgr sys = Helpers.GetInformation.GetPlayer(m); // here comes the messy way ObjData.guild_player mygp = new ObjData.guild_player(); int myindex = 0; foreach (ObjData.guild_player gp in sys.Character.Network.Guild.MembersInfo) { if (gp.MemberID == ch.Character.Information.CharacterID) { mygp = gp; mygp.DonateGP = ch.Character.Network.Guild.DonateGP; break; } myindex++; } sys.Character.Network.Guild.MembersInfo[myindex] = mygp; } } ch.Character.Network.Guild.Send(Client.Packet.GuildUpdate(ch.Character, 9, 0, 0, 0)); } } outexp = ptexp; } } else { return; } } catch (Exception ex) { Log.Exception(ex); } }
public void SetExperience() { try { //Check death if (GetDie) { //Set default parameters int percent = 0; //Exp information of the monster long exp = ObjData.Manager.ObjectBase[ID].Exp; //Sp information int sp = 119; //Level default false bool level = false; //Main perfect information byte mainpercent = 100; //Set quick info to player PlayerMgr player; //If Agro list isnt empty if (AgressiveDMG != null) { //Check how many have agro state for (byte b = 0; b < AgressiveDMG.Count; b++) { //Make sure the player isnt null if (AgressiveDMG[b].playerID != 0) { //Get player information player = Helpers.GetInformation.GetPlayer(AgressiveDMG[b].playerID); //Again double check to make sure the called information isnt null if (player != null) { //Set definition for stat attributes short stat = player.Character.Information.Attributes; //Calculate the damage dealt of the player and divide it by the monster type and hp total. percent = AgressiveDMG[b].playerDMD * 100 / ObjData.Manager.ObjectBase[ID].HP * Kat; //If the % is higher or equals 100%, we reset our % to normal if (percent >= mainpercent) { percent = mainpercent; } //Set default bool info for level level = false; //Make sure our % isnt 0 , so we dont do none needed actions if (mainpercent > 0) { //If the player is currently in a party if (player.Character.Network.Party != null) { //Set definition for the party info party ept = player.Character.Network.Party; //Set party type information from our party PlayerMgr.PartyTypes ptType = (PlayerMgr.PartyTypes)ept.Type; //If its a non shared party if (ptType == PlayerMgr.PartyTypes.NONSHARE_NO_PERMISSION || ptType == PlayerMgr.PartyTypes.NONSHARE) { //Get gap information of the players mastery level int gap = Math.Abs(player.Character.Information.Level - player.MasteryGetBigLevel) * 10; if (gap >= 90) { gap = 90; } mainpercent -= (byte)percent; //Premium tickets should be added here to increase the exp exp *= Helpers.Settings.Rate.Experience; exp -= (exp * ((Math.Abs(ObjData.Manager.ObjectBase[ID].Level - player.Character.Information.Level) - Math.Abs(player.Character.Information.Level - player.MasteryGetBigLevel)) * 10)) / 100; // kat == the type of the mob. this is the multiplier of the mob's HP and the amount of exp what the mob gives. byte monstertype = Kat; if (monstertype == 20) { monstertype = 25; } exp *= monstertype; exp = (exp * percent) / 100; exp = (exp * (100 - gap)) / 100; if (Math.Abs(ObjData.Manager.ObjectBase[ID].Level - player.Character.Information.Level) < 10) { sp = (sp * (100 + gap)) / 100; sp *= monstertype; sp *= Helpers.Settings.Rate.SkillPoint; } else { sp = 10; } if (exp <= 1) { exp = 1; } if (sp <= 1) { sp = 10; } //simple non-share pt. if (ept.Members.Count > 1) { if (Type == 0) //normal mob { exp *= 1; sp *= 1; } else if (Type == 1) //champion { exp *= 2; sp *= 2; } else if (Type == 3)// Unique { exp *= 7; sp *= 7; } else if (Type == 4) //giant { exp *= 3; sp *= 3; } else if (Type == 6) //elite { exp *= 2; sp *= 2; } else if (Type == 16) //normal ptmob { exp *= 3; sp *= 3; } else if (Type == 17) //champion ptmob { exp *= 4; sp *= 4; } else if (Type == 20)//party giant { exp *= 6; sp *= 6; } switch (ept.Members.Count) { case 2: exp += (long)(exp * 0.05); sp += (int)(sp * 0.05); break; case 3: exp += (long)(exp * 0.05) * 2; sp += (int)(sp * 0.05) * 2; break; case 4: exp += (long)(exp * 0.05) * 3; sp += (int)(sp * 0.05) * 3; break; } } } if (ptType == PlayerMgr.PartyTypes.EXPSHARE_NO_PERMISSION || ptType == PlayerMgr.PartyTypes.EXPSHARE || ptType == PlayerMgr.PartyTypes.FULLSHARE || ptType == PlayerMgr.PartyTypes.FULLSHARE_NO_PERMISSION) { if (ept.Members.Count > 1) { if (Type == 0) //normal mob { exp *= 1; sp *= 1; } else if (Type == 1) //champion { exp *= 2; sp *= 2; } else if (Type == 3)// Unique { exp *= 7; sp *= 7; } else if (Type == 4) //giant { exp *= 3; sp *= 3; } else if (Type == 6) //elite { exp *= 2; sp *= 2; } else if (Type == 16) //normal ptmob { exp *= 3; sp *= 3; } else if (Type == 17) //champion ptmob { exp *= 4; sp *= 4; } else if (Type == 20)//party giant { exp *= 6; sp *= 6; } CalcSharedPartyExpSp(ObjData.Manager.ObjectBase[ID].Exp, ept, player, ref exp); } } } //Player not in party else { int gap = Math.Abs(player.Character.Information.Level - player.MasteryGetBigLevel) * 10; if (gap >= 90) { gap = 90; } mainpercent -= (byte)percent; if (player.Character.Information.Level != ObjData.Manager.ObjectBase[ID].Level) { exp -= (exp * ((Math.Abs(ObjData.Manager.ObjectBase[ID].Level - player.Character.Information.Level) - Math.Abs(player.Character.Information.Level - player.MasteryGetBigLevel)) * 10)) / 100; } if (Type == 0) //normal mob { exp *= 1; sp *= 1; } else if (Type == 1) //champion { exp *= 2; sp *= 2; } else if (Type == 3)// Unique { exp *= 7; sp *= 7; } else if (Type == 4) //giant { exp *= 3; sp *= 3; } else if (Type == 6) //elite { exp *= 2; sp *= 2; } else if (Type == 16) //normal ptmob { exp *= 3; sp *= 3; } else if (Type == 17) //champion ptmob { exp *= 4; sp *= 4; } else if (Type == 20)//party giant { exp *= 6; sp *= 6; } exp = (exp * percent) / 100; exp = (exp * (97 + gap)) / 100; if (player.Character.Information.Level == 140 && player.Character.Information.XP >= 130527554553) { exp = 0; } if (Math.Abs(ObjData.Manager.ObjectBase[ID].Level - player.Character.Information.Level) < 10) { int gaplevel = ObjData.Manager.ObjectBase[ID].Level - player.Character.Information.Level; sp = (sp * (100 + gaplevel)) / 100; sp *= Kat; sp *= Helpers.Settings.Rate.SkillPoint; exp = (exp * (100 + gaplevel)) / 100; exp *= Kat; exp *= Helpers.Settings.Rate.Experience; } else { exp = 10; sp = 10; } if (exp <= 1) { exp = 1; } if (sp <= 1) { sp = 10; } } player.Character.Information.XP += exp; while (player.Character.Information.XP >= ObjData.Manager.LevelData[player.Character.Information.Level]) { player.Character.Information.XP -= ObjData.Manager.LevelData[player.Character.Information.Level]; if (player.Character.Information.XP < 1) { player.Character.Information.XP = 0; } stat += 3; player.Character.Information.Attributes += 3; player.Character.Information.Level++; player.Character.Stat.Intelligence++; player.Character.Stat.Strength++; player.UpdateIntelligenceInfo(1); player.UpdateStrengthInfo(1); player.SetStat(); level = true; } SetSp(player, sp); player.Character.Network.Guild.LastDonate += 2; if (player.Character.Network.Guild.Guildid != 0) { if (Math.Abs(player.Character.Network.Guild.LastDonate - player.Character.Network.Guild.DonateGP) >= 10) { int gpinformation = Rnd.Next(1, 9);//Need to make formula DB.query("UPDATE guild_members SET guild_points='" + gpinformation + "' WHERE guild_member_id='" + player.Character.Information.CharacterID + "'"); player.Character.Network.Guild.LastDonate = player.Character.Network.Guild.DonateGP; //Reload information player.LoadPlayerGuildInfo(false); // set new amount to every guild members guild class foreach (int m in player.Character.Network.Guild.Members) { if (m != 0) { PlayerMgr gmember = Helpers.GetInformation.GetPlayerMainid(m); if (gmember != null) { gmember.client.Send(Client.Packet.GuildUpdate(player.Character, 9, 0, 0, 0)); } } } player.Character.Network.Guild.LastDonate = 0; } } //Check pet level information if (player.Character.Attackpet.Active) { while (player.Character.Attackpet.Details.exp >= ObjData.Manager.LevelData[player.Character.Attackpet.Details.exp]) { player.Character.Attackpet.Details.exp -= ObjData.Manager.LevelData[player.Character.Attackpet.Details.Level]; if (player.Character.Attackpet.Details.exp < 1) { player.Character.Attackpet.Details.exp = 0; } /* * stat += 3; * player.Character.Information.Attributes += 3; * player.Character.Information.Level++; * player.Character.Stat.Intelligence++; * player.Character.Stat.Strength++; * player.UpdateIntelligenceInfo(1); * player.UpdateStrengthInfo(1); * player.SetStat(); */ level = true; } } if (level) { if (player.Character.Network.Guild.Guildid != 0) { if (Math.Abs(player.Character.Network.Guild.LastDonate - player.Character.Network.Guild.DonateGP) >= 10) { int gpinformation = Rnd.Next(1, 9);//Need to make formula DB.query("UPDATE guild_members SET guild_points='" + gpinformation + "' WHERE guild_member_id='" + player.Character.Information.CharacterID + "'"); player.Character.Network.Guild.LastDonate = player.Character.Network.Guild.DonateGP; //Reload information player.LoadPlayerGuildInfo(false); // set new amount to every guild members guild class foreach (int m in player.Character.Network.Guild.Members) { if (m != 0) { PlayerMgr gmember = Helpers.GetInformation.GetPlayerMainid(m); if (gmember != null) { gmember.client.Send(Client.Packet.GuildUpdate(player.Character, 9, 0, 0, 0)); } } } player.Character.Network.Guild.LastDonate = 0; } } if (player.Character.Attackpet.Active) { //test player.Send(Client.Packet.Player_LevelUpEffect(player.Character.Attackpet.Details.UniqueID)); player.client.Send(Client.Packet.Player_getExp(player.Character.Attackpet.Details.UniqueID, exp, sp, stat)); } if (player.Character.Information.Level == 110 && player.Character.Information.XP >= 4000000000) { exp = 0; } player.Send(Client.Packet.Player_LevelUpEffect(player.Character.Information.UniqueID)); player.client.Send(Client.Packet.Player_getExp(player.Character.Action.Target, exp, sp, stat)); player.SavePlayerInfo(); } else { if (player.Character.Network.Guild.Guildid != 0) { if (Math.Abs(player.Character.Network.Guild.LastDonate - player.Character.Network.Guild.DonateGP) >= 10) { int gpinformation = Rnd.Next(1, 9);//Need to make formula DB.query("UPDATE guild_members SET guild_points='" + gpinformation + "' WHERE guild_member_id='" + player.Character.Information.CharacterID + "'"); player.Character.Network.Guild.LastDonate = player.Character.Network.Guild.DonateGP; //Reload information player.LoadPlayerGuildInfo(false); // set new amount to every guild members guild class foreach (int m in player.Character.Network.Guild.Members) { if (m != 0) { PlayerMgr gmember = Helpers.GetInformation.GetPlayerMainid(m); if (gmember != null) { gmember.client.Send(Client.Packet.GuildUpdate(player.Character, 9, 0, 0, 0)); } } } player.Character.Network.Guild.LastDonate = 0; } } if (player.Character.Information.Level == 110 && player.Character.Information.XP >= 4000000000) { exp = 0; } //Player experience player.client.Send(Client.Packet.Player_getExp(player.Character.Action.Target, exp, sp, 0)); player.SavePlayerExperince(); // Attack pet experience if (player.Character.Attackpet.Active) { bool petlevel; player.Character.Attackpet.Details.exp += exp * 2; while (player.Character.Attackpet.Details.exp >= ObjData.Manager.LevelData[player.Character.Attackpet.Details.exp]) { player.Character.Attackpet.Details.exp -= ObjData.Manager.LevelData[player.Character.Attackpet.Details.Level]; if (player.Character.Attackpet.Details.exp < 1) { player.Character.Attackpet.Details.exp = 0; } petlevel = true; } // Add exp player.client.Send(Client.Packet.PetSpawn(player.Character.Attackpet.Details.UniqueID, 3, player.Character.Attackpet.Details)); // Save pet exp player.SaveAttackPetExp(); } } } } } } } } } catch (Exception ex) { Console.WriteLine("SetExperience :error {0}", ex); Log.Exception(ex); } }
public void CalcSharedPartyExpSp(int paramexp, party pt, PlayerMgr targetplayer, ref long outexp) { try { byte mlv = ObjData.Manager.ObjectBase[ID].Level; // party average int k = 0; List<int> NearbyMembers = new List<int>(9); if (pt.Members.Count != 0) { double playerDist; foreach (int memb in pt.Members) { PlayerMgr i = Helpers.GetInformation.GetPlayer(memb); //playerDist = Formule.gamedistance(targetplayer.Character.Position.x, targetplayer.Character.Position.y, i.Character.Position.x, i.Character.Position.y); playerDist = Formule.gamedistance(targetplayer.Character.Position, i.Character.Position); if (playerDist >= 50) { NearbyMembers.Add(i.Character.Information.UniqueID); } } foreach (int l in NearbyMembers) { k += Helpers.GetInformation.GetPlayer(l).Character.Information.Level; } k = (int)(k / pt.Members.Count); //k = átlag. foreach (int mem in NearbyMembers) { PlayerMgr ch = Helpers.GetInformation.GetPlayer(mem); int ptsp = 97; //This isn't the right formula. TODO: We must find the right one! int ptexp = (int)((((paramexp / mlv) + (mlv - k)) * mlv) / k) * ch.Character.Information.Level; ptexp *= Helpers.Settings.Rate.Experience; byte kat = Kat; if (kat == 20) kat = 25; ptexp *= kat; //we multiply the exp according to type of the mob. //TODO: premium ticket //gap: ptexp -= (ptexp * (ch.Character.Information.Level) - Math.Abs(ch.Character.Information.Level - ch.MasteryGetBigLevel)) * 10 / 100; if (ch.Character.Information.Level == 110 && ch.Character.Information.XP >= 4000000000) ptexp = 0; //we calculate the amount of sp: if (Math.Abs(ObjData.Manager.ObjectBase[ID].Level - k) < 10) { int gap = Math.Abs(ch.Character.Information.Level - ch.MasteryGetBigLevel) * 10; if (gap >= 90) gap = 90; ptsp = (ptsp * (100 + gap)) / k; //Instead of 100 I share with the avareage of the party, so we get a proportionate number. ptsp *= kat; ptsp *= Helpers.Settings.Rate.SkillPoint; } //Send total to all in party (Set exp from formula) SetPartyMemberExp(ch, (long)ptexp, ch.Character.Information.Attributes, (long)ptsp); SetSp(ch, ptsp); if (ch.Character.Network.Guild.Guildid != 0) { if (Math.Abs(ch.Character.Network.Guild.LastDonate - ch.Character.Network.Guild.DonateGP) >= 10) { DB.query("UPDATE guild_members SET guild_points='" + ch.Character.Network.Guild.DonateGP + "' WHERE guild_member_id='" + ch.Character.Information.CharacterID + "'"); ch.Character.Network.Guild.LastDonate = ch.Character.Network.Guild.DonateGP; // set new amount to every guild members guild class foreach (int m in ch.Character.Network.Guild.Members) { int targetindex = ch.Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m); if (ch.Character.Network.Guild.MembersInfo[targetindex].Online) { PlayerMgr sys = Helpers.GetInformation.GetPlayer(m); // here comes the messy way ObjData.guild_player mygp = new ObjData.guild_player(); int myindex = 0; foreach (ObjData.guild_player gp in sys.Character.Network.Guild.MembersInfo) { if (gp.MemberID == ch.Character.Information.CharacterID) { mygp = gp; mygp.DonateGP = ch.Character.Network.Guild.DonateGP; break; } myindex++; } sys.Character.Network.Guild.MembersInfo[myindex] = mygp; } } ch.Character.Network.Guild.Send(Client.Packet.GuildUpdate(ch.Character, 9, 0, 0, 0)); } } outexp = ptexp; } } else return; } catch (Exception ex) { Log.Exception(ex); } }
public void CreateFormedParty() { try { //Get packet data PacketReader Reader = new PacketReader(PacketInformation.buffer); //First and second dword are static int masteryid1 = Reader.Int32(); // MasteryID int masteryid2 = Reader.Int32(); // MasteryID2 //First byte is our party type byte PartyType = Reader.Byte(); //Second byte is purpose information byte PartyPurpose = Reader.Byte(); //3rd byte is minimal level required to join byte PartyMinLevelReq = Reader.Byte(); //4th byte is max level to join byte PartyMaxLevelReq = Reader.Byte(); //5th is short, party name lenght //6th is party name string PartyName = Reader.Text3(); //Close our reader Reader.Close(); //Make sure the user isnt in a party yet. if (Character.Network.Party != null) { //If party is formed allready return if (Character.Network.Party.IsFormed) { return; } //If party is not formed else { //Get current party information WorldMgr.party CurrentParty = Character.Network.Party; //Set formed state CurrentParty.IsFormed = true; //Party type CurrentParty.Type = PartyType; //Party purpose CurrentParty.ptpurpose = PartyPurpose; //Party minimal level CurrentParty.minlevel = PartyMinLevelReq; //Party maximum level CurrentParty.maxlevel = PartyMaxLevelReq; //Party name CurrentParty.partyname = PartyName; //Party owner CurrentParty.LeaderID = Character.Information.UniqueID; //Add party eu / ch information by model CurrentParty.Race = Character.Information.Race; //Send packet information to user client.Send(Packet.CreateFormedParty(CurrentParty)); //Add party to list Helpers.Manager.Party.Add(CurrentParty); } } //If a new formed party is created from 0 else { //New party for details WorldMgr.party newparty = new WorldMgr.party(); //Set formed state newparty.IsFormed = true; //Party type newparty.Type = PartyType; //Party purpose newparty.ptpurpose = PartyPurpose; //Party minimal level newparty.minlevel = PartyMinLevelReq; //Party maximum level newparty.maxlevel = PartyMaxLevelReq; //Party name newparty.partyname = PartyName; //Party owner newparty.LeaderID = Character.Information.UniqueID; //Add party eu / ch information by model newparty.Race = Character.Information.Race; //Add our player to the member list newparty.Members.Add(Character.Information.UniqueID); //Add player client to party list information newparty.MembersClient.Add(client); //Party id , is current count of party's + 1 newparty.ptid = Helpers.Manager.Party.Count + 1; //Add the new party list Helpers.Manager.Party.Add(newparty); //Set party to player Character.Network.Party = newparty; //bool set player in party Character.Network.Party.InParty = true; //Send packet information to user client.Send(Packet.CreateFormedParty(newparty)); } } //Catch bad exception errors catch (Exception ex) { Log.Exception(ex); } }