using CommonAI.Data; using CommonLang; using System; using System.Collections.Generic; namespace XmdsCommonServer.XLS.Data { public class MonsterData { /// /// 怪物编号. /// public int ID; /// /// 怪物名字. /// public string Name; /// /// 副本名字、称号:怪物的称号,跟随在怪物名字之前或者之后比如:死亡骑士阿尔萨斯. /// public string Title; /// /// 生物类型.0:人类1:野兽2:不死生物3:恶魔9:其他. /// public byte Atype; /// /// 性别. /// public byte Sex; /// /// 等级. /// public int Level; /// /// 名字颜色. /// public byte Qcolor; /// /// 怪物类型.BOSS、精英、普通. /// public byte Type; /// /// 1等级压制 0或空不压制 /// public byte LvRepress; /// /// 技能类型 /// public int SkillType; /// /// 战斗数值规模 /// public byte Fight_Type; /// /// 玩家围攻数量 /// public float Fight_Count; /// /// 存活时间 /// public float AliveTime; /// /// 致死玩家时间 /// public float KillPlayerTime; /// /// 变成普通怪概率. /// public int Prob1; /// /// 普通怪ID. /// public int ReviveID1; /// /// 变成稀有怪概率. /// public int Prob2; /// /// 稀有怪ID. /// public int ReviveID2; /// /// 首脑怪概率. /// public int Prob3; /// /// 首脑怪ID. /// public int ReviveID3; /// /// 变成精英怪物的概率. /// public int Prob4; /// /// 精英怪物ID. /// public int ReviveID4; /// /// 显示个性语言概率. /// public int DialogChance; /// /// 个性语言内容. /// public string DialogWords; /// /// 显示死亡个性语言概率. /// public int DeadDialogChance; /// /// 死亡个性语言内容. /// public string DeadDialogWords; /// /// 生命. /// public int MaxHP; /// /// 攻击. /// public int MaxAttack; /// /// 防御. /// public int MaxDefence; /// /// 暴击. /// public int CritRate; /// /// 暴击伤害 /// public int CritDamage; /// /// 抗暴. /// public int ResCrit; /// /// 抗暴. /// public int Resist; /// /// 无视敌人防御% /// public int IgnoreDefencePer; /// /// 是否主动攻击.0否,1是. /// public byte isAttack; /// /// 特殊能力. /// public string Ability; /// /// 触发百分比. /// public string CallAbilityPerHP; /// /// 盾血量. /// public string AbilityPar; /// /// 特殊能力脚本ID. /// public List AbilityList = null; /// /// 血量触发百分比. /// public List AbilityPerHPList = null; /// /// 血量触发的护盾值. /// public List AbilityParList = null; /// /// 是否是共享怪. /// public int ShareType = 0; /** 定力值 */ public int MPValue = 0; // 怪物类型-针对于宠物的天命类型 public UnitFateType FateType = UnitFateType.None; public int GetRandomID(int srcID, Random random) { int ret = 0; int rt = 0; if (Prob1 == 0) { ret = srcID; } else { int sum = Prob1 + Prob2 + Prob3 + Prob4; if (sum < 10000) { XLSLoader.log.Log("Monster ID = [" + srcID + "] RandomRate Error"); } int a = Prob1; int b = a + Prob2; int c = b + Prob3; int d = c + Prob4; rt = random.Next(0, 10000); if (c != d && IsInRange(rt, c, d)) { ret = GetProbValue(Prob4); } else if (b != c && IsInRange(rt, b, c)) { ret = GetProbValue(Prob3); } else if (a != b && IsInRange(rt, a, b)) { ret = GetProbValue(Prob2); } else if (0 != a && IsInRange(rt, 0, a)) { ret = GetProbValue(Prob1); } } return ret; } /// /// 是否在范围内[a,b). /// /// /// /// /// private static bool IsInRange(int value, int min, int max) { return value >= min && value < max; } private int GetProbValue(int prob) { int ret = 0; if (prob == Prob1) { ret = ReviveID1; } else if (prob == Prob2) { ret = ReviveID2; } else if (prob == Prob3) { ret = ReviveID3; } else if (prob == Prob4) { ret = ReviveID4; } return ret; } public void InitData(Random random) { //解析能力字段. //数据格式:"999000;999001". if (!string.IsNullOrEmpty(Ability)) { AbilityList = new List(); string[] strArray = Ability.Split(';'); if (strArray != null && strArray.Length > 0) { for (int i = 0; i < strArray.Length; i++) { ParseStrAddList(ref AbilityList, strArray[i]); } } //7000|3000; if (!string.IsNullOrEmpty(CallAbilityPerHP)) { AbilityPerHPList = new List(); strArray = CallAbilityPerHP.Split('|'); if (strArray != null && strArray.Length > 0) { for (int i = 0; i < strArray.Length; i++) { ParseStrAddList(ref AbilityPerHPList, strArray[i]); } } } if (!string.IsNullOrEmpty(AbilityPar)) { AbilityParList = new List(); strArray = AbilityPar.Split('|'); if (strArray != null && strArray.Length > 0) { for (int i = 0; i < strArray.Length; i++) { ParseStrAddList(ref AbilityParList, strArray[i]); } } } if (AbilityParList != null && AbilityPerHPList != null) { if(AbilityPerHPList.Count != AbilityParList.Count ) { throw new Exception("Ability ParseError"); } } } } private void ParseStrAddList(ref List list, string content) { int v = 0; if (Int32.TryParse(content, out v)) { list.Add(v); } } } }