1. function ChangeQuickswitchDelay() {
  2. var tick = 10;
  3. var tick_ms = tick*1000;
  4. var code =
  5. " 3D " + tick_ms.packToHex(4) // CMP eax, 10000
  6. + " 0F 83 AB AB 00 00" // JNB addr
  7. + " 8B AB AB AB AB 00" // MOV r32, g_qsTick
  8. ;
  9. var offsets = exe.findCodes(code, PTYPE_HEX, true, "\xAB");
  10. if (offsets.length === 0) {
  11. code = code.replace(" 8B AB AB AB AB 00", " 8B AB AB AB AB 01");
  12. offsets = exe.findCodes(code, PTYPE_HEX, true, "\xAB");
  13. }
  14. var size = offsets.length;
  15. if (size === 0)
  16. return "Failed in Step 1 - Find Quickswitch Tick";
  17. var g_qsTick = exe.fetchDWord(offsets[0]+13);
  18. var new_tick = exe.getUserInput("$my_new_tick", XTYPE_BYTE, "Number - (0-255)", "Enter the new Quickswitch delay", tick, 0, 255);
  19. if (tick == new_tick)
  20. return "Patch Cancelled - New value is same as old";
  21. var new_tick_ms = new_tick * 1000;
  22. for (i=0; i < size; ++i)
  23. {
  24. // replace the first found values
  25. exe.replace(offsets[i]+1, new_tick_ms.packToHex(4), PTYPE_HEX);
  26. // replace the later values that are shown in the chat window
  27. // "n seconds to next quick switch ..."
  28. var start = offsets[i]+17;
  29. var end = start + 50;
  30. code = " B8" + tick.packToHex(4); // MOV eax, 10
  31. var offset = exe.find(code, PTYPE_HEX, true, "\xAB", start, end);
  32. if (offset === -1)
  33. return "Failed in Step 2 - Find delay subtraction for spot " + i;
  34. exe.replace(offset+1, new_tick.packToHex(4), PTYPE_HEX);
  35. }
  36. // for when opening the full equip window - although the
  37. // status of the quickswitch button doesn't reload
  38. // when the time is expired anyways.. oh well.
  39. // find the first use of g_qsTick
  40. code = " 8B AB " + g_qsTick.packToHex(4); // MOV r32, g_qsTick
  41. var ui_offset = exe.findCode(code, PTYPE_HEX, true, "\xAB");
  42. if (ui_offset === -1)
  43. return "Failed in Step 3a - Find UI quickswitch offset";
  44. // find the comparison to the default tick_ms value
  45. code = " 3D " + tick_ms.packToHex(4); // CMP eax, tick_ms (default)
  46. offset = exe.find(code, PTYPE_HEX, true, ui_offset+6, ui_offset+30);
  47. if (offset === -1)
  48. return "Failed in Step 3b - Find Compare to " + tick_ms;
  49. exe.replace(offset + 1, new_tick_ms.packToHex(4), PTYPE_HEX);
  50. }
  51. //==============================//
  52. // Disable for Unsupported date //
  53. //==============================//
  54. function AllowSpaceInGuildName_() {
  55. return (exe.getClientDate() >= 20170517);
  56. }