public override bool Cast(Entity target, string skillKey, bool autocast = false) { string tryAlias = Engine.GetSkillManager().GetKeyFromAlias(skillKey); if (tryAlias == null) { tryAlias = skillKey; } SkillInstance skill = Skills.ContainsKey(tryAlias) ? Skills[tryAlias] : null; if (skill == null) { Engine.Log().Log($"[{Name}] You don't have that skill({tryAlias})."); //log that you don't have that skill return(false); } if (skill.CooldownFinishTime != 0) { long seconds = (skill.CooldownFinishTime - Engine.GetTimer().GetNow()) / GameConstants.TickTime; Engine.Log().Log($"[{Name}] {skill.Skill.Name} is on cooldown for {seconds} s."); return(false); } if (!Free) { Engine.Log().Log($"[{Name}] You are busy."); return(false); } if (!ResourceMap.ContainsKey(skill.Values().Cost.Resource.Key)) { Engine.Log().Log($"[{Name}] You don't have \"{skill.Values().Cost.Resource.Name}\"."); return(false); } ResourceInstance res = ResourceMap[skill.Values().Cost.Resource.Key]; double amount = Sanitizer.ReplacePropeties(skill.Values().Cost.Amount, this).Resolve().Value.ToDouble(); if (!res.CanCast(amount)) { Engine.Log().Log($"[{Name}] Not enough {skill.Values().Cost.Resource.Name} for {skill.Skill.Name}."); return(false); } res.Cast(amount); Free = false; CurrentlyCasting = new SkillCastData(skill, target, this, Engine.GetTimer().GetNow()); long time = CurrentlyCasting.CastFinishTime - Engine.GetTimer().GetNow(); if (time >= GameConstants.TickTime * 3) { string type = skill.Skill.Type == SkillType.Cast ? "casting" : "channeling"; string castedFinish = Key.Equals(CurrentlyCasting.Target.Key) ? "" : $" on {CurrentlyCasting.Target.Name}"; Engine.Log() .Log( $"[{Name}] Started {type} {CurrentlyCasting.Skill.Skill.Name}{castedFinish}."); } return(true); }