123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using CommonAI.Zone.Helper;
- using CommonAI.Zone.Instance;
- using XmdsCommonServer.Plugin;
- using XmdsCommonServer.XLS.Data;
- using XmdsCommonSkill.Plugin.Buffs;
- using System;
- using static CommonAI.Zone.Instance.InstanceUnit;
- using XmdsCommon.Plugin;
- using CommonAI.Zone;
- using XmdsCommonServer.Plugin.Units;
- using CommonAI.Zone.Formula;
- using XmdsCommonSkill.Plugin.Skills;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
- using XmdsCommonSkill.Plugin.Skills.Magic;
- using CommonLang;
- using CommonAI.Data;
- using System.Collections.Generic;
- namespace XmdsCommonSkill.Plugin.PassiveSkills.Magic
- {
- /// <summary>
- /// 灵宝套装被动: 次攻击时有X%的概率触发,使玩家的当前面板的攻击伤害提高Y%,持续时间Z秒,技能冷却时间S秒
- /// </summary>
- public class Other_100100 : XmdsPassiveSkillBase
- {
- /// 技能ID.
- public static readonly int ID = 100100;
- private static XmdsSkillValue mValueSet1; // 触发概率
- private static XmdsSkillValue mValueSet2; // 攻击百分比提高
- private static XmdsSkillValue mValueSet3; // buff持续时间
- private static XmdsSkillValue mValueSet4; // 冷却时间
- private static readonly int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.LINGBAO_BUFF;
- private int mUUID_1 = 0;
- //本次触发时间
- private long mNextTirggerTime = 0;
- //buff有效截止时间
- private long mBuffValidEndTime = 0;
- public override int SkillID { get { return ID; } }
- protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
- {
- var pack1 = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
- var bt1 = pack1.mBuffTemplate;
- bt1.LifeTimeMS = mValueSet3.GetValue(skillInfo.SkillLevel);
- pack1.BindTemplateAndDispose();
- owner.RegistSendBuff(bt1);
- mNextTirggerTime = CommonLang.CUtils.localTimeMS + mValueSet4.GetValue(skillInfo.SkillLevel);
- mUUID_1 = owner.RegistOnHitOther(OnHandleHitOther, skillInfo, true);
- }
- protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
- {
- var buf1 = unit.GetRegistBuff(Buff_ID);
- buf1.LifeTimeMS = mValueSet3.GetValue(gs.SkillLevel);
- }
- 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 > 0 && mBuffValidEndTime > CommonLang.CUtils.localTimeMS)
- {
- damage += damage * mValueSet2.GetValue(skill.SkillLevel) * XmdsUnitProp.PER;
- return damage;
- }
- else 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);
- attacker.mUnit.AddBuff(Buff_ID);
- }
- }
- return damage;
- }
- protected override void OnInitSkillParam()
- {
- XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
- 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 override void OnDispose(XmdsVirtual owner)
- {
- owner.UnRegistOnHitOther(mUUID_1);
- }
- }
- }
|