JSGXmdsHackerModule.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using CommonAI.Zone.Formula;
  2. using CommonAI.Zone.Helper;
  3. using CommonAI.Zone.Instance;
  4. using CommonAI.ZoneServer.JSGModule;
  5. using CommonLang;
  6. using CommonLang.Log;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using XmdsCommon.Plugin;
  14. using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
  15. using static CommonAI.ZoneClient.ClientStruct;
  16. using static XmdsCommonServer.Plugin.XmdsVirtual;
  17. namespace XmdsCommonServer.Plugin.JSGXmdsModule
  18. {
  19. public class JSGXmdsHackerModule
  20. {
  21. #if JSGProfile
  22. protected static readonly Logger log = LoggerFactory.GetLogger("JSGXmdsHackerModule");
  23. /** 玩家击杀怪物 */
  24. public static void OnPlayerKillMonster(InstancePlayer attacker, InstanceUnit monster)
  25. {
  26. //玩家属性打印
  27. XmdsVirtual playerVir = (attacker.Virtual as XmdsVirtual);
  28. XmdsUnitProp CurProp = playerVir.MirrorProp;
  29. XmdsUnitProp oldProp = playerVir.GetOriginProp();
  30. log.Info("ID:" + attacker.PlayerUUID + ", 所在场景:" + attacker.Parent.GetSceneID());
  31. log.Info(", 当前血:" + attacker.CurrentHP + ",基础:" + oldProp.MaxAttack + ", " + oldProp.Defence + ", " + oldProp.MaxHP
  32. + ", 攻防血" + CurProp.MaxAttack + ", " + CurProp.Defence + ", " + CurProp.MaxHP + ", 妖:" + CurProp.monsterAtk + ", " + CurProp.monsterDef
  33. + ", 妖比:" + CurProp.monsterAtkPer + ", " + CurProp.monsterDefPer);
  34. log.Info("扩展属性1, 增减伤:" + CurProp.AllDmgAdd + ", " + CurProp.AllDmgReduce + ", 玩家增减伤:" + CurProp.PlayerDamageAdd + ", " + CurProp.PlayerDamageReduce
  35. + ", 神器伤:" + CurProp.ArtifactMainPer + ", boss伤害:" + CurProp.ToBossCritRate + ", " + CurProp.ToBossCritDamage + ", 杀意:" + CurProp.KillValuePer
  36. + ", 吸血" + CurProp.NormalAtkLeech + ", " + CurProp.ActiveAtkLeech + ", 怪伤害:" + CurProp.monsterDamageAdd + ", " + CurProp.monsterDamageReduce);
  37. log.Info("扩展属性1, 暴击率:" + CurProp.CritRate + ", 爆伤:" + CurProp.CritDamage + ", 回血:" + CurProp.MaxHPReborn + ", 韧性:" + CurProp.CtrlTimeReduce
  38. + ", CD缩减:" + CurProp.SkillCD + ", 治疗效果:" + CurProp.HealEffect + ", " + CurProp.HealedEffect + ", 移攻速:" + CurProp.MoveSpeed + ", " + CurProp.AttackSpeed + ", 技伤:" + CurProp.SkillDamageAdd);
  39. UnitBuffStatus[] buffStatus = attacker.GetCurrentBuffStatus();
  40. if (buffStatus != null)
  41. {
  42. foreach (UnitBuffStatus buffItem in buffStatus)
  43. {
  44. log.Info("玩家buff:" + buffItem.ToString());
  45. }
  46. }
  47. //检测基本属性是否有异常的,打印一下
  48. float rate1 = oldProp.MaxAttack == 0 ? 1 : (float)(CurProp.MaxAttack) / oldProp.MaxAttack;
  49. float rate2 = oldProp.Defence == 0 ? 1 : CurProp.Defence / oldProp.Defence;
  50. float rate3 = oldProp.MaxHP == 0 ? 1 : CurProp.MaxHP / oldProp.MaxHP;
  51. if (rate1 > 1.2f || rate2 > 1.2f || rate3 > 1.2f)
  52. {
  53. HashMap<int, PropChangeOperation> playerProps = playerVir.GetChangePropMap();
  54. foreach (PropChangeOperation chgProp in playerProps.Values)
  55. {
  56. log.Info("玩家变更属性:" + chgProp.ToString());
  57. }
  58. }
  59. else
  60. {
  61. log.Info("无特别异常属性!");
  62. }
  63. }
  64. /** 玩家伤害监测输出 */
  65. public static void CheckAndPrintDamageLog(int damageBaseValue, XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, int damage,
  66. double DefCoef, float allDmgChgFinal, float monsterDmgChgFinal, float playerDmgChgFinal, float artifaceDmgChgFinal, float monsterAtkPer)
  67. {
  68. #if JSGProfile
  69. try
  70. {
  71. do
  72. {
  73. if (damageBaseValue > 50 && (damage <= 1 || damage > 20000))
  74. {
  75. //如果基础防御或者伤害过高,就是测试号了
  76. XmdsUnitProp attckOriginProp = attacker.GetOriginProp();
  77. if (hitter.MirrorProp.Defence > 0 && attckOriginProp.Defence /hitter.MirrorProp.Defence > 10)
  78. {
  79. break;
  80. }
  81. int finalAttack = attacker.MirrorProp.GetFinalAttack(hitter.mUnit.IsMonster);
  82. if (finalAttack <= 0)
  83. {
  84. log.Warn("攻击者最大攻击属性异常:" + attacker.mUnit.Parent.GetSceneID() + ", " + finalAttack);
  85. }
  86. else if(damage * 1.0f / finalAttack < GetDamageWarnRate(source))
  87. {
  88. break;
  89. }
  90. XmdsVirtual.FormatLog(LoggerLevel.WARNNING, "伤害异常 : {0}->{1}, ID:{2}-{3},{4}-{5},基础攻击:{6}", damageBaseValue, damage, attacker.mInfo.ID,
  91. attacker.mInfo.Name, hitter.mInfo.ID, hitter.mInfo.Name, finalAttack);
  92. XmdsVirtual.FormatLog(LoggerLevel.WARNNING, "--伤害信息 : {0}, {1}, {2}, {3}, {4}, {5}, {6}",(float)(1.0f- DefCoef), allDmgChgFinal,
  93. monsterDmgChgFinal, playerDmgChgFinal, artifaceDmgChgFinal, monsterAtkPer, JSGModule.GetAttackSourceDes(source));
  94. //XmdsVirtual.FormatLog(LoggerLevel.ERROR, "3. 伤害异常受击防御 : {0},攻击穿透:{1},防御系数:{2},杀意信息:{3},{4}",
  95. // hitter.MirrorProp.Defence, attacker.MirrorProp.IgnoreDefensePer, GetDefenceAddition(hitter.GetStateLv()),
  96. // hitter.MirrorProp.KillValuePer, attacker.MirrorProp.KillValuePer);
  97. }
  98. } while (false);
  99. }
  100. catch (Exception e)
  101. {
  102. log.Error("JSGXmdsHackerModule PrintDamageInfo catch: " + e);
  103. }
  104. #endif
  105. }
  106. /** 玩家伤害监测输出 */
  107. public static void PrintAttrErrorInfo(XmdsVirtual unit, UnitAttributeType Type, int value1, int value2)
  108. {
  109. #if JSGProfile
  110. try
  111. {
  112. bool needPrint = false;
  113. switch (Type)
  114. {
  115. case UnitAttributeType.Defence:
  116. needPrint = value1 > value2 * 4;
  117. break;
  118. case UnitAttributeType.MaxHP:
  119. needPrint = value1 > value2 * 1.5;
  120. break;
  121. default:
  122. needPrint = value1 > 10000;
  123. break;
  124. }
  125. if (needPrint)
  126. {
  127. string stackInfo = new StackTrace().ToString();
  128. XmdsVirtual.FormatLog(LoggerLevel.ERROR, "属性异常异常 : UID:{0}, {1}, {2}, {3}, {4}", unit.mUnit.PlayerUUID, Type, value1, value2, stackInfo);
  129. }
  130. }
  131. catch (Exception e)
  132. {
  133. XmdsVirtual.FormatLog(LoggerLevel.ERROR, "PrintAttrErrorInfo异常:" + Type + ", " + value1 + ", " + value2 + ", " + e);
  134. }
  135. #endif
  136. }
  137. public static bool CheckAndPrintDmgWarn(string flag, XmdsVirtual attacker, XmdsVirtual hitter, float sourceDmg, float finalDmg, AttackSource source)
  138. {
  139. #if JSGProfile
  140. try
  141. {
  142. if (source == null || source.Attack == null || source.Attack.Properties.GetAttackID() == XmdsBattleSkill.DefaultSkillScriptID)
  143. {
  144. return false;
  145. }
  146. int checkValue = (source != null && source.Attack != null && source.Attack.Properties.GetAttackID() / 100 == 1104)
  147. ? attacker.mUnit.CurrentHP : attacker.MirrorProp.GetFinalAttack(hitter == null ? false : hitter.mUnit.IsMonster);
  148. if (finalDmg / sourceDmg > GetDamageWarnRate(source) || finalDmg / checkValue > 60)
  149. {
  150. log.Warn(flag + ", dmg: " + (int)finalDmg + ", src: " + (int)sourceDmg + ", attackerAtk: " + attacker.MirrorProp.MaxAttack + ", "
  151. + attacker.MirrorProp.MaxMonsterAttack + ", atkHP:" + attacker.mUnit.CurrentHP
  152. + ", AttackInfo:[" + attacker.mUnit.Info.ID + ", UUID: " + attacker.mUnit.PlayerUUID
  153. + "], hitterInfo:[" + hitter.mUnit.Info.ID + ", UUID: " + hitter.mUnit.PlayerUUID + ", " + JSGModule.GetAttackSourceDes(source));
  154. return true;
  155. }
  156. }
  157. catch (Exception e)
  158. {
  159. log.Error("CheckAndPrintDmgWarn catch: ", e);
  160. }
  161. return false;
  162. #endif
  163. }
  164. /** 获得伤害倍率警告阈值 */
  165. private static float GetDamageWarnRate(AttackSource source)
  166. {
  167. float dmgAddition = 0;
  168. float dmgBase = 3.0f;
  169. if(source != null)
  170. {
  171. if(source.FromSkillType == XmdsSkillType.cardSkill)
  172. {
  173. dmgBase = 5.0f;
  174. }
  175. else
  176. {
  177. dmgAddition = source.mDmgAddPer + 3;
  178. }
  179. }
  180. return dmgAddition + dmgBase;
  181. }
  182. /** 卡牌系统,输出卡牌数量异常日志 */
  183. public static void CheckAndPrintCardSameErrorInfo(string tag, int cardSames, long ltime, AttackSource source)
  184. {
  185. #if JSGProfile
  186. if (cardSames <= 1)
  187. {
  188. log.Warn("触发卡牌数量异常:" + tag + ", " + ltime + ", " + JSGModule.GetAttackSourceDes(source));
  189. }
  190. #endif
  191. }
  192. #endif
  193. }
  194. }