123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- using CommonAI.Data;
- using CommonAI.Zone;
- using CommonAI.Zone.Formula;
- using CommonAI.ZoneServer.JSGModule;
- using CommonLang;
- using NPOI.SS.Formula;
- using System;
- using System.Collections.Generic;
- using XmdsCommon.Message;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin.Scene;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
- using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
- using XmdsCommonServer.XLS;
- using XmdsCommonServer.XLS.Data;
- namespace XmdsCommonServer.Plugin
- {
-
-
-
-
-
-
-
- partial class XmdsVirtual
- {
-
-
-
- public enum UnitHitEventState
- {
- Normal = 0,
- Crit = 1,
- Dodge = 2,
- Parry = 3,
- Absorb = 4,
- Immunity = 5,
- IronMaiden = 6,
- MP = 7,
- KillMonsterCrit = 8,
- }
-
-
-
- public enum AttackRlt : int
- {
- NoControl = -1,
- NormalAttack,
- CritAttack,
- ParryAttack,
- }
-
- private int On_hit_unit_vs_unit(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, ref AtkResult result)
- {
- source.OutClientState = (int)UnitHitEventState.Normal;
-
- bool isSkill = source.FromBuffState == null ? true : false;
- int damage = 0;
-
- if (isSkill == false)
- {
- BuffTemplate template = source.FromBuffState.Data;
-
- List<XmdsBuffVirtual> list = source.FromBuffState.Tag as List<XmdsBuffVirtual>;
- if (list != null)
- {
- for (int i = 0; i < list.Count; i++)
- {
- UnitBuff ub = list[i] as UnitBuff;
- damage += ub.BuffHit(hitter, attacker, source, ref result);
- }
- }
-
- damage = (int)hitter.DispatchHitDamageEvent(damage, attacker, source,ref result, template.IsHarmful ? DamageType.Damage : DamageType.Heal);
- }
- else
- {
-
- damage = CalDamage(attacker, hitter, source, ref result);
- }
- damage += source.Attack.Attack;
-
- switch (source.OutClientState)
- {
- case (int)UnitHitEventState.Dodge:
-
- XmdsAttackProperties prop = (source.Attack.Properties as XmdsAttackProperties);
- FormatLog("{0}对目标{1}使用技能【{2}】被目标【闪避】", attacker.mInfo.Name, hitter.mInfo.Name, prop.SkillTemplateID);
- damage = 0;
- break;
- case (int)UnitHitEventState.Crit:
-
- FormatLog("【{0}】攻击【{1}】结果 =【{2}】,伤害 =【{3}】", attacker.mInfo.Name, hitter.mInfo.Name, "暴击", damage);
- break;
- case (int)UnitHitEventState.Normal:
-
- FormatLog("【{0}】攻击【{1}】结果 =【{2}】,伤害 =【{3}】", attacker.mInfo.Name, hitter.mInfo.Name, "普攻", damage);
- break;
- case (int)UnitHitEventState.Immunity:
-
- FormatLog("【{0}】攻击【{1}】结果 =【{2}】,伤害 =【{3}】", attacker.mInfo.Name, hitter.mInfo.Name, "免疫", damage);
- break;
- case (int)UnitHitEventState.Absorb:
-
- FormatLog("【{0}】攻击【{1}】结果 =【{2}】,伤害 =【{3}】", attacker.mInfo.Name, hitter.mInfo.Name, "吸收", damage);
- break;
- case (int)UnitHitEventState.IronMaiden:
-
- FormatLog("【{0}】攻击【{1}】结果 =【{2}】,伤害 =【{3}】", attacker.mInfo.Name, hitter.mInfo.Name, "反伤", damage);
- break;
- default:
- break;
- }
- if (damage == 0)
- {
-
-
- }
- else
- {
- hitter.mUnit.mLastDamageTime = CommonLang.CUtils.localTimeMS;
- attacker.mUnit.mLastHitOtherTime = CommonLang.CUtils.localTimeMS;
- }
- return damage;
- }
-
-
-
-
-
-
-
- public void DispatchHitEvents(ref int damage, XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType)
- {
-
- damage = (int)attacker.DispatchHitOtherEvent(damage, hitter, source, ref result, damageType);
-
- damage = (int)hitter.DispatchHitDamageEvent(damage, attacker, source, ref result, damageType);
-
- attacker.mCardModule.OnHitOther(hitter, source);
- hitter.mCardModule.OnHitDamage(attacker, source);
- }
- private int CalDamage(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, ref AtkResult result)
- {
- int ret = 0;
-
- attacker.DispatchSkillDamageEvent(attacker, hitter, source);
- ret = attacker.DispatchCalDamageEvent(hitter, source, ref result);
- return ret;
- }
-
-
-
- public struct AtkResult
- {
-
-
-
-
- public int ThreatValue { get; set; }
-
-
-
- public int ThreatValueChangePer { get; set; }
-
-
-
- public int ThreatValueChangeModify { get; set; }
-
- public int breakShieldValue;
- }
- protected void dynamicCalcBy(XmdsUnitProp ret, float hp, float atk, float def, float crit, float CritDamage, float ignoreDef)
- {
- ret.BaseMaxHP = (int)(ret.BaseMaxHP * hp);
- ret.BaseAttack = (int)(ret.BaseAttack * atk);
- ret.BaseDefence = (int)(ret.BaseDefence * def);
- ret.CritRate = (int)(ret.CritRate * crit);
- ret.CritDamage = (int)(ret.CritDamage * CritDamage);
- ret.IgnoreDefensePer = (int)(ret.IgnoreDefensePer * ignoreDef);
- }
- protected void restoreMa2Ret(XmdsUnitProp ret, MonsterData ma)
- {
- if (ma.MaxHP != -1)
- {
- ret.BaseMaxHP = ma.MaxHP;
- }
- if (ma.MaxAttack != -1)
- {
- ret.BaseAttack = ma.MaxAttack;
- }
- if (ma.MaxDefence != -1)
- {
- ret.BaseDefence = ma.MaxDefence;
- }
- if (ma.CritRate != -1)
- {
- ret.CritRate = ma.CritRate;
- }
- if (ma.CritDamage != -1)
- {
- ret.CritDamage = ma.CritDamage;
- }
- if (ma.IgnoreDefencePer != -1)
- {
- ret.IgnoreDefensePer = ma.IgnoreDefencePer;
- }
- }
- protected void initProp(MonsterProp prop, MonsterData ma, XmdsUnitProp ret)
- {
- ret.BaseMaxHP = prop.MaxHP;
- ret.HP = prop.MaxHP;
- ret.BaseAttack = prop.Attack;
- ret.BaseDefence = prop.Def;
- ret.CritRate = prop.CritRate;
- ret.CritDamage = prop.CritDamage;
- ret.IgnoreDefensePer = prop.IgnoreDefensePer;
- this.mProp.ServerData.BaseInfo.UnitLv = prop.Mon_Level;
- this.mUnit.Level = prop.Mon_Level;
- }
- protected void initProp2(MonsterData ma, OrigData oData, UserDefineConfig udc, XmdsUnitProp ret)
- {
- UserDefineConfig config = XmdsDataMgr.GetInstance().mMonsterDynamicLoader.GetUserDefineConfig(ma.Type);
- float atkTemp = oData.Atk * config.Atk_Ratio;
- float defTemp = oData.Def * config.Def_Ratio;
- float hpTemp = oData.Hp * config.HP_Ratio;
- float critTemp = oData.CritRate * config.Crit_Ratio;
- float critDamageTemp = oData.CritDamage * config.CritDamage_Ratio;
- float ignoreDefTemp = oData.IgnoreDefensePer * config.IgnoreDef_Ratio;
-
- float drdaTemp1 = defTemp * (1 - ignoreDefTemp / XmdsDamageCalculator.PERER);
-
- float drdaTemp2 = (critTemp / XmdsDamageCalculator.PERER * critDamageTemp / XmdsDamageCalculator.PERER + 1
- - critTemp / XmdsDamageCalculator.PERER);
-
-
- float drda = 1 - (drdaTemp1 / (drdaTemp1 + XmdsDamageCalculator.GetDefByLevel(ma.Level)));
- ret.BaseMaxHP = (int)(ma.Fight_Count * ma.AliveTime * atkTemp * drda * drdaTemp2);
- float hpParma = ma.KillPlayerTime;
- ret.BaseAttack = (int)(hpParma == 0 ? hpTemp : (hpTemp / hpParma));
- ret.BaseDefence = (int)defTemp;
- ret.CritRate = (int)(critTemp);
- ret.CritDamage = (int)(critDamageTemp);
- ret.IgnoreDefensePer = (int)(ignoreDefTemp);
- }
- }
- }
|