123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119 |
- using CommonAI.Zone.Instance;
- using System;
- using XmdsCommon.Message;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin.Units;
- using XmdsCommonServer.XLS.Data;
- using CommonAI.Zone.Formula;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
- using CommonAI.Zone;
- using System.Collections.Generic;
- using CommonLang;
- using XmdsCommonServer.Plugin.Scene;
- using static CommonAI.XmdsConstConfig;
- using XmdsCommonServer.XLS;
- using CommonLang.Log;
- using static XmdsCommonServer.XLS.XLSRandomMonsterSkillLoader;
- using static XmdsCommon.Plugin.GameSkill;
- using CommonAI.Zone.Helper;
- using CommonAI.Data;
- using XmdsCommon.JSGModule.Interface;
- namespace XmdsCommonServer.Plugin
- {
- public class XmdsVirtual_Monster : XmdsVirtual
- {
- private static Logger logger = LoggerFactory.GetLogger("MonsterData");
-
-
-
- protected string[] mDialogWords = null;
-
-
-
- protected int mDialogWordRate = 100;
-
-
-
- protected string[] mDeadDialogWords = null;
-
-
-
- protected int mDeadDialogWordRate = 100;
-
-
-
- private bool mIsBoss = false;
-
-
-
- private byte mMonsterType = 0;
- private bool mIsLvRepress = false;
-
-
-
- private List<int> mAbilityList = null;
-
-
-
- private HashMap<string, PlayerDamageInfo> mSufferDamageInfo = null;
-
-
-
- private bool mIsShare = false;
-
- private byte skillType = 0;
-
- private InstanceUnit mBindAttakPlayer;
-
-
-
- private int backSpeedBuffId = 0;
- public bool IsShare
- {
- get { return mIsShare; }
- set { mIsShare = value;}
- }
- public XmdsVirtual_Monster(InstanceUnit unit) : base(unit)
- {
- mHateSystem.SetFindHeirs(true);
- }
- public override string GetPlayerUUID()
- {
- return mUnit.ID.ToString();
- }
- public override PKLevel GetCurPKLevel()
- {
- return base.GetCurPKLevel();
- }
-
-
-
-
- public static int ParseInt(string str, int dft = 0)
- {
- if (string.IsNullOrEmpty(str))
- {
- return dft;
- }
- System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(str, @"(\d+)");
- if (m.Groups.Count >= 2)
- {
- try
- {
- return System.Convert.ToInt32(m.Groups[1].Value);
- }
- catch (System.Exception)
- {
- return dft;
- }
- }
- return dft;
- }
- protected override void Init(bool pointLv)
- {
- if (this.mProp.LoadDataConfig == true)
- {
-
- InitMonsterData2(GetCurSceneType(), mUnit.Info.TemplateID, pointLv);
- }
- else
- {
- MonsterVisibleDataB2C edata = new MonsterVisibleDataB2C();
- edata.SenceType = GetCurSceneType();
- edata.MonsterID = mUnit.Info.TemplateID;
- edata.DisplayName = mUnit.Name;
- edata.AttackType = MonsterVisibleDataB2C.MonsterAttackType.Passive;
- edata.Atype = MonsterVisibleDataB2C.MonsterAtype.Monster;
- edata.MType = MonsterVisibleDataB2C.MonsterType.MType0;
- edata.Qcolor = MonsterVisibleDataB2C.MonsterQcolor.Q0;
- edata.hpPlies = (byte)ParseInt(mUnit.Info.UserTag, 1);
- mUnit.SetVisibleInfo(edata);
- }
-
- if(this.mUnit.Info.IsRandomName)
- {
- string randomName = XmdsDataMgr.GetInstance().GetRanomName();
- mUnit.SetDiaplayerName(randomName);
- }
- mHateSystem.OnHandleTargetAddEvent += MHateSystem_OnHandleTargetAddEvent;
- }
- private void MHateSystem_OnHandleTargetAddEvent(CommonAI.Zone.Helper.HateSystem.HateInfo target)
- {
- if (target.Unit != null)
- {
- if ((target.Unit.Virtual as XmdsVirtual).IsPlayerUnit())
- {
- SetCombatState(BattleStatus.PVP);
- }
- else
- {
- SetCombatState(BattleStatus.PVE);
- }
- }
- }
- public override void SetCombatState(BattleStatus value, byte reason = 0)
- {
-
- if (value == BattleStatus.PVP)
- {
- value = BattleStatus.PVE;
- }
- base.SetCombatState(value, reason);
- }
- protected override void OnCombatStateChange(BattleStatus status)
- {
- base.OnCombatStateChange(status);
-
- if (status == BattleStatus.None && this.mUnit.Info.GuardRangeLimit != 0)
- {
- (mUnit as CommonAI.Zone.Instance.InstanceGuard).backToOrgin();
-
- CleanDamageInfo();
- }
- if (status != BattleStatus.None)
- {
- RandomDialogWords();
- }
- }
-
-
-
- public void changeRunSpeed4back()
- {
- if(backSpeedBuffId > 0)
- {
- RemovePropChangeOperation(backSpeedBuffId);
- }
-
- XmdsVirtual.PropChangeOperation pco = this.CreatePropChangeOpertation();
- pco.Type = XmdsVirtual.UnitAttributeType.MoveSpeed;
- pco.Value = 5000;
- pco.OpType = XmdsVirtual.PropChangeOperation.OperateType.Percent;
- backSpeedBuffId = AddPropChangeOperation(pco);
- }
- public void onBack2PositionEnd()
- {
- RemovePropChangeOperation(backSpeedBuffId);
- }
- public override void OnUnitDead(XmdsVirtual killer)
- {
-
- var u = mHateSystem.GetHeirs();
- if (u != null)
- {
- mHateSystem.CalAtkAssistantList(mIsShare);
- CheckKillGroup((u.Virtual as XmdsVirtual));
- }
- base.OnUnitDead(killer);
- RandomDeadDialogWords();
- }
- public override int OnHit(XmdsVirtual attacker, AttackSource source)
- {
-
- if (this.mUnit.CurrentState is InstanceUnit.StateBackToPosition)
- {
- source.OutIsDamage = false;
- source.OutClientState = (int)UnitHitEventState.Immunity;
- return 0;
- }
- OnBossHit(attacker, ref source);
- int ret = base.OnHit(attacker, source);
- if (ret > 0)
- {
- OnDamageInfoCheck(attacker, ref source, ret);
- }
- return ret;
- }
- public override void SyncHeirsInfo(string name, int hpPercent, CommonAI.Data.XmdsUnitPro protype)
- {
- if (string.IsNullOrEmpty(name))
- {
- (this.mUnit.VisibleInfo as MonsterVisibleDataB2C).UnitHeirInfo = null;
- SendMonsterHeirInfoChangeEventB2C(null);
- }
- else {
- MonsterVisibleDataB2C.HeirInfo info = new MonsterVisibleDataB2C.HeirInfo();
- info.Name = name;
- info.hpPercent = hpPercent;
- info.ProType = protype;
- SendMonsterHeirInfoChangeEventB2C(info);
- (this.mUnit.VisibleInfo as MonsterVisibleDataB2C).UnitHeirInfo = info;
- }
- }
- private void SendMonsterHeirInfoChangeEventB2C(MonsterVisibleDataB2C.HeirInfo info)
- {
- MonsterHeirInfoChangeEventB2C evt = new MonsterHeirInfoChangeEventB2C();
- evt.UnitHeirInfo = info;
- this.mUnit.queueEvent(evt);
- }
-
- public override bool IsTeamMember(InstanceUnit unit)
- {
- return IsAllies(unit.Virtual as XmdsVirtual);
- }
- protected override bool JudgeChangeCombatStateChange(BattleStatus status, byte reason)
- {
-
- if (status == BattleStatus.None && reason == 0)
- {
- if (mSummonList != null && mSummonList.Count > 0)
- {
- for (int i = 0; i < mSummonList.Count; i++)
- {
- if (mSummonList[i].CombatState != BattleStatus.None)
- {
- return false;
- }
- }
- }
- }
- return base.JudgeChangeCombatStateChange(status, reason);
- }
- protected override void CombatStateConnect(BattleStatus status, byte reason)
- {
- if (mSummonList != null && mSummonList.Count > 0)
- {
- for (int i = 0; i < mSummonList.Count; i++)
- {
- mSummonList[i].SetCombatState(status, reason);
- }
- }
- }
- protected override void Dispose()
- {
- UnInitBossAbilities();
- CleanSummonList();
- DisposeDamageInfo();
- base.Dispose();
- }
- public override int GetVirtualTemplateID()
- {
- MonsterVisibleDataB2C data = (this.mUnit.VisibleInfo as MonsterVisibleDataB2C);
- if (data != null)
- {
- return data.MonsterID;
- }
- else
- {
- return base.GetVirtualTemplateID();
- }
- }
- public void DoUnitStateReset()
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- private void RemoveSelfAndCreate()
- {
- var pos = (this.mUnit as XmdsInstanceMonster).GetOrginPosition();
- float x = 0;
- float y = 0;
- if (pos != null)
- {
- x = pos.X;
- y = pos.Y;
- }
- else
- {
- x = this.mUnit.X;
- y = this.mUnit.Y;
- }
- var u = this.mUnit.Parent.AddUnit(this.mUnit.Info.ID,
- this.mUnit.Name,
- this.mUnit.Force,
- this.mProp.ServerData.BaseInfo.UnitLv,
- x,
- y,
- this.mUnit.Direction, false);
- if (u != null)
- {
- u.UnitTag = this.mUnit.UnitTag;
- }
- this.mUnit.removeFromParent();
- }
- protected override void InitSkillInfo(XmdsUnitData data)
- {
- this.checkSkillData(data);
-
- if (this.skillType > 0)
- {
-
-
-
-
-
- randomMonsterSkillInfo(this.mUnit.Info.ID, this.skillType);
- }
-
- if(this.IsBoss())
- {
- this.mProp.ServerData.Skills.UnitSkills.Add(new GameSkill(XmdsComSrvData.BOSS_CARD_SKILLID, XmdsSkillType.active, false));
- }
- mFinishSkillInit = true;
- mSkillHelper.InitSkill(data.Skills, this);
- if (mAbilityList != null)
- {
- InitAbilityList(mAbilityList);
- }
- }
- #region 共享相关计算.
- private void CheckKillGroup(XmdsVirtual killer)
- {
- if (killer == null) { return; }
- XmdsVirtual_Player ret = killer.GetPlayerUnit();
- if (ret == null) { return; }
- List<string> lt = ret.TeamList as List<string>;
-
- if (lt != null && lt.Count > 0)
- {
- this.mHateSystem.ClearSharedList();
- string uuid = null;
-
- for (int i = 0; i < lt.Count; i++)
- {
- uuid = lt[i];
- var unit = this.mUnit.Parent.getPlayerByUUID(uuid);
- if (unit != null)
- {
- float dist = CMath.getDistance(this.mUnit.X, this.mUnit.Y, unit.X, unit.Y);
-
- if (dist <= XmdsConfig.Instance.SHARED_AWARD_MAX_RANGE)
- {
- this.mHateSystem.AddSharedList(uuid);
- }
- }
- }
- }
- }
- #endregion
- #region SummonUnit.
- private List<XmdsVirtual> mSummonList = new List<XmdsVirtual>();
- public void AddSummonUnitList(XmdsVirtual unit)
- {
- mSummonList.Add(unit);
- unit.mUnit.OnDead += MUnit_OnDead;
- }
- private void MUnit_OnDead(CommonAI.Zone.Instance.InstanceUnit unit, CommonAI.Zone.Instance.InstanceUnit attacker)
- {
- XmdsVirtual v = unit.Virtual as XmdsVirtual;
- if (v != null && mSummonList != null)
- {
- unit.OnDead -= MUnit_OnDead;
- mSummonList.Remove(v);
- }
- }
- public int GetSummonUnitListCount()
- {
- return mSummonList.Count;
- }
- public XmdsVirtual GetFirstTimesupSummonUnit()
- {
- if (mSummonList.Count > 0)
- {
- return mSummonList[0];
- }
- return null;
- }
- public List<XmdsVirtual> GetSummonUnits()
- {
- return mSummonList;
- }
- public void CleanSummonList()
- {
- if (mSummonList != null && mSummonList.Count > 0)
- {
- for (int i = 0; i < mSummonList.Count; i++)
- {
- mSummonList[i].mUnit.OnDead -= MUnit_OnDead;
- mSummonList[i].mUnit.kill(null, false);
- }
- mSummonList.Clear();
- }
- }
- #endregion
- #region 单位能力读取加载.
-
- protected void InitMonsterData2(string _sceneType, int templateID, bool pointLv)
- {
-
- String ss = _sceneType;
- if (ss == XLSMonsterDataLoader.DUNGEONHERO || ss == XLSMonsterDataLoader.DUNGEONELITE)
- ss = XLSMonsterDataLoader.DUNGEONNORMAL;
- MonsterData ma = XmdsDataMgr.GetInstance().GetMonsterData(ss, templateID, null, false);
-
- MonsterVisibleDataB2C edata = new MonsterVisibleDataB2C();
- if (ma == null)
- {
- edata.MonsterID = templateID;
- edata.DisplayName = string.Format("Cfg Err id={0}", templateID);
- edata.AttackType = MonsterVisibleDataB2C.MonsterAttackType.Passive;
- edata.Atype = MonsterVisibleDataB2C.MonsterAtype.Monster;
- edata.MType = MonsterVisibleDataB2C.MonsterType.MType0;
- edata.Qcolor = MonsterVisibleDataB2C.MonsterQcolor.Q0;
- edata.hpPlies = (byte)ParseInt(mUnit.Info.UserTag, 1);
- mUnit.SetVisibleInfo(edata);
- return;
- }
- XmdsUnitProp ret = (XmdsUnitProp)mProp.ServerData.Prop;
-
- if (ma.FateType == UnitFateType.Random)
- {
- ret.fateType = (UnitFateType)(this.mUnit.RandomN.Next() % (int)UnitFateType.Five + 1);
- }
- else
- {
- ret.fateType = ma.FateType;
- }
- XmdsServerScene scene = this.mUnit.Parent as XmdsServerScene;
- SceneType sceneType = this.mUnit.GetSceneType();
- int lvl_monster = pointLv ? this.mUnit.Level : ma.Level;
- this.skillType = (byte)ma.SkillType;
- int floor = 1;
- TowerMonsterRatio tmr = null;
- if (sceneType == SceneType.HaoYueJing || sceneType == SceneType.PickLotus)
- {
-
- IEnumerable<InstancePlayer> players = scene.AllPlayers;
- int level = 0;
- foreach (InstancePlayer player in players)
- {
- level += player.Level;
- }
- if (scene.AllPlayersCount == 0)
- {
-
- lvl_monster = 1;
- }
- else
- {
- level = level / scene.AllPlayersCount;
-
- lvl_monster += level;
- }
- }
- else if (sceneType == SceneType.GoblinTower)
- {
- floor = (int)scene.Data.MonsterAddPropPercentWithFloor;
- const int MAX_FLOOR = 80;
- if (floor < 1)
- floor = 1;
- if (floor > MAX_FLOOR)
- floor = MAX_FLOOR;
- tmr = XmdsDataMgr.GetInstance().GetTowerMonsterRatio(floor);
- lvl_monster = tmr.TowMon_Lv;
- }
- else if (sceneType == SceneType.AbyssDungeon)
- {
- floor = (int)scene.Data.MonsterAddPropPercentWithFloor;
- const int MAX_FLOOR = 80;
- if (floor < 1)
- floor = 1;
- if (floor > MAX_FLOOR)
- floor = MAX_FLOOR;
- tmr = XmdsDataMgr.GetInstance().GetAbyssMonsterRatio(floor);
- lvl_monster = tmr.TowMon_Lv;
- }
- else if (sceneType == SceneType.SourceDungeon)
- {
-
- }
- else if (sceneType == SceneType.GuildBoss || sceneType == SceneType.SHI_MEN_POS)
- {
- if (scene.Data.DefaultUnitLevel > 1)
- {
- lvl_monster = (int)scene.Data.DefaultUnitLevel;
- }
- }
- this.mUnit.Level = lvl_monster;
- this.mProp.ServerData.BaseInfo.UnitLv = lvl_monster;
-
- int upLv = lvl_monster - 70;
- if (upLv > 0)
- {
- this.mProp.ServerData.BaseInfo.StateLv = (byte)(upLv / 10);
- }
- else
- {
- this.mProp.ServerData.BaseInfo.StateLv = 0;
- }
- if (ma.Fight_Type == 1)
- {
- MonsterProp prop = XmdsDataMgr.GetInstance().GetSingleMonsterProp(lvl_monster, ma.Type);
- initProp(prop, ma, ret);
- }
- else if (ma.Fight_Type == 2)
- {
- MonsterProp prop = XmdsDataMgr.GetInstance().GetMultipleMonsterProp(lvl_monster, ma.Type);
- initProp(prop, ma, ret);
- }
- else if (ma.Fight_Type == 4)
- {
- lvl_monster = ma.Level;
- MonsterProp prop = XmdsDataMgr.GetInstance().GetSingleMonsterProp(lvl_monster, ma.Type);
- initProp(prop, ma, ret);
- }
- else
- {
- OrigData oData = XmdsDataMgr.GetInstance().GetOrigData(lvl_monster);
- UserDefineConfig udc = XmdsDataMgr.GetInstance().GetUserDefineConfig(ma.Type);
- initProp2(ma, oData, udc, ret);
- }
- ret.BaseMaxHP = (int)(ret.BaseMaxHP * XmdsDataMgr.GetInstance().mMonsterDynamicLoader.Mon_Hp_Ratio);
- ret.BaseAttack = (int)(ret.BaseAttack * XmdsDataMgr.GetInstance().mMonsterDynamicLoader.Mon_Atk_Ratio);
- restoreMa2Ret(ret, ma);
-
- if (sceneType == SceneType.GoblinTower && tmr != null)
- {
- dynamicCalcBy(ret,
- tmr.TowMon_Hp_Ratio,
- tmr.TowMon_Atk_Ratio,
- tmr.TowMon_Def_Ratio,
- tmr.TowMon_Crit_Ratio,
- tmr.TowMon_CritDamage_Ratio,
- tmr.TowMon_IgnoreDef_Ratio);
- }
- else if (sceneType == SceneType.AbyssDungeon && tmr != null)
- {
- float extRate = 1.0F;
- if (scene.Data.isTeam)
- {
- AbyssMutilAddition abyssAddition = XmdsDataMgr.GetInstance().GetAbyssMutilAddition();
- tmr.TowMon_Atk_Ratio *= abyssAddition.AttackAddition;
- tmr.TowMon_Def_Ratio *= abyssAddition.DefenceAddition;
- tmr.TowMon_Hp_Ratio *= abyssAddition.HPAddition;
- }
- dynamicCalcBy(ret,
- tmr.TowMon_Hp_Ratio * extRate,
- tmr.TowMon_Atk_Ratio * extRate,
- tmr.TowMon_Def_Ratio * extRate,
- tmr.TowMon_Crit_Ratio * extRate,
- tmr.TowMon_CritDamage_Ratio * extRate,
- tmr.TowMon_IgnoreDef_Ratio * extRate);
- }
- if (sceneType == SceneType.GuildBoss)
- {
- GuildBossRatio gbr = XmdsDataMgr.GetInstance().GetGuildBossRatio(lvl_monster);
- if (gbr != null)
- {
- dynamicCalcBy(ret,
- gbr.GBoss_Hp_Ratio,
- gbr.GBoss_Atk_Ratio,
- gbr.GBoss_Def_Ratio,
- gbr.GBoss_Crit_Ratio,
- gbr.GBoss_CritDamage_Ratio,
- gbr.GBoss_IgnoreDef_Ratio);
- }
- }
- if (_sceneType == XLSMonsterDataLoader.DUNGEONELITE)
- {
- ma = XmdsDataMgr.GetInstance().GetMonsterData(_sceneType, templateID, null, true);
- DungeonMonsterRatio dmr = XmdsDataMgr.GetInstance().mMonsterDynamicLoader.GetDungeonMonsterRatio(ma.Type);
- dynamicCalcBy(ret,
- dmr.Normal_Hp_Ratio,
- dmr.Normal_Atk_Ratio,
- dmr.Normal_Def_Ratio,
- dmr.Normal_DM_Ratio,
- dmr.Normal_DM_Ratio,
- dmr.Normal_DM_Ratio);
- restoreMa2Ret(ret, ma);
- }
- if (_sceneType == XLSMonsterDataLoader.DUNGEONHERO)
- {
- ma = XmdsDataMgr.GetInstance().GetMonsterData(_sceneType, templateID, null, true);
- DungeonMonsterRatio dmr = XmdsDataMgr.GetInstance().mMonsterDynamicLoader.GetDungeonMonsterRatio(ma.Type);
- dynamicCalcBy(ret,
- dmr.Hard_Hp_Ratio,
- dmr.Hard_Atk_Ratio,
- dmr.Hard_Def_Ratio,
- dmr.Hard_DM_Ratio,
- dmr.Hard_DM_Ratio,
- dmr.Hard_DM_Ratio);
- restoreMa2Ret(ret, ma);
- }
- ret.HP = ret.BaseMaxHP;
- XmdsInstanceMonster unit = this.mUnit as XmdsInstanceMonster;
- if (unit != null)
- {
- unit.MonsterID = ma.ID;
-
- if (ma.isAttack == 0)
- {
- this.mUnit.Info.GuardRange = 0;
- this.mUnit.Info.GuardRangeGroup = 0;
- }
- }
- edata.SenceType = GetCurSceneType();
- edata.MonsterID = ma.ID;
- edata.DisplayName = ma.Name;
- edata.Title = ma.Title;
- edata.Qcolor = (MonsterVisibleDataB2C.MonsterQcolor)ma.Qcolor;
- edata.AttackType = (MonsterVisibleDataB2C.MonsterAttackType)ma.isAttack;
- edata.Atype = (MonsterVisibleDataB2C.MonsterAtype)ma.Atype;
- edata.MType = (MonsterVisibleDataB2C.MonsterType)ma.Type;
- edata.hpPlies = (byte)ParseInt(mUnit.Info.UserTag, 1);
- this.mProp.ServerData.BaseInfo.name = ma.Name;
-
- if (!string.IsNullOrEmpty(ma.DialogWords))
- {
- mDialogWords = ma.DialogWords.Split('|');
- mDialogWordRate = ma.DialogChance;
- }
-
- if (!string.IsNullOrEmpty(ma.DeadDialogWords))
- {
- mDeadDialogWords = ma.DeadDialogWords.Split('|');
- mDeadDialogWordRate = ma.DeadDialogChance;
- }
- mIsShare = ma.ShareType == 1;
- this.mMonsterType = ma.Type;
- this.mIsLvRepress = (ma.LvRepress == 1) && (this.mMonsterType == (byte)MonsterVisibleDataB2C.MonsterType.MType6);
-
- if (ma.Type >= (byte)MonsterVisibleDataB2C.MonsterType.MType4)
- {
- InitBossAbilities();
- }
-
- if (ma.AbilityList != null && mProp != null)
- {
-
- mAbilityList = new List<int>(ma.AbilityList);
- }
-
- if (ret.AttackSpeed <= 0)
- {
- ret.AttackSpeed = GlobalData.DEFAULT_ATTACK_SPEED;
- }
-
- ret.ShieldValue = ma.MPValue;
- mUnit.SetVisibleInfo(edata);
-
- if (ret.MaxHP <= 0 || ret.MaxAttack <= 0 || ret.Defence <= 0)
- {
- log.Error("怪物属性错误:" + this.mUnit.Parent.GetSceneID() + ", " + this.mUnit.Info.ID + ", 生命:" + ret.MaxHP +
- ", 攻击:" + ret.MaxAttack + ", 防御:" + ret.Defence);
- }
- else if(this.IsBoss() || ret.MaxHP > 500000 || ret.MaxAttack > 10000)
- {
- log.Info("场景:" + this.mUnit.Parent.GetSceneID() + ", ID: " + templateID + ", " + this.mUnit.Parent.UUID + ", UID: " + this.mUnit.ID + ", 等级: " + lvl_monster
- + ", 战斗规模:" + ma.Fight_Type + ",(攻-" + ret.BaseAttack + ", 防-" + ret.BaseDefence + ", 血-" + ret.BaseMaxHP + ", 爆-" + ret.CritRate
- + ", 爆伤-" + ret.CritDamage + ", 穿透-" + ret.IgnoreDefensePer + ")");
- }
- }
- private void randomMonsterSkillInfo(int monsterId, int skillType)
- {
- MonsterSkills skillInfo = XmdsDataMgr.GetInstance().GetMonsterSkillInfo(monsterId);
- if (skillInfo == null)
- {
-
- skillInfo = XmdsDataMgr.GetInstance().GetMonsterSkillInfo();
- if(skillInfo == null)
- {
- return;
- }
- }
- if(this.mProp.ServerData.Skills == null)
- {
- this.mProp.ServerData.Skills = new XmdsUnitSkillInfo();
- }
-
-
-
-
-
- if ((skillType & (int)MonsterRandomSkillType.OnlyActive) > 0)
- {
-
- if (this.mUnit.RandomN.Next(10000) < skillInfo.Skill1Probability)
- {
- XmdsSkillData activeSkill = XmdsDataMgr.GetInstance().GetBossRandomActiveSkill(this.mUnit.RandomN);
-
- if (activeSkill != null)
- {
- this.mProp.ServerData.Skills.UnitSkills.Add(new GameSkill(activeSkill.SkillID, XmdsSkillType.active));
-
- }
- }
- }
- if ((skillType & (int)MonsterRandomSkillType.OnlyPassive) > 0)
- {
- int[] nArray = { skillInfo.Skill2Probability, skillInfo.Skill3Probability, skillInfo.Skill4Probability };
- XmdsSkillData[] passiveSkills = new XmdsSkillData[3];
- int passiveIndex = 0;
- for (int i = 0; i < nArray.Length; i++)
- {
- if (nArray[i] > 0 && this.mUnit.RandomN.Next(10000) < nArray[i] && (passiveSkills[passiveIndex] =
- XmdsDataMgr.GetInstance().GetBossRandomPassiveSkill(this.mUnit.RandomN, passiveSkills)) != null)
- {
- passiveIndex++;
- }
- }
-
- for (int i = 0; i < passiveIndex; i++)
- {
- this.mProp.ServerData.Skills.UnitSkills.Add(new GameSkill(passiveSkills[i].SkillID, XmdsSkillType.passive));
-
- }
- }
- }
-
-
-
- protected void RandomDialogWords()
- {
- if (mDialogWords != null && mDialogWords.Length > 0 && mDialogWordRate > 0)
- {
- int v = this.mUnit.RandomN.Next(0, 100);
-
- if (v <= mDialogWordRate)
- {
-
- v = this.mUnit.RandomN.Next(0, mDialogWords.Length);
- SendBubbleTipsEventB2C(mDialogWords[v]);
- }
- }
- }
-
-
-
- protected void RandomDeadDialogWords()
- {
- if (mDeadDialogWords != null && mDeadDialogWords.Length > 0 && mDeadDialogWordRate > 0)
- {
- int v = this.mUnit.RandomN.Next(0, 100);
-
- if (v <= mDeadDialogWordRate)
- {
-
- v = this.mUnit.RandomN.Next(0, mDeadDialogWords.Length);
- SendBubbleTipsEventB2C(mDeadDialogWords[v]);
- }
- }
- }
-
-
-
-
- private void InitAbilityList(List<int> list)
- {
- GameSkill gs = null;
- List<GameSkill> mlist = new List<GameSkill>();
- for (int i = 0; i < list.Count; i++)
- {
- gs = new GameSkill();
- gs.SkillID = list[i];
- gs.SkillType = XmdsSkillType.passive;
- mlist.Add(gs);
- }
- this.SkillHelper.AddSkill(mlist);
- }
- public override InstanceUnit GetAtkTarget(InstanceUnit target)
- {
- if(mBindAttakPlayer != null)
- {
- if (mBindAttakPlayer.IsActive)
- {
- return mBindAttakPlayer;
- }
-
- this.mUnit.kill();
- }
- else
- {
- string bindAttackPlayerId = this.mUnit.GetAttackPlayer();
- if (bindAttackPlayerId != null)
- {
- mBindAttakPlayer = this.mUnit.Parent.getPlayerByUUID(bindAttackPlayerId);
- if(mBindAttakPlayer == null)
- {
- log.Warn("GetAtkTarget有攻击目标玩家找不到:" + this.mUnit.Info.ID + ", " + mBindAttakPlayer);
- this.mUnit.BindAttackPlayer(null);
- this.mUnit.kill();
- }
- else
- {
- return mBindAttakPlayer;
- }
- }
- }
-
- return base.GetAtkTarget(target);
- }
- #endregion
- #region BOSS能力.
- private void InitBossAbilities()
- {
- mIsBoss = true;
- GameSkill gs = new GameSkill();
- gs.SkillID = 0;
- this.RegistTryAddBuffEvent(OnTryAddBuffEvent, gs);
- }
- private void UnInitBossAbilities()
- {
- if (mIsBoss)
- {
-
- }
- }
- private bool OnTryAddBuffEvent(ref BuffTemplate buff, XmdsVirtual attacker, XmdsVirtual hitter, GameSkill skill)
- {
-
- if (!buff.forceAdd && buff.IsHarmful && XmdsInstanceUtils.IsControlBuff_Monster(buff))
- {
- return false;
- }
- return true;
- }
- private void OnBossHit(XmdsVirtual attacker, ref AttackSource source)
- {
- if (mIsBoss)
- {
- if (source.OutIsDamage == true && this.mUnit.CurrentState is InstanceUnit.StateSkill)
- {
- this.mUnit.SetStunTimeMS(0);
- }
- source.OutIsDamage = false;
- }
- }
- private void OnDamageInfoCheck(XmdsVirtual attacker, ref AttackSource source, int damage)
- {
- if (mIsBoss)
- {
- var player = attacker.GetPlayerUnit();
- AddDamageInfo(player, damage);
- }
- }
- private void AddDamageInfo(XmdsVirtual_Player attacker, int damage)
- {
-
- if (attacker == null || attacker.mUnit.IsActive == false)
- {
- return;
- }
- if (mSufferDamageInfo == null)
- {
- mSufferDamageInfo = new HashMap<string, PlayerDamageInfo>();
- }
- PlayerDamageInfo info = null;
- string uuid = attacker.GetPlayerUUID();
- if (string.IsNullOrEmpty(uuid) == false)
- {
- if (mSufferDamageInfo.TryGetValue(uuid, out info))
- {
- info.Damage += damage;
- info.PlayerInfo = attacker.mProp.ServerData.BaseInfo;
- }
- else
- {
- info = new PlayerDamageInfo();
- info.Damage += damage;
- info.PlayerInfo = attacker.mProp.ServerData.BaseInfo;
- info.PlayerUUID = uuid;
- mSufferDamageInfo.Add(uuid, info);
- }
- }
- }
- private void CleanDamageInfo()
- {
- if (mSufferDamageInfo != null)
- {
- mSufferDamageInfo.Clear();
- }
- }
- private void DisposeDamageInfo()
- {
- CleanDamageInfo();
- }
-
-
-
-
- public HashMap<string, PlayerDamageInfo> GetSufferDamage()
- {
- return mSufferDamageInfo;
- }
- public override int GetMaType()
- {
- return this.mMonsterType;
- }
- public override bool IsLvRepress()
- {
- return this.mIsLvRepress;
- }
- public override bool IsBoss()
- {
- return this.mIsBoss;
- }
- #endregion
- }
- }
|