123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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.Plugin.XmdsSkillTemplate.DamageCalculator;
- using XmdsCommonServer.XLS.Data;
- using XmdsCommonSkill.Plugin.Buffs;
- using XmdsCommonSkill.Plugin.Interface;
- using XmdsCommonSkill.Plugin.PassiveSkills.Magic;
- using static CommonAI.Zone.Instance.InstanceUnit;
- using static XmdsCommonSkill.Plugin.Buffs.XmdsBuff_SwordShadow;
- using static XmdsCommonSkill.Plugin.Interface.ComSpellTemplate;
- namespace XmdsCommonSkill.Plugin.Skills.Magic
- {
- /// <summary>
- /// 天数基础技能:每次攻击(怪物)时有X%的概率触发,使玩家的下一次普攻伤害提高Y%,持续时间Z秒,技能冷却时间S秒
- /// </summary>
- public abstract class TianShuBase : XmdsPassiveSkillBase
- {
- private static XmdsSkillValue mValueSet1; // 触发概率
- private static XmdsSkillValue mValueSet2; // 攻击百分比提高
- private static XmdsSkillValue mValueSet3; // buff持续时间
- private static XmdsSkillValue mValueSet4; // 冷却时间
- //本次触发时间
- private long mNextTirggerTime = 0;
- //buff有效截止时间
- private long mBuffValidEndTime = 0;
- private int mUUID_2;
- protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
- {
- var pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(this.GetBindBuffID());
- var buff = (XmdsBuff_Damage)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.Damage);
- buff.mDamagePer = mValueSet2.GetValue(skillInfo.SkillLevel) + skillInfo.TalentSkillLevel1;
- var bt = pack.mBuffTemplate;
- pack.BindTemplateAndDispose();
- owner.RegistSendBuff(bt);
- // 伤害监听
- mUUID_2 = owner.RegistOnHitOther(OnHandleHitOther, skillInfo, true);
- mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(skillInfo.SkillLevel);
- }
- protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
- {
- var buff = (XmdsBuff_Damage)unit.GetRegisBuffVirtual(this.GetBindBuffID());
- buff.mDamagePer = mValueSet2.GetValue(gs.SkillLevel) + gs.TalentSkillLevel1;
- }
- private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
- {
- if(source == null || source.FromBuff != null)
- {
- return damage;
- }
- // 对战玩家触发
- if (hitted != null && !hitted.IsPlayerUnit())
- {
- //如果buff生效了
- if(mBuffValidEndTime > CommonLang.CUtils.localTimeMS && source.FromSkillType == XmdsSkillType.normalAtk)
- {
- this.mBuffValidEndTime = 0; // 标记失效
- //hitted.mUnit.AddBuff(this.GetBindBuffID(), attacker.mUnit);
- this.launchEffectSpell(attacker, hitted, false);
- damage += damage * (mValueSet2.GetValue(skill.SkillLevel) + skill.TalentSkillLevel1) * XmdsUnitProp.PER;
- return damage;
- }
- if(mNextTirggerTime < CommonLang.CUtils.localTimeMS && attacker.mUnit.RandomN.Next(0, 10000) < mValueSet1.GetValue(skill.SkillLevel))
- {
- mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(skill.SkillLevel);
- mBuffValidEndTime = CommonLang.CUtils.localTimeMS + mValueSet3.GetValue(skill.SkillLevel);
- // 释放法术特效
- this.launchEffectSpell(attacker, attacker, true);
- }
- }
- return damage;
- }
- protected override void OnDispose(XmdsVirtual owner)
- {
- owner.UnRegistOnHitOther(mUUID_2);
- }
- protected override void OnInitSkillParam()
- {
- XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(this.SkillID);
- InitData(data, out mValueSet1, XmdsSkillData.XmdsSkillDataKey.ValueSet);
- InitData(data, out mValueSet2, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
- InitData(data, out mValueSet3, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
- InitData(data, out mValueSet4, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
- }
- protected virtual XmdsSpellID GetLaunchSpellID(bool self) { return 0; }
- protected void launchEffectSpell(XmdsVirtual launcher, XmdsVirtual target, bool self)
- {
- LaunchSpell spell = ComSpellTemplate.Instance().GetSpellByID(this.GetLaunchSpellID(self));
- launcher.mUnit.Parent.unitLaunchSpell(XmdsSkillType.none, launcher.mUnit, spell, target.mUnit.X, target.mUnit.Y, target.mUnit.ID);
- }
- protected virtual int GetBindBuffID()
- {
- return 0;
- }
- }
- }
|