public void Attach(Client client) { LoggedInAccounts.Add(this); // Basic Account client.SetData(EntityData.Account, this); client.Name = Name; client.Health = Health; client.Armor = Armor; Console.WriteLine($"{client.Name} has logged in."); // Set Position Vector3 position = JsonConvert.DeserializeObject <Vector3>(LastPosition); NAPI.Entity.SetEntityPosition(client, position); // Appearance Appearance appearance = Appearance.RetrieveAppearance(this); appearance.Attach(client); client.SendChatMessage(Exceptions.LoginLoadedAppearance); // Clothing Clothing clothing = Clothing.RetrieveClothing(this); clothing.Attach(client); client.SendChatMessage(Exceptions.LoginLoadedClothing); // Skills Skillsheet skills = JsonConvert.DeserializeObject <Skillsheet>(LevelSkills); skills.Attach(client); client.SendChatMessage(Exceptions.LoginLoadedSkills); // Levels AccountUtil.UpdateLevelSystemLocally(client); // Inventory InventoryHandler.SendInventoryLocally(client); // Reload existing weapons. AccountUtil.ReloadPlayerWeapons(client); if (IsDead) { IsDead = false; Health = 75; client.Health = 75; } // Finish FinishLogin(client); }
/// <summary> /// Compare skills between two players. Impact will always effect the initiator. /// </summary> /// <param name="client"></param> /// <param name="target"></param> /// <param name="type"></param> /// <param name="impact"></param> /// <returns></returns> public static bool SkillCheckPlayers(Client client, Client target, Skills type, int impact = 0, int clientModifier = 0, int targetModifier = 0) { if (!client.HasData(EntityData.Skills)) { return(false); } if (!target.HasData(EntityData.Skills)) { return(false); } int clientRoll = 0; int targetRoll = 0; Skillsheet clientSheet = client.GetData(EntityData.Skills); Skillsheet targetSheet = target.GetData(EntityData.Skills); int initialClientRoll = Dice.RollDice(20); int initialTargetRoll = Dice.RollDice(20); if (initialClientRoll == 20) { client.SendNotification("You rolled a ~o~20!"); client.TriggerEvent("eventLastRoll", initialClientRoll); target.TriggerEvent("eventLastRoll", initialTargetRoll); return(true); } switch (type) { case Skills.strength: clientRoll = clientSheet.GetScore(clientSheet.Strength, clientSheet.StrengthModifier) + initialClientRoll - clientModifier; targetRoll = targetSheet.GetScore(targetSheet.Strength, targetSheet.StrengthModifier) + initialTargetRoll - targetModifier; break; case Skills.endurance: clientRoll = clientSheet.GetScore(clientSheet.Endurance, clientSheet.EnduranceModifier) + initialClientRoll - clientModifier; targetRoll = targetSheet.GetScore(targetSheet.Endurance, targetSheet.EnduranceModifier) + initialTargetRoll - targetModifier; break; case Skills.intelligence: clientRoll = clientSheet.GetScore(clientSheet.Intelligence, clientSheet.IntelligenceModifier) + initialClientRoll - clientModifier; targetRoll = targetSheet.GetScore(targetSheet.Intelligence, targetSheet.IntelligenceModifier) + initialTargetRoll - targetModifier; break; case Skills.charisma: clientRoll = clientSheet.GetScore(clientSheet.Charisma, clientSheet.CharismaModifier) + initialClientRoll - clientModifier; targetRoll = targetSheet.GetScore(targetSheet.Charisma, targetSheet.CharismaModifier) + initialTargetRoll - targetModifier; break; } client.TriggerEvent("eventLastRoll", clientRoll); target.TriggerEvent("eventLastRoll", targetRoll); if (clientRoll > targetRoll) { return(true); } switch (type) { case Skills.strength: clientSheet.StrengthModifier += impact; break; case Skills.endurance: clientSheet.EnduranceModifier += impact; break; case Skills.intelligence: clientSheet.IntelligenceModifier += impact; break; case Skills.charisma: clientSheet.CharismaModifier += impact; break; } clientSheet.Update(client); return(false); }