123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- using CommonAI;
- using CommonAI.Zone;
- using CommonAI.Zone.Helper;
- using CommonAI.Zone.Instance;
- using CommonLang;
- using CommonLang.Geometry;
- using System;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin;
- using XmdsCommonServer.Plugin.Units;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
- using XmdsCommonServer.XLS.Data;
- using XmdsCommonSkill.Plugin.Buffs;
- using XmdsCommonSkill.Plugin.PassiveSkills.Magic;
- using static CommonAI.Zone.Instance.InstanceUnit;
- using static XmdsCommonSkill.Plugin.Buffs.XmdsBuff_SwordShadow;
- namespace XmdsCommonSkill.Plugin.Skills.Magic
- {
- /// <summary>
- /// 控制一名随机玩家,使该玩家眩晕,并攻击队友。其他玩家需要在指定时间内击杀掉A玩家分身,否则该玩家会死,BOSS也会回血
- /// </summary>
- public class Skill_910050 : XmdsSkillBase
- {
- public static readonly int ID = 910050;
- public override int SkillID { get { return ID; } }
- private static readonly int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.COM_SLIENT;
- private static readonly int mSummonRange = 2; // 召唤物检测半径
- public static XmdsSkillValue mSummonTime; // 召唤时间
- public static XmdsSkillValue mSummonPropPrecent; // 分身属性万分比
- public static XmdsSkillValue mFinalAddHP; // 分身消失时,boss回血比例
- private long mSummonStartTime = 0;
- //被禁锢的玩家
- private XmdsVirtual mBindPlayer;
- //召唤分身
- private InstanceUnit mSummonUnit;
- //主人
- private XmdsVirtual mOwner;
- protected override void OnInit(GameSkill info, XmdsVirtual unit, ref SkillTemplate template)
- {
- // Buff修改
- var pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
- var bt = pack.mBuffTemplate;
- bt.LifeTimeMS = mSummonTime.GetValue() + 2000; //默认比召唤物的时间长2s
- bt.IsHarmful = true;
- pack.BindTemplateAndDispose();
- unit.RegistSendBuff(bt);
- this.mOwner = unit;
- }
- protected override void OnSkillLogicEvent(BattleParams param)
- {
- param.UseDamageType = CommonAI.Data.DamageType.None;
- XmdsVirtual_Monster materMonster = param.Attacker as XmdsVirtual_Monster;
- if (materMonster.GetSummonUnitListCount() > 0)
- {
- return ;
- }
- //如果之前已经绑定了某个玩家,移除该玩家buff
- if (mBindPlayer != null && mBindPlayer.mUnit.IsActive)
- {
- mBindPlayer.mUnit.removeBuff(Buff_ID);
- mBindPlayer = null;
- }
- XmdsVirtual hitterPlayer = param.Hitter;
- if (hitterPlayer.mUnit.IsPet) //如果是宠物,目标为玩家
- {
- hitterPlayer = (param.Hitter as XmdsVirtual_Pet).GetMaster();
- }
- XmdsUnitProperties prop = hitterPlayer.mUnit.Properties as XmdsUnitProperties;
- String showName = prop.ServerData.BaseInfo.name + "-分身";
- UnitInfo info = (UnitInfo)hitterPlayer.mUnit.Info.Clone();
- info.ID = XmdsConstConfig.DEFAULT_PLAYER_TEMPLATE_ID;
- info.UType = UnitInfo.UnitType.TYPE_SUMMON;
- info.Name = showName;
- info.RebirthTimeMS = 0;
- info.LifeTimeMS = mSummonTime.GetValue();
- XmdsUnitProperties unitProp = (info.Properties as XmdsUnitProperties);
- unitProp.LoadDataConfig = false;
- //分身属性调整. 攻防血
- unitProp.ServerData.Prop.BaseAttack = CUtils.CastInt(unitProp.ServerData.Prop.BaseAttack * XmdsUnitProp.PER * mSummonPropPrecent.GetValue());
- unitProp.ServerData.Prop.BaseDefence = CUtils.CastInt(unitProp.ServerData.Prop.BaseDefence * XmdsUnitProp.PER * mSummonPropPrecent.GetValue());
- unitProp.ServerData.Prop.BaseMaxHP = CUtils.CastInt(unitProp.ServerData.Prop.BaseMaxHP * XmdsUnitProp.PER * mSummonPropPrecent.GetValue());
- unitProp.ServerData.Prop.HP = unitProp.ServerData.Prop.BaseMaxHP;
- this.ProcessSummonUnit(param.Attacker, hitterPlayer, info, showName);
- }
- protected bool ProcessSummonUnit(XmdsVirtual attacker, XmdsVirtual hitter, UnitInfo info, String showName)
- {
- AddUnitEvent aue = null;
- var pos = attacker.mUnit.Parent.PathFinder.FindNearRandomMoveableNode(
- attacker.mUnit.RandomN, attacker.mUnit.X, attacker.mUnit.Y, mSummonRange, true);
- mSummonUnit = attacker.mUnit.Parent.AddUnit(
- info, info.Name,
- attacker.mUnit.Force, attacker.GetUnitLv(),
- pos.PosX, pos.PosY,
- attacker.mUnit.Direction,
- out aue,
- attacker.mUnit, showName);
- if(mSummonUnit == null)
- {
- log.Warn("Skill_910050添加召唤物失败:" + info.ID);
- return false;
- }
- // 监听召唤物死亡
- mSummonUnit.OnDead += onSummonDead;
- (attacker as XmdsVirtual_Monster).AddSummonUnitList(mSummonUnit.Virtual as XmdsVirtual);
- //目标玩家死亡监听
- hitter.mUnit.AddBuff(Buff_ID, attacker.mUnit, 0, true);
- this.mBindPlayer = hitter;
- this.mSummonStartTime = CommonLang.CUtils.localTimeMS;
- mBindPlayer.mUnit.OnDead += onBindPlayerDead;
- return true;
- }
- private void onSummonDead(InstanceUnit unit, InstanceUnit attacker)
- {
- mSummonUnit.OnDead -= onSummonDead;
- if (mBindPlayer != null && mBindPlayer.mUnit.IsActive && mBindPlayer.mUnit.GetBuffByID(Buff_ID) != null)
- {
- long summonTimePass = CommonLang.CUtils.localTimeMS - this.mSummonStartTime + 500;
- mBindPlayer.mUnit.removeBuff(Buff_ID);
- //判断是否到召唤截止时间了
- if (summonTimePass >= mSummonTime.GetValue())
- {
- //杀死目标玩家
- mBindPlayer.mUnit.kill();
- //boss回血
- this.mOwner.mUnit.AddHP(CUtils.CastInt(this.mOwner.mUnit.MaxHP * XmdsUnitProp.PER * mFinalAddHP.GetValue()), null);
- }
- else
- {
- // 分身被击杀了
-
- }
- this.mBindPlayer = null;
- this.mSummonStartTime = 0;
- }
- }
- private void onBindPlayerDead(InstanceUnit unit, InstanceUnit attacker)
- {
- if(mBindPlayer != null)
- {
- mBindPlayer.mUnit.OnDead -= onBindPlayerDead;
- mBindPlayer.mUnit.removeBuff(Buff_ID);
- }
- }
- protected override void OnInitConfig()
- {
- XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
- InitData(data, out mSummonTime, XmdsSkillData.XmdsSkillDataKey.ValueSet);
- InitData(data, out mSummonPropPrecent, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
- InitData(data, out mFinalAddHP, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
- }
- }
- }
|