using CommonAI.Data; using CommonAI.Zone; using CommonAI.Zone.Formula; using CommonAI.Zone.Helper; using CommonAI.Zone.Instance; using CommonLang; using System; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.XLS.Data; using XmdsCommonSkill.Plugin.Buffs; namespace XmdsCommonSkill.Plugin.Skills.Warrior { /// /// 五技能 :基类 /// 至少聚气0.5秒,最多2秒(点击开始聚气,再按一次图标),期间获得20%免伤,降低20%移动速度, /// 不可释放其他技能。聚气完后旋转挥击巨剑,自身形成烈焰风暴环绕,周身产生烟尘, /// 对周围敌人每0.5秒造成一次n%攻击力伤害,聚气时间越长伤害越高(正比提升),持续5秒。整个期间,免疫眩晕(转换成最大减速50%) /// public class Warrior_110500 : XmdsSkillBase { private static readonly int ID = 110500; protected static readonly int Buff_ID_1 = (int)XmdsBuffBase.XmdsBuffList. LAUNCH_BUF_ZS_5; // 剑刃风暴,免控buf protected static readonly int Buff_ID_2 = (int)XmdsBuffBase.XmdsBuffList.TRY_LAUNCH_BUF_ZS_5; // 聚气buf public override int SkillID { get { return ID; } } protected static readonly int DAMAGE_SPELL_TIME = 5000; //剑刃风暴时间,和编辑器挂钩,这里标记一个变量 //聚气减伤,减速buff,时间编辑器固定不能修改 protected XmdsSkillValue mJuQiValue; //剑刃风暴,免疫控制,转换成减速 protected XmdsSkillValue mValueSet5; //蓄力五段伤害,5段时间。策划确定写死 protected XmdsSkillValue mValueSet6; //每次触发段造成伤害,增加怒气值 protected XmdsSkillValue mValueSet8; //伤害倍数. protected XmdsSkillValue mValueSet1; //根据时间,控制每一段造成伤害加怒气的唯一性 protected bool[] mIsHit = { false, false, false, false, false}; protected long launchTime = 0; // protected long damageStartTime = 0; // 伤害开始时间 //聚气伤害加成 protected int mReadyDamageAddition = 0; protected bool mAutoLaunch = true; protected override void OnSkillDamagePerEvent(BattleParams param) { param.SkillDamageAdd = mValueSet1.GetValue(param.GameSkill.SkillLevel); param.SkillDamagePer = CUtils.CastInt(mValueSet1.GetValueExt(param.GameSkill.SkillLevel) * XmdsUnitProp.PER * this.mReadyDamageAddition); } protected override void OnInit(GameSkill info, XmdsVirtual unit, ref SkillTemplate template) { // 释放剑刃风暴获得buff var pack1 = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID_1); var buff = (XmdsBuff_IgnorCtrlToSpeedDown)pack1.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.IgnorCtrl_To_SpeedDown); buff.speedChange = -mValueSet5.GetValue(info.SkillLevel); //减速万分之N var bt1 = pack1.mBuffTemplate; bt1.IsHarmful = true; bt1.LifeTimeMS = DAMAGE_SPELL_TIME; //时间由spell确定,所以写死 pack1.BindTemplateAndDispose(); unit.RegistSendBuff(bt1); // 聚气buff var pack2 = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID_2); var buff2 = (XmdsBuff_SpeedChg_DamageRemit)pack2.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.SpeedChg_DamageRemit); buff2.speedChange = -mJuQiValue.GetValue(info.SkillLevel, 1); //减速万分之N buff2.damageRemit = mJuQiValue.GetValue(info.SkillLevel, 2); //减伤万分之N var bt2 = pack2.mBuffTemplate; bt2.IsHarmful = true; bt2.LifeTimeMS = 2000; //时间由动作确定,所以写死 pack2.BindTemplateAndDispose(); unit.RegistSendBuff(bt2); unit.RegistLaunchSkillOver(OnLaunchSkillOver, info); unit.RegistTrySendSpellEvent(OnTrySendSpell, info); unit.RegistOnHitOther(OnHandleHitOther, info); } protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit) { base.OnSkillDataChange(gs, unit); var buff = unit.GetRegisBuffVirtual(Buff_ID_2) as XmdsBuff_SpeedChg_DamageRemit; buff.speedChange = -mJuQiValue.GetValue(gs.SkillLevel, 1); //减速万分之N buff.damageRemit = mJuQiValue.GetValue(gs.SkillLevel, 2); //减伤万分之N } private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { //int timeIndex = Math.Min((int)((CommonLang.CUtils.localTimeMS - damageStartTime) / 1000), mIsHit.Length); int timeIndex = (int)((CommonLang.CUtils.localTimeMS - damageStartTime) / 1000); if (timeIndex < 0 || timeIndex >= mIsHit.Length) { if(timeIndex > 7) { log.Error("Warrior_110500获取时间索引异常:" + attacker.mUnit.PlayerUUID + ", " + timeIndex + ", " + attacker.mUnit.Parent.GetSceneID()); } return damage; } if(!mIsHit[timeIndex]) { mIsHit[timeIndex] = true; attacker.Talent__Add(mValueSet8.GetValue(skill.SkillLevel)); } return damage; } private void OnTrySendSpell(GameSkill skill, XmdsVirtual launcher, LaunchSpell launch, ref SpellTemplate spell, ref JSGCreateSpellData createData, ref float startX, ref float startY) { //System.Console.WriteLine("OnTrySendSpell: " + spell.ID + ", " + CommonLang.CUtils.localTimeMS); damageStartTime = CommonLang.CUtils.localTimeMS; } private int OnLaunchSkillOver(GameSkill info, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.SkillState state) { if(state.ActionIndex == 0) { this.launchTime = CommonLang.CUtils.localTimeMS; this.mReadyDamageAddition = mValueSet6.GetValue(1, 5); this.mAutoLaunch = true; for(int i = 0; i < mIsHit.Length; i++) { this.mIsHit[i] = false; } } else if(state.ActionIndex == 2) //手动释放剑刃风暴 { this.mAutoLaunch = false; attacker.mUnit.removeBuff(Buff_ID_2); long curTime = CommonLang.CUtils.localTimeMS; long readyTime = (curTime - this.launchTime); if (readyTime <= 500) { this.mReadyDamageAddition = mValueSet6.GetValue(1, 1); } else if(readyTime <= 1000) { this.mReadyDamageAddition = mValueSet6.GetValue(1, 2); } else if(readyTime <= 1500) { this.mReadyDamageAddition = mValueSet6.GetValue(1, 3); } else if (readyTime < 2000) { this.mReadyDamageAddition = mValueSet6.GetValue(1, 4); } this.launchTime = curTime; } return 0; } protected override void OnInitConfig() { XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID); InitData(data, out mJuQiValue, XmdsSkillData.XmdsSkillDataKey.DmgRate); InitData(data, out mValueSet1, XmdsSkillData.XmdsSkillDataKey.ValueSet); //扩展配置 InitData(data, out mValueSet5, XmdsSkillData.XmdsSkillDataKey.ValueSet5); InitData(data, out mValueSet6, XmdsSkillData.XmdsSkillDataKey.ValueSet6); InitData(data, out mValueSet8, XmdsSkillData.XmdsSkillDataKey.ValueSet8); } } }