/// <summary> /// Adds a specific amount of experience to the player. /// </summary> /// <param name="newExperience">The new amount of experience.</param> public void AddExperience(ulong newExperience) { if (Player.Level >= Data.Constants.GameMode.MaxLevel) { return; } ulong requiredExperience = Data.Constants.Level.GetLevelExperience(Player.Level); newExperience *= Data.Constants.GameMode.PlayerExperienceRate; newExperience += (ulong)(newExperience * Player.RainbowGemPercentage); Player.Experience += newExperience; if (Player.Experience >= requiredExperience) { long nextExperience = (long)Player.Experience; Player.Experience = 0; byte addLevels = 1; nextExperience -= (long)requiredExperience; while (nextExperience >= (long)requiredExperience && addLevels <= 12 && (Player.Level + addLevels) < Data.Constants.GameMode.MaxLevel) { addLevels++; requiredExperience = Data.Constants.Level.GetLevelExperience((byte)(Player.Level + addLevels)); nextExperience -= (long)requiredExperience; } Player.Level += addLevels; if (Player.Reborns > 0) { Player.AttributePoints += (ushort)(addLevels * 3); } if (addLevels >= 12) { Player.Experience = 0; } else { Player.Experience = (ulong)nextExperience; } var levelUpEffect = new Models.Packets.Misc.StringPacket { Action = Enums.StringAction.RoleEffect, Data = Player.ClientId, String = "LevelUp" }; Player.UpdateScreen(false, levelUpEffect); Player.ClientSocket.Send(levelUpEffect); } else if (Player.LoggedIn) { Player.SendFormattedSystemMessage("GAIN_EXP", true, newExperience); } }
public static bool Handle(Models.Entities.Player player, Models.Packets.Misc.StringPacket packet) { var whisperPlayer = Collections.PlayerCollection.GetPlayerByName(packet.Strings[0]); if (whisperPlayer != null) { var guildName = whisperPlayer.Guild != null ? whisperPlayer.Guild.DbGuild.Name : string.Empty; string infoString = whisperPlayer.ClientId + " "; infoString += whisperPlayer.Level + " "; infoString += whisperPlayer.Level + " "; //battle power infoString += "~" + guildName + " "; infoString += "# "; //unknown, family ?? infoString += whisperPlayer.Spouse + " "; infoString += 0 + " "; //unknown if (whisperPlayer.Mesh % 10 < 3) { infoString += "1 "; } else { infoString += "0 "; } var stringPacket = new Models.Packets.Misc.StringPacket { Action = Enums.StringAction.WhisperWindowInfo }; stringPacket.Strings.Add(whisperPlayer.Name); stringPacket.Strings.Add(infoString); player.ClientSocket.Send(stringPacket); } return(true); }
public static bool HandleQueryMate(Models.Entities.Player player, Models.Packets.Misc.StringPacket packet) { Models.Entities.Player requestPlayer = Collections.PlayerCollection.GetPlayerByClientId(packet.Data); if (requestPlayer != null) { player.ClientSocket.Send(new Models.Packets.Misc.StringPacket { String = requestPlayer.Spouse, Action = Enums.StringAction.QueryMate }); } return(true); }
public static bool HandleMarry(Models.Entities.Player player, Models.Packets.Entities.InteractionPacket packet) { if (packet.TargetClientId == player.ClientId) { return(false); } if (player.Spouse != "None") { return(true); } Models.Maps.IMapObject obj; if (player.GetFromScreen(packet.TargetClientId, out obj)) { var marriageTarget = obj as Models.Entities.Player; if (marriageTarget != null) { if (marriageTarget.Spouse != "None") { return(true); } if (marriageTarget.PendingSpouse != player.ClientId) { return(true); } player.AddActionLog("Marriage", player.Name + " : " + marriageTarget.Name); marriageTarget.Spouse = player.Name; player.Spouse = marriageTarget.Name; player.ClientSocket.Send(new Models.Packets.Misc.StringPacket { Action = Enums.StringAction.Mate, Data = player.ClientId, String = marriageTarget.Name }); marriageTarget.ClientSocket.Send(new Models.Packets.Misc.StringPacket { Action = Enums.StringAction.Mate, Data = marriageTarget.ClientId, String = player.Name }); var fireworks = new Models.Packets.Misc.StringPacket { Action = Enums.StringAction.MapEffect, PositionX = player.X, PositionY = player.Y, String = "firework-2love" }; player.ClientSocket.Send(fireworks); fireworks.PositionX = marriageTarget.X; fireworks.PositionY = marriageTarget.Y; marriageTarget.ClientSocket.Send(fireworks); Collections.PlayerCollection.BroadcastFormattedMessage("MARRIAGE_CONGRATZ", player.Name, marriageTarget.Name); } } return(true); }