using CommonAI.Zone;
using XmdsCommon.Plugin;
using XmdsCommonServer.Plugin;
using XmdsCommonServer.Plugin.Units;
using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
using XmdsCommonServer.XLS.Data;
namespace XmdsCommonSkill.Plugin.Skills.Monster
{
///
/// 巢穴驯兽师 - 召唤黑狼4: 召唤一头黑狼.
///
public class Monster_1724002 : XmdsSkillBase
{
public static int ID = 1724002;
public static int SummonUnit_ID = 17250;
/// 可召唤最大个数.
public static XmdsSkillValue SummonLimit;
/// 单次召唤数量(目前固定为1).
public static XmdsSkillValue SumUnitCount;
public override int SkillID { get { return ID; } }
protected override void OnRegistEvent()
{
this.RegistEvent(EventType.UseFormluaType, OnUseFormluaTypeEvent);
base.OnRegistEvent();
}
private void OnUseFormluaTypeEvent(BattleParams param)
{
param.UseDamageType = CommonAI.Data.DamageType.None;
}
protected override void OnSkillLogicEvent(BattleParams param)
{
if (param.AtkProp.DamagePerID == 1)
{
callMonster(param, SummonUnit_ID);
}
}
///
/// 召唤黑狼.
///
protected void callMonster(BattleParams param, int templateID)
{
UnitInfo info = XmdsBattleSkill.GetUnitInfo(templateID);
int r = this.GetTargetFormulaValue(param.GameSkill.SkillLevel, SummonLimit);
int numPerTime = this.GetTargetFormulaValue(param.GameSkill.SkillLevel, SumUnitCount);
XmdsVirtual_Monster monster = param.Attacker as XmdsVirtual_Monster;
XmdsVirtual su = null;
if (monster != null)
{
int cur = monster.GetSummonUnitListCount();
while (cur + numPerTime > r)
{
su = monster.GetFirstTimesupSummonUnit();
if (su != null)
{
(su.mUnit).kill(null, false);
cur--;
}
}
}
for (int i = 0; i < numPerTime; i++)
{
var pos = param.Attacker.mUnit.Parent.PathFinder.FindNearRandomMoveableNode(
param.Attacker.mUnit.RandomN,
param.Attacker.mUnit.X,
param.Attacker.mUnit.Y,
2, true);
AddUnitEvent aue = null;
//控制生命周期.
info.LifeTimeMS = 10000;
var unit = (param.Attacker.mUnit.Parent.AddUnit(
info, info.Name,
param.Attacker.mUnit.Force, param.Attacker.GetUnitLv(),
pos.PosX,
pos.PosY,
param.Attacker.mUnit.Direction,
out aue,
param.Attacker.mUnit)) as XmdsInstanceMonster;
XmdsVirtual zv = (unit.Virtual) as XmdsVirtual;
unit.guardUnit(param.Attacker.mUnit);
if (monster != null)
{
monster.AddSummonUnitList(unit.Virtual as XmdsVirtual);
}
}
}
protected override void OnInitSkillParam()
{
XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
InitData(data, out SummonLimit, XmdsSkillData.XmdsSkillDataKey.ValueSet);
InitData(data, out SumUnitCount, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
}
}
}