public GameClient LearnSpell(Mundane source, SpellTemplate subject, string message) { var canLearn = false; if (subject.Prerequisites != null) { canLearn = PayPrerequisites(subject.Prerequisites); } if (subject.LearningRequirements != null && subject.LearningRequirements.Any()) { canLearn = subject.LearningRequirements.TrueForAll(PayPrerequisites); } if (!canLearn) { return(this); } Spell.GiveTo(this, subject.Name); SendOptionsDialog(source, message); Aisling.Show(Scope.NearbyAislings, new ServerFormat29((uint)Aisling.Serial, (uint)source.Serial, subject.TargetAnimation, subject.TargetAnimation, 100)); return(this); }
public static void ExploreSpell(SpellTemplate spell, int level, bool critical) { var levelTemplate = SpellManager.Instance.GetSpellLevel((int)spell.SpellLevelsIds[level - 1]); var type = SpellManager.Instance.GetSpellType(spell.TypeId); Console.WriteLine("Spell '{0}' : {1} ({2}) - Level {3}", spell.Id, spell.Name, TextManager.Instance.GetText(spell.NameId, SecondaryLanguage), level); Console.WriteLine("Description: {0}", spell.Description); Console.WriteLine(""); Console.WriteLine("Type : {0} - {1}", type.ShortName, type.LongName); Console.WriteLine("Level.SpellBreed = {0}, Level.HideEffects = {1}", levelTemplate.SpellBreed, levelTemplate.HideEffects); Console.WriteLine("Cost = {0}, Max Stack = {1}, MaxCastPerTurn = {2}, MaxCastPerTarget= {3}, MinCastInterval = {4}", levelTemplate.ApCost, levelTemplate.MaxStack, levelTemplate.MaxCastPerTurn, levelTemplate.MaxCastPerTarget, levelTemplate.MinCastInterval); Console.WriteLine("Range = {0}, MinRange = {1}, RangeCanBeBoosted={2}", levelTemplate.Range, levelTemplate.MinRange, levelTemplate.RangeCanBeBoosted); Console.WriteLine("CastInLine = {0}, CastInDiagonal = {1}, CastTestLos={2}", levelTemplate.CastInLine, levelTemplate.CastInDiagonal, levelTemplate.CastTestLos); Console.WriteLine("StatesRequired = {0}, StatesForbidden = {1}", levelTemplate.StatesRequiredCSV, levelTemplate.StatesForbiddenCSV); Console.WriteLine(""); foreach (var effect in critical ? levelTemplate.CriticalEffects : levelTemplate.Effects) { Console.WriteLine("Effect \"{0}\" ({1}, {2})", TextManager.Instance.GetText(effect.Template.DescriptionId), effect.EffectId, (int)effect.EffectId); Console.WriteLine("DiceFace = {0}, DiceNum = {1}, Value = {2}", effect.DiceFace, effect.DiceNum, effect.Value); Console.WriteLine("Hidden = {0}, Modificator = {1}, Random = {2}, Group = {5}, Triggers = {3}, Delay = {4}, Category = {6}", effect.Hidden, effect.Modificator, effect.Random, effect.Triggers, effect.Delay, effect.Group, effect.Template.Category); Console.WriteLine("ZoneShape = {0}, ZoneSize = {1}-{2}, Duration = {3}, Target = {4}, Group = {5}, Priority = {6}, Template.Priority={7}", effect.ZoneShape, effect.ZoneMinSize, effect.ZoneSize, effect.Duration, effect.TargetMask, effect.Group, effect.Priority, effect.Template.EffectPriority); Console.WriteLine("Template.Active = {0}, Template.BonusType = {1}, Template.Boost = {2}", effect.Template.Active, effect.Template.BonusType, effect.Template.Boost); Console.WriteLine("Template.Category = {0}, Template.Characteristic = {1}, Template.ForceMinMax = {2}", effect.Template.Category, effect.Template.Characteristic, effect.Template.ForceMinMax); Console.WriteLine("Template.Operator = {0}, Template.Id = {1}, Template.ShowInSet = {2}", effect.Template.Operator, effect.Template.Id, effect.Template.ShowInSet); Console.WriteLine("Template.ShowInTooltip = {0}, Template.UseDice = {1}", effect.Template.ShowInTooltip, effect.Template.UseDice); Console.WriteLine(""); } Console.WriteLine(""); Console.WriteLine("---------------------------------------------"); Console.WriteLine(""); }
/// <summary> /// /// </summary> /// <param name="spellId"></param> /// <returns></returns> public SpellTemplate GetTemplate(int spellId) { SpellTemplate spell = null; m_templateById.TryGetValue(spellId, out spell); return(spell); }
private void InitializeHandlers() { foreach (System.Type current in from entry in System.Reflection.Assembly.GetExecutingAssembly().GetTypes() where entry.IsSubclassOf(typeof(SpellCastHandler)) && !entry.IsAbstract select entry) { if (current.GetCustomAttribute <DefaultSpellCastHandlerAttribute>(false) == null) { SpellCastHandlerAttribute spellCastHandlerAttribute = current.GetCustomAttributes <SpellCastHandlerAttribute>().SingleOrDefault <SpellCastHandlerAttribute>(); if (spellCastHandlerAttribute == null) { SpellManager.logger.Error("SpellCastHandler '{0}' has no SpellCastHandlerAttribute, or more than 1", current.Name); } else { SpellTemplate spellTemplate = this.GetSpellTemplate(spellCastHandlerAttribute.Spell); if (spellTemplate == null) { SpellManager.logger.Error <string, int>("SpellCastHandler '{0}' -> Spell {1} not found", current.Name, spellCastHandlerAttribute.Spell); } else { this.AddSpellCastHandler(current, spellTemplate); } } } } }
public static void ExploreSpell(SpellTemplate spell, int level, bool critical, TriggerBase trigger) { var levelTemplate = SpellManager.Instance.GetSpellLevel((int)spell.SpellLevelsIds[level - 1]); var type = SpellManager.Instance.GetSpellType(spell.TypeId); trigger.ReplyBold("Spell '{0}' : {1} - Level {2}", spell.Id, spell.Name, level); trigger.ReplyBold("Type : {0} - {1}", type.ShortName, type.LongName); trigger.ReplyBold("Level.SpellBreed = {0}, Level.HideEffects = {1}", levelTemplate.SpellBreed, levelTemplate.HideEffects); trigger.ReplyBold(""); foreach (var effect in critical ? levelTemplate.CriticalEffects : levelTemplate.Effects) { trigger.ReplyBold("Effect \"{0}\" ({1}, {2})", TextManager.Instance.GetText(effect.Template.DescriptionId), effect.EffectId, (int)effect.EffectId); trigger.ReplyBold("DiceFace = {0}, DiceNum = {1}, Value = {2}", effect.DiceFace, effect.DiceNum, effect.Value); trigger.ReplyBold("Hidden = {0}, Modificator = {1}, Random = {2}, Trigger = {3}, Delay = {4}", effect.Hidden, effect.Modificator, effect.Random, effect.Trigger, effect.Delay); trigger.ReplyBold("ZoneShape = {0}, ZoneSize = {1}-{2}, Duration = {3}, Target = {4}, Group = {5}", effect.ZoneShape, effect.ZoneMinSize, effect.ZoneSize, effect.Duration, effect.Targets, effect.Group); trigger.ReplyBold("Template.Active = {0}, Template.BonusType = {1}, Template.Boost = {2}", effect.Template.Active, effect.Template.BonusType, effect.Template.Boost); trigger.ReplyBold("Template.Category = {0}, Template.Characteristic = {1}, Template.ForceMinMax = {2}", effect.Template.Category, effect.Template.Characteristic, effect.Template.ForceMinMax); trigger.ReplyBold("Template.Operator = {0}, Template.Id = {1}, Template.ShowInSet = {2}", effect.Template.Operator, effect.Template.Id, effect.Template.ShowInSet); trigger.ReplyBold("Template.ShowInTooltip = {0}, Template.UseDice = {1}", effect.Template.ShowInTooltip, effect.Template.UseDice); trigger.ReplyBold(""); } trigger.ReplyBold(""); trigger.ReplyBold("---------------------------------------------"); trigger.ReplyBold(""); }
public SpellCastInterruptSelector(SpellTemplate spell) { InitializeComponent(); this.Title = "CAST INTERRUPT of " + spell.ID; _spell = spell; uint flags = spell.InterruptFlags; if ((flags & 1 << 0) != 0) { p.IsChecked = true; } if ((flags & 1 << 1) != 0) { p1.IsChecked = true; } if ((flags & 1 << 2) != 0) { p2.IsChecked = true; } if ((flags & 1 << 3) != 0) { p3.IsChecked = true; } if ((flags & 1 << 4) != 0) { p4.IsChecked = true; } if ((flags & 1 << 5) != 0) { p5.IsChecked = true; } }
public CharacterSpell LearnSpell(SpellTemplate template) { CharacterSpellRecord record = Singleton <SpellManager> .Instance.CreateSpellRecord(this.Owner.Record, template); CharacterSpell characterSpell = new CharacterSpell(record); this.m_spells.Add(characterSpell.Id, characterSpell); InventoryHandler.SendSpellUpgradeSuccessMessage(this.Owner.Client, characterSpell); return(characterSpell); }
public CharacterSpellRecord CreateSpellRecord(CharacterRecord owner, SpellTemplate template) { return(new CharacterSpellRecord { OwnerId = owner.Id, Level = 1, Position = 63, SpellId = template.Id }); }
public Spell(SpellTemplate template, byte level) { m_id = template.Id; m_level = level; Template = template; SpellType = SpellManager.Instance.GetSpellType(Template.TypeId); var counter = 1; ByLevel = SpellManager.Instance.GetSpellLevels(Template).ToDictionary(entry => counter++); }
public Spell(SpellTemplate template, byte level) { this.m_id = template.Id; this.m_level = level; this.Template = template; this.SpellType = Singleton <SpellManager> .Instance.GetSpellType(this.Template.TypeId); int counter = 1; this.ByLevel = Singleton <SpellManager> .Instance.GetSpellLevels(this.Template).ToDictionary((SpellLevelTemplate entry) => counter++); }
public void AddSpellCastHandler(Type handler, SpellTemplate spell) { var ctor = handler.GetConstructor(new[] { typeof(SpellCastInformations) }); if (ctor == null) { throw new Exception(string.Format("Handler {0} : No valid constructor found !", handler.Name)); } m_spellsCastHandler.Add(spell.Id, ctor.CreateDelegate <SpellCastConstructor>()); }
/// <summary> /// /// </summary> /// <param name="spellId"></param> /// <param name="spellLevel"></param> /// <returns></returns> public SpellLevel GetSpellLevel(int spellId, int spellLevel) { SpellTemplate spell = null; SpellLevel level = null; if (m_templateById.TryGetValue(spellId, out spell)) { level = spell.GetLevel(spellLevel); } return(level); }
public CharacterSpell LearnSpell(SpellTemplate template) { var record = SpellManager.Instance.CreateSpellRecord(Owner.Record, template); var spell = new CharacterSpell(record); m_spells.Add(spell.Id, spell); ContextRoleplayHandler.SendSpellModifySuccessMessage(Owner.Client, spell); return(spell); }
public void TestApplyGetSpellName() { var spellMock = new Mock <ISpell>(); var characterMock = new Mock <ICharacterInformation>(); spellMock.Setup(s => s.Name).Returns("SpellName").Verifiable(); var sut = new SpellTemplate(); var iblock = sut.Apply(spellMock.Object, characterMock.Object); spellMock.Verify(s => s.Name, Times.Once); }
public void TestApplyZfW() { var spellMock = new Mock <ISpell>(); var characterMock = new Mock <ICharacterInformation>(); spellMock.Setup(m => m.ZfW).Returns(15).Verifiable(); ISpellTemplate sut = new SpellTemplate(); IBlock block = sut.Apply(spellMock.Object, characterMock.Object); spellMock.Verify(m => m.ZfW, Times.AtLeastOnce); Assert.IsTrue(block.ContainsChild(r => r.Id == "ZfW")); }
public void LearnSpell(Mundane Source, SpellTemplate subject, string message) { if (PayPrerequisites(subject.Prerequisites)) { Spell.GiveTo(this, subject.Name); SendOptionsDialog(Source, message); Aisling.Show(Scope.NearbyAislings, new ServerFormat29((uint)Aisling.Serial, (uint)Source.Serial, subject?.TargetAnimation ?? 124, subject?.TargetAnimation ?? 124, 100)); } }
public HotAura(SpellTemplate st, Mobile c, Mobile t, int d, int dur, int freq) { if (t.Dead) { return; } spell = st; from = c; target = t; heal = d; duration = dur; frequency = freq; PeriodicAura(new AuraPeriodicEffect(this.PeriodicDamage), dur, freq); }
public DrainHealthAura(SpellTemplate st, Mobile c, Mobile t, int d, int dur, int freq) { if (t.Dead) { return; } spell = st; from = c; target = t; dmg = (float)d; duration = dur; frequency = freq; PeriodicAura(new AuraPeriodicEffect(this.PeriodicDrainHealth), dur, freq); }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="activeType"></param> /// <param name="fight"></param> /// <param name="caster"></param> /// <param name="castInfos"></param> /// <param name="cell"></param> /// <param name="duration"></param> /// <param name="actionId"></param> /// <param name="canGoThrough"></param> /// <param name="canStack"></param> /// <param name="hide"></param> protected AbstractActivableObject(FightObstacleTypeEnum type, ActiveType activeType, AbstractFight fight, AbstractFighter caster, CastInfos castInfos, int cell, int duration, int actionId, bool canGoThrough, bool canStack, bool hide = false) { m_fight = fight; m_caster = caster; m_spellId = castInfos.SpellId; m_actionSpell = SpellManager.Instance.GetTemplate(castInfos.Value1); m_actionEffect = m_actionSpell.GetLevel(castInfos.Value2); Cell = fight.GetCell(cell); ObstacleType = type; ActivationType = activeType; CanGoThrough = canGoThrough; CanStack = canStack; Color = castInfos.Value3; Targets = new List <AbstractFighter>(); Length = Pathfinding.GetDirection(castInfos.RangeType[1]); AffectedCells = new List <FightCell>(); Duration = duration; ActionId = actionId; Hide = hide; foreach (var effect in m_actionEffect.Effects) { if (CastInfos.IsDamageEffect(effect.TypeEnum)) { Priority--; } } // On ajout l'objet a toutes les cells qu'il affecte foreach (var cellId in CellZone.GetCircleCells(fight.Map, cell, Length)) { var fightCell = m_fight.GetCell(cellId); if (fightCell != null) { fightCell.AddObject(this); AffectedCells.Add(fightCell); } } if (Hide) { Appear(caster.Team); } else { AppearForAll(); } }
public SpellLevelTemplate GetSpellLevel(int templateid, int level) { SpellTemplate spellTemplate = this.GetSpellTemplate(templateid); SpellLevelTemplate result; if (spellTemplate == null) { result = null; } else { result = ((spellTemplate.SpellLevelsIds.Length <= level - 1) ? null : this.GetSpellLevel((int)spellTemplate.SpellLevelsIds[level - 1])); } return(result); }
public void AddSpellCastHandler(System.Type handler, SpellTemplate spell) { System.Reflection.ConstructorInfo constructor = handler.GetConstructor(new System.Type[] { typeof(FightActor), typeof(Spell), typeof(Cell), typeof(bool) }); if (constructor == null) { throw new System.Exception(string.Format("Handler {0} : No valid constructor found !", handler.Name)); } this.m_spellsCastHandler.Add(spell.Id, constructor.CreateDelegate <SpellManager.SpellCastConstructor>()); }
public void TestApplyGetEigenschaften() { var spellMock = new Mock <ISpell>(); var characterMock = new Mock <ICharacterInformation>(); characterMock.Setup(c => c.GetEigenschaft(It.IsAny <Eigenschaft>())).Returns(0).Verifiable(); var sut = new SpellTemplate(); var iblock = sut.Apply(spellMock.Object, characterMock.Object); foreach (Eigenschaft e in Enum.GetValues(typeof(Eigenschaft))) { characterMock.Verify(c => c.GetEigenschaft(e), Times.AtLeastOnce); } }
public void TestApplyZauberdauer() { var spellMock = new Mock <ISpell>(); var characterMock = new Mock <ICharacterInformation>(); spellMock.Setup(m => m.ZD).Returns(7).Verifiable(); spellMock.Setup(m => m.ZDEinheit).Returns(Zeiteinheit.AR).Verifiable(); ISpellTemplate sut = new SpellTemplate(); IBlock block = sut.Apply(spellMock.Object, characterMock.Object); spellMock.Verify(m => m.ZD, Times.AtLeastOnce); spellMock.Verify(m => m.ZDEinheit, Times.Once); Assert.IsTrue(block.ContainsChild(r => r.Id == "ZD")); }
public void TestApplyAllBlocksNamed() { var spellMock = new Mock <ISpell>(); var characterMock = new Mock <ICharacterInformation>(); ISpellTemplate sut = new SpellTemplate(); var iblock = sut.Apply(spellMock.Object, characterMock.Object); bool AssertBlockIdsRecursively(IBlock block) { return(!string.IsNullOrEmpty(block.Id) && block.Children.OfType <IBlock>().All(AssertBlockIdsRecursively)); } Assert.IsTrue(AssertBlockIdsRecursively(iblock)); }
public CharacterSpell LearnSpell(int id) { SpellTemplate spellTemplate = Singleton <SpellManager> .Instance.GetSpellTemplate(id); CharacterSpell result; if (spellTemplate == null) { result = null; } else { result = this.LearnSpell(spellTemplate); } return(result); }
public bool UpgradeSpell(int spellId) { bool result; lock (this.m_lock) { int num = System.Array.IndexOf <ushort>(Guild.TAX_COLLECTOR_SPELLS, (ushort)spellId); if (num == -1) { result = false; } else { if (this.Boost < 5u) { result = false; } else { Spell spell = this.m_spells[num]; if (spell == null) { SpellTemplate spellTemplate = Singleton <SpellManager> .Instance.GetSpellTemplate(spellId); if (spellTemplate == null) { Guild.logger.Error("Cannot boost tax collector spell {0}, template not found", spellId); result = false; return(result); } this.m_spells[num] = new Spell(spellTemplate, 1); } else { if (!spell.BoostSpell()) { result = false; return(result); } } this.Boost -= 5u; result = true; } } } return(result); }
public void Load(SpellTemplate spell) { if (spell == null) { return; } _spell = spell; for (int i = 0; i != 32; ++i) { attr[i].IsChecked = (_spell.Attributes[0] & (1 << i)) != 0; attrEx[i].IsChecked = (_spell.Attributes[1] & (1 << i)) != 0; attrEx2[i].IsChecked = (_spell.Attributes[2] & (1 << i)) != 0; attrEx3[i].IsChecked = (_spell.Attributes[3] & (1 << i)) != 0; attrEx4[i].IsChecked = (_spell.Attributes[4] & (1 << i)) != 0; attrEx5[i].IsChecked = (_spell.Attributes[5] & (1 << i)) != 0; attrEx6[i].IsChecked = (_spell.Attributes[6] & (1 << i)) != 0; attrEx7[i].IsChecked = (_spell.Attributes[7] & (1 << i)) != 0; } }
public void TestApplyReichweite() { var spellMock = new Mock <ISpell>(); var characterMock = new Mock <ICharacterInformation>(); spellMock.Setup(m => m.Reichweite).Returns(7).Verifiable(); spellMock.Setup(m => m.ReichweiteEinheit).Returns(DistanzEinheit.Schritt).Verifiable(); ISpellTemplate sut = new SpellTemplate(); IBlock block = sut.Apply(spellMock.Object, characterMock.Object); Assert.IsTrue(block.ContainsChild(r => r.Id == "Reichweite")); IBlock reichweiteBlock = block.FindChild <IBlock>(b => b.Id == "Reichweite"); IText label = reichweiteBlock.Children.OfType <IText>().FirstOrDefault(r => r.Style == TextStyle.Label); Assert.NotNull(label); Assert.AreEqual("Reichweite:", label.Content); IText content = reichweiteBlock.Children.OfType <IText>().FirstOrDefault(r => r.Style != TextStyle.Label); Assert.NotNull(content); Assert.AreEqual("7 Schritt", content.Content); }
public override void Execute(TriggerBase trigger) { SpellTemplate spellTemplate = trigger.Get <SpellTemplate>("spell"); Character target = base.GetTarget(trigger); CharacterSpell characterSpell = target.Spells.LearnSpell(spellTemplate); if (characterSpell != null) { trigger.Reply("'{0}' learned the spell '{1}'", new object[] { trigger.Bold(target), trigger.Bold(spellTemplate.Name) }); } else { trigger.ReplyError("Spell {0} not learned. Unknow reason", new object[] { trigger.Bold(spellTemplate.Name) }); } }
public override void Execute(TriggerBase trigger) { Character target = base.GetTarget(trigger); SpellTemplate spellTemplate = trigger.Get <SpellTemplate>("spell"); int num = trigger.Get <int>("level"); CharacterSpell spell = target.Spells.GetSpell(spellTemplate.Id); if (spell == null) { trigger.ReplyError("Spell {0} not found", new object[] { trigger.Bold(spell) }); } else { if (!spell.ByLevel.ContainsKey(num)) { trigger.ReplyError("Level {0} not found. Give a level between {1} and {2}", new object[] { trigger.Bold(num), trigger.Bold(spell.ByLevel.Keys.Min()), trigger.Bold(spell.ByLevel.Keys.Max()) }); } else { spell.CurrentLevel = (byte)num; trigger.ReplyBold("{0}'s spell {1} is now level {2}", new object[] { target, spell.Template.Name, num }); InventoryHandler.SendSpellUpgradeSuccessMessage(target.Client, spell); } } }