Esempio n. 1
0
        public void AddSkill(uint skillId)
        {
            var template = SkillManager.Instance.GetSkillTemplate(skillId);

            if (template.AbilityId > 0 &&
                template.AbilityId != (byte)Owner.Ability1 &&
                template.AbilityId != (byte)Owner.Ability2 &&
                template.AbilityId != (byte)Owner.Ability3)
            {
                return;
            }
            var points = ExpirienceManager.Instance.GetSkillPointsForLevel(Owner.Level);

            points -= GetUsedSkillPoints();
            if (template.SkillPoints > points)
            {
                return;
            }

            if (Skills.ContainsKey(skillId))
            {
                Skills[skillId].Level++;
                Owner.SendPacket(new SCSkillUpgradedPacket(Skills[skillId]));
            }
            else
            {
                AddSkill(template, 1, true);
            }
        }
Esempio n. 2
0
    public void AddExperience(SkillType skill_type, long amount)
    {
        if (skill_type == SkillType.Unknown)
        {
            Console.WriteLine("Gained " + amount + " experience in unfound skill.");
            return;
        }
        if (amount <= 0 || !Skills.ContainsKey(skill_type))
        {
            return;
        }

        Skill skill = Skills[skill_type];

        if (!LastLevelledSkillLocked)
        {
            LastLevelledSkill = skill.SkillType;
        }
        else
        {
            skill.Experience += (long)(amount * GetExperienceGainBonus(skill));
        }

        SkillExperienceAdd?.Invoke(this, new SkillExperienceAddedEventArgs(skill, amount));
        skill.TryIncreaseLevels();
    }
Esempio n. 3
0
        // ~CreatureId()
        // {
        //    OnLocationChanged -= CheckAutoAttack;         // Are we in range with our target now/still?
        //    OnLocationChanged -= CheckPendingActions;                  // Are we in range with any of our pending actions?
        //    //OnTargetChanged -= CheckAutoAttack;           // Are we attacking someone new / not attacking anymore?
        //    //OnInventoryChanged -= Mind.AttackConditionsChanged;      // Equipped / DeEquiped something?
        // }
        public void IncreaseSkillCounter(SkillType skill, ushort value)
        {
            if (!Skills.ContainsKey(skill))
            {
                // TODO: proper logging.
                Console.WriteLine($"CreatureId {Name} does not have the skill {skill} in it's skill set.");
            }

            Skills[skill].IncreaseCounter(value);
        }
Esempio n. 4
0
    public float GetGatherSpeed(SkillType skillType)
    {
        float totalBonus = 1;

        if (!Skills.ContainsKey(skillType))
        {
            Skill skill = Skills[skillType];

            foreach (GameItem item in Player.EquippedItems)
            {
                if (item.ActionsEnabled != null && item.ActionsEnabled.Contains(skill.Name))
                {
                    if (item.GatherSpeedBonus > 0)
                    {
                        totalBonus *= 1 - item.GatherSpeedBonus;
                    }
                }
                else if (item.ActionRequired != null && item.ActionRequired.Contains(skill.Name))
                {
                    if (item.GatherSpeedBonus > 0)
                    {
                        totalBonus *= 1 - item.GatherSpeedBonus;
                    }
                }
            }
            int level = skill.Level;
            if (level < 100)
            {
                totalBonus *= 1 - (level * 0.005f);
            }
            else if (level < 200)
            {
                totalBonus *= 1 - (100 * 0.005f);
                totalBonus *= 1 - (level * 0.002f);
            }
            else if (level < 300)
            {
                totalBonus *= 1 - (100 * 0.005f);
                totalBonus *= 1 - (200 * 0.002f);
                totalBonus *= 1 - (level * 0.001f);
            }
            else
            {
                totalBonus *= 1 - (100 * 0.005f);
                totalBonus *= 1 - (200 * 0.002f);
                totalBonus *= 1 - (300 * 0.001f);
                totalBonus *= 1 - (level * 0.0005f);
            }
            //totalBonus -= GetLevel(skill) * 0.005f;
            totalBonus = Math.Max(totalBonus, 0.01f);
        }

        return(totalBonus);
    }
Esempio n. 5
0
 private void AddSkill(Skill skill)
 {
     if (!Skills.ContainsKey(skill.Name))
     {
         Skills.Add(skill.Name, skill.Clone());
     }
     else
     {
         Skills[skill.Name].Level += skill.Level;
     }
 }
Esempio n. 6
0
 public void AddSkill(Skill skill)
 {
     Journal.Add(string.Format(Properties.Resources.Msg_ReceivedSkill, skill.Name, skill.Level));
     if (!Skills.ContainsKey(skill.Name))
     {
         Skills.Add(skill.Name, skill);
     }
     else
     {
         Skills[skill.Name].Level += skill.Level;
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Method that executes a <see cref="SkillBase"/> of the resource
 /// </summary>
 /// <param name="s">The <see cref="SkillBase"/> by name to execute</param>
 /// <param name="execParams">The parameters used for the Execution</param>
 /// <returns></returns>
 public Task ExecuteSkill(string s, object execParams = null)
 {
     if (!Skills.ContainsKey(s))
     {
         Logger.Log($"Could not execute Skill {s}, since it was not in list");
         return(null);
     }
     else
     {
         return(Skills[s].Execute(execParams));
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Method that executes a <see cref="SkillBase"/> of the resource
        /// </summary>
        /// <param name="s">The <see cref="SkillBase"/> to execute</param>
        /// <param name="execParams">The parameters used for the Execution</param>
        /// <returns></returns>
        public Task ExecuteSkill(SkillBase s, object execParams = null)
        {
            string key = $"{s.ExecutingResource.Name}.{s.Name}";

            if (Skills.ContainsKey(key))
            {
                Logger.Log($"Could not execute Skill {s.Name}, since it was not in list");
                return(null);
            }
            else
            {
                return(ExecuteSkill(key, execParams));
            }
        }
Esempio n. 9
0
        public static Skill GetSkill(string path)
        {
            Skill skill = null;

            if (Skills.ContainsKey(path))
            {
                skill = Skills[path];
            }
            else
            {
                skill        = Logic.Skill.SkillUtility.GetTimelineGroup <Skill>(path);
                Skills[path] = skill;
            }
            return(skill);
        }
Esempio n. 10
0
        public bool FromJObject(JObject obj, IGameEngine engine)
        {
            string name            = obj[GcConstants.General.NAME].ToObject <string>();
            int    level           = obj[GcConstants.General.LEVEL].ToObject <int>();
            double currentExp      = obj[GcConstants.General.CURRENT_EXP].ToObject <double>();
            int    attributePoints = obj[GcConstants.General.ATTRIBUTE_POINTS].ToObject <int>();
            bool   isDead          = obj[GcConstants.General.DEAD].ToObject <bool>();
            long   reviveTime      = obj[GcConstants.General.REVIVE_TIME].ToObject <long>();

            IsDead          = isDead;
            ReviveTime      = reviveTime;
            Name            = name;
            Level           = level;
            CurrentExp      = currentExp;
            AttributePoints = attributePoints;
            JToken[] attributesArray = obj[GcConstants.Classes.ATTRIBUTES].ToArray();
            foreach (JToken attribute in attributesArray)
            {
                string key = attribute[GcConstants.General.KEY].ToObject <string>();
                if (Attributes.ContainsKey(key))
                {
                    Attributes[key].FromJObject(attribute.ToObject <JObject>(), Engine);
                }
            }
            JToken[] resourcesArray = obj[GcConstants.Classes.RESOURCES].ToArray();
            foreach (JToken resource in resourcesArray)
            {
                string key = resource[GcConstants.General.KEY].ToObject <string>();
                if (ResourceMap.ContainsKey(key))
                {
                    ResourceMap[key].FromJObject(resource.ToObject <JObject>(), Engine);
                }
            }
            JToken[] skillsArray = obj[GcConstants.Classes.SKILLS].ToArray();
            foreach (JToken skill in skillsArray)
            {
                string key = skill[GcConstants.General.KEY].ToObject <string>();
                if (Skills.ContainsKey(key))
                {
                    Skills[key].FromJObject(skill.ToObject <JObject>(), Engine);
                }
            }
            return(true);
        }
Esempio n. 11
0
        public bool Add(Skill skill, Entity source)
        {
            if (skill.ShortName != Name)
            {
                return(false);
            }
            if (Skills.Any(sk => skill.Id == sk.Key.Id && skill.IsHotDot == sk.Key.IsHotDot && sk.Value.Contains(source)))
            {
                return(false);
            }

            if (Skills.ContainsKey(skill))
            {
                Skills[skill].Add(source);
                _playerDealtUnrelieable = true;
            }
            else
            {
                Skills.Add(skill, new List <Entity> {
                    source
                });
            }
            return(true);
        }
Esempio n. 12
0
 public Skill Get(int skillId)
 {
     return(Skills.ContainsKey(skillId) ? Skills[skillId] : null);
 }
Esempio n. 13
0
        public Skill Get(int id, int lvl)
        {
            long hash = (id * 65536) + lvl;

            return(Skills.ContainsKey(hash) ? Skills[hash] : null);
        }
Esempio n. 14
0
 public SkillTemplate GetSkill(string key)
 {
     return(Skills.ContainsKey(key) ? Skills[key] : null);
 }
Esempio n. 15
0
 public Skill this[SkillType skillType] => Skills.ContainsKey(skillType) ? Skills[skillType] : null;