/// <summary> /// Called on every timer tick /// </summary> protected override void OnTick() { GamePlayer player = (GamePlayer)m_actionSource; player.IsStrafing = (m_flags & 0x4000) != 0; player.TargetInView = (m_flags & 0xa000) != 0; // why 2 bits? that has to be figured out player.GroundTargetInView = ((m_flags & 0x1000) != 0); List <Tuple <SpellLine, List <Skill> > > snap = player.GetAllUsableListSpells(); Skill sk = null; SpellLine sl = null; // is spelline in index ? if (m_spellLineIndex < snap.Count) { int index = snap[m_spellLineIndex].Item2.FindIndex(s => s is Spell ? s.Level == m_spellLevel : (s is Styles.Style ? ((Styles.Style)s).SpecLevelRequirement == m_spellLevel : (s is Ability ? ((Ability)s).SpecLevelRequirement == m_spellLevel : false))); if (index > -1) { sk = snap[m_spellLineIndex].Item2[index]; } sl = snap[m_spellLineIndex].Item1; } if (sk is Spell && sl != null) { player.CastSpell((Spell)sk, sl); } else if (sk is Styles.Style) { player.ExecuteWeaponStyle((Styles.Style)sk); } else if (sk is Ability) { Ability ab = (Ability)sk; IAbilityActionHandler handler = SkillBase.GetAbilityActionHandler(ab.KeyName); if (handler != null) { handler.Execute(ab, player); } ab.Execute(player); } else { if (Log.IsWarnEnabled) { Log.Warn("Client <" + player.Client.Account.Name + "> requested incorrect spell at level " + m_spellLevel + " in spell-line " + ((sl == null || sl.Name == null) ? "unkown" : sl.Name)); } player.Out.SendMessage(string.Format("Error : Spell (Line {0}, Level {1}) can't be resolved...", m_spellLineIndex, m_spellLevel), eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); } }
/// <summary> /// Called on every timer tick /// </summary> protected override void OnTick() { GamePlayer player = (GamePlayer)m_actionSource; if (player == null) { return; } if ((m_flagSpeedData & 0x200) != 0) { player.CurrentSpeed = (short)(-(m_flagSpeedData & 0x1ff)); // backward movement } else { player.CurrentSpeed = (short)(m_flagSpeedData & 0x1ff); // forwardmovement } player.IsStrafing = (m_flagSpeedData & 0x4000) != 0; player.TargetInView = (m_flagSpeedData & 0xa000) != 0; // why 2 bits? that has to be figured out player.GroundTargetInView = ((m_flagSpeedData & 0x1000) != 0); List <Tuple <Skill, Skill> > snap = player.GetAllUsableSkills(); Skill sk = null; Skill sksib = null; // we're not using a spec ! if (m_type > 0) { // find the first non-specialization index. int begin = Math.Max(0, snap.FindIndex(it => (it.Item1 is Specialization) == false)); // are we in list ? if (m_index + begin < snap.Count) { sk = snap[m_index + begin].Item1; sksib = snap[m_index + begin].Item2; } } else { // mostly a spec ! if (m_index < snap.Count) { sk = snap[m_index].Item1; sksib = snap[m_index].Item2; } } // we really got a skill ! if (sk != null) { // Test if we can use it ! int reuseTime = player.GetSkillDisabledDuration(sk); if (reuseTime > 60000) { player.Out.SendMessage( string.Format("You must wait {0} minutes {1} seconds to use this ability!", reuseTime / 60000, reuseTime % 60000 / 1000), eChatType.CT_System, eChatLoc.CL_SystemWindow); if (player.Client.Account.PrivLevel < 2) { return; } } else if (reuseTime > 0) { player.Out.SendMessage(string.Format("You must wait {0} seconds to use this ability!", reuseTime / 1000 + 1), eChatType.CT_System, eChatLoc.CL_SystemWindow); if (player.Client.Account.PrivLevel < 2) { return; } } // See what we should do depending on skill type ! if (sk is Specialization) { Specialization spec = (Specialization)sk; ISpecActionHandler handler = SkillBase.GetSpecActionHandler(spec.KeyName); if (handler != null) { handler.Execute(spec, player); } } else if (sk is Ability) { Ability ab = (Ability)sk; IAbilityActionHandler handler = SkillBase.GetAbilityActionHandler(ab.KeyName); if (handler != null) { handler.Execute(ab, player); return; } ab.Execute(player); } else if (sk is Spell) { if (sksib != null && sksib is SpellLine) { player.CastSpell((Spell)sk, (SpellLine)sksib); } } else if (sk is Style) { player.ExecuteWeaponStyle((Style)sk); } } if (sk == null) { player.Out.SendMessage("Skill is not implemented.", eChatType.CT_Advise, eChatLoc.CL_SystemWindow); } }