static void CheckSkills(Player __instance, Skills.SkillType skill, float level) { string title = PatchedSkills.getSkillTitle(skill.ToString().ToLower()); string rank = PatchedSkills.getSkillRank((byte)level); int levelInt = (int)level; string message = ""; ZPackage pkg = new ZPackage(); //Add number of clean lines to package pkg.Write(1); // check if a new rank has been acquired if (levelInt % 10 == 0) { message = $"{rank} {title}!"; // TODO use Message() on Player class! // _instance.Message(, message); var icon = PatchedSkills.getSkillIcon(skill); // MessageHud.MessageType type, string msg, int amount = 0, icon = null) ShowMessage("self", message, icon: icon); } pkg.Write($"{skill.ToString()}:{(byte)level}"); EpicTitles.Log.LogInfo($"SENT SKILL: {skill.ToString()}:{(byte)level}"); ZRoutedRpc.instance.InvokeRoutedRPC("SkillUpdate", Player.m_localPlayer.GetPlayerName(), pkg); // send update to the server // sendSkillUpdate(skill, level); // ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SkillUpdate", Player.m_localPlayer.GetPlayerName(), skill.ToString(), (int)level); // ZRoutedRpc.instance.InvokeRoutedRPC("SkillUpdate", Player.m_localPlayer.GetPlayerName(), skill.ToString(), (int)level); // EpicTitles.Log.LogInfo("SkillUpdateSent"); // TODO retrieve a list of the skills with the current value // List<Skills.Skill> char_skills = __instance.GetSkills().GetSkillList(); // Log.LogInfo($"{skill.m_info}: {skill.m_level}"); // foreach (KeyValuePair<Skills.SkillType, Skills.Skill> keyValuePair in __instance.GetSkills().char_skills) // { // list.Add(keyValuePair.Value); // } // foreach (var skillx in char_skills){ // Log.LogInfo(string.Format("Skill: {0}", skillx)); // } }
static String getSkillLadder(string skill, string playerName = "") { string message = ""; if (skillLadders.ContainsKey(skill)) { var counter = 1; var _title = PatchedSkills.getSkillTitle(skill); var position = 0; foreach (KeyValuePair <string, byte> skillLadder in skillLadders[skill].OrderByDescending(key => key.Value)) { var _rank = PatchedSkills.getSkillRank(skillLadder.Value); if (skillLadder.Key == playerName) { position = counter; } // message += $"\n<b>{counter++}. {skillLadder.Key}, the {_rank} {_title} ({skillLadder.Value})</b>"; message += $"\n{counter++}. {skillLadder.Key}, the {_rank} {_title} ({skillLadder.Value})"; } var skillUpper = skill.ToUpper(); var title = $"===== {skillUpper} LADDER ====="; var divider = ""; for (int i = 0; i < title.Length; i++) { divider += "="; } message = "\n" + divider + message; if (position > 0) { message = $"\nYou're in position #{position}!" + message; } message = title + message; } else { message = $"There's no ladder for {skill}!"; } return(message); }
static void NotifityOtherClients(long sender, String playerName, String skill, byte level) { var znet = Traverse.Create(typeof(ZNet)).Field("m_instance").GetValue() as ZNet; var mPeers = Traverse.Create((znet)).Field("m_peers").GetValue() as List <ZNetPeer>; var message = $"{playerName} is now a {PatchedSkills.getSkillRank(level)} {PatchedSkills.getSkillTitle(skill.ToLower())}!"; foreach (var peer in mPeers) { if (peer.IsReady()) { if (peer.m_uid == sender) { // EpicTitles.Log.LogInfo("sender == peer; Skip notification"); // peer.m_rpc.Invoke(peer.m_uid, "SkillUpdate", Player.m_localPlayer.GetPlayerName(), String.Format("{0}", skill), (int)level); // ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "SkillRankUpNotification", playerName, skill, message); continue; } // Not viable for now :( // PatchedPlayer.sendMessageToPlayer(peer.m_uid, message); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "SkillRankUpNotification", skill, message); // EpicTitles.Log.LogInfo($"SkillRankUpNotification sent to {peer.m_playerName}"); // ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SkillUpdate", Player.m_localPlayer.GetPlayerName(), String.Format("{0}", skill), (int)level); } } }