123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- using CommonAI.Data;
- using CommonLang;
- using System;
- using System.Collections.Generic;
- namespace XmdsCommonServer.XLS.Data
- {
- public class MonsterData
- {
- /// <summary>
- /// 怪物编号.
- /// </summary>
- public int ID;
- /// <summary>
- /// 怪物名字.
- /// </summary>
- public string Name;
- /// <summary>
- /// 副本名字、称号:怪物的称号,跟随在怪物名字之前或者之后比如:死亡骑士阿尔萨斯.
- /// </summary>
- public string Title;
- /// <summary>
- /// 生物类型.0:人类1:野兽2:不死生物3:恶魔9:其他.
- /// </summary>
- public byte Atype;
- /// <summary>
- /// 性别.
- /// </summary>
- public byte Sex;
- /// <summary>
- /// 等级.
- /// </summary>
- public int Level;
- /// <summary>
- /// 名字颜色.
- /// </summary>
- public byte Qcolor;
- /// <summary>
- /// 怪物类型.BOSS、精英、普通.
- /// </summary>
- public byte Type;
- /// <summary>
- /// 1等级压制 0或空不压制
- /// </summary>
- public byte LvRepress;
- /// <summary>
- /// 技能类型
- /// </summary>
- public int SkillType;
- /// <summary>
- /// 战斗数值规模
- /// </summary>
- public byte Fight_Type;
- /// <summary>
- /// 玩家围攻数量
- /// </summary>
- public float Fight_Count;
- /// <summary>
- /// 存活时间
- /// </summary>
- public float AliveTime;
- /// <summary>
- /// 致死玩家时间
- /// </summary>
- public float KillPlayerTime;
- /// <summary>
- /// 变成普通怪概率.
- /// </summary>
- public int Prob1;
- /// <summary>
- /// 普通怪ID.
- /// </summary>
- public int ReviveID1;
- /// <summary>
- /// 变成稀有怪概率.
- /// </summary>
- public int Prob2;
- /// <summary>
- /// 稀有怪ID.
- /// </summary>
- public int ReviveID2;
- /// <summary>
- /// 首脑怪概率.
- /// </summary>
- public int Prob3;
- /// <summary>
- /// 首脑怪ID.
- /// </summary>
- public int ReviveID3;
- /// <summary>
- /// 变成精英怪物的概率.
- /// </summary>
- public int Prob4;
- /// <summary>
- /// 精英怪物ID.
- /// </summary>
- public int ReviveID4;
- /// <summary>
- /// 显示个性语言概率.
- /// </summary>
- public int DialogChance;
- /// <summary>
- /// 个性语言内容.
- /// </summary>
- public string DialogWords;
- /// <summary>
- /// 显示死亡个性语言概率.
- /// </summary>
- public int DeadDialogChance;
- /// <summary>
- /// 死亡个性语言内容.
- /// </summary>
- public string DeadDialogWords;
- /// <summary>
- /// 生命.
- /// </summary>
- public int MaxHP;
- /// <summary>
- /// 攻击.
- /// </summary>
- public int MaxAttack;
- /// <summary>
- /// 防御.
- /// </summary>
- public int MaxDefence;
- /// <summary>
- /// 暴击.
- /// </summary>
- public int CritRate;
- /// <summary>
- /// 暴击伤害
- /// </summary>
- public int CritDamage;
- /// <summary>
- /// 抗暴.
- /// </summary>
- public int ResCrit;
-
- /// <summary>
- /// 抗暴.
- /// </summary>
- public int Resist;
- /// <summary>
- /// 无视敌人防御%
- /// </summary>
- public int IgnoreDefencePer;
- /// <summary>
- /// 是否主动攻击.0否,1是.
- /// </summary>
- public byte isAttack;
- /// <summary>
- /// 特殊能力.
- /// </summary>
- public string Ability;
- /// <summary>
- /// 触发百分比.
- /// </summary>
- public string CallAbilityPerHP;
- /// <summary>
- /// 盾血量.
- /// </summary>
- public string AbilityPar;
- /// <summary>
- /// 特殊能力脚本ID.
- /// </summary>
- public List<int> AbilityList = null;
- /// <summary>
- /// 血量触发百分比.
- /// </summary>
- public List<int> AbilityPerHPList = null;
- /// <summary>
- /// 血量触发的护盾值.
- /// </summary>
- public List<int> AbilityParList = null;
- /// <summary>
- /// 是否是共享怪.
- /// </summary>
- 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;
- }
- /// <summary>
- /// 是否在范围内[a,b).
- /// </summary>
- /// <param name="value"></param>
- /// <param name="min"></param>
- /// <param name="max"></param>
- /// <returns></returns>
- 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<int>();
- 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<int>();
- 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<int>();
- 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<int> list, string content)
- {
- int v = 0;
- if (Int32.TryParse(content, out v))
- {
- list.Add(v);
- }
- }
- }
- }
|