JSGHackerModule.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using CommonAI.Data;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.Formula;
  4. using CommonAI.Zone.Helper;
  5. using CommonAI.Zone.Instance;
  6. using CommonLang.Log;
  7. using CommonLang.Vector;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Diagnostics;
  11. using System.Linq;
  12. using System.Text;
  13. using static CommonAI.ZoneClient.ClientStruct;
  14. //using System.Threading.Tasks;
  15. namespace CommonAI.ZoneServer.JSGModule
  16. {
  17. public class JSGHackerModule
  18. {
  19. protected static readonly Logger log = LoggerFactory.GetLogger("JSGHackerModule");
  20. public static void OnPlayerKillMonster(InstanceUnit attacker, InstanceUnit monster)
  21. {
  22. #if JSGProfile
  23. try
  24. {
  25. InstancePlayer player = (InstancePlayer)(attacker.IsPlayer ? attacker : attacker.Virtual.GetMasterUnit());
  26. if (player == null)
  27. {
  28. log.Info("OnPlayerKillMonster player not exist:" + attacker.Parent.GetSceneID() + ", mID:" + monster.Info.ID + ", PID: " + attacker.PlayerUUID);
  29. return;
  30. }
  31. player.Virtual.OnPlayerKillMonster(monster);
  32. }
  33. catch (Exception e)
  34. {
  35. log.Warn("CI OnPlayerKillMonster catch:", e);
  36. }
  37. #endif
  38. }
  39. public static void PrintDmgInfo(InstanceUnit unit, InstanceUnit sender, AttackSource source, int hp, int finalHP)
  40. {
  41. #if JSGProfile
  42. try
  43. {
  44. if (!unit.IsPlayer){ return;}
  45. int atkPropID = (source == null || source.Attack == null || source.Attack.Properties == null) ? 0 : source.Attack.Properties.GetAttackID();
  46. if (atkPropID != 9999901 && (finalHP < -100000000 || finalHP > 100000000) && !(unit.IsMonster && hp == unit.MaxHP))
  47. {
  48. string stackInfo = new StackTrace().ToString();
  49. log.Error("伤害异常: " + finalHP + ", ID" + unit.Info.ID + ", " + (sender == null ? "-1" : sender.PlayerUUID)
  50. + JSGModule.GetAttackSourceDes(source) + ", " + stackInfo);
  51. }
  52. }
  53. catch (Exception e)
  54. {
  55. log.Warn("JSGHackerModule PrintDmgInfo:", e);
  56. }
  57. #endif
  58. }
  59. }
  60. }