CheckConfigModule.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using CommonAI.Zone;
  2. using CommonAI.Zone.ZoneEditor;
  3. using CommonLang;
  4. using CommonLang.Log;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using static CommonAI.Zone.LaunchSpell;
  11. using static CommonAI.Zone.SpellTemplate;
  12. using static CommonAI.Zone.UnitActionData;
  13. namespace xmds_battle_server.JSGModule
  14. {
  15. /**
  16. * 检测战斗服配置模块
  17. */
  18. class CheckConfigModule
  19. {
  20. public static Logger log = LoggerFactory.GetDefLogger();
  21. //检测技能攻击异常
  22. public static void CheckActiveSkillAttackRange(EditorTemplates Templates)
  23. {
  24. HashMap <int, SkillTemplate> skills = Templates.Templates.getAllSkillData();
  25. foreach(SkillTemplate skillItem in skills.Values)
  26. {
  27. foreach (UnitActionData skillAction in skillItem.ActionQueue)
  28. {
  29. if(skillAction.IsJumpToTarget) { continue; }
  30. foreach(UnitActionData.KeyFrame actionFrame in skillAction.KeyFrames)
  31. {
  32. if(actionFrame.Spell == null || actionFrame.Spell.SpellID <= 0 || actionFrame.Move != null ||
  33. (actionFrame.Spell.PType == PosType.POS_TYPE_RANDOM_FOR_SPELL || actionFrame.Spell.PType == PosType.POS_TYPE_RANDOM_POS))
  34. {
  35. continue;
  36. }
  37. SpellTemplate spellData = Templates.Templates.getSpell(actionFrame.Spell.SpellID);
  38. if (spellData == null)
  39. {
  40. log.Error("技能:" + skillItem.ID + "-" + skillItem.Name + ", 配置了不存在的法术:" + actionFrame.Spell.SpellID);
  41. continue;
  42. }
  43. if (!skillItem.IsLaunchBody)
  44. {
  45. continue;
  46. }
  47. CheckSpellRange(Templates, skillItem, spellData);
  48. }
  49. }
  50. }
  51. }
  52. private static bool CheckSpellRange(EditorTemplates Templates, SkillTemplate skillItem, SpellTemplate spellData, int baseID = 0)
  53. {
  54. //无伤害的不判断
  55. if (spellData.HitIntervalKeyFrame == null && spellData.HitOnExplosionKeyFrame == null)
  56. {
  57. bool isAllNull = true;
  58. foreach (SpellTemplate.KeyFrame spellFrame in spellData.KeyFrames)
  59. {
  60. if (spellFrame.Attack != null)
  61. {
  62. isAllNull = false;
  63. }
  64. if (spellFrame.Spell != null && spellFrame.Spell.SpellID > 0 && baseID != spellFrame.Spell.SpellID)
  65. {
  66. if (!CheckSpellRange(Templates, skillItem, Templates.Templates.getSpell(spellFrame.Spell.SpellID), baseID))
  67. {
  68. baseID = spellFrame.Spell.SpellID;
  69. }
  70. }
  71. }
  72. if (isAllNull)
  73. {
  74. return true;
  75. }
  76. }
  77. if (spellData.MType == MotionType.Missile || spellData.MType == MotionType.Straight || spellData.MType == MotionType.StraightAndStop ||
  78. spellData.MType == MotionType.SeekerMissile)
  79. {
  80. if ((spellData.MSpeedAdd + spellData.MSpeedSEC) * spellData.LifeTimeMS * 0.001f + spellData.BodySize < skillItem.AttackRange)
  81. {
  82. log.Error("A技能:" + skillItem.ID + "-" + skillItem.Name + ", 的法术:" + spellData.ID + ", 范围异常!");
  83. return false;
  84. }
  85. }
  86. else if (spellData.MType == MotionType.Immovability || spellData.MType == MotionType.Binding || spellData.MType == MotionType.Straight)
  87. {
  88. if (spellData.BodySize < skillItem.AttackRange)
  89. {
  90. log.Error("B技能:" + skillItem.ID + "-" + skillItem.Name + ", 的法术:" + spellData.ID + ", 范围异常!");
  91. return false;
  92. }
  93. }
  94. return true;
  95. }
  96. }
  97. }