コード例 #1
0
ファイル: SpellOutput.cs プロジェクト: KroneckerX/WCell
 public static void DumpSpell(TextWriter writer, Spell spell)
 {
     spell.Dump(writer, "\t");
     writer.WriteLine();
     writer.WriteLine("#################################################################");
     writer.WriteLine();
 }
コード例 #2
0
ファイル: Deadmines.cs プロジェクト: KroneckerX/WCell
		public static void InitSneedSpells()
		{
			disarm = SpellHandler.Get(SpellId.Disarm_2);  //disarm
			disarm.AISettings.SetCooldown(10000);
			disarm.OverrideAITargetDefinitions(DefaultTargetAdders.AddAreaSource,		// random hostile nearby character
											   DefaultTargetEvaluators.RandomEvaluator,
											   DefaultTargetFilters.IsPlayer, DefaultTargetFilters.IsHostile);


			SpellHandler.Apply(spell => spell.CooldownTime = 20000, SpellId.MoltenMetal);
			SpellHandler.Apply(spell => spell.CooldownTime = 25000, SpellId.MeltOre);


			// Rhakzor's slam has a cooldown of about 12s
			SpellHandler.Apply(spell => { spell.AISettings.SetCooldown(10000, 14000); }, SpellId.RhahkZorSlam);


			SpellHandler.Apply(spell => spell.CooldownTime = 10000, SpellId.SmiteSlam);

			// remember the Spells for later use
			terrify = SpellHandler.Get(SpellId.Terrify);
			terrify.AISettings.SetCooldown(21000);
			terrify.OverrideAITargetDefinitions(DefaultTargetAdders.AddAreaSource,		// random hostile nearby character
											   DefaultTargetEvaluators.RandomEvaluator,
											   DefaultTargetFilters.IsPlayer, DefaultTargetFilters.IsHostile);

			distractingPain = SpellHandler.Get(SpellId.DistractingPain);
			distractingPain.AISettings.SetCooldown(12000);
			distractingPain.OverrideAITargetDefinitions(DefaultTargetAdders.AddAreaSource,		// random hostile nearby character
											   DefaultTargetEvaluators.RandomEvaluator,
											   DefaultTargetFilters.IsPlayer, DefaultTargetFilters.IsHostile);

			ejectSneed = SpellHandler.Get(SpellId.EjectSneed);
		}
コード例 #3
0
ファイル: IcecrownCitadel.cs プロジェクト: KroneckerX/WCell
 public static void InitMarrowgar()
 {
     BoneSlice = SpellHandler.Get(SpellId.BoneSlice);
     BoneStorm = SpellHandler.Get(SpellId.BoneStorm);
     ColdFlame = SpellHandler.Get(SpellId.Coldflame_3);
     ColdFlameBone = SpellHandler.Get(SpellId.Coldflame_13);
     boneLength = Utility.Random(20, 30);
 }
コード例 #4
0
ファイル: IcecrownCitadel.cs プロジェクト: NVN/WCell
 static void InitMarrowgar()
 {
     BoneSlice = SpellHandler.Get(SpellId.BoneSlice);
     BoneStorm = SpellHandler.Get(SpellId.BoneStorm);
     ColdFlame = SpellHandler.Get(SpellId.Coldflame_3);
     ColdFlameBone = SpellHandler.Get(SpellId.Coldflame_13);
     boneLength = urand.Next(20, 30);
 }
コード例 #5
0
ファイル: SpellLine.cs プロジェクト: pallmall/WCell
		internal void AddSpell(Spell spell)
		{
			if (spell == null)
			{
				throw new ArgumentNullException("spell");
			}
			Spells.Add(spell);
			spell.Line = this;
		}
コード例 #6
0
ファイル: SpellCast.Aura.cs プロジェクト: enjoii/WCell
		/// <summary>
		/// Checks whether the given target resisted the debuff, represented through the given spell
		/// </summary>
		public static CastMissReason CheckDebuffResist(Unit target, Spell spell, int casterLevel, bool hostile)
		{
			var missReason = CastMissReason.None;
			if (hostile && target.CheckDebuffResist(casterLevel, target.GetLeastResistantSchool(spell)))
			{
				missReason = CastMissReason.Resist;
			}
			return missReason;
		}
コード例 #7
0
ファイル: AISpellCastAction.cs プロジェクト: ebakkedahl/WCell
        public AISpellCastAction(Unit owner, Spell spell)
            : base(owner)
        {
            m_spell = spell;

            //if (m_target != null)
            //{
            //    m_range = new SimpleRange(m_spell.Range.Min, m_spell.Range.Max);
            //}
        }
コード例 #8
0
ファイル: DisenchantingTest.cs プロジェクト: NVN/WCell
		public static void Init(TestContext testContext)
		{
			chr = Setup.AllianceCharacterPool.Create();
			client = chr.FakeClient;
			disenchantSpell = SpellHandler.Get(SpellId.DisenchantPT);
			disenchantSpell.CastDelay = 0;	// we don't want to wait

			ItemMgr.LoadAll();
			//LootMgr.LoadAll();
			ContentMgr.Load<ItemLootItemEntry>();
		}
コード例 #9
0
ファイル: SpellCastAction.cs プロジェクト: KroneckerX/WCell
		public SpellCastAction(IBrain owner, Unit target, Spell spell) : base(owner)
		{
			m_ownerBrain = owner;
			m_target = target;
			m_spell = spell;

			if (m_target != null)
				m_range = new AIRange(m_spell.Range.Min, m_spell.Range.Max);

			IsPrimary = true;
		}
コード例 #10
0
ファイル: SpellCast.cs プロジェクト: pallmall/WCell
		//internal static readonly ObjectPool<List<AuraApplicationInfo>> AuraAppListPool = ObjectPoolMgr.CreatePool(() => new List<AuraApplicationInfo>());

		public static void Trigger(WorldObject caster, SpellEffect triggerEffect, Spell spell)
		{
			var cast = SpellCastPool.Obtain();
			cast.Caster = caster;
			cast.m_triggerEffect = triggerEffect;

			caster.ExecuteInContext(() =>
			{
				cast.Start(spell, true);
				cast.Dispose();
			});
		}
コード例 #11
0
ファイル: SpellCast.Perform.cs プロジェクト: enjoii/WCell
		/// <summary>
		/// Returns whether the spell can be casted (true) or if immunity of the target prevents it (false)
		/// </summary>
		public static bool CheckImmune(Unit target, Spell spell, bool hostile)
		{
			if (spell.Mechanic != SpellMechanic.None &&
						hostile == spell.Mechanic.IsNegative() &&
						((spell.Mechanic == SpellMechanic.Invulnerable_2 || spell.Mechanic == SpellMechanic.Invulnerable) &&
						!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) &&
						(target.IsImmune(SpellMechanic.Invulnerable_2) || target.IsImmune(SpellMechanic.Invulnerable))) ||
						(target.IsImmune(spell.Mechanic) || target.IsImmune(spell.DispelType)))
			{
				return false;
			}
			return true;
		}
コード例 #12
0
ファイル: SpellCast.cs プロジェクト: primax/WCell
		public static void Trigger(WorldObject caster, Spell spell, ref Vector3 targetLoc, WorldObject selected, Item casterItem)
		{
			var cast = ObtainPooledCast(caster);
			cast.TargetLoc = targetLoc;
			cast.Selected = selected;
			cast.CasterItem = casterItem;

			cast.ExecuteInContext(() =>
			{
				cast.Start(spell, true);
				//cast.Dispose();
			});
		}
コード例 #13
0
ファイル: DebugSpells.cs プロジェクト: KroneckerX/WCell
		private static void DisplayPath(Spell spell, WorldObject caster, WorldObject target, ref Vector3 to)
		{
			if (!(caster is Character)) return;
			if (!NPCMgr.Loaded)
			{
				NPCMgr.LoadAllLater();
				caster.Say("Loading NPCs...");
				return;
			}


			var from = caster.Position;
			from.Z += 5;
			to.Z += 5;
			caster.Map.Terrain.FindPath(new PathQuery(from, ref to, caster, OnFoundPath));
		}
コード例 #14
0
ファイル: SpellLine.cs プロジェクト: pallmall/WCell
		public SpellLine(SpellLineId id, params Spell[] spells)
		{
			LineId = id;
			AuraUID =  (uint)id;
			Spells = new List<Spell>();
			if (spells.Length > 0)
			{
				m_firstSpell = spells[0];

				for (var i = 0; i < spells.Length; i++)
				{
					var spell = spells[i];
					AddSpell(spell);
				}
			}
		}
コード例 #15
0
ファイル: WSGFaction.cs プロジェクト: pallmall/WCell
#pragma warning restore 0649

		#endregion

		protected WSGFaction(WarsongGulch instance,
			SpellId flagSpell,
			SpellId flagDropSpell,
			SpellId flagDropDebuff,
			SpellId flagCarrierDebuffSpellId,
			GOEntryId flagStand,
			GOEntryId flagDropId)
		{
			Instance = instance;
			_flagSpell = SpellHandler.Get(flagSpell);
			_flagDropSpell = SpellHandler.Get(flagDropSpell);
			_flagDropDebuff = SpellHandler.Get(flagDropDebuff);
			_flagCarrierDebuffSpell = SpellHandler.Get(flagCarrierDebuffSpellId);
			FlagStandEntry = GOMgr.GetEntry(flagStand);
			DroppedFlagEntry = GOMgr.GetEntry(flagDropId);

			_flagRespawn = WarsongGulch.FlagRespawnTime;
			Score = 0;
		}
コード例 #16
0
ファイル: SpellCast.Perform.cs プロジェクト: primax/WCell
		/// <summary>
		/// Returns whether the given target is immune to the given spell
		/// </summary>
		public static bool IsImmune(Unit target, Spell spell, bool hostile)
		{
			if (
						hostile &&
						spell.Mechanic.IsNegative() &&
						!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) &&
						(spell.Mechanic == SpellMechanic.Invulnerable_2 || spell.Mechanic == SpellMechanic.Invulnerable) &&
						(
							// immune against spell
							target.IsInvulnerable ||
							target.IsImmune(SpellMechanic.Invulnerable_2) ||
							target.IsImmune(SpellMechanic.Invulnerable) ||
							target.IsImmune(spell.Mechanic) ||
							target.IsImmune(spell.DispelType)
						)
				)
			{
				return true;
			}
			return false;
		}
コード例 #17
0
ファイル: CastingTest.cs プロジェクト: KroneckerX/WCell
        public static void ApplyAura(TestCharacter chr, Spell spell)
        {
            Assert.IsTrue(spell.IsAura || spell.IsAreaAura, "Spell {0} is not an Aura", spell);

            chr.EnsureInWorld();

            chr.ShapeshiftForm = ShapeshiftForm.Normal;
            chr.Auras.Clear();

            Assert.AreEqual(0, chr.Auras.Count);

            // important: Execute this in the Map's thread
            chr.Map.AddMessageAndWait(new Message(() => {
                chr.SpellCast.TriggerSelf(spell);

                var failure =
                    chr.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_SPELL_FAILURE);

                Assert.IsNull(failure,
                              failure != null
                                ? "Spell failed: " + failure["FailReason"].Value
                                : "");

                Assert.AreEqual(1, chr.Auras.Count, "Aura was not added.");
                var aura = chr.Auras[spell, !spell.HasHarmfulEffects];

                Assert.IsNotNull(aura);

                Assert.AreEqual(spell.GetDuration(chr.SharedReference, chr), (uint)aura.Duration);
                Assert.AreNotEqual(0, spell.GetDuration(chr.SharedReference, chr));
                Asser.GreaterOrEqual(spell.GetDuration(chr.SharedReference, chr), (uint)aura.TimeLeft);

                aura.Cancel();

                Assert.IsNull(chr.Auras[spell, !spell.HasHarmfulEffects]);
                Assert.AreEqual(0, chr.Auras.Count);
            }));
        }
コード例 #18
0
ファイル: TotemHandler.cs プロジェクト: KroneckerX/WCell
        public static bool SendTotemCreated(IPacketReceiver client, Spell totemSpell, EntityId totemEntityId)
        {
            var chr = client as Character;
            if (chr == null)
                return false;

            var effect = totemSpell.GetEffect(SpellEffectType.Summon);
            if (effect == null)
                return false;

            var slot = effect.SummonEntry.Slot - 1;

            using(var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TOTEM_CREATED))
            {
                packet.Write(slot);
                packet.Write(totemEntityId);
                packet.Write(totemSpell.GetDuration(chr.SharedReference));
                packet.Write(totemSpell.Id);

                client.Send(packet);
            }
            return true;
        }
コード例 #19
0
ファイル: SpellLineWriter.cs プロジェクト: pallmall/WCell
		private static void AddSpell(Spell spell)
		{
			var clss = spell.ClassId;
			if (clss == ClassId.PetTalents && spell.Talent != null)
			{
				clss = ClassId.Hunter;
			}

			var map = Maps[(int)clss];
			if (map == null)
			{
				Maps[(int)clss] = map = new Dictionary<string, HashSet<Spell>>(100);
			}

			var name = spell.Name;
			if (!string.IsNullOrEmpty(spell.RankDesc) && !spell.RankDesc.Contains("Rank"))
			{
				name += " " + spell.RankDesc;
			}
			var line = map.GetOrCreate(name);
			line.Add(spell);
		}
コード例 #20
0
		public override void AddSpell(Spell spell)
		{
		    if (m_byId.ContainsKey(spell.SpellId)) return;
		    //NPCOwner.Brain.ActionCollection.AddFactory
		    base.AddSpell(spell);

		    OnNewSpell(spell);
		}
コード例 #21
0
			public CooldownRemoveTimer(int millis, Spell spell) : base(millis, null)
			{
				Spell = spell;
				Callback = DoRemoveCooldown;
			}
コード例 #22
0
	    /// <summary>
		/// Returns the delay until the given spell has cooled down in milliseconds
		/// </summary>
		public int GetRemainingCooldownMillis(Spell spell)
		{
			if (m_cooldowns == null) return 0;

		    var cooldown = m_cooldowns.Find(cd => cd.Spell.Id == spell.Id);
            return cooldown == null ? 0 : cooldown.GetDelayUntilNextExecution(Owner);
		}
コード例 #23
0
		public override void ClearCooldown(Spell spell, bool alsoCategory = true)
		{
		    if (m_cooldowns == null) return;
		    for (var i = 0; i < m_cooldowns.Count; i++)
		    {
		        var cd = m_cooldowns[i];
		        if (cd.Spell.Id != spell.Id) continue;

		        m_cooldowns.Remove(cd);
		        AddReadySpell(cd.Spell);
		        break;
		    }
		}
コード例 #24
0
		private void AddCooldown(Spell spell, int millis)
		{
			if (millis <= 0) return;
			m_readySpells.Remove(spell);

			var action = new CooldownRemoveTimer(millis, spell);
			Owner.AddUpdateAction(action);
			if (m_cooldowns == null)
			{
				m_cooldowns = new List<CooldownRemoveTimer>();
			}
			m_cooldowns.Add(action);
		}
コード例 #25
0
		public void AddCooldown(Spell spell, DateTime cdTime)
		{
			var millis = (cdTime - DateTime.Now).ToMilliSecondsInt();
			AddCooldown(spell, millis);
		}
コード例 #26
0
        int GetSpecIndex(Spell spell)
        {
            var chr = OwnerChar;

            return(spell.IsTalent ? chr.Talents.CurrentSpecIndex : SpellRecord.NoSpecIndex);
        }
コード例 #27
0
 /// <summary>
 /// Add everything to the caster that this spell requires
 /// </summary>
 public void AddSpellRequirements(Spell spell)
 {
     /*var chr = OwnerChar;
      * // add reagents
      * foreach (var reagent in spell.Reagents)
      * {
      *      var templ = reagent.Template;
      *      if (templ != null)
      *      {
      *              var amt = reagent.Amount * 10;
      *              chr.Inventory.Ensure(templ, amt);
      *      }
      * }
      *
      * // add tools
      * if (spell.RequiredTools != null)
      * {
      *      foreach (var tool in spell.RequiredTools)
      *      {
      *              chr.Inventory.Ensure(tool.Template, 1);
      *      }
      * }
      * if (spell.RequiredToolCategories != null)
      * {
      *      foreach (var cat in spell.RequiredToolCategories)
      *      {
      *              var tool = ItemMgr.GetFirstItemOfToolCategory(cat);
      *              if (tool != null)
      *              {
      *                      chr.Inventory.Ensure(tool, 1);
      *              }
      *      }
      * }
      *
      * // Profession
      * if (spell.Ability != null && spell.Ability.Skill != null)
      * {
      *      chr.Skills.TryLearn(spell.Ability.Skill.Id);
      * }
      *
      *
      * // add spellfocus object (if not present)
      * if (spell.RequiredSpellFocus != 0)
      * {
      *      var range = Owner.GetSpellMaxRange(spell);
      *      var go = chr.Map.GetGOWithSpellFocus(chr.Position, spell.RequiredSpellFocus,
      *              range > 0 ? (range) : 5f, chr.Phase);
      *
      *      if (go == null)
      *      {
      *              foreach (var entry in GOMgr.Entries.Values)
      *              {
      *                      if (entry is GOSpellFocusEntry &&
      *                              ((GOSpellFocusEntry)entry).SpellFocus == spell.RequiredSpellFocus)
      *                      {
      *                              entry.Spawn(chr, chr);
      *                              break;
      *                      }
      *              }
      *      }
      * }*/
 }
コード例 #28
0
 public override void AddSpell(Spell spell)
 {
     AddSpell(spell, true);
 }
コード例 #29
0
ファイル: Unit.cs プロジェクト: ray2006/WCell
		/// <summary>
		/// Returns the modified power-cost needed to cast a Spell of the given DamageSchool 
		/// and the given base amount of power required
		/// </summary>
		public virtual int GetPowerCost(DamageSchool school, Spell spell, int cost)
		{
			int modifier = PowerCostModifier;
			if (m_schoolPowerCostMods != null)
			{
				modifier += m_schoolPowerCostMods[(int)school];
			}

			cost += modifier;

			cost = (int)(Math.Round(PowerCostMultiplier) * cost);
			return cost;
		}
コード例 #30
0
ファイル: Unit.cs プロジェクト: ray2006/WCell
		public bool HasEnoughPowerToCast(Spell spell, WorldObject selected)
		{
			if (!spell.CostsMana)
			{
				return true;
			}
			if (selected is Unit)
			{
				return Power >= spell.CalcPowerCost(this, ((Unit)selected).GetLeastResistant(spell));
			}
			return Power >= spell.CalcPowerCost(this, spell.Schools[0]);
		}
コード例 #31
0
ファイル: Unit.cs プロジェクト: ray2006/WCell
		public DamageSchool GetLeastResistant(Spell spell)
		{
			if (spell.Schools.Length == 1)
			{
				return spell.Schools[0];
			}

			var least = int.MaxValue;
			var leastSchool = DamageSchool.Physical;
			foreach (var school in spell.Schools)
			{
				var res = GetResistance(school);
				if (res < least)
				{
					least = res;
					leastSchool = school;
				}
			}
			return leastSchool;
		}
コード例 #32
0
		public override bool IsReady(Spell spell)
		{
			return m_readySpells.Contains(spell);
		}
コード例 #33
0
ファイル: Unit.cs プロジェクト: ray2006/WCell
		/// <summary>
		/// Tries to consume the given amount of Power, also considers modifiers to Power-cost.
		/// </summary>
		public bool ConsumePower(DamageSchool type, Spell spell, int neededPower)
		{
			neededPower = GetPowerCost(type, spell, neededPower);

			if (Power >= neededPower)
			{
				Power -= neededPower;
				return true;
			}

			return false;
		}
コード例 #34
0
 public void AddNew(Spell spell)
 {
     AddSpell(spell, false);
 }