public override void Tick(Living l) { if (this.HitTimer.Allow()) { //Locate harvest skill. Skill skill = l.CreatureSkills.Find(x => x.InternalName == HarvestingSkill.InternalIDName); HarvestingSkill harvestSkill = (HarvestingSkill)skill; //Calculate how much to mine based upon skill of creature in harvesting double amount = this.CalculatePercentHarvest(harvestSkill); //Harvest whatever List <World.Base.Item> drop = this.Harvestable.HarvestingBehavior.HarvestSomePercent(amount, this.Target); //Give out XP for the harvest skill. skill.GainXP(1); if (drop != null && drop.Count > 0) { int length = drop.Count; for (int i = 0; i < length; i++) { this.DropItem(l, drop[i]); } } if (this.Harvestable.HarvestingBehavior.PercentHarvested > 1) { this.RemoveResource(l.Dimension); this.CompleteTask(); } } }
/// <summary> /// Determines how much to harvest based upon the creatures skill. /// </summary> /// <returns></returns> private double CalculatePercentHarvest(HarvestingSkill l) { float baseAmount = .1F; return(baseAmount + Math.Sqrt(l.SkillAmount.GetValue() / 100)); }