linux.do.cq.auto.fire

auto fire wall

  1. // ==UserScript==
  2. // @name linux.do.cq.auto.fire
  3. // @namespace https://linux.do/u/io.oi/cq.auto.fire
  4. // @version 1.3.3
  5. // @author io.oi
  6. // @description auto fire wall
  7. // @license MIT
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=e-hai.one
  9. // @match http://cq.e-hai.one/play?*
  10. // @match http://chuanqi.proxy2world.com/play?*
  11. // @grant GM_addStyle
  12. // ==/UserScript==
  13.  
  14. (o=>{if(typeof GM_addStyle=="function"){GM_addStyle(o);return}const t=document.createElement("style");t.textContent=o,document.head.append(t)})(" .control-panel{position:fixed;bottom:0;left:0;min-width:auto}.control-panel .control-group{display:flex}.control-panel .control-group .button{color:#ece6cf;background-color:#084552;padding:.4rem;border:none;cursor:pointer;border-radius:.1rem} ");
  15.  
  16. (function () {
  17. 'use strict';
  18.  
  19. var __defProp = Object.defineProperty;
  20. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  21. var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  22. class Icons {
  23. }
  24. __publicField(Icons, "startIcon", '<svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M823.8 603.5l-501.2 336c-50.7 34-119.3 20.4-153.2-30.2-12.2-18.2-18.7-39.6-18.7-61.5v-672c0-61 49.5-110.4 110.4-110.4 21.9 0 43.3 6.5 61.5 18.7l501.1 336c50.7 34 64.2 102.6 30.2 153.2-7.8 11.9-18.1 22.2-30.1 30.2z m0 0"></path></svg>');
  25. __publicField(Icons, "stopIcon", '<svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M941.967463 109.714286v804.571428q0 14.857143-10.857143 25.714286t-25.714286 10.857143H100.824606q-14.857143 0-25.714286-10.857143t-10.857143-25.714286V109.714286q0-14.857143 10.857143-25.714286t25.714286-10.857143h804.571428q14.857143 0 25.714286 10.857143t10.857143 25.714286z"></path></svg>');
  26. function createControlPanel(clicked) {
  27. const controlPanel = document.createElement("div");
  28. controlPanel.id = "control-panel";
  29. controlPanel.className = "control-panel";
  30. controlPanel.innerHTML = `
  31. <div class="control-group">
  32. <button id="toggle" class="button" title="点击开始自动释放火墙">${Icons.startIcon}</button>
  33. <button id="random" class="button" title="封魔谷全自动挂机
  34. 1.人物进城自动飞鞋,不止防小黑屋,也防贴着建筑走路慢的问题
  35. 2.挂机误入其他图,会自动传送封魔谷,自动开启挂机
  36. 3.监测挂机状态,中断会自动开启挂机
  37. 4.检测周围怪物和掉落物数量,无怪无掉落物自动飞鞋
  38. 注:以上功能全部基于飞鞋,请多充些飞鞋点数">${Icons.startIcon}</button>
  39. <button id="auto-fly" class="button" title="周围无怪无掉落物自动飞鞋和监测挂机状态,这个功能无法和封魔谷挂机同时开启">${Icons.startIcon}</button>
  40. </div>`;
  41. const btns = Array.from(controlPanel.querySelectorAll("button"));
  42. for (const btn of btns) {
  43. btn.addEventListener("click", () => {
  44. clicked(btn);
  45. });
  46. }
  47. return controlPanel;
  48. }
  49. class Rectangle {
  50. constructor(vertices) {
  51. __publicField(this, "vertices");
  52. this.vertices = vertices;
  53. }
  54. crossProduct(x, y, z) {
  55. return (z[1] - y[1]) * (y[0] - x[0]) - (z[0] - y[0]) * (y[1] - x[1]);
  56. }
  57. isOnSameSide(p1, p2, a, b) {
  58. const cp1 = this.crossProduct(a, b, p1);
  59. const cp2 = this.crossProduct(a, b, p2);
  60. return cp1 * cp2 >= 0;
  61. }
  62. isInside(x, y) {
  63. const [A, B, C, D] = this.vertices;
  64. const p = [x, y];
  65. return this.isOnSameSide(p, A, B, C) && this.isOnSameSide(p, B, C, D) && this.isOnSameSide(p, C, D, A) && this.isOnSameSide(p, D, A, B);
  66. }
  67. }
  68. window.addEventListener("load", () => {
  69. let timer = void 0;
  70. let watchTimer = void 0;
  71. let autoFlyTimer = void 0;
  72. let status = "None";
  73. const buttonColor = "#55b47d";
  74. const buttonColor2 = "#084552";
  75. function checkEdcwsp() {
  76. if (!app.qTVCL.ins().isOpen) {
  77. app.qTVCL.ins().edcwsp();
  78. toast("开始挂机", "0x00ff60");
  79. }
  80. }
  81. function checkMonster() {
  82. const all = app.NWRFmB.ins().YUwhM();
  83. let count = 0;
  84. for (const a in all) {
  85. const monster = all[a];
  86. if (monster.propSet.getRace() == 1) {
  87. count++;
  88. }
  89. }
  90. return count;
  91. }
  92. function checkDropCount() {
  93. const drops = app.NWRFmB.ins().dropList;
  94. let count = 0;
  95. for (const _ in drops) {
  96. count++;
  97. }
  98. return count;
  99. }
  100. function inMap(id) {
  101. return app.GameMap.mapID === id;
  102. }
  103. function fly() {
  104. app.EhSWiR.m_clickSkillId = 58;
  105. }
  106. function fire() {
  107. app.EhSWiR.m_clickSkillId = 14;
  108. }
  109. function send(user, mapId) {
  110. app.PKRX.ins().send_1_7(user, mapId);
  111. }
  112. function getPlayer() {
  113. return app.NWRFmB.ins().getPayer;
  114. }
  115. function toast(message, color = "0xff7700") {
  116. app.uMEZy.ins().IrCm(`|C:${color}&T:${message}|`);
  117. }
  118. function toggleBtnStatus(btn, color, icon) {
  119. btn.style.backgroundColor = color;
  120. btn.innerHTML = icon;
  121. }
  122. function autoFly(player) {
  123. const count = player.propSet.getFlyshoes();
  124. if (count > 0) {
  125. toast(`周围没有怪了,开始飞,飞鞋点数剩余:${count - 1}`);
  126. fly();
  127. } else {
  128. toast(`飞鞋点数不足,请补充飞鞋点数`, "0xff0000");
  129. }
  130. }
  131. const panel = createControlPanel((btn) => {
  132. const id = btn.getAttribute("id");
  133. switch (id) {
  134. case "toggle":
  135. if (timer) {
  136. clearInterval(timer);
  137. timer = void 0;
  138. toggleBtnStatus(btn, buttonColor2, Icons.startIcon);
  139. } else {
  140. fire();
  141. timer = setInterval(() => {
  142. fire();
  143. }, 9e3);
  144. toggleBtnStatus(btn, buttonColor, Icons.stopIcon);
  145. }
  146. break;
  147. case "random":
  148. if (status === "Other") {
  149. toast("封魔谷挂机和无怪自动飞鞋只能开启一个,请关闭无怪自动飞鞋后重试");
  150. return;
  151. }
  152. if (watchTimer) {
  153. clearInterval(watchTimer);
  154. watchTimer = void 0;
  155. toggleBtnStatus(btn, buttonColor2, Icons.startIcon);
  156. status = "None";
  157. } else {
  158. toast("4秒后开始挂机,请不要有任何操作");
  159. const player = getPlayer();
  160. const rectangle = new Rectangle([[162, 60], [208, 95], [155, 130], [110, 100]]);
  161. watchTimer = setInterval(() => {
  162. if (inMap(9)) {
  163. checkEdcwsp();
  164. if (rectangle.isInside(player.lastX, player.lastY)) {
  165. toast(`人[${player.lastX},${player.lastY}],在封魔谷的城中,危险,防止小黑屋,开飞`, "0xff0000");
  166. fly();
  167. } else if (checkMonster() < 1 && checkDropCount() < 1) {
  168. autoFly(player);
  169. }
  170. } else {
  171. toast("不在封魔谷,开始传送");
  172. send(player.recog, 12);
  173. const tt = setInterval(() => {
  174. if (inMap(9)) {
  175. checkEdcwsp();
  176. clearInterval(tt);
  177. }
  178. }, 2e3);
  179. }
  180. }, 4e3);
  181. toggleBtnStatus(btn, buttonColor, Icons.stopIcon);
  182. status = "FengMoGu";
  183. }
  184. break;
  185. case "auto-fly":
  186. if (status === "FengMoGu") {
  187. toast("封魔谷挂机和无怪自动飞鞋只能开启一个,请关闭封魔谷挂机后重试");
  188. return;
  189. }
  190. if (autoFlyTimer) {
  191. clearInterval(autoFlyTimer);
  192. autoFlyTimer = void 0;
  193. toggleBtnStatus(btn, buttonColor2, Icons.startIcon);
  194. status = "None";
  195. } else {
  196. toast("3秒后开启无怪自动飞鞋");
  197. const player = getPlayer();
  198. autoFlyTimer = setInterval(() => {
  199. if (checkMonster() < 1 && checkDropCount() < 1) {
  200. autoFly(player);
  201. }
  202. checkEdcwsp();
  203. }, 3e3);
  204. status = "Other";
  205. toggleBtnStatus(btn, buttonColor, Icons.stopIcon);
  206. }
  207. break;
  208. }
  209. });
  210. document.body.appendChild(panel);
  211. });
  212.  
  213. })();