Example #1
0
 private void SetCooldown(RPGInfo rpgInfo, float time, Dictionary<string, float> playerCooldowns, string skillKey)
 {
     var modifier = SkillTable[skillKey].Modifiers[HRK.CooldownModifier];
     var availableAt = SkillMethods.CooldownModifier(rpgInfo.Skills[skillKey], Convert.ToInt32(modifier.Args[0]),
         Convert.ToInt32(modifier.Args[1]), time);
     playerCooldowns[skillKey] = availableAt;
 }
Example #2
0
 private bool PlayerHaveSkill(BasePlayer player, RPGInfo rpgInfo, string skillKey,bool sendMsg = true)
 {
     if (rpgInfo.Skills.ContainsKey(skillKey)) return true;
     if (sendMsg)
         ChatMessage(player, MessagesTable.GetMessage(HMK.SkillNotLearned));
     return false;
 }
Example #3
0
 private RPGInfo RPGInfo(BasePlayer player)
 {
     var steamId = RPGHelper.SteamId(player);
     if (RPGConfig.ContainsKey(steamId)) return RPGConfig[steamId];
     RPGConfig[steamId] = new RPGInfo(player.displayName);
     PluginInstance.SaveRPG(RPGConfig, PlayersFurnaces);
     return RPGConfig[steamId];
 }
Example #4
0
 private void LevelUpChatHandler(BasePlayer player, string[] args, RPGInfo rpgInfo)
 {
     if (!player.IsAdmin()) return;
     var callerPlayer = player;
     int commandArgs = args.Length - 1;
     if (commandArgs > 2 && commandArgs < 1)
         InvalidCommand(player, args);
     else
     {
         int levelIndex = 1;
         if (commandArgs  == 2)
         {
             levelIndex = 2;
             string playerToSearch = args[1].ToLower();
             var activePlayerList = BasePlayer.activePlayerList;
             var playersFound = (from basePlayer in activePlayerList let displayName = basePlayer.displayName.ToLower() where displayName.Equals(playerToSearch) select basePlayer).ToDictionary(basePlayer => basePlayer.displayName);
             if (playersFound.Count > 1)
             {
                 var playerFoundNames = String.Join(",", playersFound.Select(basePlayer => basePlayer.Key).ToArray());
                 ChatMessage(callerPlayer, String.Format("Multiple players found. {0}", playerFoundNames));
                 return;
             }
             if (playersFound.Count == 0)
             {
                 ChatMessage(callerPlayer, "No player found with that name!");
                 return;
             }
             player = playersFound.First().Value;
             rpgInfo = RPGInfo(player);
         }
         int desiredLevel;
         if (!Int32.TryParse(args[levelIndex], out desiredLevel))
         {
             InvalidCommand(callerPlayer, args);
             return;
         }
         if (desiredLevel <= rpgInfo.Level) return;
         LevelUpPlayer(rpgInfo, desiredLevel);
         NotifyLevelUp(player, rpgInfo);
         if (callerPlayer != player)
             ChatMessage(callerPlayer, String.Format("Player {0} lvlup to {1}", player, desiredLevel));
     }
 }
Example #5
0
 private void NotifyLevelUp(BasePlayer player, RPGInfo rpgInfo)
 {
     ChatMessage(player, String.Format("<color=yellow>Level Up! You are now level {0}</color>", rpgInfo.Level));
     DisplayProfile(player);
     PluginInstance.SaveRPG(RPGConfig, PlayersFurnaces, false);
 }
Example #6
0
 private void ToogleBlinkArrow(BasePlayer player, RPGInfo rpgInfo)
 {
     rpgInfo.Preferences.UseBlinkArrow = !rpgInfo.Preferences.UseBlinkArrow;
     var blinkArrowStatus = rpgInfo.Preferences.UseBlinkArrow ? "On" : "Off";
     ChatMessage(player, String.Format("Blink Arrow is now {0}", blinkArrowStatus));
 }
Example #7
0
 public static float GetEvasion(RPGInfo rpgInfo)
 {
     var evasion = (float) (rpgInfo.Agility/HRK.MaxEvasion);
     return evasion;
 }
Example #8
0
 private void ChangePlayerXPMessagePreference(BasePlayer player, string[] args, RPGInfo rpgInfo)
 {
     var commandArgs = args.Length - 1;
     if (commandArgs != 1)
     {
         InvalidCommand(player, args);
         return;
     }
     float xpPercent;
     if (!Single.TryParse(args[1], out xpPercent))
     {
         InvalidCommand(player, args);
         return;
     }
     rpgInfo.Preferences.ShowXPMessagePercent = xpPercent/100;
     ChatMessage(player, String.Format("XP will be shown at every {0:P} change", rpgInfo.Preferences.ShowXPMessagePercent));
 }
Example #9
0
 private string CurrentHealth(RPGInfo rpgInfo, BasePlayer player)
 {
     return String.Format("Health: {0:F1}/{1:F}", player.health, RPGHelper.GetMaxHealth(rpgInfo));
 }
Example #10
0
        public bool ReserachItem(BasePlayer player, string[] args, RPGInfo rpgInfo)
        {
            int commandArgs = args.Length - 1;
            if (commandArgs != 1)
            {
                InvalidCommand(player, args);
                return false;
            }

            if (!PlayerHaveSkill(player, rpgInfo, HRK.Researcher)) return false;
            var playerResearchPoints = rpgInfo.Skills[HRK.Researcher];
            var itemname = args[1];
            itemname = itemname.ToLower();
            if (ItemTable.ContainsKey(itemname))
                itemname = ItemTable[itemname].Shortname;
            var definition = ItemManager.FindItemDefinition(itemname);
            if (definition == null)
            {
                ChatMessage(player, MessagesTable.GetMessage(HMK.ItemNotFound, new[] { itemname }));
                return false;
            }
            var playerContainer = player.inventory.containerMain;
            var hasItem = player.inventory.AllItems().Any(item => item.info.shortname.Equals(itemname));
            if (!hasItem)
            {
                ChatMessage(player, String.Format("In order to research an item you must have it on your inventory"));
                return false;
            }
            if (!ResearchTable.ContainsKey(definition.category))
            {
                ChatMessage(player, "You can research itens of this type");
                return false;
            }
            var requiredSkillPoints = ResearchTable[definition.category];
            if (playerResearchPoints < requiredSkillPoints)
            {
                ChatMessage(player, String.Format("Your research skills are not hight enought. Required {0}", requiredSkillPoints));
                return false;
            }

            var steamId = RPGHelper.SteamId(player);
            float availableAt = 0;
            var time = Time.realtimeSinceStartup;
            var playerCooldowns = PlayerCooldowns(steamId);
            var isReady = RPGHelper.IsSkillReady(playerCooldowns, ref availableAt, time, HRK.Researcher);
            if (isReady)
            {
                var random = Random(0, 1);
                if (random > 0.6)
                {
                    ChatMessage(player, String.Format("You managed to reverse enginier the {0}. The blueprint its on your inventory", definition.displayName.translated));
                    player.inventory.GiveItem(ItemManager.CreateByItemID(definition.itemid, 1, true), playerContainer);
                    NoticeArea.ItemPickUp(definition,1, true);
                }
                else
                {
                    ChatMessage(player, String.Format("OPS! While you were trying to research the {0} you accidently broke it.", definition.displayName.translated));
                    var itemInstance = player.inventory.FindItemID(definition.itemid);
                    player.inventory.Take(new List<Item> { itemInstance }, definition.itemid, 1);
                }
                SetCooldown(rpgInfo, time, playerCooldowns, HRK.Researcher);
            }
            else
            {
                var formatedTimeLeft = RPGHelper.TimeLeft(availableAt, time);
                ChatMessage(player, String.Format("You have tried this moments ago, give it a rest. Time left to research again: {0}",formatedTimeLeft));
            }
            return true;
        }
Example #11
0
 public string XPProgression(RPGInfo rpgInfo)
 {
     var percent = CurrentPercent(rpgInfo);
     string nightBonus = "";
     if (IsNight())
         nightBonus = "Bonus Night Exp On";
     return String.Format("Current XP: {0:P}. {1}", percent, nightBonus);
 }
Example #12
0
 public string Profile(RPGInfo rpgInfo, BasePlayer player)
 {
     var sb = new StringBuilder();
     sb.AppendLine();
     sb.AppendLine(String.Format("========{0}========", rpgInfo.SteamName));
     sb.AppendLine(String.Format("Level: {0}", rpgInfo.Level));
     sb.AppendLine(CurrentHealth(rpgInfo, player));
     sb.AppendLine(String.Format("Evasion Chance: {0:P}", RPGHelper.GetEvasion(rpgInfo)));
     sb.AppendLine(String.Format("Crafting Reducer: {0:P}", RPGHelper.GetCraftingReducer(rpgInfo)));
     sb.AppendLine(XPProgression(rpgInfo));
     sb.Append(String.Format("<color={0}>Agi: {1}</color> | ","green", rpgInfo.Agility));
     sb.Append(String.Format("<color={0}>Str: {1}</color> | ", "red", rpgInfo.Strength));
     sb.Append(String.Format("<color={0}>Int: {1}</color>", "blue", rpgInfo.Intelligence));
     sb.AppendLine();
     sb.AppendLine(String.Format("Stats Points: {0}", rpgInfo.StatsPoints));
     sb.AppendLine(String.Format("Skill Points: {0}", rpgInfo.SkillPoints));
     sb.AppendLine(String.Format("========<color={0}>Skills</color>========", "purple"));
     foreach (var skill in rpgInfo.Skills)
         sb.AppendLine(String.Format("{0}: {1}/{2}", skill.Key, skill.Value, SkillTable[skill.Key].MaxPoints));
     sb.AppendLine("====================");
     return sb.ToString();
 }
Example #13
0
 public void LevelUpPlayer(RPGInfo rpgInfo, int desiredLevel)
 {
     var levelsToUp = desiredLevel - rpgInfo.Level;
     for (int i = 0; i < levelsToUp; i++)
     {
         long requiredXP = RequiredExperience(rpgInfo.Level);
         rpgInfo.AddExperience(requiredXP, requiredXP);
     }
 }
Example #14
0
 public static float GetMaxHealth(RPGInfo rpgInfo)
 {
     var healthMultiplier = (float) (rpgInfo.Strength/HRK.MaxHealth);
     var extraHealht = rpgInfo.Strength * healthMultiplier;
     return 100 + extraHealht;
 }
Example #15
0
        private void SetSkillsCommand(BasePlayer player, string[] args, RPGInfo rpgInfo)
        {
            int commandArgs = args.Length - 1;
            if (args.Length < 3 || (commandArgs%2) != 0)
            {
                InvalidCommand(player, args);
                return;
            }
            var pointsSpent = new List<string>();
            int pairs = (commandArgs / 2) + 1;
            for (int i = 1; i < pairs; i++)
            {
                int index = i * 2 - 1;
                string skillKey = args[index];
                int points;
                if (!Int32.TryParse(args[index + 1], out points))
                {
                    InvalidCommand(player, args);
                    continue;
                }

                if (SkillTable.ContainsKey(skillKey))
                {
                    var skill = SkillTable[skillKey];
                    string reason;
                    var pointsAdded = rpgInfo.AddSkill(skill, points, out reason);
                    if (pointsAdded > 0)
                        pointsSpent.Add(String.Format("<color={0}>{1}: +{2}</color>", "purple", skillKey,
                            pointsAdded));
                    else
                    {
                        pointsSpent.AddRange(MessagesTable.GetMessage(reason));
                        pointsSpent.AddRange(MessagesTable.GetMessage(HMK.SkillInfo));
                    }

                }
                else
                    pointsSpent.AddRange(MessagesTable.GetMessage(HMK.InvalidSkillName));
            }
            ChatMessage(player, pointsSpent);
        }
Example #16
0
 private float CurrentPercent(RPGInfo rpgInfo)
 {
     return rpgInfo.Experience/(float) (RequiredExperience(rpgInfo.Level));
 }
Example #17
0
        private void SetStatsCommand(BasePlayer player, string[] args, RPGInfo rpgInfo)
        {
            int commandArgs = args.Length - 1;
            if (args.Length < 3 || (commandArgs%2) != 0)
                InvalidCommand(player, args);
            else
            {
                var pointsSpent = new List<string>();
                int pairs = (commandArgs/2) + 1;
                for (int i = 1; i < pairs; i++)
                {
                    int index = i*2 - 1;
                    int points;
                    if (!Int32.TryParse(args[index + 1], out points))
                    {
                        InvalidCommand(player, args);
                        continue;
                    }

                    switch (args[index].ToLower())
                    {
                        case "agi":
                            if (rpgInfo.AddAgi(points))
                                pointsSpent.Add(String.Format("<color={0}>Agi: +{1}</color>", "green", points));
                            else
                                pointsSpent.AddRange(MessagesTable.GetMessage(HMK.NotEnoughtPoints));
                            break;
                        case "str":
                            if (rpgInfo.AddStr(points))
                            {
                                SetMaxHealth(player);
                                pointsSpent.Add(String.Format("<color={0}>Str: +{1}</color>", "red", points));
                            }
                            else
                                pointsSpent.AddRange(MessagesTable.GetMessage(HMK.NotEnoughtPoints));
                            break;
                        case "int":
                            if (rpgInfo.AddInt(points))
                                pointsSpent.Add(String.Format("<color={0}>Int: +{1}</color>", "blue", points));
                            else
                                pointsSpent.AddRange(MessagesTable.GetMessage(HMK.NotEnoughtPoints));
                            break;
                        default:
                            InvalidCommand(player, args);
                            break;
                    }
                }
                ChatMessage(player, pointsSpent);
            }
        }
Example #18
0
 private void ExpGain(RPGInfo rpgInfo, int experience, BasePlayer player)
 {
     var steamId = RPGHelper.SteamId(player);
     if (IsNight())
         experience *= 2;
     if (rpgInfo.AddExperience(experience, RequiredExperience(rpgInfo.Level)))
     {
         NotifyLevelUp(player, rpgInfo);
         PlayerLastPercentChange[steamId] = 0;
     }
     else
     {
         var currentPercent = CurrentPercent(rpgInfo);
         if (!PlayerLastPercentChange.ContainsKey(steamId))
             PlayerLastPercentChange.Add(steamId, currentPercent);
         var lastPercent = PlayerLastPercentChange[steamId];
         var requiredPercentChange = rpgInfo.Preferences.ShowXPMessagePercent;
         float percentChange = currentPercent - lastPercent;
         if (percentChange < requiredPercentChange) return;
         ChatMessage(player, XPProgression(rpgInfo));
         PlayerLastPercentChange[steamId] = currentPercent;
     }
 }
Example #19
0
 private void ToogleCraftMessage(BasePlayer player, RPGInfo rpgInfo)
 {
     rpgInfo.Preferences.ShowCraftMessage = !rpgInfo.Preferences.ShowCraftMessage;
     var craftMessageStatus = rpgInfo.Preferences.ShowCraftMessage ? "On" : "Off";
     ChatMessage(player, String.Format("Craft message is now {0}",craftMessageStatus));
 }
Example #20
0
 public static float GetCraftingReducer(RPGInfo rpgInfo)
 {
     return rpgInfo.Intelligence /HRK.MaxCraftingTimeReducer;
 }