MWI-Equipment-Diff

Make life easier

当前为 2025-06-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MWI-Equipment-Diff
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Make life easier
  6. // @author BKN46
  7. // @match https://*.milkywayidle.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=milkywayidle.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let selfData = {};
  17.  
  18. const colors = {
  19. info: 'rgb(0, 108, 158)',
  20. smaller: 'rgb(199, 21, 21)',
  21. greater: 'rgb(23, 151, 12)',
  22. };
  23. let equipmentToDiff = {};
  24. const isZHInGameSetting = localStorage.getItem("i18nextLng")?.toLowerCase()?.startsWith("zh");
  25. let isZH = isZHInGameSetting;
  26.  
  27. function transZH(zh) {
  28. if (isZH) return zh;
  29. return {
  30. "战斗风格": "Combat Style",
  31. "伤害类型": "Damage Type",
  32. "自动攻击伤害": "Auto Attack Damage",
  33. "攻击速度": "Attack Speed",
  34. "攻击间隔": "Attack Interval",
  35. "暴击率": "Critical Rate",
  36. "暴击伤害": "Critical Damage",
  37. "技能急速": "Ability Haste",
  38. "施法速度": "Cast Speed",
  39.  
  40. "刺击精准度": "Stab Accuracy",
  41. "刺击伤害": "Stab Damage",
  42. "斩击精准度": "Slash Accuracy",
  43. "斩击伤害": "Slash Damage",
  44. "钝击精准度": "Smash Accuracy",
  45. "钝击伤害": "Smash Damage",
  46. "远程精准度": "Ranged Accuracy",
  47. "远程伤害": "Ranged Damage",
  48. "魔法精准度": "Magic Accuracy",
  49. "魔法伤害": "Magic Damage",
  50.  
  51. "物理增幅": "Physical Amplify",
  52. "火系增幅": "Fire Amplify",
  53. "水系增幅": "Water Amplify",
  54. "自然系增幅": "Nature Amplify",
  55. "护甲穿透": "Armor Penetration",
  56. "火系穿透": "Fire Penetration",
  57. "水系穿透": "Water Penetration",
  58. "自然系穿透": "Nature Penetration",
  59. }[zh] || zh;
  60. }
  61.  
  62. function parseEquipmentModal(element) {
  63. const equipmentDetail = {};
  64. const detailLines = element.querySelectorAll('.EquipmentStatsText_stat__27Sus');
  65. for (const line of detailLines) {
  66. if (line.querySelector('.EquipmentStatsText_uniqueStat__2xvqX')) continue;
  67. const data = line.textContent.split(':');
  68. if (data.length === 2) {
  69. const key = data[0].trim();
  70. const value = data[1].split('(')[0].trim();
  71. if (value === 'N/A') continue;
  72. equipmentDetail[key] = value;
  73. }
  74. }
  75.  
  76. if (!element.querySelector('.diff-tooltip')) {
  77. const diffTooltip = document.createElement('div');
  78. diffTooltip.className = 'diff-tooltip';
  79. diffTooltip.textContent = isZH ? '按\'d\'来添加作为对比对象' : 'Press "d" to add to quick diff';
  80. diffTooltip.style = `color: ${colors.info}; font-weight: bold;`;
  81. element.appendChild(diffTooltip);
  82.  
  83. if (equipmentToDiff.data) {
  84. const diffRemoveTooltip = document.createElement('div');
  85. diffRemoveTooltip.className = 'diff-remove-tooltip';
  86. diffRemoveTooltip.textContent = isZH ? '按\'r\'来移除当前对比' : 'Press "r" to remove present quick diff';
  87. diffRemoveTooltip.style = `color: ${colors.info}; font-weight: bold;`;
  88. element.appendChild(diffRemoveTooltip);
  89. }
  90. }
  91. return equipmentDetail;
  92. }
  93.  
  94.  
  95. // #region Diff Modal
  96. function addDiffToModal(element, data, price) {
  97. if (element.querySelector('.diff-value') || element.querySelector('.diff-header')) return;
  98. const parentArea = element.querySelector('.EquipmentStatsText_equipmentStatsText__djKBS');
  99. const TextArea = parentArea.firstChild;
  100.  
  101. const diffMap = {};
  102. const detailLines = element.querySelectorAll('.EquipmentStatsText_stat__27Sus');
  103. for (const line of detailLines) {
  104. const key = line.textContent.split(':')[0].trim();
  105. const valueElement = line.querySelectorAll('span')[1];
  106. const diffSpan = document.createElement('span');
  107. diffSpan.className = 'diff-value';
  108. if (key in equipmentToDiff.data) {
  109. const diffValue = equipmentToDiff.data[key];
  110. if (data[key] === diffValue) {
  111. continue;
  112. }
  113. const diff = strDiff(diffValue, data[key]);
  114. diffMap[key] = diff;
  115. diffSpan.textContent = ` (${diff})`;
  116. const color = diff.startsWith('-') ? colors.smaller : colors.greater;
  117. diffSpan.style = `color: ${color}; font-weight: bold;`;
  118. valueElement.appendChild(diffSpan);
  119. } else if (valueElement) {
  120. diffMap[key] = valueElement.textContent.startsWith('-') ? valueElement.textContent.replace('-', '') : `-${valueElement.textContent}`;
  121. diffSpan.textContent = ` (${diffMap[key]})`;
  122. const color = valueElement.textContent.startsWith('-') ? colors.smaller: colors.greater;
  123. diffSpan.style = `color: ${color}; font-weight: bold;`;
  124. valueElement.appendChild(diffSpan);
  125. } else { // special ability on equipment
  126. // diffSpan.textContent = ` (N/A)`;
  127. // diffSpan.style = `color: ${colors.smaller}; font-weight: bold;`;
  128. // line.appendChild(diffSpan);
  129. }
  130. }
  131. for (const key in equipmentToDiff.data) {
  132. if (!(key in data)) {
  133. const newLine = document.createElement('div');
  134. newLine.className = 'EquipmentStatsText_stat__27Sus';
  135.  
  136. const keySpan = document.createElement('span');
  137. keySpan.textContent = `${key}: `;
  138. newLine.appendChild(keySpan);
  139.  
  140. const valueSpan = document.createElement('span');
  141. valueSpan.textContent = 'N/A';
  142. newLine.appendChild(valueSpan);
  143.  
  144. const diffSpan = document.createElement('span');
  145. diffSpan.className = 'diff-value';
  146. diffSpan.textContent = ` (${equipmentToDiff.data[key]})`;
  147. diffMap[key] = equipmentToDiff.data[key];
  148.  
  149. const color = equipmentToDiff.data[key].startsWith('-') ? colors.greater : colors.smaller;
  150. diffSpan.style = `color: ${color}; font-weight: bold;`;
  151. valueSpan.appendChild(diffSpan);
  152. TextArea.appendChild(newLine);
  153. }
  154. }
  155.  
  156. // #region Diff header
  157. if (equipmentToDiff.name) {
  158. const newLine = document.createElement('div');
  159. newLine.className = 'diff-header';
  160. newLine.style = 'display: flex; grid-gap: 6px; gap: 6px; justify-content: space-between;'
  161.  
  162. const keySpan = document.createElement('span');
  163. keySpan.textContent = isZH ? '对比对象: ' : 'Compares to: ';
  164. keySpan.style = `color: ${colors.info}; font-weight: bold;`;
  165. newLine.appendChild(keySpan);
  166. const diffTitle = document.createElement('span');
  167. diffTitle.textContent = equipmentToDiff.name;
  168. diffTitle.style = `color: ${colors.info}; font-weight: bold;`;
  169. newLine.appendChild(diffTitle);
  170. parentArea.insertBefore(newLine, TextArea);
  171. }
  172. if (price >= 0 && equipmentToDiff.price >= 0) {
  173. const newLine = document.createElement('div');
  174. newLine.className = 'diff-header';
  175. newLine.style = 'display: flex; grid-gap: 6px; gap: 6px; justify-content: space-between;'
  176.  
  177. const keySpan = document.createElement('span');
  178. keySpan.textContent = isZH ? `价格差: ` : `Price diff: `;
  179. keySpan.style = `color: ${colors.info}; font-weight: bold;`;
  180. newLine.appendChild(keySpan);
  181. const priceSpan = document.createElement('span');
  182. priceSpan.className = 'diff-price';
  183. const priceDiff = priceParse(price - equipmentToDiff.price);
  184. priceSpan.textContent = `${priceDiff}`;
  185. const priceColor = priceDiff.startsWith('-') ? colors.greater : colors.smaller;
  186. priceSpan.style = `color: ${priceColor}; font-weight: bold;`;
  187. newLine.appendChild(priceSpan);
  188.  
  189. parentArea.insertBefore(newLine, TextArea);
  190. }
  191. // #region DPS diff
  192. if (Object.keys(diffMap).length > 0) {
  193. const newLine = document.createElement('div');
  194. newLine.className = 'diff-header';
  195. newLine.style = 'display: flex; grid-gap: 6px; gap: 6px; justify-content: space-between;'
  196.  
  197. const keySpan = document.createElement('span');
  198. keySpan.textContent = isZH ? `粗略DPS变化: ` : `Rough DPS diff: `;
  199. keySpan.style = `color: ${colors.info}; font-weight: bold;`;
  200. newLine.appendChild(keySpan);
  201.  
  202. const selfType = getSelfStyleTrans();
  203. if (equipmentToDiff.data[transZH('战斗风格')] != selfType || data[transZH('战斗风格')] != selfType) {
  204. const diffValue = document.createElement('span');
  205. diffValue.textContent = isZH ? '不支持对比和角色战斗风格不一致武器' : 'Cannot compare weapons with different combat styles';
  206. diffValue.style = `color: ${colors.info}; font-weight: bold;`;
  207. newLine.appendChild(diffValue);
  208. parentArea.insertBefore(newLine, TextArea);
  209. return;
  210. }
  211.  
  212. let dpsCompare = 0;
  213. try {
  214. dpsCompare = getDPSCompare(diffMap);
  215. const diffValue = document.createElement('span');
  216. diffValue.textContent = dpsCompare * 100 > 0 ? `+${(dpsCompare * 100).toFixed(3)}%` : `${(dpsCompare * 100).toFixed(3)}%`;
  217. const color = dpsCompare > 0 ? colors.greater : colors.smaller;
  218. diffValue.style = `color: ${color}; font-weight: bold;`;
  219. newLine.appendChild(diffValue);
  220. } catch (error) {
  221. const diffValue = document.createElement('span');
  222. diffValue.textContent = isZH ? '[计算过程发生错误]' : '[Error]';
  223. diffValue.style = `color: ${colors.info}; font-weight: bold;`;
  224. console.error('Equipment Diff: Error calculating DPS diff:', error);
  225. newLine.appendChild(diffValue);
  226. }
  227. parentArea.insertBefore(newLine, TextArea);
  228.  
  229. if (dpsCompare > 0 && price >= 0 && equipmentToDiff.price >= 0) {
  230. const priceLine = document.createElement('div');
  231. priceLine.className = 'diff-header';
  232. priceLine.style = 'display: flex; grid-gap: 6px; gap: 6px; justify-content: space-between;'
  233. const priceKeySpan = document.createElement('span');
  234. priceKeySpan.textContent = isZH ? `每10M价格DPS提升: ` : `DPS% per 10M coin: `;
  235. priceKeySpan.style = `color: ${colors.info}; font-weight: bold;`;
  236. priceLine.appendChild(priceKeySpan);
  237. const dpsPriceSpan = document.createElement('span');
  238. dpsPriceSpan.className = 'diff-price';
  239. const dpsPerMil = (dpsCompare * 100) / ((price - equipmentToDiff.price) / 1e6) * 10;
  240. dpsPriceSpan.textContent = dpsPerMil > 0 ? `+${dpsPerMil.toFixed(5)}%` : `${dpsPerMil.toFixed(5)}%`;
  241. const priceColor = dpsPerMil > 0 ? colors.greater : colors.smaller;
  242. dpsPriceSpan.style = `color: ${priceColor}; font-weight: bold;`;
  243. priceLine.appendChild(dpsPriceSpan);
  244. parentArea.insertBefore(priceLine, TextArea);
  245. }
  246. }
  247. }
  248.  
  249. function strDiff(s1, s2) {
  250. if (s1 === s2) return '';
  251. if (!s1 || !s2) return s1 || s2;
  252. let postfix = '';
  253. let isNeg = false;
  254. if (s1.endsWith('%')) postfix = '%';
  255. if (s1.startsWith('-')) isNeg = true;
  256. const proc = (t) => parseFloat(t.replace('%', '').replace(',', '').replace(' ', '').replace('+', '').replace('_', ''));
  257. const diff = proc(s2) - proc(s1);
  258. if (isNaN(diff)) return s1;
  259. if (diff === 0) return '';
  260. if (diff > 0) return `${isNeg ? '-' : '+'}${parseFloat(diff.toFixed(3))}${postfix}`;
  261. return `${isNeg ? '+' : '-'}${parseFloat(Math.abs(diff).toFixed(3))}${postfix}`;
  262. }
  263.  
  264. function hookWS() {
  265. const dataProperty = Object.getOwnPropertyDescriptor(MessageEvent.prototype, "data");
  266. const oriGet = dataProperty.get;
  267.  
  268. dataProperty.get = hookedGet;
  269. Object.defineProperty(MessageEvent.prototype, "data", dataProperty);
  270.  
  271. function hookedGet() {
  272. const socket = this.currentTarget;
  273. if (!(socket instanceof WebSocket)) {
  274. return oriGet.call(this);
  275. }
  276. if (socket.url.indexOf("api.milkywayidle.com/ws") <= -1 && socket.url.indexOf("api-test.milkywayidle.com/ws") <= -1) {
  277. return oriGet.call(this);
  278. }
  279.  
  280. const message = oriGet.call(this);
  281. Object.defineProperty(this, "data", { value: message }); // Anti-loop
  282.  
  283. try {
  284. return handleMessage(message);
  285. } catch (error) {
  286. console.log("Error in handleMessage:", error);
  287. return message;
  288. }
  289. }
  290. }
  291. hookWS();
  292.  
  293. function handleMessage(message) {
  294. if (typeof message !== "string") {
  295. return message;
  296. }
  297. try {
  298. const parsedMessage = JSON.parse(message);
  299. if (parsedMessage && parsedMessage.type === "init_character_data") {
  300. selfData = parsedMessage;
  301. }
  302. } catch (error) {
  303. console.log("Error parsing message:", error);
  304. }
  305. return message;
  306. }
  307.  
  308. function parsePrice(costText) {
  309. if (costText.endsWith('M')) {
  310. return parseFloat(costText.replace('M', '').replace(',', '')) * 1e6
  311. } else if (costText.endsWith('k')) {
  312. return parseFloat(costText.replace('k', '').replace(',', '')) * 1e3
  313. } else if (costText.endsWith('K')) {
  314. return parseFloat(costText.replace('K', '').replace(',', '')) * 1e3
  315. } else if (costText.endsWith('B')) {
  316. return parseFloat(costText.replace('B', '').replace(',', '')) * 1e9
  317. } else if (costText.endsWith('T')) {
  318. return parseFloat(costText.replace('T', '').replace(',', '')) * 1e12
  319. } else {
  320. return parseFloat(costText.replace(',', ''))
  321. }
  322. }
  323.  
  324. function priceParse(priceNum) {
  325. const isNegative = priceNum < 0;
  326. const absValue = Math.abs(priceNum);
  327. let result;
  328. if (absValue >= 1e10) {
  329. result = parseFloat((absValue / 1e9).toFixed(3)) + 'B';
  330. } else if (absValue >= 1e7) {
  331. result = parseFloat((absValue / 1e6).toFixed(3)) + 'M';
  332. } else if (absValue >= 1e4) {
  333. result = parseFloat((absValue / 1e3).toFixed(3)) + 'K';
  334. } else {
  335. result = parseFloat(absValue.toFixed(3));
  336. }
  337. return isNegative ? '-' + result : '+' + result;
  338. }
  339.  
  340. function getMWIToolsPrice(modal) {
  341. const enhancedPriceText = isZH ? '总成本' : 'Total cost';
  342. let costNodes = Array.from(modal.querySelectorAll('*')).filter(el => {
  343. if (!el.textContent || !el.textContent.includes(enhancedPriceText)) return false;
  344. return Array.from(el.childNodes).every(node => node.nodeType === Node.TEXT_NODE);
  345. });
  346. if (costNodes.length > 0) {
  347. const node = costNodes[0];
  348. const costText = node.textContent.replace(enhancedPriceText, '').trim();
  349. return parsePrice(costText);
  350. }
  351.  
  352. const normalPriceText = isZH ? '日均价' : 'Daily average price';
  353. costNodes = Array.from(modal.querySelectorAll('*')).filter(el => {
  354. if (!el.textContent || !el.textContent.includes(normalPriceText)) return false;
  355. return Array.from(el.childNodes).every(node => node.nodeType === Node.TEXT_NODE);
  356. });
  357. if (costNodes.length > 0) {
  358. const node = costNodes[0];
  359. const costText = node.textContent.split('/')[0].split(' ')[1].trim();
  360. return parsePrice(costText);
  361. }
  362.  
  363. return -1;
  364. }
  365.  
  366. function getSelfStyleTrans() {
  367. const combatStyle = selfData?.combatUnit.combatDetails.combatStats.combatStyleHrids[0];
  368. return {
  369. '/combat_styles/stab': isZH ? '刺击' : 'Stab',
  370. '/combat_styles/slash': isZH ? '斩击' : 'Slash',
  371. '/combat_styles/smash': isZH ? '钝击' : 'Smash',
  372. '/combat_styles/ranged': isZH ? '远程' : 'Ranged',
  373. '/combat_styles/magic': isZH ? '魔法' : 'Magic',
  374. }[combatStyle] || combatStyle;
  375. }
  376.  
  377. setInterval(() => {
  378. const modals = document.querySelectorAll('.MuiPopper-root');
  379. if (!modals) return;
  380. // compatibility with chat-enhance addon
  381. let equipmentDetail = null;
  382. let modal = null;
  383. for (const modal_ of modals) {
  384. equipmentDetail = modal_.querySelector('.ItemTooltipText_equipmentDetail__3sIHT');
  385. if (equipmentDetail) {
  386. modal = modal_;
  387. break
  388. };
  389. }
  390. if (!equipmentDetail) return;
  391.  
  392. const equipmentName = modal.querySelector('.ItemTooltipText_name__2JAHA').textContent.trim();
  393. const equipmentData = parseEquipmentModal(equipmentDetail);
  394.  
  395. const price = getMWIToolsPrice(modal);
  396.  
  397. if (equipmentToDiff.data) {
  398. addDiffToModal(equipmentDetail, equipmentData, price);
  399. }
  400.  
  401. document.onkeydown = (event) => {
  402. if (event.key === 'd') {
  403. // event.preventDefault();
  404. console.log(`Added to quick diff: ${equipmentName}`);
  405. equipmentToDiff = {
  406. data: equipmentData,
  407. name: equipmentName,
  408. price: price,
  409. };
  410. equipmentDetail.querySelector('.diff-tooltip').textContent = isZH ? '已添加作为对比' : 'Added to quick diff';
  411. } else if (event.key === 'r') {
  412. // event.preventDefault();
  413. console.log(`Removed from quick diff: ${equipmentName}`);
  414. equipmentToDiff = {};
  415. equipmentDetail.querySelector('.diff-tooltip').textContent = isZH ? '已移除对比' : 'Removed from quick diff';
  416. }
  417. };
  418.  
  419. }, 500)
  420.  
  421. // #region DPS Caculator
  422. const monsterStatusMap = {
  423. 50: {evasion: 80, resistence: 14},
  424. 80: {evasion: 130, resistence: 18},
  425. 100: {evasion: 170, resistence: 30},
  426. 120: {evasion: 250, resistence: 40},
  427. 140: {evasion: 300, resistence: 80},
  428. 200: {evasion: 400, resistence: 100},
  429. }
  430. const abilityDamgeMap = {
  431. 50: {ratio: 0.66, flat: 12},
  432. 80: {ratio: 0.69, flat: 13},
  433. 100: {ratio: 0.735, flat: 14.5},
  434. 120: {ratio: 0.78, flat: 16},
  435. 140: {ratio: 0.825, flat: 17.5},
  436. 200: {ratio: 0.87, flat: 19},
  437. }
  438.  
  439. function chooseBelow(level, map) {
  440. const keys = Object.keys(map).map(Number).filter(k => k <= level);
  441. if (keys.length === 0) return null;
  442. const maxKey = Math.max(...keys);
  443. return map[maxKey];
  444. }
  445.  
  446. function getDamageBase(combatStyle, skillLevel, atkAcc, atkAmp, dmgAmp, dmgPen, critAmp, critDmg) {
  447. const isMagic = combatStyle === "/combat_styles/magic";
  448. const abilityFlatDmg = isMagic ? chooseBelow(skillLevel, abilityDamgeMap)?.flat : 0;
  449. const abilityRatioDmg = isMagic ? chooseBelow(skillLevel, abilityDamgeMap)?.ratio + 1 : 1;
  450. const enemyEvasion = chooseBelow(skillLevel, monsterStatusMap)?.evasion || 80;
  451. const enemyResistence = chooseBelow(skillLevel, monsterStatusMap)?.resistence || 80;
  452.  
  453. const accuracy = (10+skillLevel)*(1+atkAcc)
  454. const hitRate = Math.pow(accuracy, 1.4) / (Math.pow(accuracy, 1.4) + Math.pow(enemyEvasion, 1.4));
  455. const critRate = combatStyle == "/combat_styles/ranged" ? hitRate * 0.3 + critAmp : critAmp;
  456.  
  457. const baseDmg = (10+skillLevel) * (1+atkAmp);
  458. const minDmg = (1+dmgAmp) * (1+abilityFlatDmg);
  459. const maxDmg = (1+dmgAmp) * (abilityRatioDmg*baseDmg + abilityFlatDmg);
  460. const estDmg = (minDmg + maxDmg) / 2 * (1-critRate) + maxDmg * critRate * (1+critDmg);
  461. const actDmg = estDmg * (100 / (100 + (enemyResistence / ( 1 + dmgPen))))
  462. return actDmg * hitRate;
  463. }
  464.  
  465. function getSkillLevel(skillName, map) {
  466. for (const skill of map) {
  467. if (skill.skillHrid === skillName) {
  468. return skill.level;
  469. }
  470. }
  471. return -1
  472. }
  473.  
  474. function getDPSCompare(diffMap) {
  475. const combatDetails = selfData?.combatUnit.combatDetails;
  476. const combatStyle = combatDetails.combatStats.combatStyleHrids[0];
  477. const damageType = combatDetails.combatStats.damageType;
  478.  
  479. function getValueFromDiffMap(key) {
  480. const k = transZH(key);
  481. if (!diffMap || !diffMap[k]) return 0;
  482. const s = diffMap[k].replace(',', '').replace(' ', '').replace('+', '').replace('_', '')
  483. if (s.endsWith('%')) {
  484. return parseFloat(s.replace('%', '')) / 100;
  485. } else if (s.endsWith('s')) {
  486. return parseFloat(s.replace('s', '')) * 1000000000;
  487. } else {
  488. return parseFloat(s);
  489. }
  490. }
  491.  
  492. let atkSkillLevel = getSkillLevel('/skills/attack', selfData.characterSkills);
  493. let dmgSkillLevel = getSkillLevel('/skills/power', selfData.characterSkills);
  494. let originalAmp = {
  495. atkAcc: 0,
  496. atkAmp: 0,
  497. dmgAmp: combatDetails.combatStats.physicalAmplify,
  498. dmgPen: combatDetails.combatStats.armorPenetration,
  499. autoDmg: combatDetails.combatStats.autoAttackDamage,
  500. autoSpeed: combatDetails.combatStats.attackInterval,
  501. abilitySpeed: (100 + combatDetails.combatStats.abilityHaste)/100 * (1+combatDetails.combatStats.castSpeed),
  502. critAmp: combatDetails.combatStats.criticalRate,
  503. critDmg: combatDetails.combatStats.criticalDamage || 0,
  504. speedFactor: 0,
  505. }
  506. let targetAmp = {
  507. atkAcc: 0,
  508. atkAmp: 0,
  509. dmgAmp: originalAmp.dmgAmp + getValueFromDiffMap('物理增幅'),
  510. dmgPen: originalAmp.dmgPen + getValueFromDiffMap('护甲穿透'),
  511. autoDmg: originalAmp.autoDmg + getValueFromDiffMap('自动攻击伤害'),
  512. autoSpeed: originalAmp.autoSpeed + getValueFromDiffMap('攻击间隔'),
  513. abilitySpeed: (100 + combatDetails.combatStats.abilityHaste + getValueFromDiffMap('技能急速'))/100 * (1+combatDetails.combatStats.castSpeed+getValueFromDiffMap('施法速度')),
  514. critAmp: originalAmp.critAmp + getValueFromDiffMap('暴击率'),
  515. critDmg: originalAmp.critDmg + getValueFromDiffMap('暴击伤害'),
  516. speedFactor: 0,
  517. }
  518. switch (combatStyle) {
  519. case "/combat_styles/stab":
  520. originalAmp.atkAcc = combatDetails.stabAccuracyRating / (10 + atkSkillLevel) - 1;
  521. originalAmp.atkAmp = combatDetails.stabMaxDamage / (10 + dmgSkillLevel) - 1;
  522. originalAmp.speedFactor = originalMap.autoSpeed;
  523. targetAmp.atkAcc = originalAmp.atkAcc + getValueFromDiffMap('刺击精准度');
  524. targetAmp.atkAmp = originalAmp.atkAmp + getValueFromDiffMap('刺击伤害');
  525. targetAmp.speedFactor = targetAmp.autoSpeed;
  526. break;
  527. case "/combat_styles/slash":
  528. originalAmp.atkAcc = combatDetails.slashAccuracyRating / (10 + atkSkillLevel) - 1;
  529. originalAmp.atkAmp = combatDetails.slashMaxDamage / (10 + dmgSkillLevel) - 1;
  530. originalAmp.speedFactor = originalMap.autoSpeed;
  531. targetAmp.atkAcc = originalAmp.atkAcc + getValueFromDiffMap('斩击精准度');
  532. targetAmp.atkAmp = originalAmp.atkAmp + getValueFromDiffMap('斩击伤害');
  533. targetAmp.speedFactor = targetAmp.autoSpeed;
  534. break;
  535. case "/combat_styles/smash":
  536. originalAmp.atkAcc = combatDetails.smashAccuracyRating / (10 + atkSkillLevel) - 1;
  537. originalAmp.atkAmp = combatDetails.smashMaxDamage / (10 + dmgSkillLevel) - 1;
  538. originalAmp.speedFactor = originalMap.autoSpeed;
  539. targetAmp.atkAcc = originalAmp.atkAcc + getValueFromDiffMap('钝击精准度');
  540. targetAmp.atkAmp = originalAmp.atkAmp + getValueFromDiffMap('钝击伤害');
  541. targetAmp.speedFactor = targetAmp.autoSpeed;
  542. break;
  543. case "/combat_styles/ranged":
  544. atkSkillLevel = getSkillLevel('/skills/ranged', selfData.characterSkills);
  545. dmgSkillLevel = atkSkillLevel;
  546. originalAmp.atkAcc = combatDetails.rangedAccuracyRating / (10 + atkSkillLevel) - 1;
  547. originalAmp.atkAmp = combatDetails.rangedMaxDamage / (10 + dmgSkillLevel) - 1;
  548. originalAmp.speedFactor = originalMap.autoSpeed;
  549. targetAmp.atkAcc = originalAmp.atkAcc + getValueFromDiffMap('远程精准度');
  550. targetAmp.atkAmp = originalAmp.atkAmp + getValueFromDiffMap('远程伤害');
  551. targetAmp.speedFactor = targetAmp.autoSpeed;
  552. break;
  553. case "/combat_styles/magic":
  554. atkSkillLevel = getSkillLevel('/skills/magic', selfData.characterSkills);
  555. dmgSkillLevel = atkSkillLevel;
  556. originalAmp.atkAcc = combatDetails.magicAccuracyRating / (10 + atkSkillLevel) - 1;
  557. originalAmp.atkAmp = combatDetails.magicMaxDamage / (10 + dmgSkillLevel) - 1;
  558. originalAmp.speedFactor = originalAmp.abilitySpeed;
  559. targetAmp.atkAcc = originalAmp.atkAcc + getValueFromDiffMap('魔法精准度');
  560. targetAmp.atkAmp = originalAmp.atkAmp + getValueFromDiffMap('魔法伤害');
  561. targetAmp.speedFactor = targetAmp.abilitySpeed;
  562. switch (damageType) {
  563. case '/damage_types/fire':
  564. originalAmp.dmgAmp = combatDetails.combatStats.fireAmplify;
  565. originalAmp.dmgPen = combatDetails.combatStats.firePenetration;
  566. targetAmp.dmgAmp = originalAmp.dmgAmp + getValueFromDiffMap('火系增幅');
  567. targetAmp.dmgPen = originalAmp.dmgPen + getValueFromDiffMap('火系穿透');
  568. break;
  569. case '/damage_types/water':
  570. originalAmp.dmgAmp = combatDetails.combatStats.waterAmplify;
  571. originalAmp.dmgPen = combatDetails.combatStats.waterPenetration;
  572. targetAmp.dmgAmp = originalAmp.dmgAmp + getValueFromDiffMap('水系增幅');
  573. targetAmp.dmgPen = originalAmp.dmgPen + getValueFromDiffMap('水系穿透');
  574. break;
  575. case '/damage_types/nature':
  576. originalAmp.dmgAmp = combatDetails.combatStats.natureAmplify;
  577. originalAmp.dmgPen = combatDetails.combatStats.naturePenetration;
  578. targetAmp.dmgAmp = originalAmp.dmgAmp + getValueFromDiffMap('自然系增幅');
  579. targetAmp.dmgPen = originalAmp.dmgPen + getValueFromDiffMap('自然系穿透');
  580. break;
  581. default:
  582. console.warn(`Equipment Diff: Unknown damge style: ${damageType}`);
  583. return 0;
  584. }
  585. break;
  586. default:
  587. console.warn(`Equipment Diff: Unknown combat style: ${combatStyle}`);
  588. return 0;
  589. }
  590.  
  591. const originalDamage = getDamageBase(combatStyle, atkSkillLevel, originalAmp.atkAcc, originalAmp.atkAmp, originalAmp.dmgAmp, originalAmp.dmgPen, originalAmp.critAmp, originalAmp.critDmg);
  592. const targetDamage = getDamageBase(combatStyle, atkSkillLevel, targetAmp.atkAcc, targetAmp.atkAmp, targetAmp.dmgAmp, targetAmp.dmgPen, targetAmp.critAmp, targetAmp.critDmg);
  593.  
  594. const diffRatio = targetDamage / originalDamage * (1 + targetAmp.speedFactor / originalAmp.speedFactor) / 2 - 1;
  595. return diffRatio
  596. }
  597.  
  598. })();